Six SEV failure sites terminate the guest with the generic (SEV_TERM_SET_GEN, GHCB_SEV_ES_GEN_REQ) reason pair. Since the GHCB MSR termination protocol only conveys a 4-bit reason set and an 8-bit reason code to the hypervisor, all of these failures are indistinguishable from the VMM's point of view, which makes triaging a dead guest harder in environments without a working console. Add distinct Linux-specific reason codes and switch each generic callsite to a specific (SEV_TERM_SET_LINUX, GHCB_TERM_*) pair so the failing component is identifiable from the termination code alone. The four #VC handling failures (decompressor, MSR-protocol, early boot and runtime) share a single GHCB_TERM_VC_FAIL code as they represent the same failure class; the remaining two sites use GHCB_TERM_GHCB_SETUP and GHCB_TERM_NEGOTIATE. Signed-off-by: Kim Phillips --- arch/x86/boot/compressed/sev-handle-vc.c | 4 ++-- arch/x86/boot/startup/sev-shared.c | 2 +- arch/x86/coco/sev/core.c | 2 +- arch/x86/coco/sev/vc-handle.c | 4 ++-- arch/x86/include/asm/sev-common.h | 3 +++ 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/boot/compressed/sev-handle-vc.c b/arch/x86/boot/compressed/sev-handle-vc.c index 030001b46554..8a4963193114 100644 --- a/arch/x86/boot/compressed/sev-handle-vc.c +++ b/arch/x86/boot/compressed/sev-handle-vc.c @@ -101,7 +101,7 @@ void do_boot_stage2_vc(struct pt_regs *regs, unsigned long exit_code) enum es_result result; if (!boot_ghcb && !early_setup_ghcb()) - sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SEV_ES_GEN_REQ); + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_GHCB_SETUP); vc_ghcb_invalidate(boot_ghcb); result = vc_init_em_ctxt(&ctxt, regs, exit_code); @@ -132,5 +132,5 @@ void do_boot_stage2_vc(struct pt_regs *regs, unsigned long exit_code) if (result == ES_OK) vc_finish_insn(&ctxt); else if (result != ES_RETRY) - sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SEV_ES_GEN_REQ); + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_VC_FAIL); } diff --git a/arch/x86/boot/startup/sev-shared.c b/arch/x86/boot/startup/sev-shared.c index d9ac3a929d33..1e4fef117171 100644 --- a/arch/x86/boot/startup/sev-shared.c +++ b/arch/x86/boot/startup/sev-shared.c @@ -514,7 +514,7 @@ void do_vc_no_ghcb(struct pt_regs *regs, unsigned long exit_code) fail: /* Terminate the guest */ - sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SEV_ES_GEN_REQ); + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_VC_FAIL); } struct cc_setup_data { diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index eb2e853e950a..e94746b78e9a 100644 --- a/arch/x86/coco/sev/core.c +++ b/arch/x86/coco/sev/core.c @@ -1108,7 +1108,7 @@ void setup_ghcb(void) * This gets called only in the BSP boot phase. */ if (!sev_es_negotiate_protocol()) - sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SEV_ES_GEN_REQ); + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_NEGOTIATE); /* * Clear the boot_ghcb. The first exception comes in before the bss diff --git a/arch/x86/coco/sev/vc-handle.c b/arch/x86/coco/sev/vc-handle.c index f25d302efceb..fc390c0deb55 100644 --- a/arch/x86/coco/sev/vc-handle.c +++ b/arch/x86/coco/sev/vc-handle.c @@ -975,7 +975,7 @@ noinstr void kernel_exc_vmm_communication(struct pt_regs *regs, unsigned long er show_regs(regs); /* Ask hypervisor to sev_es_terminate */ - sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SEV_ES_GEN_REQ); + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_VC_FAIL); /* If that fails and we get here - just panic */ panic("Returned from Terminate-Request to Hypervisor\n"); @@ -1067,6 +1067,6 @@ bool __init handle_vc_boot_ghcb(struct pt_regs *regs) fail: show_regs(regs); - sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SEV_ES_GEN_REQ); + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_VC_FAIL); } diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h index 01a6e4dbe423..3717796c4673 100644 --- a/arch/x86/include/asm/sev-common.h +++ b/arch/x86/include/asm/sev-common.h @@ -209,6 +209,9 @@ struct snp_psc_desc { #define GHCB_TERM_SECURE_TSC 10 /* Secure TSC initialization failed */ #define GHCB_TERM_SVSM_CA_REMAP_FAIL 11 /* SVSM is present but CA could not be remapped */ #define GHCB_TERM_SAVIC_FAIL 12 /* Secure AVIC-specific failure */ +#define GHCB_TERM_VC_FAIL 13 /* #VC exception handling failure */ +#define GHCB_TERM_GHCB_SETUP 14 /* GHCB setup/mapping failure */ +#define GHCB_TERM_NEGOTIATE 15 /* HV GHCB protocol negotiation failure */ #define GHCB_RESP_CODE(v) ((v) & GHCB_MSR_INFO_MASK) -- 2.43.0