]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: TDX: Report supported optional TDVMCALLs in TDX capabilities
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 20 Jun 2025 18:20:20 +0000 (14:20 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 20 Jun 2025 18:20:20 +0000 (14:20 -0400)
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 <pbonzini@redhat.com>
Documentation/virt/kvm/x86/intel-tdx.rst
arch/x86/include/uapi/asm/kvm.h
arch/x86/kvm/vmx/tdx.c

index 76bdd95334d6088ba73647066d98939ac6b948e6..5efac62c92c7b38519b65e00619372c474e1a632 100644 (file)
@@ -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;
index 6f3499507c5efb560c94a58d053144f04671140b..0f15d683817d6a77b0c7cdfe3fda2b6bef2e4172 100644 (file)
@@ -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;
index b4055a746ecdecc1e9452835edd042bd371268d2..f31ccdeb905b4e9ba7c646725f8a53c587461045 100644 (file)
@@ -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);