Commit 28224ef0 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

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: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 4580dbef
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -79,7 +79,20 @@ to be configured to the TDX guest.
  struct kvm_tdx_capabilities {
        __u64 supported_attrs;
        __u64 supported_xfam;
        __u64 reserved[254];

        /* TDG.VP.VMCALL hypercalls executed in kernel and forwarded to
         * userspace, respectively
         */
        __u64 kernel_tdvmcallinfo_1_r11;
        __u64 user_tdvmcallinfo_1_r11;

        /* TDG.VP.VMCALL instruction executions subfunctions executed in kernel
         * and forwarded to userspace, respectively
         */
        __u64 kernel_tdvmcallinfo_1_r12;
        __u64 user_tdvmcallinfo_1_r12;

        __u64 reserved[250];

        /* Configurable CPUID bits for userspace */
        struct kvm_cpuid2 cpuid;
+7 −1
Original line number Diff line number Diff line
@@ -965,7 +965,13 @@ struct kvm_tdx_cmd {
struct kvm_tdx_capabilities {
	__u64 supported_attrs;
	__u64 supported_xfam;
	__u64 reserved[254];

	__u64 kernel_tdvmcallinfo_1_r11;
	__u64 user_tdvmcallinfo_1_r11;
	__u64 kernel_tdvmcallinfo_1_r12;
	__u64 user_tdvmcallinfo_1_r12;

	__u64 reserved[250];

	/* Configurable CPUID bits for userspace */
	struct kvm_cpuid2 cpuid;
+7 −0
Original line number Diff line number Diff line
@@ -173,6 +173,9 @@ static void td_init_cpuid_entry2(struct kvm_cpuid_entry2 *entry, unsigned char i
	tdx_clear_unsupported_cpuid(entry);
}

#define TDVMCALLINFO_GET_QUOTE				BIT(0)
#define TDVMCALLINFO_SETUP_EVENT_NOTIFY_INTERRUPT	BIT(1)

static int init_kvm_tdx_caps(const struct tdx_sys_info_td_conf *td_conf,
			     struct kvm_tdx_capabilities *caps)
{
@@ -188,6 +191,10 @@ static int init_kvm_tdx_caps(const struct tdx_sys_info_td_conf *td_conf,

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

	caps->user_tdvmcallinfo_1_r11 =
		TDVMCALLINFO_GET_QUOTE |
		TDVMCALLINFO_SETUP_EVENT_NOTIFY_INTERRUPT;

	for (i = 0; i < td_conf->num_cpuid_config; i++)
		td_init_cpuid_entry2(&caps->cpuid.entries[i], i);