mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2026-07-31 08:38:30 -05:00
* Extend the header size to 4KB align the code segment in the image file. A recent change (commit e41655885) to the Fedora implementation of the GRUB "linux" command for EFI boot means it now loads the entire image (including the header) at the preferred load address instead of just loading the code section. This means the code section is no longer 4KB aligned. In our image, the code section contains the combined .text and .data sections, so this means the .data section is also no longer 4kB aligned, which results in a GPF when the startup code loads the new page directory address into CR3. Work around this issue by extending the header size to force the code to start on a 4KB boundary. * Disable memory write protection after EFI setup. A recent change (commit e41655885) to the Fedora implementation of the GRUB "linux" command for EFI boot means it now attempts to make the loaded code section read-only, using the EFI_MEMORY_ATTRIBUTE_PROTOCOL. In our image the code section contains the combined .text and .data sections. Our startup code needs to write to the .data section before we can switch to our own page descriptor table, so globally disable write protection as soon as we return from efisetup(). Our page descriptor table makes all pages writable (we need to be able to write to memory to test it), so there's no need to reenable the write protection once we've made the switch. I have no UEFI firmware that implements the EFI_MEMORY_ATTRIBUTE_PROTOCOL, so this fix is not yet proven.