[PATCH] xen/efi: Explicitly set NX_COMPAT on xen.efi

Andrew Cooper posted 1 patch 22 hours ago
xen/arch/x86/Makefile | 1 +
1 file changed, 1 insertion(+)
[PATCH] xen/efi: Explicitly set NX_COMPAT on xen.efi
Posted by Andrew Cooper 22 hours ago
Binutils since 2.45 no longer set NX_COMPAT.  Programs have to ask for it
explicitly.

Xen is NX_COMPAT-able; Xen does not execute from it's stack at all.  The
property is mandated by the Microsoft UEFI signing requirements.

The --nxcompat option is available since binutils 2.20 and llvm 6, so can be
used unconditionally given our toolchain baseline.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Roger Pau Monné <roger@xenproject.org>
CC: Teddy Astie <teddy.astie@vates.tech>
CC: Ross Lagerwall <ross.lagerwall@citrix.com>

Backporting notes: 4.20 and earlier need this turning into an $(ld-option).
---
 xen/arch/x86/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 2be90ea09880..320593a1e824 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -131,6 +131,7 @@ EFI_LDFLAGS += --major-image-version=$(XEN_VERSION)
 EFI_LDFLAGS += --minor-image-version=$(XEN_SUBVERSION)
 EFI_LDFLAGS += --major-os-version=2 --minor-os-version=0
 EFI_LDFLAGS += --major-subsystem-version=2 --minor-subsystem-version=0
+EFI_LDFLAGS += --nxcompat
 # It seems ld unfortunately can't set a custom timestamp, so add a zero value
 # for the timestamp (option --no-insert-timestamp) if SOURCE_DATE_EPOCH is
 # defined to make reproducible builds possible.

base-commit: 56e231174e1050a43cf199411d5b8a041f5625c6
-- 
2.39.5


Re: [PATCH] xen/efi: Explicitly set NX_COMPAT on xen.efi
Posted by Jan Beulich 22 hours ago
On 25.11.2026 13:23, Andrew Cooper wrote:
> Binutils since 2.45 no longer set NX_COMPAT.

For completeness - ld prior to 2.36 doesn't either.

>  Programs have to ask for it explicitly.
> 
> Xen is NX_COMPAT-able; Xen does not execute from it's stack at all.  The
> property is mandated by the Microsoft UEFI signing requirements.
> 
> The --nxcompat option is available since binutils 2.20 and llvm 6, so can be
> used unconditionally given our toolchain baseline.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
Re: [PATCH] xen/efi: Explicitly set NX_COMPAT on xen.efi
Posted by Andrew Cooper 22 hours ago
On 25/11/2026 12:43 pm, Jan Beulich wrote:
> On 25.11.2026 13:23, Andrew Cooper wrote:
>> Binutils since 2.45 no longer set NX_COMPAT.
> For completeness - ld prior to 2.36 doesn't either.

Oh, does it not?  In which case I'll adjust the sentence to this:

Binutils between 2.36 and 2.44 set NX_COMPAT by default.  Outside of
this range, programs have to ask for it explicitly.

>
>>  Programs have to ask for it explicitly.
>>
>> Xen is NX_COMPAT-able; Xen does not execute from it's stack at all.  The
>> property is mandated by the Microsoft UEFI signing requirements.
>>
>> The --nxcompat option is available since binutils 2.20 and llvm 6, so can be
>> used unconditionally given our toolchain baseline.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Thanks.

~Andrew