Re: [PATCH v7 16/22] x86/virt/tdx: Update tdx_sysinfo and check features post-update
From: Chao Gao
Date: Tue Apr 07 2026 - 08:18:17 EST
>+int tdx_module_post_update(struct tdx_sys_info *info)
>+{
>+ struct tdx_sys_info_version *old, *new;
>+ int ret;
>+
>+ /* Shouldn't fail as the update has succeeded. */
>+ ret = get_tdx_sys_info(info);
>+ if (WARN_ONCE(ret, "version retrieval failed after update, replace the TDX module\n"))
>+ return ret;
Dave's comment on another patch applies here too: don't preemptively handle
errors that never occur. The custom error message is unnecessary, and
propagating the error isn't worth it. Will simplify it to:
/* Shouldn't fail as the update has succeeded. */
WARN_ON_ONCE(get_tdx_sys_info(info));
>+
>+ old = &tdx_sysinfo.version;
>+ new = &info->version;
>+ pr_info("version " TDX_VERSION_FMT " -> " TDX_VERSION_FMT "\n",
>+ old->major_version, old->minor_version, old->update_version,
>+ new->major_version, new->minor_version, new->update_version);
>+
>+ /*
>+ * Blindly refreshing the entire tdx_sysinfo could disrupt running
>+ * software, as it may subtly rely on the previous state unless
>+ * proven otherwise.
>+ *
>+ * Only refresh update_version and handoff version. They don't
>+ * affect TDX functionality. Major/minor versions do not change
>+ * across updates, so no refresh is needed.
>+ */
>+ tdx_sysinfo.version.update_version = info->version.update_version;
>+ tdx_sysinfo.handoff = info->handoff;
>+
>+ if (!memcmp(&tdx_sysinfo, info, sizeof(*info)))
>+ return 0;
>+
>+ pr_info("TDX module features have changed after updates, but might not take effect.\n");
>+ pr_info("Please consider updating your BIOS to install the TDX module.\n");
>+ return 0;
>+}