Author: sginsberg
Date: Thu Aug 14 07:42:57 2008
New Revision: 35333
URL:
http://svn.reactos.org/svn/reactos?rev=35333&view=rev
Log:
- Rework MiSyncThreadProcessViews
- Perform the Mm hack-sync in KiIdleLoop before switching context (thanks to Aleksey for
writing this!)
Modified:
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
trunk/reactos/ntoskrnl/ke/procobj.c
trunk/reactos/ntoskrnl/ke/thrdobj.c
trunk/reactos/ntoskrnl/ke/thrdschd.c
trunk/reactos/ntoskrnl/mm/mm.c
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Thu Aug 14 07:42:57 2008
@@ -1552,16 +1552,12 @@
IN BOOLEAN PurgeSection
);
-FORCEINLINE
-VOID
-NTAPI
-MiSyncThreadProcessViews(IN PVOID Process,
- IN PVOID Address,
- IN ULONG Size)
-{
- MmUpdatePageDir((PEPROCESS)Process, Address, Size);
-}
-
+/* ReactOS Mm Hack */
+VOID
+FASTCALL
+MiSyncThreadProcessViews(
+ IN PKTHREAD NextThread
+);
extern PMM_AVL_TABLE MmKernelAddressSpace;
Modified: trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/ctxswitch…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S [iso-8859-1] Thu Aug 14 07:42:57 2008
@@ -736,6 +736,10 @@
#endif
SwapContext:
+ /* ReactOS Mm Hack */
+ mov ecx, esi
+ call @MiSyncThreadProcessViews@4
+
/* Swap context at APC_LEVEL */
mov ecx, APC_LEVEL
call @KiSwapContextInternal@0
Modified: trunk/reactos/ntoskrnl/ke/procobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/procobj.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/procobj.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/procobj.c [iso-8859-1] Thu Aug 14 07:42:57 2008
@@ -447,12 +447,8 @@
ASSERT_PROCESS(Process);
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
- /* Make sure that we are in the right page directory */
- MiSyncThreadProcessViews(Process,
- (PVOID)Thread->StackLimit,
- Thread->LargeStack ?
- KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
- MiSyncThreadProcessViews(Process, Thread, sizeof(ETHREAD));
+ /* Make sure that we are in the right page directory (ReactOS Mm Hack) */
+ MiSyncThreadProcessViews(Thread);
/* Check if we're already in that process */
if (Thread->ApcState.Process == Process) return;
@@ -577,12 +573,8 @@
ASSERT_PROCESS(Process);
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
- /* Make sure that we are in the right page directory */
- MiSyncThreadProcessViews(Process,
- (PVOID)Thread->StackLimit,
- Thread->LargeStack ?
- KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
- MiSyncThreadProcessViews(Process, Thread, sizeof(ETHREAD));
+ /* Make sure that we are in the right page directory (ReactOS Mm Hack) */
+ MiSyncThreadProcessViews(Thread);
/* Crash system if DPC is being executed! */
if (KeIsExecutingDpc())
Modified: trunk/reactos/ntoskrnl/ke/thrdobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/thrdobj.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/thrdobj.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/thrdobj.c [iso-8859-1] Thu Aug 14 07:42:57 2008
@@ -810,12 +810,8 @@
Thread->StackLimit = (ULONG_PTR)KernelStack - KERNEL_STACK_SIZE;
Thread->KernelStackResident = TRUE;
- /* Make sure that we are in the right page directory */
- MiSyncThreadProcessViews(Process,
- (PVOID)Thread->StackLimit,
- Thread->LargeStack ?
- KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
- MiSyncThreadProcessViews(Process, Thread, sizeof(ETHREAD));
+ /* Make sure that we are in the right page directory (ReactOS Mm Hack) */
+ MiSyncThreadProcessViews(Thread);
/* Enter SEH to avoid crashes due to user mode */
Status = STATUS_SUCCESS;
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] Thu Aug 14 07:42:57 2008
@@ -344,13 +344,7 @@
WaitIrql = CurrentThread->WaitIrql;
/* REACTOS Mm Hack of Doom */
- MiSyncThreadProcessViews(PsGetCurrentProcess(),
- ((PETHREAD)NextThread)->ThreadsProcess,
- sizeof(EPROCESS));
- MiSyncThreadProcessViews(PsGetCurrentProcess(),
- (PVOID)((PETHREAD)NextThread)->Tcb.StackLimit,
- NextThread->LargeStack ?
- KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
+ MiSyncThreadProcessViews(NextThread);
/* Swap contexts */
ApcState = KiSwapContext(CurrentThread, NextThread);
@@ -720,13 +714,7 @@
ASSERT(OldIrql <= DISPATCH_LEVEL);
/* REACTOS Mm Hack of Doom */
- MiSyncThreadProcessViews(PsGetCurrentProcess(),
- ((PETHREAD)NextThread)->ThreadsProcess,
- sizeof(EPROCESS));
- MiSyncThreadProcessViews(PsGetCurrentProcess(),
- (PVOID)((PETHREAD)NextThread)->Tcb.StackLimit,
- NextThread->LargeStack ?
- KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
+ MiSyncThreadProcessViews(NextThread);
/* Swap to new thread */
KiSwapContext(Thread, NextThread);
Modified: trunk/reactos/ntoskrnl/mm/mm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mm.c?rev=35333…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mm.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/mm.c [iso-8859-1] Thu Aug 14 07:42:57 2008
@@ -23,6 +23,20 @@
MM_STATS MmStats;
/* FUNCTIONS ****************************************************************/
+
+VOID
+FASTCALL
+MiSyncThreadProcessViews(IN PKTHREAD NextThread)
+{
+ /* Hack Sync because Mm is broken */
+ MmUpdatePageDir(PsGetCurrentProcess(),
+ ((PETHREAD)NextThread)->ThreadsProcess,
+ sizeof(EPROCESS));
+ MmUpdatePageDir(PsGetCurrentProcess(),
+ (PVOID)((PETHREAD)NextThread)->Tcb.StackLimit,
+ NextThread->LargeStack ?
+ KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
+}
/*
* @implemented