git: loader: Clear CR0.WP during EFI kernel relocation

Aaron LI aly at crater.dragonflybsd.org
Thu Oct 1 18:44:07 PDT 2026


commit 4ac0f974ad924e21db4fffc3a292ee79072ec326
Author: David Bidner <david at crap.solutions>
Date:   Thu Oct 1 05:04:52 2026 +0200

    loader: Clear CR0.WP during EFI kernel relocation
    
    Firmware on an HP ProDesk 600 G4 leaves relocation destination pages
    read-only. efi_copy_finish() faults at 0x1001000 with page-fault error
    code 3 (supervisor write, protection violation) while CR0.WP is set.
    
    Save CR0 and clear WP around the relocation copy after ExitBootServices,
    with interrupts disabled. Restore CR0 before entering the kernel. Reject
    active CET before leaving boot services, since it prevents clearing WP.
    
    Bug: https://bugs.dragonflybsd.org/issues/3427

Summary of changes:
 stand/boot/efi/loader/arch/x86_64/amd64_tramp.S   | 11 +++++++++++
 stand/boot/efi/loader/arch/x86_64/elf64_freebsd.c |  8 ++++++++
 2 files changed, 19 insertions(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/4ac0f974ad924e21db4fffc3a292ee79072ec326


-- 
DragonFly BSD source repository


More information about the Commits mailing list