https://git.reactos.org/?p=reactos.git;a=commitdiff;h=80dd9f5a90487188213da…
commit 80dd9f5a90487188213da24ff1e46335461e2281
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Mon Apr 10 22:14:23 2023 +0300
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Sat Jul 29 14:00:44 2023 +0300
[NTOS:Mm] Add PFN ShareCount handling to old Mm
---
ntoskrnl/mm/i386/page.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c
index 4c64dd2a941..38cd5066256 100644
--- a/ntoskrnl/mm/i386/page.c
+++ b/ntoskrnl/mm/i386/page.c
@@ -325,7 +325,18 @@ MmDeleteVirtualMappingEx(
if (!IsPhysical && OldPte.u.Hard.Valid)
{
- // TODO: Handle PFN ShareCount
+ PMMPFN Pfn1;
+ KIRQL OldIrql;
+
+ OldIrql = MiAcquirePfnLock();
+ Pfn1 = &MmPfnDatabase[OldPte.u.Hard.PageFrameNumber];
+ ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
+ ASSERT(Pfn1->u2.ShareCount > 0);
+ if (--Pfn1->u2.ShareCount == 0)
+ {
+ Pfn1->u3.e1.PageLocation = TransitionPage;
+ }
+ MiReleasePfnLock(OldIrql);
}
MiUnlockProcessWorkingSetUnsafe(Process, PsGetCurrentThread());
@@ -685,7 +696,14 @@ MmCreateVirtualMappingUnsafeEx(
if (!IsPhysical)
{
- // TODO: Handle PFN ShareCount
+ PMMPFN Pfn1;
+ KIRQL OldIrql;
+
+ OldIrql = MiAcquirePfnLock();
+ Pfn1 = &MmPfnDatabase[TempPte.u.Hard.PageFrameNumber];
+ Pfn1->u2.ShareCount++;
+ Pfn1->u3.e1.PageLocation = ActiveAndValid;
+ MiReleasePfnLock(OldIrql);
}
/* We don't need to flush the TLB here because it only caches valid translations