On Sun, Dec 01, 2024 at 11:53:51AM +0800, Binbin Wu wrote: >From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> > >Add a place holder and related helper functions for preparation of >TDG.VP.VMCALL handling. > >The TDX module specification defines TDG.VP.VMCALL API (TDVMCALL for short) >for the guest TD to call hypercall to VMM. When the guest TD issues a >TDVMCALL, the guest TD exits to VMM with a new exit reason. The arguments >from the guest TD and returned values from the VMM are passed in the guest >registers. The guest RCX register indicates which registers are used. >Define helper functions to access those registers. > >A new VMX exit reason TDCALL is added to indicate the exit is due to TDVMCALL >from the guest TD. Define the TDCALL exit reason and add a place holder to >handle such exit. > >Co-developed-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx> >Signed-off-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx> >Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> >Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> >Co-developed-by: Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx> >Signed-off-by: Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx> Reviewed-by: Chao Gao <chao.gao@xxxxxxxxx> >--- >Hypercalls exit to userspace breakout: >- Update changelog. >- Drop the unused tdx->tdvmcall. (Chao) >- Use TDVMCALL_STATUS prefix for TDX call status codes (Binbin) >--- > arch/x86/include/uapi/asm/vmx.h | 4 ++- > arch/x86/kvm/vmx/tdx.c | 48 +++++++++++++++++++++++++++++++++ > 2 files changed, 51 insertions(+), 1 deletion(-) > >diff --git a/arch/x86/include/uapi/asm/vmx.h b/arch/x86/include/uapi/asm/vmx.h >index a5faf6d88f1b..6a9f268a2d2c 100644 >--- a/arch/x86/include/uapi/asm/vmx.h >+++ b/arch/x86/include/uapi/asm/vmx.h >@@ -92,6 +92,7 @@ > #define EXIT_REASON_TPAUSE 68 > #define EXIT_REASON_BUS_LOCK 74 > #define EXIT_REASON_NOTIFY 75 >+#define EXIT_REASON_TDCALL 77 > > #define VMX_EXIT_REASONS \ > { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \ >@@ -155,7 +156,8 @@ > { EXIT_REASON_UMWAIT, "UMWAIT" }, \ > { EXIT_REASON_TPAUSE, "TPAUSE" }, \ > { EXIT_REASON_BUS_LOCK, "BUS_LOCK" }, \ >- { EXIT_REASON_NOTIFY, "NOTIFY" } >+ { EXIT_REASON_NOTIFY, "NOTIFY" }, \ >+ { EXIT_REASON_TDCALL, "TDCALL" } Side topic: Strictly speaking, TDCALL vm-exit handling can happen for normal VMs. so, KVM may need to handle it by injecting #UD. Of course, it is not necessary for this series.