Page MenuHomeFreeBSD

loader: Allocate trampoline as EfiLoaderCode, not Data
ClosedPublic

Authored by emaste on Jul 21 2026, 7:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Sep 5, 10:39 AM
Unknown Object (File)
Thu, Aug 27, 12:05 AM
Unknown Object (File)
Thu, Aug 27, 12:01 AM
Unknown Object (File)
Tue, Aug 25, 4:34 AM
Unknown Object (File)
Fri, Aug 21, 4:14 PM
Unknown Object (File)
Fri, Aug 21, 1:09 AM
Unknown Object (File)
Thu, Aug 20, 9:44 AM
Unknown Object (File)
Tue, Aug 11, 11:45 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I tested this patch on the nigeria-sp7 in the Kitchener office, and it resolves an exception that originally took place during the loader stage.

stand/efi/loader/arch/amd64/elf64_freebsd.c
114

The trampoline stack is located at the same page as code. So for EfiLoaderCode, could it be that some fw would deny the write?

stand/efi/loader/arch/amd64/elf64_freebsd.c
114

I am not certain, but believe that we will get only RWX or RW from AllocatePages for code or data. It may happen for PE image sections but not for allocations, I think.

If this is a concern we'd need to split into two allocations I suppose. Or EFI_MEMORY_ATTRIBUTE_PROTOCOL

This revision is now accepted and ready to land.Jul 21 2026, 9:01 PM

So you can't allocate pages for code read only... you've got to write to them sometime and there's no interface to change the mapping.

EFI_MEMORY_ATTRIBUTE_PROTOCOL is the interface to change mapping

EFI_MEMORY_ATTRIBUTE_PROTOCOL is the interface to change mapping

Oh! That's shiny. I'll have to try that out... While sharing the stack and trampoline code is super-old-school, I know that some uses of that cause security problems... So far none here, but we'll keep this in mind if something pops up or I get a bunch of time to test it, etc, which I might have later in the year.