]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/virt/tdx: Refresh TDX module version after update
authorChao Gao <chao.gao@intel.com>
Wed, 20 May 2026 22:29:12 +0000 (15:29 -0700)
committerDave Hansen <dave.hansen@linux.intel.com>
Wed, 3 Jun 2026 15:59:44 +0000 (08:59 -0700)
The kernel exposes the TDX module version through sysfs so userspace
can check update compatibility. That information needs to remain
accurate across runtime updates.

A runtime update may change the module's update_version, so refresh
the cached version right after a successful update.

Drop __ro_after_init from tdx_sysinfo because it is now updated at
runtime.

Do not refresh the rest of tdx_sysinfo, even if some values change
across updates. TDX module updates are backward compatible, so
existing tdx_sysinfo consumers, such as KVM, can continue to operate
without seeing the new values.

[ dhansen: trim changelog ]

Signed-off-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Link: https://patch.msgid.link/20260520133909.409394-22-chao.gao@intel.com
arch/x86/virt/vmx/tdx/tdx.c
arch/x86/virt/vmx/tdx/tdx_global_metadata.c

index d54c2eca3c6766b887d47e354a0141c92958ed30..b15269b5941dc89486ca894a2427c727614dd01c 100644 (file)
@@ -67,7 +67,7 @@ static struct tdmr_info_list tdx_tdmr_list;
 /* All TDX-usable memory regions.  Protected by mem_hotplug_lock. */
 static LIST_HEAD(tdx_memlist);
 
-static struct tdx_sys_info tdx_sysinfo __ro_after_init;
+static struct tdx_sys_info tdx_sysinfo;
 
 static DEFINE_RAW_SPINLOCK(sysinit_lock);
 
@@ -1321,6 +1321,13 @@ int tdx_module_run_update(void)
        if (ret)
                return ret;
 
+       ret = get_tdx_sys_info_version(&tdx_sysinfo.version);
+       /*
+        * Only fails if there is something unexpected
+        * and severely wrong with the module.
+        */
+       WARN_ON_ONCE(ret);
+
        tdx_module_state.initialized = true;
        return 0;
 }
index e793dec688abd3fbf45a4b2bea9456792b44d59e..e49c300f23d435eba9de001c3f779eecdb4cc98f 100644 (file)
@@ -7,7 +7,7 @@
  * Include this file to other C file instead.
  */
 
-static __init int get_tdx_sys_info_version(struct tdx_sys_info_version *sysinfo_version)
+static int get_tdx_sys_info_version(struct tdx_sys_info_version *sysinfo_version)
 {
        int ret = 0;
        u64 val;