https://git.reactos.org/?p=reactos.git;a=commitdiff;h=727e73f253a665cb8a74b…
commit 727e73f253a665cb8a74b2144d884d4c03241677
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Mon Jan 25 09:23:46 2021 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Feb 3 09:41:23 2021 +0100
|NTOS:MM] Simplify some code
---
ntoskrnl/cache/section/sptab.c | 45 ++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/ntoskrnl/cache/section/sptab.c b/ntoskrnl/cache/section/sptab.c
index 7a2481a4752..f0cb3d36c2a 100644
--- a/ntoskrnl/cache/section/sptab.c
+++ b/ntoskrnl/cache/section/sptab.c
@@ -204,27 +204,30 @@ _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
OldEntry,
Entry);
- if (PFN_FROM_SSE(Entry) == PFN_FROM_SSE(OldEntry)) {
- /* Nothing */
- } else if (Entry && !IS_SWAP_FROM_SSE(Entry)) {
- ASSERT(!OldEntry || IS_SWAP_FROM_SSE(OldEntry));
- MmSetSectionAssociation(PFN_FROM_SSE(Entry), Segment, Offset);
- } else if (OldEntry && !IS_SWAP_FROM_SSE(OldEntry)) {
- ASSERT(!Entry || IS_SWAP_FROM_SSE(Entry));
+ if (Entry && !IS_SWAP_FROM_SSE(Entry))
+ {
+ /* We have a valid entry. See if we must do something */
+ if (OldEntry && !IS_SWAP_FROM_SSE(OldEntry))
+ {
+ /* The previous entry was valid. Shall we swap the Rmaps ? */
+ if (PFN_FROM_SSE(Entry) != PFN_FROM_SSE(OldEntry))
+ {
+ MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry));
+ MmSetSectionAssociation(PFN_FROM_SSE(Entry), Segment, Offset);
+ }
+ }
+ else
+ {
+ /* We're switching to a valid entry from an invalid one. Add the Rmap */
+ MmSetSectionAssociation(PFN_FROM_SSE(Entry), Segment, Offset);
+ }
+ }
+ else if (OldEntry && !IS_SWAP_FROM_SSE(OldEntry))
+ {
+ /* We're switching to an invalid entry from a valid one */
MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry));
- } else if (IS_SWAP_FROM_SSE(Entry)) {
- ASSERT(!IS_SWAP_FROM_SSE(OldEntry) ||
- SWAPENTRY_FROM_SSE(OldEntry) == MM_WAIT_ENTRY);
- if (OldEntry && SWAPENTRY_FROM_SSE(OldEntry) != MM_WAIT_ENTRY)
- MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry));
- } else if (IS_SWAP_FROM_SSE(OldEntry)) {
- ASSERT(!IS_SWAP_FROM_SSE(Entry));
- if (Entry)
- MmSetSectionAssociation(PFN_FROM_SSE(OldEntry), Segment, Offset);
- } else {
- /* We should not be replacing a page like this */
- ASSERT(FALSE);
}
+
PageTable->PageEntries[PageIndex] = Entry;
return STATUS_SUCCESS;
}
@@ -332,13 +335,13 @@ MmGetSectionAssociation(PFN_NUMBER Page,
PMM_SECTION_SEGMENT Segment = NULL;
PCACHE_SECTION_PAGE_TABLE PageTable;
- PageTable = (PCACHE_SECTION_PAGE_TABLE)MmGetSegmentRmap(Page,
- &RawOffset);
+ PageTable = MmGetSegmentRmap(Page, &RawOffset);
if (PageTable)
{
Segment = PageTable->Segment;
Offset->QuadPart = PageTable->FileOffset.QuadPart +
((ULONG64)RawOffset << PAGE_SHIFT);
+ ASSERT(PFN_FROM_SSE(PageTable->PageEntries[RawOffset]) == Page);
}
return Segment;