Author: fireball
Date: Fri Sep 30 21:45:25 2011
New Revision: 53909
URL:
http://svn.reactos.org/svn/reactos?rev=53909&view=rev
Log:
[NTOS/MM]
- Implement MiInitializePfnAndMakePteValid() which is basically MiInitializePfn() combined
with making PTE valid and some other changes.
- Don't initialize PTE and pass valid PTE for initialization to MiInitializePfn() when
allocating a page in special pool, this is wrong. Instead call a function designed to do
this - MiInitializePfnAndMakePteValid(). It performs correct checks and PFN reference
counting.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
trunk/reactos/ntoskrnl/mm/ARM3/special.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Fri Sep 30 21:45:25 2011
@@ -1152,6 +1152,14 @@
VOID
NTAPI
+MiInitializePfnAndMakePteValid(
+ IN PFN_NUMBER PageFrameIndex,
+ IN PMMPTE PointerPte,
+ IN MMPTE TempPte
+);
+
+VOID
+NTAPI
MiInitializePfnForOtherProcess(
IN PFN_NUMBER PageFrameIndex,
IN PMMPTE PointerPte,
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] Fri Sep 30 21:45:25 2011
@@ -776,6 +776,64 @@
Pfn1->u2.ShareCount++;
}
+VOID
+NTAPI
+MiInitializePfnAndMakePteValid(IN PFN_NUMBER PageFrameIndex,
+ IN PMMPTE PointerPte,
+ IN MMPTE TempPte)
+{
+ PMMPFN Pfn1;
+ NTSTATUS Status;
+ PMMPTE PointerPtePte;
+ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
+
+ /* PTE must be invalid */
+ ASSERT(PointerPte->u.Hard.Valid == 0);
+
+ /* Setup the PTE */
+ Pfn1 = MI_PFN_ELEMENT(PageFrameIndex);
+ Pfn1->PteAddress = PointerPte;
+ Pfn1->OriginalPte = DemandZeroPte;
+
+ /* Otherwise this is a fresh page -- set it up */
+ ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
+ Pfn1->u3.e2.ReferenceCount++;
+ Pfn1->u2.ShareCount++;
+ Pfn1->u3.e1.PageLocation = ActiveAndValid;
+ ASSERT(Pfn1->u3.e1.Rom == 0);
+ Pfn1->u3.e1.Modified = 1;
+
+ /* Get the page table for the PTE */
+ PointerPtePte = MiAddressToPte(PointerPte);
+ if (PointerPtePte->u.Hard.Valid == 0)
+ {
+ /* Make sure the PDE gets paged in properly */
+ Status = MiCheckPdeForPagedPool(PointerPte);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Crash */
+ KeBugCheckEx(MEMORY_MANAGEMENT,
+ 0x61940,
+ (ULONG_PTR)PointerPte,
+ (ULONG_PTR)PointerPtePte->u.Long,
+ (ULONG_PTR)MiPteToAddress(PointerPte));
+ }
+ }
+
+ /* Get the PFN for the page table */
+ PageFrameIndex = PFN_FROM_PTE(PointerPtePte);
+ ASSERT(PageFrameIndex != 0);
+ Pfn1->u4.PteFrame = PageFrameIndex;
+
+ /* Increase its share count so we don't get rid of it */
+ Pfn1 = MI_PFN_ELEMENT(PageFrameIndex);
+ Pfn1->u2.ShareCount++;
+
+ /* Write valid PTE */
+ MI_WRITE_VALID_PTE(PointerPte, TempPte);
+}
+
+
PFN_NUMBER
NTAPI
MiAllocatePfn(IN PMMPTE PointerPte,
Modified: trunk/reactos/ntoskrnl/mm/ARM3/special.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/special.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/special.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/special.c [iso-8859-1] Fri Sep 30 21:45:25 2011
@@ -234,8 +234,7 @@
/* Initialize PFN and make it valid */
TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
- MI_WRITE_VALID_PTE(PointerPte, TempPte);
- MiInitializePfn(PageFrameNumber, PointerPte, TRUE);
+ MiInitializePfnAndMakePteValid(PageFrameNumber, PointerPte, TempPte);
/* Release the PFN database lock */
KeReleaseQueuedSpinLock(LockQueuePfnLock, Irql);