From: Kim Phillips <kim.phillips@amd.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
"Nikunj A Dadhania" <nikunj@amd.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
"Michael Roth" <michael.roth@amd.com>,
Borislav Petkov <borislav.petkov@amd.com>,
Borislav Petkov <bp@alien8.de>, Naveen Rao <naveen.rao@amd.com>,
Dave Hansen <dave.hansen@linux.intel.com>, <tglx@kernel.org>,
<mingo@redhat.com>, <ardb@kernel.org>, <hpa@zytor.com>
Cc: <linux-kernel@vger.kernel.org>, <x86@kernel.org>,
<kvm@vger.kernel.org>, Kim Phillips <kim.phillips@amd.com>,
Nathan Fontenot <nathan.fontenot@amd.com>
Subject: [PATCH 2/3] x86/sev: Report distinct termination reasons in do_vc_no_ghcb()
Date: Tue, 17 Nov 2026 16:32:56 -0600 [thread overview]
Message-ID: <20261117223257.748178-3-kim.phillips@amd.com> (raw)
In-Reply-To: <20261117223257.748178-1-kim.phillips@amd.com>
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 <kim.phillips@amd.com>
---
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
next prev parent reply other threads:[~2026-11-17 22:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 22:32 [PATCH 0/3] x86/sev: Make guest termination reasons identifiable Kim Phillips
2026-11-17 22:32 ` [PATCH 1/3] x86/sev: Report distinct termination reasons for generic requests Kim Phillips
2026-11-17 22:45 ` sashiko-bot
2026-11-17 22:32 ` Kim Phillips [this message]
2026-11-17 22:32 ` [PATCH 3/3] x86/sev: Distinguish CC-blob failures from generic SNP-unsupported Kim Phillips
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117223257.748178-3-kim.phillips@amd.com \
--to=kim.phillips@amd.com \
--cc=ardb@kernel.org \
--cc=borislav.petkov@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kprateek.nayak@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=nathan.fontenot@amd.com \
--cc=naveen.rao@amd.com \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox