]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
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)
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

index 3b354eb9516df416e8e2a595044c016fabf6f98f..6589ddd4cfaf2cb6f45e8bf14be03c95cc1c4881 100644 (file)
@@ -208,10 +208,6 @@ SYM_DATA_START_LOCAL(gdt)
        .quad   0x00cf92000000ffff      /* __KERNEL_DS */
 SYM_DATA_END_LABEL(gdt, SYM_L_LOCAL, gdt_end)
 
-#ifdef CONFIG_EFI_STUB
-SYM_DATA(image_offset, .long 0)
-#endif
-
 /*
  * Stack and heap for uncompression
  */
index 36f37f95c98857bd6bd071df61158ec632372ee4..34d03953b08c57be9ce599d44171d4e00176ba97 100644 (file)
@@ -718,10 +718,6 @@ SYM_DATA_START(boot32_idt)
 SYM_DATA_END_LABEL(boot32_idt, SYM_L_GLOBAL, boot32_idt_end)
 #endif
 
-#ifdef CONFIG_EFI_STUB
-SYM_DATA(image_offset, .long 0)
-#endif
-
 #ifdef CONFIG_AMD_MEM_ENCRYPT
        __HEAD
        .code32
index 33a7811e12c656428d82cc60f6718f38361019ac..a0bfd31358ba97b1ac8b604c98b1981b19364ee2 100644 (file)
@@ -23,7 +23,7 @@
 
 const efi_system_table_t *efi_system_table;
 const efi_dxe_services_table_t *efi_dxe_table;
-extern u32 image_offset;
+u32 image_offset __section(".data");
 static efi_loaded_image_t *image = NULL;
 
 static efi_status_t