x86/sev: Make guest termination reasons identifiable
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | x86/sev: Report distinct termination reasons for generic requestsarch/ arch/ arch/ +2 more | +9 | 0 replies | |
| 2/3 | x86/sev: Report distinct termination reasons in do_vc_no_ghcb()arch/ | +8 | 0 replies | |
| 3/3 | x86/sev: Distinguish CC-blob failures from generic SNP-unsupportedarch/ arch/ arch/ | +3 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] x86/sev: Make guest termination reasons identifiable
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(-)
Signature · 1 line
2.43.0