From 6aa148784b658271342d03b15331b8188ba3cc1d Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Mon, 22 Dec 2025 10:14:11 +0100 Subject: [PATCH] Select correct self-map base for PAE and non-PAE paging --- boot/xtldr/modules/xtos_o/i686/memory.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/boot/xtldr/modules/xtos_o/i686/memory.cc b/boot/xtldr/modules/xtos_o/i686/memory.cc index c2b2e1c..44ee233 100644 --- a/boot/xtldr/modules/xtos_o/i686/memory.cc +++ b/boot/xtldr/modules/xtos_o/i686/memory.cc @@ -59,9 +59,22 @@ EFI_STATUS Xtos::EnablePaging(IN PXTBL_PAGE_MAPPING PageMap) { EFI_STATUS Status; + ULONG_PTR SelfMapAddress; + + /* Initialize self map address */ + if(PageMap->PageMapLevel == 3) + { + /* For PML3 (PAE) use PTE base address */ + SelfMapAddress = MM_PTE_BASE; + } + else + { + /* For PML2 (PAE disabled) use legacy PDE base address */ + SelfMapAddress = MM_PDE_LEGACY_BASE; + } /* Build page map */ - Status = XtLdrProtocol->Memory.BuildPageMap(PageMap, MM_PTE_BASE); + Status = XtLdrProtocol->Memory.BuildPageMap(PageMap, SelfMapAddress); if(Status != STATUS_EFI_SUCCESS) { /* Failed to build page map */