do_vc_no_ghcb() funnels every failure through a single label, so a guest that dies in the MSR-protocol #VC handler reports GHCB_TERM_VC_FAIL whether the CPUID table lookup failed, the hypervisor fallback failed, or the hypervisor lied about SEV being active. CPUID is by far the most common early-boot #VC source, so it is worth separating out from the generic #VC failure class. Use the existing GHCB_TERM_CPUID for the CPUID-handling failures (the snp_cpuid() error and the two SEV sanity checks on the returned values) and GHCB_TERM_CPUID_HV for a failed hypervisor fallback. The two checks that reject the #VC before any CPUID work is attempted - a non-CPUID exit-code and a non-CPUID faulting instruction - keep reporting GHCB_TERM_VC_FAIL. No new reason codes are needed. Signed-off-by: Kim Phillips --- arch/x86/boot/startup/sev-shared.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/boot/startup/sev-shared.c b/arch/x86/boot/startup/sev-shared.c index 1e4fef117171..9ffe04dfb28c 100644 --- a/arch/x86/boot/startup/sev-shared.c +++ b/arch/x86/boot/startup/sev-shared.c @@ -470,14 +470,14 @@ void do_vc_no_ghcb(struct pt_regs *regs, unsigned long exit_code) goto cpuid_done; if (ret != -EOPNOTSUPP) - goto fail; + goto fail_cpuid; /* * This is reached by a SEV-ES guest and needs to invoke the HV for * the CPUID data. */ if (__sev_cpuid_hv_msr(&leaf)) - goto fail; + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_CPUID_HV); cpuid_done: regs->ax = leaf.eax; @@ -502,16 +502,20 @@ void do_vc_no_ghcb(struct pt_regs *regs, unsigned long exit_code) if (fn == 0x80000000 && (regs->ax < 0x8000001f)) /* SEV leaf check */ - goto fail; + goto fail_cpuid; else if ((fn == 0x8000001f && !(regs->ax & BIT(1)))) /* SEV bit */ - goto fail; + goto fail_cpuid; /* Skip over the CPUID two-byte opcode */ regs->ip += 2; return; +fail_cpuid: + /* Terminate the guest, blaming the CPUID handling */ + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_CPUID); + fail: /* Terminate the guest */ sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_VC_FAIL); -- 2.43.0