]> git.baikalelectronics.ru Git - kernel.git/commit
x86/boot: Put globals that are accessed early into the .data section
authorMichael Roth <michael.roth@amd.com>
Wed, 20 Apr 2022 15:26:13 +0000 (10:26 -0500)
committerBorislav Petkov <bp@suse.de>
Wed, 20 Apr 2022 18:10:54 +0000 (20:10 +0200)
commit850db4a905d361f14de9d1adce558bc50854bbe0
tree45069fe71abd5adf737d9c88b83a75547566e211
parentcfd7a40ccc6e487362703e3f500d5162e5e7de69
x86/boot: Put globals that are accessed early into the .data section

The helpers in arch/x86/boot/compressed/efi.c might be used during
early boot to access the EFI system/config tables, and in some cases
these EFI helpers might attempt to print debug/error messages, before
console_init() has been called.

__putstr() checks some variables to avoid printing anything before
the console has been initialized, but this isn't enough since those
variables live in .bss, which may not have been cleared yet. This can
lead to a triple-fault occurring, primarily when booting in legacy/CSM
mode (where EFI helpers will attempt to print some debug messages).

Fix this by declaring these globals in .data section instead so there
is no dependency on .bss being cleared before accessing them.

Fixes: 3466a59e1c7b7 ("x86/compressed: Add SEV-SNP feature detection/setup")
Reported-by: Borislav Petkov <bp@suse.de>
Suggested-by: Thomas Lendacky <Thomas.Lendacky@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20220420152613.145077-1-michael.roth@amd.com
arch/x86/boot/compressed/early_serial_console.c
arch/x86/boot/compressed/misc.c