[NTOS:MM] Get rid of MmSetCleanAllRmaps and MmIsDirtyPageRmap

Everything is wrong with them. Bad locking. Bad logic.
This commit is contained in:
Jérôme Gardou 2021-03-10 15:16:29 +01:00 committed by Jérôme Gardou
parent 7bffb92099
commit 9e121fb6c2
3 changed files with 1 additions and 66 deletions

View file

@ -903,13 +903,6 @@ VOID
NTAPI NTAPI
MmInitializeRmapList(VOID); MmInitializeRmapList(VOID);
VOID
NTAPI
MmSetCleanAllRmaps(PFN_NUMBER Page);
BOOLEAN
NTAPI
MmIsDirtyPageRmap(PFN_NUMBER Page);
NTSTATUS NTSTATUS
NTAPI NTAPI
MmPageOutPhysicalAddress(PFN_NUMBER Page); MmPageOutPhysicalAddress(PFN_NUMBER Page);

View file

@ -307,61 +307,6 @@ WriteSegment:
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
VOID
NTAPI
MmSetCleanAllRmaps(PFN_NUMBER Page)
{
PMM_RMAP_ENTRY current_entry;
KIRQL OldIrql;
OldIrql = MiAcquirePfnLock();
current_entry = MmGetRmapListHeadPage(Page);
if (current_entry == NULL)
{
DPRINT1("MmSetCleanAllRmaps: No rmaps.\n");
KeBugCheck(MEMORY_MANAGEMENT);
}
while (current_entry != NULL)
{
if (!RMAP_IS_SEGMENT(current_entry->Address))
MmSetCleanPage(current_entry->Process, current_entry->Address);
current_entry = current_entry->Next;
}
MiReleasePfnLock(OldIrql);
}
BOOLEAN
NTAPI
MmIsDirtyPageRmap(PFN_NUMBER Page)
{
PMM_RMAP_ENTRY current_entry;
KIRQL OldIrql;
BOOLEAN Dirty = FALSE;
OldIrql = MiAcquirePfnLock();
current_entry = MmGetRmapListHeadPage(Page);
if (current_entry == NULL)
{
DPRINT1("MmIsDirtyPageRmap: No rmaps.\n");
KeBugCheck(MEMORY_MANAGEMENT);
}
while (current_entry != NULL)
{
if (!RMAP_IS_SEGMENT(current_entry->Address))
{
if (MmIsDirtyPage(current_entry->Process, current_entry->Address))
{
Dirty = TRUE;
break;
}
}
current_entry = current_entry->Next;
}
MiReleasePfnLock(OldIrql);
return Dirty;
}
VOID VOID
NTAPI NTAPI
MmInsertRmap(PFN_NUMBER Page, PEPROCESS Process, MmInsertRmap(PFN_NUMBER Page, PEPROCESS Process,

View file

@ -4848,9 +4848,6 @@ MmCheckDirtySegment(
Entry = WRITE_SSE(Entry); Entry = WRITE_SSE(Entry);
MmSetPageEntrySectionSegment(Segment, Offset, Entry); MmSetPageEntrySectionSegment(Segment, Offset, Entry);
/* Tell the other users that we are clean again */
MmSetCleanAllRmaps(Page);
MmUnlockSectionSegment(Segment); MmUnlockSectionSegment(Segment);
if (FlagOn(*Segment->Flags, MM_DATAFILE_SEGMENT)) if (FlagOn(*Segment->Flags, MM_DATAFILE_SEGMENT))
@ -4915,7 +4912,7 @@ MmCheckDirtySegment(
else else
{ {
/* Check if someone dirtified this page while we were not looking */ /* Check if someone dirtified this page while we were not looking */
DirtyAgain = IS_DIRTY_SSE(Entry) || MmIsDirtyPageRmap(Page); DirtyAgain = IS_DIRTY_SSE(Entry);
} }
/* Drop the reference we got, deleting the write altogether. */ /* Drop the reference we got, deleting the write altogether. */