x86/boot: Align mbi2.c stack to 16 bytes

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: eb21ce14d7 ('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>
This commit is contained in:
Frediano Ziglio authored and Andrew Cooper committed 2024-10-15 18:20:57 +01:00
1 parent 3f6ee3db2e
commit f4c3300d88
1 file changed
+2 -2
+2 -2
View 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
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.