KVM: TDX: Handle TDG.VP.VMCALL<GetTdVmCallInfo> hypercall
authorIsaku Yamahata <isaku.yamahata@intel.com>
Thu, 27 Feb 2025 01:20:12 +0000 (09:20 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 14 Mar 2025 18:20:57 +0000 (14:20 -0400)
Implement TDG.VP.VMCALL<GetTdVmCallInfo> hypercall.  If the input value is
zero, return success code and zero in output registers.

TDG.VP.VMCALL<GetTdVmCallInfo> hypercall is a subleaf of TDG.VP.VMCALL to
enumerate which TDG.VP.VMCALL sub leaves are supported.  This hypercall is
for future enhancement of the Guest-Host-Communication Interface (GHCI)
specification.  The GHCI version of 344426-001US defines it to require
input R12 to be zero and to return zero in output registers, R11, R12, R13,
and R14 so that guest TD enumerates no enhancement.

Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com>
Message-ID: <20250227012021.1778144-12-binbin.wu@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/shared/tdx.h
arch/x86/kvm/vmx/tdx.c

index f23657350d28361d48314d442cb7344a34bc9bdd..606d93a1cbace74f24b80f7fd573dea7d0a16468 100644 (file)
@@ -67,6 +67,7 @@
 #define TD_CTLS_LOCK                   BIT_ULL(TD_CTLS_LOCK_BIT)
 
 /* TDX hypercall Leaf IDs */
+#define TDVMCALL_GET_TD_VM_CALL_INFO   0x10000
 #define TDVMCALL_MAP_GPA               0x10001
 #define TDVMCALL_GET_QUOTE             0x10002
 #define TDVMCALL_REPORT_FATAL_ERROR    0x10003
index 1aecb4050082918cdbccbc91b7d55b83c77b0a72..24881e2fafc2ba851cf71c7ad2192b43c896554c 100644 (file)
@@ -1448,6 +1448,20 @@ error:
        return 1;
 }
 
+static int tdx_get_td_vm_call_info(struct kvm_vcpu *vcpu)
+{
+       struct vcpu_tdx *tdx = to_tdx(vcpu);
+
+       if (tdx->vp_enter_args.r12)
+               tdvmcall_set_return_code(vcpu, TDVMCALL_STATUS_INVALID_OPERAND);
+       else {
+               tdx->vp_enter_args.r11 = 0;
+               tdx->vp_enter_args.r13 = 0;
+               tdx->vp_enter_args.r14 = 0;
+       }
+       return 1;
+}
+
 static int handle_tdvmcall(struct kvm_vcpu *vcpu)
 {
        switch (tdvmcall_leaf(vcpu)) {
@@ -1455,6 +1469,8 @@ static int handle_tdvmcall(struct kvm_vcpu *vcpu)
                return tdx_map_gpa(vcpu);
        case TDVMCALL_REPORT_FATAL_ERROR:
                return tdx_report_fatal_error(vcpu);
+       case TDVMCALL_GET_TD_VM_CALL_INFO:
+               return tdx_get_td_vm_call_info(vcpu);
        default:
                break;
        }