Skip to content

Commit 0473383

Browse files
yamahatabonzini
authored andcommitted
KVM: TDX: Handle TDG.VP.VMCALL<GetTdVmCallInfo> hypercall
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>
1 parent 9fc3402 commit 0473383

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

arch/x86/include/asm/shared/tdx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#define TD_CTLS_LOCK BIT_ULL(TD_CTLS_LOCK_BIT)
6868

6969
/* TDX hypercall Leaf IDs */
70+
#define TDVMCALL_GET_TD_VM_CALL_INFO 0x10000
7071
#define TDVMCALL_MAP_GPA 0x10001
7172
#define TDVMCALL_GET_QUOTE 0x10002
7273
#define TDVMCALL_REPORT_FATAL_ERROR 0x10003

arch/x86/kvm/vmx/tdx.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,13 +1448,29 @@ static int tdx_emulate_mmio(struct kvm_vcpu *vcpu)
14481448
return 1;
14491449
}
14501450

1451+
static int tdx_get_td_vm_call_info(struct kvm_vcpu *vcpu)
1452+
{
1453+
struct vcpu_tdx *tdx = to_tdx(vcpu);
1454+
1455+
if (tdx->vp_enter_args.r12)
1456+
tdvmcall_set_return_code(vcpu, TDVMCALL_STATUS_INVALID_OPERAND);
1457+
else {
1458+
tdx->vp_enter_args.r11 = 0;
1459+
tdx->vp_enter_args.r13 = 0;
1460+
tdx->vp_enter_args.r14 = 0;
1461+
}
1462+
return 1;
1463+
}
1464+
14511465
static int handle_tdvmcall(struct kvm_vcpu *vcpu)
14521466
{
14531467
switch (tdvmcall_leaf(vcpu)) {
14541468
case TDVMCALL_MAP_GPA:
14551469
return tdx_map_gpa(vcpu);
14561470
case TDVMCALL_REPORT_FATAL_ERROR:
14571471
return tdx_report_fatal_error(vcpu);
1472+
case TDVMCALL_GET_TD_VM_CALL_INFO:
1473+
return tdx_get_td_vm_call_info(vcpu);
14581474
default:
14591475
break;
14601476
}

0 commit comments

Comments
 (0)