Merge branch 'kvm-tdx-userspace-exit' into HEAD
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 12 Mar 2025 11:41:52 +0000 (07:41 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 14 Mar 2025 18:26:29 +0000 (14:26 -0400)
commit4d2dc9a26765131641c545549ad5476ae7f4d611
treec79e854e4d6bdb8f214c9c4cb52d1b661020499c
parent77ab80c6bda044a716da2d2022f6d93e46c052ac
parentbb723bebde1eee606ab0bd56bbc9aafda96d3801
Merge branch 'kvm-tdx-userspace-exit' into HEAD

Introduces support for VM exits that are forwarded the host VMM in
userspace.  These are initiated from the TDCALL exit code; although
these userspace exits have the same TDX exit code, they result in several
different types of exits to userspace.

When a guest TD issues a TDVMCALL, it
exits to VMM with a new exit reason.  The arguments from the guest TD and
return values from the VMM are passed through the guest registers.  The
ABI details for the guest TD hypercalls are specified in the TDX GHCI
specification.

There are two types of hypercalls defined in the GHCI specification:

- Standard TDVMCALLs: When input of R10 from guest TD is set to 0, it
  indicates that the TDVMCALL sub-function used in R11 is defined in GHCI
  specification.

- Vendor-Specific TDVMCALLs: When input of R10 from guest TD is non-zero,
  it indicates a vendor-specific TDVMCALL. KVM hypercalls from the guest
  follow this interface, using R10 as KVM hypercall number and R11-R14 as
  4 arguments.  The error code returned in R10.

This series includes basic standard TDVMCALLs that map to existing eixt
reasons:

- TDG.VP.VMCALL<MapGPA> reuses exit reason KVM_EXIT_HYPERCALL with the
  hypercall number KVM_HC_MAP_GPA_RANGE.

- TDG.VP.VMCALL<ReportFatalError> reuses exit reason KVM_EXIT_SYSTEM_EVENT
  with a new event type KVM_SYSTEM_EVENT_TDX_FATAL.

- TDG.VP.VMCALL<Instruction.IO> reuses exit reason KVM_EXIT_IO.

- TDG.VP.VMCALL<#VE.RequestMMIO> reuses exit reason KVM_EXIT_MMIO.

Notably, handling for TDG.VP.VMCALL<SetupEventNotifyInterrupt> and
TDG.VP.VMCALL<GetQuote> is not included yet.