Correctly initialize PFN entries for pre-mapped KSEG0 based memory
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 27s
Builds / ExectOS (amd64, release) (push) Successful in 46s
Builds / ExectOS (i686, release) (push) Successful in 43s

This commit is contained in:
2026-01-14 17:44:50 +01:00
parent 587b85d0a4
commit 0f38d39705

View File

@@ -190,6 +190,7 @@ MM::Pfn::ProcessMemoryDescriptor(IN PFN_NUMBER BasePage,
IN LOADER_MEMORY_TYPE MemoryType) IN LOADER_MEMORY_TYPE MemoryType)
{ {
PFN_NUMBER PageNumber; PFN_NUMBER PageNumber;
PMMPDE PointerPde;
PMMPFN Pfn; PMMPFN Pfn;
/* Check if the memory descriptor describes a free memory region */ /* Check if the memory descriptor describes a free memory region */
@@ -227,17 +228,24 @@ MM::Pfn::ProcessMemoryDescriptor(IN PFN_NUMBER BasePage,
/* Get the PFN entry for the current ROM page */ /* Get the PFN entry for the current ROM page */
Pfn = GetPfnEntry(BasePage + PageNumber); Pfn = GetPfnEntry(BasePage + PageNumber);
/* Ensure that the page is not already in-use */
if(Pfn->u3.e2.ReferenceCount == 0)
{
/* Get the page directory entry for the current page */
PointerPde = MM::Paging::GetPdeAddress((PVOID)(KSEG0_BASE + (BasePage << MM_PAGE_SHIFT)));
/* Initialize the PFN entry to represent a ROM page */ /* Initialize the PFN entry to represent a ROM page */
Pfn->PteAddress = 0; Pfn->PteAddress = MM::Paging::GetPteAddress((PVOID)(KSEG0_BASE + (BasePage << MM_PAGE_SHIFT)));
Pfn->u1.Flink = 0; Pfn->u1.Flink = 0;
Pfn->u2.ShareCount = 0; Pfn->u2.ShareCount = 0;
Pfn->u3.e1.CacheAttribute = PfnNonCached; Pfn->u3.e1.CacheAttribute = PfnCached;
Pfn->u3.e1.PageLocation = 0; Pfn->u3.e1.PageLocation = 0;
Pfn->u3.e1.PrototypePte = 1; Pfn->u3.e1.PrototypePte = 1;
Pfn->u3.e1.Rom = 1; Pfn->u3.e1.Rom = 1;
Pfn->u3.e2.ReferenceCount = 0; Pfn->u3.e2.ReferenceCount = 0;
Pfn->u4.InPageError = 0; Pfn->u4.InPageError = 0;
Pfn->u4.PteFrame = 0; Pfn->u4.PteFrame = MM::Paging::GetPageFrameNumber(PointerPde);
}
} }
break; break;
default: default:
@@ -247,8 +255,20 @@ MM::Pfn::ProcessMemoryDescriptor(IN PFN_NUMBER BasePage,
/* Get the PFN entry for the current in-use page */ /* Get the PFN entry for the current in-use page */
Pfn = GetPfnEntry(BasePage + PageNumber); Pfn = GetPfnEntry(BasePage + PageNumber);
/* Mark the PFN as active and valid to prevent it from being allocated */ /* Ensure that the page is not already in-use */
if(Pfn->u3.e2.ReferenceCount == 0)
{
/* Get the page directory entry for the current page */
PointerPde = MM::Paging::GetPdeAddress((PVOID)(KSEG0_BASE + (BasePage << MM_PAGE_SHIFT)));
/* Initialize the PFN entry to represent an in-use page and prevent it from being allocated */
Pfn->PteAddress = MM::Paging::GetPteAddress((PVOID)(KSEG0_BASE + (BasePage << MM_PAGE_SHIFT)));
Pfn->u2.ShareCount++;
Pfn->u3.e1.CacheAttribute = PfnCached;
Pfn->u3.e1.PageLocation = ActiveAndValid; Pfn->u3.e1.PageLocation = ActiveAndValid;
Pfn->u3.e2.ReferenceCount = 1;
Pfn->u4.PteFrame = MM::Paging::GetPageFrameNumber(PointerPde);
}
} }
break; break;
} }