Author: sginsberg Date: Wed Aug 13 12:00:49 2008 New Revision: 35308
URL: http://svn.reactos.org/svn/reactos?rev=35308&view=rev Log: - "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)
Modified: trunk/reactos/ntoskrnl/ke/procobj.c trunk/reactos/ntoskrnl/ke/thrdschd.c
Modified: trunk/reactos/ntoskrnl/ke/procobj.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/procobj.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/ke/procobj.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/procobj.c [iso-8859-1] Wed Aug 13 12:00:49 2008 @@ -451,7 +451,7 @@ 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 @@ 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! */
Modified: trunk/reactos/ntoskrnl/ke/thrdschd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/thrdschd.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/ke/thrdschd.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/thrdschd.c [iso-8859-1] Wed Aug 13 12:00:49 2008 @@ -347,6 +347,10 @@ 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);