Skip to content

Commit e6e04ed

Browse files
tlendackySasha Levin
authored andcommitted
x86/boot/sev: Move SEV decompressor variables into the .data section
commit 4ca191c upstream. As part of the work to remove the dependency on calling into the decompressor code (startup_64()) for a UEFI boot, a call to rmpadjust() was removed from sev_enable() in favor of checking the value of the snp_vmpl variable. When booting through a non-UEFI path and calling startup_64(), the call to sev_enable() is performed before the BSS section is zeroed. With the removal of the rmpadjust() call and the corresponding check of the return code, the snp_vmpl variable is checked. Since the kernel is running at VMPL0, the snp_vmpl variable will not have been set and should be the default value of 0. However, since the call occurs before the BSS is zeroed, the snp_vmpl variable may not actually be zero, which will cause the guest boot to fail. Since the decompressor relocates itself, the BSS would need to be cleared both before and after the relocation, but this would, in effect, cause all of the changes to BSS variables before relocation to be lost after relocation. Instead, move the snp_vmpl variable into the .data section so that it is initialized and the value made safe during relocation. As a pre-caution against future changes, move other SEV-related decompressor variables into the .data section, too. Fixes: 68a501d ("x86/boot: Drop redundant RMPADJUST in SEV SVSM presence check") Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Changyuan Lyu <changyuanl@google.com> Tested-by: Kevin Hui <kevinhui@meta.com> Tested-by: Changyuan Lyu <changyuanl@google.com> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/5648b7de5b0a5d0dfef3785f9582b718678c6448.1770217260.git.thomas.lendacky@amd.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b91d180 commit e6e04ed

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

arch/x86/boot/compressed/sev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@
2828
#include "sev.h"
2929

3030
static struct ghcb boot_ghcb_page __aligned(PAGE_SIZE);
31-
struct ghcb *boot_ghcb;
31+
struct ghcb *boot_ghcb __section(".data");
3232

3333
#undef __init
3434
#define __init
3535

3636
#define __BOOT_COMPRESSED
3737

38-
u8 snp_vmpl;
39-
u16 ghcb_version;
38+
u8 snp_vmpl __section(".data");
39+
u16 ghcb_version __section(".data");
4040

41-
u64 boot_svsm_caa_pa;
41+
u64 boot_svsm_caa_pa __section(".data");
4242

4343
/* Include code for early handlers */
4444
#include "../../boot/startup/sev-shared.c"

arch/x86/boot/startup/sev-shared.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static u32 cpuid_std_range_max __ro_after_init;
3131
static u32 cpuid_hyp_range_max __ro_after_init;
3232
static u32 cpuid_ext_range_max __ro_after_init;
3333

34-
bool sev_snp_needs_sfw;
34+
bool sev_snp_needs_sfw __section(".data");
3535

3636
void __noreturn
3737
sev_es_terminate(unsigned int set, unsigned int reason)

0 commit comments

Comments
 (0)