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 0/3] x86/sev: Make guest termination reasons identifiable
Date: Tue, 17 Nov 2026 16:32:54 -0600	[thread overview]
Message-ID: <20261117223257.748178-1-kim.phillips@amd.com> (raw)

When an SEV-ES/SNP guest dies early, the only thing that reliably escapes
the guest is the GHCB MSR termination request: a 4-bit reason set and an
8-bit reason code written to the GHCB MSR before the final VMGEXIT. There
is no console, no dmesg and no crash dump to fall back on - in a hosted
environment the guest owner often has nothing but that one code to work
with.

Today a large fraction of the termination sites in the guest-side SEV code
collapse onto a handful of values that say almost nothing about what went
wrong:

 - Six sites terminate with the generic (SEV_TERM_SET_GEN,
   GHCB_SEV_ES_GEN_REQ) pair. A #VC the decompressor could not handle, a
   #VC the running kernel could not handle, a GHCB that could not be set
   up, and a GHCB protocol negotiation that failed are all reported
   identically.

 - do_vc_no_ghcb(), the MSR-protocol #VC handler used before a GHCB
   exists, funnels every one of its failure paths through a single label,
   so a CPUID table lookup failure, a failed hypervisor CPUID fallback and
   a hypervisor lying about SEV being active are indistinguishable.

 - Both find_cc_blob() implementations report GHCB_SNP_UNSUPPORTED when
   the Confidential Computing blob they found has a bad header magic. That
   code otherwise means "the hypervisor does not support SNP", so a
   firmware or bootloader bug inside the guest's own boot chain looks
   exactly like an unsupported host - and points debugging at the wrong
   party.

The cost of fixing this is low: the Linux-specific reason set
(SEV_TERM_SET_LINUX) exists precisely so the guest can report codes of its
own choosing, and the existing GHCB_TERM_* codes already follow this
pattern for more recently added features such as Secure TSC, SVSM and
Secure AVIC. These patches extend that convention to the older, more
generic sites.

Patch 1 replaces the six generic callsites, adding GHCB_TERM_VC_FAIL,
GHCB_TERM_GHCB_SETUP and GHCB_TERM_NEGOTIATE. The four #VC handling
failures deliberately share one code, as they are the same failure class
observed at different stages of boot.

Patch 2 splits do_vc_no_ghcb()'s failure paths, reusing the existing
GHCB_TERM_CPUID and GHCB_TERM_CPUID_HV codes - no new codes needed. The
two checks that reject the #VC before any CPUID work is attempted keep
reporting GHCB_TERM_VC_FAIL.

Patch 3 adds GHCB_TERM_CC_BLOB for the invalid-blob-magic checks, leaving
the sites that genuinely mean "hypervisor does not support SNP",
including the CC-blob/SNP-enablement discrepancy check in sme_enable(),
on GHCB_SNP_UNSUPPORTED.

There is no functional change for a healthy guest: every modified site
already terminated the guest unconditionally, and only the reported reason
changes. Hypervisors that decode termination requests will see new codes
in the Linux reason set; that set is explicitly reserved for exactly this,
so no hypervisor can have been relying on the old values to mean anything
specific.

Kim Phillips (3):
  x86/sev: Report distinct termination reasons for generic requests
  x86/sev: Report distinct termination reasons in do_vc_no_ghcb()
  x86/sev: Distinguish CC-blob failures from generic SNP-unsupported

 arch/x86/boot/compressed/sev-handle-vc.c |  4 ++--
 arch/x86/boot/compressed/sev.c           |  2 +-
 arch/x86/boot/startup/sev-shared.c       | 14 +++++++++-----
 arch/x86/boot/startup/sev-startup.c      |  2 +-
 arch/x86/coco/sev/core.c                 |  2 +-
 arch/x86/coco/sev/vc-handle.c            |  4 ++--
 arch/x86/include/asm/sev-common.h        |  4 ++++
 7 files changed, 20 insertions(+), 12 deletions(-)

-- 
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 Kim Phillips [this message]
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 ` [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-1-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.