- "Sync" to the next thread's initial stack in KiSwapThread. This fixes an invalid page fault (faulting while interrupts are disabled) during context switching, where we access the next thread's initial stack before performing the address space switch. Many thanks to Alex for his help with this bug!

- Fix stack size calculations in KeAttachProcess and KeStackAttachProcess (thanks to Alex for pointing this out)

svn path=/trunk/; revision=35308
This commit is contained in:
Stefan Ginsberg 2008-08-13 17:00:49 +00:00
parent d36e61f36c
commit 6c420630c9
2 changed files with 6 additions and 2 deletions

View file

@ -451,7 +451,7 @@ KeAttachProcess(IN PKPROCESS Process)
MiSyncThreadProcessViews(Process,
(PVOID)Thread->StackLimit,
Thread->LargeStack ?
KERNEL_STACK_SIZE : KERNEL_LARGE_STACK_SIZE);
KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
MiSyncThreadProcessViews(Process, Thread, sizeof(ETHREAD));
/* Check if we're already in that process */
@ -581,7 +581,7 @@ KeStackAttachProcess(IN PKPROCESS Process,
MiSyncThreadProcessViews(Process,
(PVOID)Thread->StackLimit,
Thread->LargeStack ?
KERNEL_STACK_SIZE : KERNEL_LARGE_STACK_SIZE);
KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
MiSyncThreadProcessViews(Process, Thread, sizeof(ETHREAD));
/* Crash system if DPC is being executed! */

View file

@ -347,6 +347,10 @@ KiSwapThread(IN PKTHREAD CurrentThread,
MiSyncThreadProcessViews(PsGetCurrentProcess(),
((PETHREAD)NextThread)->ThreadsProcess,
sizeof(EPROCESS));
MiSyncThreadProcessViews(PsGetCurrentProcess(),
(PVOID)((PETHREAD)NextThread)->Tcb.StackLimit,
NextThread->LargeStack ?
KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
/* Swap contexts */
ApcState = KiSwapContext(CurrentThread, NextThread);