[NTOS:MM] Fix another instance of reentrant spinlock acquisition

This commit is contained in:
Jérôme Gardou 2021-05-20 11:48:02 +02:00 committed by Jérôme Gardou
parent 31322f5df9
commit 91587a432b
4 changed files with 19 additions and 7 deletions

View file

@ -160,3 +160,16 @@ CcpPinMappedData(IN PNOCC_CACHE_MAP Map,
IN ULONG Length,
IN ULONG Flags,
IN OUT PVOID *Bcb);
ULONG
MmGetReferenceCountPageWithoutLock(PFN_NUMBER Page)
{
ULONG Ret;
KIRQL OldIrql = MiAcquirePfnLock();
Ret = MmGetReferenceCountPage(Page);
MiReleasePfnLock(OldIrql);
return Ret;
}

View file

@ -643,7 +643,7 @@ MiFreeSegmentPage(PMM_SECTION_SEGMENT Segment,
OldPage,
FileOffset->QuadPart,
Segment,
MmGetReferenceCountPage(OldPage),
MmGetReferenceCountPageWithoutLock(OldPage),
Entry,
IS_DIRTY_SSE(Entry) ? "true" : "false");

View file

@ -172,11 +172,11 @@ MmFinalizeSectionPageOut(PMM_SECTION_SEGMENT Segment,
SWAPENTRY Swap = MmGetSavedSwapEntryPage(Page);
/* Bail early if the reference count isn't where we need it */
if (MmGetReferenceCountPage(Page) != 1)
if (MmGetReferenceCountPageWithoutLock(Page) != 1)
{
DPRINT1("Cannot page out locked page %x with ref count %lu\n",
Page,
MmGetReferenceCountPage(Page));
MmGetReferenceCountPageWithoutLock(Page));
return STATUS_UNSUCCESSFUL;
}
@ -357,7 +357,7 @@ MmpPageOutPhysicalAddress(PFN_NUMBER Page)
NTSTATUS Status = STATUS_SUCCESS;
MM_REQUIRED_RESOURCES Resources = { 0 };
DPRINTC("Page out %x (ref ct %x)\n", Page, MmGetReferenceCountPage(Page));
DPRINTC("Page out %x (ref ct %x)\n", Page, MmGetReferenceCountPageWithoutLock(Page));
ExAcquireFastMutex(&MiGlobalPageOperation);
if ((Segment = MmGetSectionAssociation(Page, &FileOffset)))

View file

@ -537,20 +537,19 @@ ULONG
NTAPI
MmGetReferenceCountPage(PFN_NUMBER Pfn)
{
KIRQL oldIrql;
ULONG RCount;
PMMPFN Pfn1;
MI_ASSERT_PFN_LOCK_HELD();
DPRINT("MmGetReferenceCountPage(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT);
oldIrql = MiAcquirePfnLock();
Pfn1 = MiGetPfnEntry(Pfn);
ASSERT(Pfn1);
ASSERT_IS_ROS_PFN(Pfn1);
RCount = Pfn1->u3.e2.ReferenceCount;
MiReleasePfnLock(oldIrql);
return(RCount);
}