x86/boot/compressed, efi: Merge multiple definitions of image_offset into one
authorArd Biesheuvel <ardb@kernel.org>
Tue, 22 Nov 2022 16:10:07 +0000 (17:10 +0100)
committerBorislav Petkov <bp@suse.de>
Thu, 24 Nov 2022 07:55:55 +0000 (08:55 +0100)
commit4b52016247aeaa55ca3e3bc2e03cd91114c145c2
treedbd637079dd18c6d25b952137b33ee1d7ceace02
parent7f22ca396778fea9332d83ec2359dbe8396e9a06
x86/boot/compressed, efi: Merge multiple definitions of image_offset into one

There is no need for head_32.S and head_64.S both declaring a copy of
the global 'image_offset' variable, so drop those and make the extern C
declaration the definition.

When image_offset is moved to the .c file, it needs to be placed
particularly in the .data section because it lands by default in the
.bss section which is cleared too late, in .Lrelocated, before the first
access to it and thus garbage gets read, leading to SEV guests exploding
in early boot.

This happens only when the SEV guest kernel is loaded through grub. If
supplied with qemu's -kernel command line option, that memory is always
cleared upfront by qemu and all is fine there.

  [ bp: Expand commit message with SEV aspect. ]

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20221122161017.2426828-8-ardb@kernel.org
arch/x86/boot/compressed/head_32.S
arch/x86/boot/compressed/head_64.S
drivers/firmware/efi/libstub/x86-stub.c