All of lore.kernel.org
 help / color / mirror / Atom feed
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 1/3] x86/sev: Report distinct termination reasons for generic requests
Date: Tue, 17 Nov 2026 16:32:55 -0600	[thread overview]
Message-ID: <20261117223257.748178-2-kim.phillips@amd.com> (raw)
In-Reply-To: <20261117223257.748178-1-kim.phillips@amd.com>

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 <kim.phillips@amd.com>
---
 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


  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 ` Kim Phillips [this message]
2026-11-17 22:45   ` [PATCH 1/3] x86/sev: Report distinct termination reasons for generic requests sashiko-bot
2026-11-17 22:32 ` [PATCH 2/3] x86/sev: Report distinct termination reasons in do_vc_no_ghcb() Kim Phillips
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-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.