Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH 0/3] x86/sev: Make guest termination reasons identifiable
@ 2026-11-17 22:32 Kim Phillips
  2026-11-17 22:32 ` [PATCH 1/3] x86/sev: Report distinct termination reasons for generic requests Kim Phillips
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kim Phillips @ 2026-11-17 22:32 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, K Prateek Nayak,
	Nikunj A Dadhania, Tom Lendacky, Michael Roth, Borislav Petkov,
	Borislav Petkov, Naveen Rao, Dave Hansen, tglx, mingo, ardb, hpa
  Cc: linux-kernel, x86, kvm, Kim Phillips, Nathan Fontenot

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-17 22:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox