From nobody Sat Feb 7 08:27:17 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2710436A023; Fri, 23 Jan 2026 15:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769180441; cv=none; b=tsc3RdBklViwpKvVgy8oxIM2lZAN7dEmVIW6eYZmF0tnmXK3byUcPY5kl7rV8pd5gzLyOr0BihiF3pHNRw4bOJJMSrtVQUgWOImM0DwinyDtvq2olsSiu38inGn7ziWxImqgWmi293mjr9lWWXPFq05LZmL/zg9WgWPABMdbMjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769180441; c=relaxed/simple; bh=KbDSi56WVEYQ90zmpbaEQB1XUcz2GYksChn0Kc4VnyA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pGkB5n9Y9I2YDYZhYl3Kns/KrvEGqIt2me0WSa5MHEm+Lot3EvCTH4lGdg0stc0mEFvWf1beow0JQsYw+saEtZBI69dmZ/yin8M7hYByUgcnwFY9Tm1u06W3Lsd/oJLmoRD4X4VKE3c8dQ3TgBx6fOXj0nBLZl54Mu4uRwRxRR0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GUB75IwX; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GUB75IwX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1769180438; x=1800716438; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KbDSi56WVEYQ90zmpbaEQB1XUcz2GYksChn0Kc4VnyA=; b=GUB75IwXcV+6madUsrNGb8VHQ+UvRnpRSGoQ6xI92U1XqoLyI1CVUzmv HCNunnTPUYhJ/HyIvjKvyaC5+Bh8gGvYaqwjqNT70Y4hW/gnVvGL/WxdW fEx+Nu+CCxy49o4HFzdhTvtbab2iXNMQ6SSmAeIQzB6ausJ85oyYikaYI aWtO748LG0VRiARa9kx+w2ZF3PmcJFP7djiXCqvgNnZdJ5eBIJo4eYguU UFaBWspZRElkTiTnbR3LqK69nmFBwe0XjKvJZwKJZhLem62+h5uomaxC+ NfWCgcuyRVw5DWbnSlPXNx8pg6ux5bKSWZafr4ExGgVaFAKhCQn9jIyT4 w==; X-CSE-ConnectionGUID: sMDsa1exT/63jXf+ZQzrxQ== X-CSE-MsgGUID: z8sRJTTxQ+O7LL62NFUc3Q== X-IronPort-AV: E=McAfee;i="6800,10657,11680"; a="70334516" X-IronPort-AV: E=Sophos;i="6.21,248,1763452800"; d="scan'208";a="70334516" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2026 07:00:20 -0800 X-CSE-ConnectionGUID: a/4x6YlUT8CPTGQa5rPs+g== X-CSE-MsgGUID: Wxhmcr6QRc2rUwj2QAJcUw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,248,1763452800"; d="scan'208";a="237697208" Received: from 984fee019967.jf.intel.com ([10.23.153.244]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2026 07:00:20 -0800 From: Chao Gao To: linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org Cc: reinette.chatre@intel.com, ira.weiny@intel.com, kai.huang@intel.com, dan.j.williams@intel.com, yilun.xu@linux.intel.com, sagis@google.com, vannapurve@google.com, paulmck@kernel.org, nik.borisov@suse.com, zhenzhong.duan@intel.com, seanjc@google.com, rick.p.edgecombe@intel.com, kas@kernel.org, dave.hansen@linux.intel.com, vishal.l.verma@intel.com, Chao Gao , Farrah Chen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Subject: [PATCH v3 22/26] x86/virt/tdx: Update tdx_sysinfo and check features post-update Date: Fri, 23 Jan 2026 06:55:30 -0800 Message-ID: <20260123145645.90444-23-chao.gao@intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260123145645.90444-1-chao.gao@intel.com> References: <20260123145645.90444-1-chao.gao@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" tdx_sysinfo contains all metadata of the active TDX module, including versions, supported features, and TDMR/TDCS/TDVPS information. These elements may change over updates. Blindly refreshing the entire tdx_sysinfo could disrupt running software, as it may subtly rely on the previous state unless proven otherwise. Adopt a conservative approach, like microcode updates, by only refreshing version information that does not affect functionality, while ignoring all other changes. This is acceptable as new modules are required to maintain backward compatibility. Any updates to metadata beyond versions should be justified and reviewed on a case-by-case basis. Note that preallocating a tdx_sys_info buffer before updates is to avoid having to handle -ENOMEM when updating tdx_sysinfo after a successful update. Signed-off-by: Chao Gao Tested-by: Farrah Chen Reviewed-by: Tony Lindgren Reviewed-by: Xu Yilun --- v3: - use 'old' instead of 'cur' as the local variable to represent the sysinfo of the previous module [Binbin] - combine if(ret) and WARN_ONCE(1, ...) to WARN_ONCE(ret, ...) [Binbin] - Improve the print log messages after detecting new features from updates. [Binbin] v2: - don't add a separate function for version and feature checks. Do them directly in tdx_module_post_update() - add a comment about preallocating a tdx_sys_info buffer in seamldr_install_module(). --- arch/x86/virt/vmx/tdx/seamldr.c | 11 ++++++++- arch/x86/virt/vmx/tdx/tdx.c | 43 +++++++++++++++++++++++++++++++++ arch/x86/virt/vmx/tdx/tdx.h | 3 +++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/arch/x86/virt/vmx/tdx/seamldr.c b/arch/x86/virt/vmx/tdx/seamld= r.c index 7fa68c0c6ce4..d2d85114d6c4 100644 --- a/arch/x86/virt/vmx/tdx/seamldr.c +++ b/arch/x86/virt/vmx/tdx/seamldr.c @@ -357,6 +357,15 @@ int seamldr_install_module(const u8 *data, u32 size) if (!is_vmalloc_addr(data)) return -EINVAL; =20 + /* + * Preallocating a tdx_sys_info buffer before updates is to avoid having = to + * handle -ENOMEM when updating tdx_sysinfo after a successful update. + */ + struct tdx_sys_info *sysinfo __free(kfree) =3D kzalloc(sizeof(*sysinfo), + GFP_KERNEL); + if (!sysinfo) + return -ENOMEM; + struct seamldr_params *params __free(free_seamldr_params) =3D init_seamldr_params(data, size); if (IS_ERR(params)) @@ -374,6 +383,6 @@ int seamldr_install_module(const u8 *data, u32 size) if (ret) return ret; =20 - return 0; + return tdx_module_post_update(sysinfo); } EXPORT_SYMBOL_FOR_MODULES(seamldr_install_module, "tdx-host"); diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 2654aa169dda..5d3f3f3eeb7d 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -1218,6 +1218,49 @@ int tdx_module_run_update(void) return 0; } =20 +/* + * Update tdx_sysinfo and check if any TDX module features changed after + * updates + */ +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 =3D get_tdx_sys_info(info); + if (WARN_ONCE(ret, "version retrieval failed after update, replace TDX Mo= dule\n")) + return ret; + + old =3D &tdx_sysinfo.version; + new =3D &info->version; + pr_info("version %u.%u.%02u -> %u.%u.%02u\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 version information (including handoff version) + * that does not affect functionality, and ignore all other + * changes. + */ + tdx_sysinfo.version =3D info->version; + tdx_sysinfo.handoff =3D info->handoff; + + if (!memcmp(&tdx_sysinfo, info, sizeof(*info))) + return 0; + + pr_info("TDX module features have changed after updates, but might not ta= ke effect.\n"); + pr_info("Please consider updating your BIOS to install the TDX Module.\n"= ); + return 0; +} + static bool is_pamt_page(unsigned long phys) { struct tdmr_info_list *tdmr_list =3D &tdx_tdmr_list; diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h index 0887debfd139..d1807a476d3b 100644 --- a/arch/x86/virt/vmx/tdx/tdx.h +++ b/arch/x86/virt/vmx/tdx/tdx.h @@ -4,6 +4,8 @@ =20 #include =20 +#include + /* * This file contains both macros and data structures defined by the TDX * architecture and Linux defined software data structures and functions. @@ -122,5 +124,6 @@ struct tdmr_info_list { =20 int tdx_module_shutdown(void); int tdx_module_run_update(void); +int tdx_module_post_update(struct tdx_sys_info *info); =20 #endif --=20 2.47.3