Truncate memory descriptor to 4GB only with PML2
Builds / ExectOS (i686) (push) Successful in 36s Details
Builds / ExectOS (amd64) (push) Successful in 37s Details

This commit is contained in:
Rafal Kupiec 2024-04-29 23:59:17 +02:00
parent 763bade115
commit c4d5b5bb25
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
1 changed files with 16 additions and 4 deletions

View File

@ -325,11 +325,23 @@ BlMapEfiMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
continue;
}
/* Check if memory descriptor exceeds the lowest physical page */
if(Descriptor->PhysicalStart + (Descriptor->NumberOfPages << EFI_PAGE_SHIFT) > MAXUINT_PTR)
/* Check if preparing page map level 2 (non-PAE i686) */
if(PageMap->PageMapLevel == 2)
{
/* Truncate memory descriptor to the 4GB */
Descriptor->NumberOfPages = ((MAXUINT_PTR + 1) - Descriptor->PhysicalStart) >> EFI_PAGE_SHIFT;
/* Check if physical address starts beyond 4GB */
if(Descriptor->PhysicalStart > 0xFFFFFFFF)
{
/* Go to the next descriptor */
Descriptor = (PEFI_MEMORY_DESCRIPTOR)((PUCHAR)Descriptor + MemoryMap->DescriptorSize);
continue;
}
/* Check if memory descriptor exceeds the lowest physical page */
if(Descriptor->PhysicalStart + (Descriptor->NumberOfPages << EFI_PAGE_SHIFT) > MAXULONG)
{
/* Truncate memory descriptor to the 4GB */
Descriptor->NumberOfPages = (((ULONGLONG)MAXULONG + 1) - Descriptor->PhysicalStart) >> EFI_PAGE_SHIFT;
}
}
/* Convert EFI memory type into XTLDR memory type */