From 54422db2b8c57e14fcd8dfa80366e232d8e08bfa Mon Sep 17 00:00:00 2001 From: Daniel Victor Date: Thu, 30 Apr 2026 18:56:19 -0300 Subject: [PATCH] [FREELDR] Fix UEFI IA-32 boot (#8886) The PAE flag might be enabled on some x86-32 UEFI platforms, causing a crash in the kernel. ``` Assertion C:\reactos-master\reactos\ntoskrnl\mm\ARM3\miarm.h(971): PointerPte->u.Hard.Valid == 0 nt!MI_WRITE_VALID_PTE+0x28: 822d1d08 cd2c int 2Ch ``` Tested using qemu with `OVMF32_CODE_4M.fd` firmware, and with 32bit UEFI in VMware. --- boot/freeldr/freeldr/ntldr/arch/i386/winldr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c b/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c index 2a2054ff405..3b7674d236a 100644 --- a/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c +++ b/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c @@ -455,6 +455,12 @@ WinLdrSetProcessorContext( /* Re-initialize EFLAGS */ __writeeflags(0); + /* Disable paging first before disabling PAE to avoid crash + * because UEFI might have enabled paged mode with PAE. + * Our kernel doesn't support PAE, so disable it. */ + __writecr0(__readcr0() & ~CR0_PG); + __writecr4(__readcr4() & ~CR4_PAE); + /* Set the PDBR */ __writecr3((ULONG_PTR)PDE);