[NTOS] Re-enable the APC debug check in the system call exit code that somehow got removed in 46247.

[NTOS] Use an inline for emitting the iret instruction in C code for portability.
[NTOS] Simplify the MSC assembly in KiSwitchToBootStack.

svn path=/trunk/; revision=47487
This commit is contained in:
Stefan Ginsberg 2010-05-31 12:52:16 +00:00
parent 11f78560e8
commit 98ca38a88c
3 changed files with 34 additions and 10 deletions

View file

@ -774,8 +774,7 @@ KiSwitchToBootStack(IN ULONG_PTR InitialStack)
VOID NTAPI KiSystemStartupBootStack(VOID); VOID NTAPI KiSystemStartupBootStack(VOID);
__asm __asm
{ {
mov ecx, InitialStack mov esp, InitialStack
mov esp, ecx
sub esp, (NPX_FRAME_LENGTH + KTRAP_FRAME_ALIGN + KTRAP_FRAME_LENGTH) sub esp, (NPX_FRAME_LENGTH + KTRAP_FRAME_ALIGN + KTRAP_FRAME_LENGTH)
push (CR0_EM | CR0_TS | CR0_MP) push (CR0_EM | CR0_TS | CR0_MP)
jmp KiSystemStartupBootStack jmp KiSystemStartupBootStack
@ -785,6 +784,30 @@ KiSwitchToBootStack(IN ULONG_PTR InitialStack)
#endif #endif
} }
//
// Emits the iret instruction for C code
//
DECLSPEC_NORETURN
VOID
FORCEINLINE
KiIret(VOID)
{
#if defined(__GNUC__)
__asm__ __volatile__
(
"iret\n"
);
#elif defined(_MSC_VER)
__asm
{
iret
}
#else
#error Unsupported compiler
#endif
UNREACHABLE;
}
// //
// Normally this is done by the HAL, but on x86 as an optimization, the kernel // Normally this is done by the HAL, but on x86 as an optimization, the kernel
// initiates the end by calling back into the HAL and exiting the trap here. // initiates the end by calling back into the HAL and exiting the trap here.

View file

@ -8,7 +8,7 @@
#pragma once #pragma once
//#define TRAP_DEBUG 1 #define TRAP_DEBUG 0
// //
// Unreachable code hint for GCC 4.5.x, older GCC versions, and MSVC // Unreachable code hint for GCC 4.5.x, older GCC versions, and MSVC
@ -81,7 +81,7 @@ KiDumpTrapFrame(IN PKTRAP_FRAME TrapFrame)
DbgPrint("V86Gs: %x\n", TrapFrame->V86Gs); DbgPrint("V86Gs: %x\n", TrapFrame->V86Gs);
} }
#ifdef TRAP_DEBUG #if TRAP_DEBUG
VOID VOID
FORCEINLINE FORCEINLINE
KiFillTrapFrameDebug(IN PKTRAP_FRAME TrapFrame) KiFillTrapFrameDebug(IN PKTRAP_FRAME TrapFrame)
@ -168,7 +168,7 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall,
0, 0,
0); 0);
} }
#if 0
/* Make sure we're not attached and that APCs are not disabled */ /* Make sure we're not attached and that APCs are not disabled */
if ((KeGetCurrentThread()->ApcStateIndex != CurrentApcEnvironment) || if ((KeGetCurrentThread()->ApcStateIndex != CurrentApcEnvironment) ||
(KeGetCurrentThread()->CombinedApcDisable != 0)) (KeGetCurrentThread()->CombinedApcDisable != 0))
@ -180,7 +180,6 @@ KiExitSystemCallDebugChecks(IN ULONG SystemCall,
KeGetCurrentThread()->CombinedApcDisable, KeGetCurrentThread()->CombinedApcDisable,
0); 0);
} }
#endif
} }
} }
#else #else
@ -200,9 +199,11 @@ DECLSPEC_NORETURN VOID FASTCALL KiTrapReturn(IN PKTRAP_FRAME TrapFrame);
DECLSPEC_NORETURN VOID FASTCALL KiTrapReturnNoSegments(IN PKTRAP_FRAME TrapFrame); DECLSPEC_NORETURN VOID FASTCALL KiTrapReturnNoSegments(IN PKTRAP_FRAME TrapFrame);
typedef typedef
DECLSPEC_NORETURN
VOID VOID
(FASTCALL (FASTCALL *PFAST_SYSTEM_CALL_EXIT)(
*PFAST_SYSTEM_CALL_EXIT)(IN PKTRAP_FRAME TrapFrame); IN PKTRAP_FRAME TrapFrame
);
extern PFAST_SYSTEM_CALL_EXIT KiFastCallExitHandler; extern PFAST_SYSTEM_CALL_EXIT KiFastCallExitHandler;
@ -222,7 +223,7 @@ KiExitV86Trap(IN PKTRAP_FRAME TrapFrame)
while (TRUE) while (TRUE)
{ {
/* Return if this isn't V86 mode anymore */ /* Return if this isn't V86 mode anymore */
if (!(TrapFrame->EFlags & EFLAGS_V86_MASK)) KiEoiHelper(TrapFrame);; if (!(TrapFrame->EFlags & EFLAGS_V86_MASK)) KiEoiHelper(TrapFrame);
/* Turn off the alerted state for kernel mode */ /* Turn off the alerted state for kernel mode */
Thread->Alerted[KernelMode] = FALSE; Thread->Alerted[KernelMode] = FALSE;

View file

@ -547,7 +547,7 @@ KiTrap02(VOID)
// //
// Handled, return from interrupt // Handled, return from interrupt
// //
__asm__ __volatile__ ("iret\n"); KiIret();
} }
// //