Skip to content

Commit 28224ef

Browse files
committed
KVM: TDX: Report supported optional TDVMCALLs in TDX capabilities
Allow userspace to advertise TDG.VP.VMCALL subfunctions that the kernel also supports. For each output register of GetTdVmCallInfo's leaf 1, add two fields to KVM_TDX_CAPABILITIES: one for kernel-supported TDVMCALLs (userspace can set those blindly) and one for user-supported TDVMCALLs (userspace can set those if it knows how to handle them). Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 4580dbe commit 28224ef

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Documentation/virt/kvm/x86/intel-tdx.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,20 @@ to be configured to the TDX guest.
7979
struct kvm_tdx_capabilities {
8080
__u64 supported_attrs;
8181
__u64 supported_xfam;
82-
__u64 reserved[254];
82+
83+
/* TDG.VP.VMCALL hypercalls executed in kernel and forwarded to
84+
* userspace, respectively
85+
*/
86+
__u64 kernel_tdvmcallinfo_1_r11;
87+
__u64 user_tdvmcallinfo_1_r11;
88+
89+
/* TDG.VP.VMCALL instruction executions subfunctions executed in kernel
90+
* and forwarded to userspace, respectively
91+
*/
92+
__u64 kernel_tdvmcallinfo_1_r12;
93+
__u64 user_tdvmcallinfo_1_r12;
94+
95+
__u64 reserved[250];
8396

8497
/* Configurable CPUID bits for userspace */
8598
struct kvm_cpuid2 cpuid;

arch/x86/include/uapi/asm/kvm.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,13 @@ struct kvm_tdx_cmd {
965965
struct kvm_tdx_capabilities {
966966
__u64 supported_attrs;
967967
__u64 supported_xfam;
968-
__u64 reserved[254];
968+
969+
__u64 kernel_tdvmcallinfo_1_r11;
970+
__u64 user_tdvmcallinfo_1_r11;
971+
__u64 kernel_tdvmcallinfo_1_r12;
972+
__u64 user_tdvmcallinfo_1_r12;
973+
974+
__u64 reserved[250];
969975

970976
/* Configurable CPUID bits for userspace */
971977
struct kvm_cpuid2 cpuid;

arch/x86/kvm/vmx/tdx.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ static void td_init_cpuid_entry2(struct kvm_cpuid_entry2 *entry, unsigned char i
173173
tdx_clear_unsupported_cpuid(entry);
174174
}
175175

176+
#define TDVMCALLINFO_GET_QUOTE BIT(0)
177+
#define TDVMCALLINFO_SETUP_EVENT_NOTIFY_INTERRUPT BIT(1)
178+
176179
static int init_kvm_tdx_caps(const struct tdx_sys_info_td_conf *td_conf,
177180
struct kvm_tdx_capabilities *caps)
178181
{
@@ -188,6 +191,10 @@ static int init_kvm_tdx_caps(const struct tdx_sys_info_td_conf *td_conf,
188191

189192
caps->cpuid.nent = td_conf->num_cpuid_config;
190193

194+
caps->user_tdvmcallinfo_1_r11 =
195+
TDVMCALLINFO_GET_QUOTE |
196+
TDVMCALLINFO_SETUP_EVENT_NOTIFY_INTERRUPT;
197+
191198
for (i = 0; i < td_conf->num_cpuid_config; i++)
192199
td_init_cpuid_entry2(&caps->cpuid.entries[i], i);
193200

0 commit comments

Comments
 (0)