1
0
Fork 0
mirror of https://github.com/reactos/reactos.git synced 2025-05-23 19:14:48 +00:00

[NTOS:MM] Assert PFN lock ownership in MiInsertPageInFreeList.

AMD64 initialization previously only raised the IRQL.
It now acquires the lock where needed, as i386 does.
This commit is contained in:
Thomas Faber 2020-02-12 21:09:49 +01:00
parent 67b3b73d82
commit 6831468ccf
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
2 changed files with 8 additions and 13 deletions
ntoskrnl/mm

View file

@ -611,7 +611,7 @@ MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
PMMCOLOR_TABLES ColorTable; PMMCOLOR_TABLES ColorTable;
/* Make sure the page index is valid */ /* Make sure the page index is valid */
ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL); MI_ASSERT_PFN_LOCK_HELD();
ASSERT((PageFrameIndex != 0) && ASSERT((PageFrameIndex != 0) &&
(PageFrameIndex <= MmHighestPhysicalPage) && (PageFrameIndex <= MmHighestPhysicalPage) &&
(PageFrameIndex >= MmLowestPhysicalPage)); (PageFrameIndex >= MmLowestPhysicalPage));

View file

@ -533,6 +533,7 @@ MiAddDescriptorToDatabase(
TYPE_OF_MEMORY MemoryType) TYPE_OF_MEMORY MemoryType)
{ {
PMMPFN Pfn; PMMPFN Pfn;
KIRQL OldIrql;
ASSERT(!MiIsMemoryTypeInvisible(MemoryType)); ASSERT(!MiIsMemoryTypeInvisible(MemoryType));
@ -542,6 +543,9 @@ MiAddDescriptorToDatabase(
/* Get the last pfn of this descriptor. Note we loop backwards */ /* Get the last pfn of this descriptor. Note we loop backwards */
Pfn = &MmPfnDatabase[BasePage + PageCount - 1]; Pfn = &MmPfnDatabase[BasePage + PageCount - 1];
/* Lock the PFN Database */
OldIrql = MiAcquirePfnLock();
/* Loop all pages */ /* Loop all pages */
while (PageCount--) while (PageCount--)
{ {
@ -552,6 +556,9 @@ MiAddDescriptorToDatabase(
/* Go to the previous page */ /* Go to the previous page */
Pfn--; Pfn--;
} }
/* Release PFN database */
MiReleasePfnLock(OldIrql);
} }
else if (MemoryType == LoaderXIPRom) else if (MemoryType == LoaderXIPRom)
{ {
@ -668,8 +675,6 @@ NTAPI
INIT_FUNCTION INIT_FUNCTION
MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{ {
KIRQL OldIrql;
ASSERT(MxPfnAllocation != 0); ASSERT(MxPfnAllocation != 0);
/* Set some hardcoded addresses */ /* Set some hardcoded addresses */
@ -693,9 +698,6 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
MiBuildSystemPteSpace(); MiBuildSystemPteSpace();
/* Need to be at DISPATCH_LEVEL for MiInsertPageInFreeList */
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
/* Map the PFN database pages */ /* Map the PFN database pages */
MiBuildPfnDatabase(LoaderBlock); MiBuildPfnDatabase(LoaderBlock);
@ -705,16 +707,9 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
/* PFNs are initialized now! */ /* PFNs are initialized now! */
MiPfnsInitialized = TRUE; MiPfnsInitialized = TRUE;
//KeLowerIrql(OldIrql);
/* Need to be at DISPATCH_LEVEL for InitializePool */
//KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
/* Initialize the nonpaged pool */ /* Initialize the nonpaged pool */
InitializePool(NonPagedPool, 0); InitializePool(NonPagedPool, 0);
KeLowerIrql(OldIrql);
/* Initialize the balancer */ /* Initialize the balancer */
MmInitializeBalancer((ULONG)MmAvailablePages, 0); MmInitializeBalancer((ULONG)MmAvailablePages, 0);