Skip to content

Commit 8939301

Browse files
ardbiesheuvelbp3tk0v
authored andcommitted
x86/sev: Don't hang but terminate on failure to remap SVSM CA
Commit 09d3504 ("x86/sev: Avoid WARN()s and panic()s in early boot code") replaced a panic() that could potentially hit before the kernel is even mapped with a deadloop, to ensure that execution does not proceed when the condition in question hits. As Tom suggests, it is better to terminate and return to the hypervisor in this case, using a newly invented failure code to describe the failure condition. Suggested-by: Tom Lendacky <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Tom Lendacky <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 99b863d commit 8939301

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

arch/x86/coco/sev/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,8 +2356,8 @@ static __head void svsm_setup(struct cc_blob_sev_info *cc_info)
23562356
call.rax = SVSM_CORE_CALL(SVSM_CORE_REMAP_CA);
23572357
call.rcx = pa;
23582358
ret = svsm_perform_call_protocol(&call);
2359-
while (ret)
2360-
cpu_relax(); /* too early to panic */
2359+
if (ret)
2360+
sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_SVSM_CA_REMAP_FAIL);
23612361

23622362
RIP_REL_REF(boot_svsm_caa) = (struct svsm_ca *)pa;
23632363
RIP_REL_REF(boot_svsm_caa_pa) = pa;

arch/x86/include/asm/sev-common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ struct snp_psc_desc {
206206
#define GHCB_TERM_NO_SVSM 7 /* SVSM is not advertised in the secrets page */
207207
#define GHCB_TERM_SVSM_VMPL0 8 /* SVSM is present but has set VMPL to 0 */
208208
#define GHCB_TERM_SVSM_CAA 9 /* SVSM is present but CAA is not page aligned */
209+
#define GHCB_TERM_SVSM_CA_REMAP_FAIL 10 /* SVSM is present but CA could not be remapped */
209210

210211
#define GHCB_RESP_CODE(v) ((v) & GHCB_MSR_INFO_MASK)
211212

0 commit comments

Comments
 (0)