mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
[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. svn path=/trunk/; revision=53909
This commit is contained in:
parent
c596e299c6
commit
921e734833
3 changed files with 67 additions and 2 deletions
|
@ -1150,6 +1150,14 @@ MiInitializePfn(
|
|||
IN BOOLEAN Modified
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
MiInitializePfnAndMakePteValid(
|
||||
IN PFN_NUMBER PageFrameIndex,
|
||||
IN PMMPTE PointerPte,
|
||||
IN MMPTE TempPte
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
MiInitializePfnForOtherProcess(
|
||||
|
|
|
@ -776,6 +776,64 @@ MiInitializePfn(IN PFN_NUMBER PageFrameIndex,
|
|||
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,
|
||||
|
|
|
@ -234,8 +234,7 @@ MmAllocateSpecialPool(SIZE_T NumberOfBytes, ULONG Tag, POOL_TYPE PoolType, ULONG
|
|||
|
||||
/* 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);
|
||||
|
|
Loading…
Reference in a new issue