]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
x86/boot: Align mbi2.c stack to 16 bytes
authorFrediano Ziglio <frediano.ziglio@cloud.com>
Tue, 15 Oct 2024 08:25:12 +0000 (09:25 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 15 Oct 2024 17:20:57 +0000 (18:20 +0100)
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 <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
[rewrite the commit message]
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/efi/Makefile

index 7e2b5c07deaaa630e3ecd43f6a1483d7252be0c4..c6678652fc984ec5480e85e5081c2ed6232b0677 100644 (file)
@@ -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