Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/boot: Drop redundant RMPADJUST in SEV SVSM presence check

snp_vmpl will be assigned a non-zero value when executing at a VMPL other than
0, and this is inferred from a call to RMPADJUST, which only works when
running at VMPL0.

This means that testing snp_vmpl is sufficient, and there is no need to
perform the same check again.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250828102202.1849035-34-ardb+git@google.com

authored by

Ard Biesheuvel and committed by
Borislav Petkov (AMD)
68a501d7 c54604fb

+3 -17
+3 -17
arch/x86/boot/compressed/sev.c
··· 406 406 */ 407 407 if (sev_status & MSR_AMD64_SEV_SNP_ENABLED) { 408 408 u64 hv_features; 409 - int ret; 410 409 411 410 hv_features = get_hv_features(); 412 411 if (!(hv_features & GHCB_HV_FT_SNP)) 413 412 sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED); 414 413 415 414 /* 416 - * Enforce running at VMPL0 or with an SVSM. 417 - * 418 - * Use RMPADJUST (see the rmpadjust() function for a description of 419 - * what the instruction does) to update the VMPL1 permissions of a 420 - * page. If the guest is running at VMPL0, this will succeed. If the 421 - * guest is running at any other VMPL, this will fail. Linux SNP guests 422 - * only ever run at a single VMPL level so permission mask changes of a 423 - * lesser-privileged VMPL are a don't-care. 415 + * Running at VMPL0 is required unless an SVSM is present and 416 + * the hypervisor supports the required SVSM GHCB events. 424 417 */ 425 - ret = rmpadjust((unsigned long)&boot_ghcb_page, RMP_PG_SIZE_4K, 1); 426 - 427 - /* 428 - * Running at VMPL0 is not required if an SVSM is present and the hypervisor 429 - * supports the required SVSM GHCB events. 430 - */ 431 - if (ret && 432 - !(snp_vmpl && (hv_features & GHCB_HV_FT_SNP_MULTI_VMPL))) 418 + if (snp_vmpl && !(hv_features & GHCB_HV_FT_SNP_MULTI_VMPL)) 433 419 sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_NOT_VMPL0); 434 420 } 435 421