From f4c3300d88189ab18b6459e22e1aa945ab1d3f6f Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Tue, 15 Oct 2024 09:25:12 +0100 Subject: [PATCH] x86/boot: Align mbi2.c stack to 16 bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of Xen is built with a stack alignment of 8 bytes, but the UEFI spec mandates 16 and UEFI services will fault if the stack is misaligned. While the caller of efi_multiboot2_prelude() takes care to align the stack, mbi2.c accidentally got the Xen-wide default of 8, and has a 50% chance of crashing depending on how many variables the compiler decided to spill to the stack. Compile mbi2.c with the appropriate alignment for UEFI functionality. Also take the opportunity to make it a fully .init object. Fixes: eb21ce14d709 ('x86/boot: Rewrite EFI/MBI2 code partly in C') Signed-off-by: Frediano Ziglio Reviewed-by: Jan Beulich Acked-by: Marek Marczykowski-Górecki [rewrite the commit message] Signed-off-by: Andrew Cooper --- xen/arch/x86/efi/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile index 7e2b5c07de..c6678652fc 100644 --- a/xen/arch/x86/efi/Makefile +++ b/xen/arch/x86/efi/Makefile @@ -9,11 +9,11 @@ $(obj)/%.o: $(src)/%.ihex FORCE $(obj)/boot.init.o: $(obj)/buildid.o $(call cc-option-add,cflags-stack-boundary,CC,-mpreferred-stack-boundary=4) -$(addprefix $(obj)/,$(EFIOBJ-y)): CFLAGS_stack_boundary := $(cflags-stack-boundary) +$(addprefix $(obj)/,$(EFIOBJ-y) mbi2.init.o): CFLAGS_stack_boundary := $(cflags-stack-boundary) obj-y := common-stub.o stub.o obj-$(XEN_BUILD_EFI) := $(filter-out %.init.o,$(EFIOBJ-y)) obj-bin-$(XEN_BUILD_EFI) := $(filter %.init.o,$(EFIOBJ-y)) -obj-bin-y += mbi2.o +obj-bin-y += mbi2.init.o extra-$(XEN_BUILD_EFI) += buildid.o relocs-dummy.o nocov-$(XEN_BUILD_EFI) += stub.o