[ros-diffs] [ros-arm-bringup] 42252: - Create a double-mapping PTE for the shared user data region and fault it in whenever a process touches that address. - Remove the old hack which used the PCR's page frame number to create a fake PTE each time to reference it, basing on the fact that the shared user data region was on the same page as the PCR on certain architectures.

ros-arm-bringup at svn.reactos.org ros-arm-bringup at svn.reactos.org
Mon Jul 27 04:13:19 CEST 2009


Author: ros-arm-bringup
Date: Mon Jul 27 04:13:19 2009
New Revision: 42252

URL: http://svn.reactos.org/svn/reactos?rev=42252&view=rev
Log:
- Create a double-mapping PTE for the shared user data region and fault it in whenever a process touches that address.
- Remove the old hack which used the PCR's page frame number to create a fake PTE each time to reference it, basing on the fact that the shared user data region was on the same page as the PCR on certain architectures.

Modified:
    trunk/reactos/ntoskrnl/mm/mmfault.c
    trunk/reactos/ntoskrnl/mm/mminit.c

Modified: trunk/reactos/ntoskrnl/mm/mmfault.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mmfault.c?rev=42252&r1=42251&r2=42252&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mmfault.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/mmfault.c [iso-8859-1] Mon Jul 27 04:13:19 2009
@@ -150,7 +150,7 @@
    MEMORY_AREA* MemoryArea;
    NTSTATUS Status;
    BOOLEAN Locked = FromMdl;
-   PFN_TYPE Pfn;
+   extern PMMPTE MmSharedUserDataPte;
 
    DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
 
@@ -228,14 +228,8 @@
             break;
 
          case MEMORY_AREA_SHARED_DATA:
-            Pfn = MmGetPhysicalAddress((PVOID)PCR).LowPart >> PAGE_SHIFT;
-            Pfn++;
-            Status =
-               MmCreateVirtualMapping(PsGetCurrentProcess(),
-                                      (PVOID)PAGE_ROUND_DOWN(Address),
-                                      PAGE_READONLY,
-                                      &Pfn,
-                                      1);
+              *MiAddressToPte(USER_SHARED_DATA) = *MmSharedUserDataPte;
+              Status = STATUS_SUCCESS;
             break;
 
          default:

Modified: trunk/reactos/ntoskrnl/mm/mminit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=42252&r1=42251&r2=42252&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] Mon Jul 27 04:13:19 2009
@@ -48,6 +48,7 @@
 PBOOLEAN Mm64BitPhysicalAddress = FALSE;
 ULONG MmReadClusterSize;
 MM_STATS MmStats;
+PMMPTE MmSharedUserDataPte;
 PMMSUPPORT MmKernelAddressSpace;
 extern KMUTANT MmSystemLoadLock;
 extern ULONG MmBootImageSize;
@@ -181,6 +182,11 @@
 MmInitSystem(IN ULONG Phase,
              IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
+    extern MMPTE HyperTemplatePte;
+    PMMPTE PointerPte;
+    MMPTE TempPte = HyperTemplatePte;
+    PFN_NUMBER PageFrameNumber;
+    
     if (Phase == 0)
     {
         /* Initialize Mm bootstrap */
@@ -210,6 +216,31 @@
         MmInitSectionImplementation();
         MmInitPagingFile();
         
+        //
+        // Create a PTE to double-map the shared data section. We allocate it
+        // from paged pool so that we can't fault when trying to touch the PTE
+        // itself (to map it), since paged pool addresses will already be mapped
+        // by the fault handler.
+        //
+        MmSharedUserDataPte = ExAllocatePoolWithTag(PagedPool,
+                                                    sizeof(MMPTE),
+                                                    '  mM');
+        if (!MmSharedUserDataPte) return FALSE;
+        
+        //
+        // Now get the PTE for shared data, and read the PFN that holds it
+        //
+        PointerPte = MiAddressToPte(KI_USER_SHARED_DATA);
+        ASSERT(PointerPte->u.Hard.Valid == 1);
+        PageFrameNumber = PFN_FROM_PTE(PointerPte);
+        
+        //
+        // Now write a copy of it
+        //
+        TempPte.u.Hard.Owner = 1;
+        TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
+        *MmSharedUserDataPte = TempPte;
+        
         /*
          * Unmap low memory
          */




More information about the Ros-diffs mailing list