From mboxrd@z Thu Jan 1 00:00:00 1970 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 7186F33FE01 for ; Fri, 23 Jan 2026 15:00:22 +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=1769180426; cv=none; b=ZoW8BJmtCFzp4Xbst2wJiGnt38NBQ5JcDB1DukXY1Jwxqus5IEUEp+XnpIjVAahr/ijmHovAMsR5HwjuFnpo15niJDAsxCpjSCXlCIJ+hCsdBQFWvDRGwi1pkLigBymLbiX5uWET94bWxsWMuS/X+vi0QX+VcsUaCx9YaojkbV0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769180426; c=relaxed/simple; bh=LmLmoBJLYp1Fw5ImScOvQ6T5aiGshRkqk4yUpZCR5VE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U4Xg+vATyYNorwRnGn9MTPs5Fw/e4eZvOk1uiRnFovCe8ZA1a4bRdTakY3Ql33x2oyxM5VPejAEjiOsvLMdIqpERuglY/O7O3NLyre1J3G5EX+JIaky+f1s3a5uaV4RJHwEpVui9/grB7GustCJgoW7G9YnkZrPG1yYaBI+Acsw= 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=KXiLYRYa; 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="KXiLYRYa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1769180423; x=1800716423; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LmLmoBJLYp1Fw5ImScOvQ6T5aiGshRkqk4yUpZCR5VE=; b=KXiLYRYaIvREWxpx0+eKmBltFSHkgM/ZydRTTJtLwoy71YNORPS2FiGk 8ljz0oNUIyNfZPsJeDefFv22HvNhNJcqWV07MEbM3A7xzjcfshJFqoRLy ZUQYEQ5jk55KyjWH5TqAK1h8P0VRB5hez0JMGvUanzMaaYdDWC1yRCj2s py9gDsOFJRa+NHLue2PG7KOC5A0dEBuzwe31+HZZTk67asg9lJ6vfSVSH AEHyj/6N76d9KTj7wRSgbr02akF4TE754tuilHpdOZ9se9Jct4W6acNGy qJ/oAIISDn208IO/0rp0KCM8H06PerbCWcTqDNMaJXbGaSGFVu02NKqBp g==; X-CSE-ConnectionGUID: RS/2tnG1SuWw7gwVuK8PEQ== X-CSE-MsgGUID: /0FyuxyJTtOFOkzdnM2k5Q== X-IronPort-AV: E=McAfee;i="6800,10657,11680"; a="70334397" X-IronPort-AV: E=Sophos;i="6.21,248,1763452800"; d="scan'208";a="70334397" 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:13 -0800 X-CSE-ConnectionGUID: Lh9ZhzXMQMu36ykEEVeoeA== X-CSE-MsgGUID: 9uN2K5lnT/GK6m5fB1tdeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,248,1763452800"; d="scan'208";a="237697115" 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:13 -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 Subject: [PATCH v3 09/26] coco/tdx-host: Expose P-SEAMLDR information via sysfs Date: Fri, 23 Jan 2026 06:55:17 -0800 Message-ID: <20260123145645.90444-10-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-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TDX Module updates require userspace to select the appropriate module to load. Expose necessary information to facilitate this decision. Two values are needed: - P-SEAMLDR version: for compatibility checks between TDX Module and P-SEAMLDR - num_remaining_updates: indicates how many updates can be performed Expose them as tdx-host device attributes. Signed-off-by: Chao Gao Tested-by: Farrah Chen --- v3: - use #ifdef rather than .is_visible() to control P-SEAMLDR sysfs visibility [Yilun] --- .../ABI/testing/sysfs-devices-faux-tdx-host | 25 ++++++++ drivers/virt/coco/tdx-host/tdx-host.c | 60 ++++++++++++++++++- 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-devices-faux-tdx-host b/Documentation/ABI/testing/sysfs-devices-faux-tdx-host index 901abbae2e61..a3f155977016 100644 --- a/Documentation/ABI/testing/sysfs-devices-faux-tdx-host +++ b/Documentation/ABI/testing/sysfs-devices-faux-tdx-host @@ -4,3 +4,28 @@ Description: (RO) Report the version of the loaded TDX Module. The TDX Module version is formatted as x.y.z, where "x" is the major version, "y" is the minor version and "z" is the update version. Versions are used for bug reporting, TDX Module updates and etc. + +What: /sys/devices/faux/tdx_host/seamldr/version +Contact: linux-coco@lists.linux.dev +Description: (RO) Report the version of the loaded SEAM loader. The SEAM + loader version is formatted as x.y.z, where "x" is the major + version, "y" is the minor version and "z" is the update version. + Versions are used for bug reporting and compatibility check. + +What: /sys/devices/faux/tdx_host/seamldr/num_remaining_updates +Contact: linux-coco@lists.linux.dev +Description: (RO) Report the number of remaining updates that can be performed. + The CPU keeps track of TCB versions for each TDX Module that + has been loaded. Since this tracking database has finite + capacity, there's a maximum number of Module updates that can + be performed. + + After each successful update, the number reduces by one. Once it + reaches zero, further updates will fail until next reboot. The + number is always zero if P-SEAMLDR doesn't support updates. + + See IntelĀ® Trust Domain Extensions - SEAM Loader (SEAMLDR) + Interface Specification Chapter 3.3 "SEAMLDR_INFO" and Chapter + 4.2 "SEAMLDR.INSTALL" for more information. The documentation is + available at: + https://cdrdv2-public.intel.com/739045/intel-tdx-seamldr-interface-specification.pdf diff --git a/drivers/virt/coco/tdx-host/tdx-host.c b/drivers/virt/coco/tdx-host/tdx-host.c index 0424933b2560..f4ce89522806 100644 --- a/drivers/virt/coco/tdx-host/tdx-host.c +++ b/drivers/virt/coco/tdx-host/tdx-host.c @@ -11,6 +11,7 @@ #include #include +#include #include static const struct x86_cpu_id tdx_host_ids[] = { @@ -40,7 +41,64 @@ static struct attribute *tdx_host_attrs[] = { &dev_attr_version.attr, NULL, }; -ATTRIBUTE_GROUPS(tdx_host); + +struct attribute_group tdx_host_group = { + .attrs = tdx_host_attrs, +}; + +#ifdef CONFIG_INTEL_TDX_MODULE_UPDATE +static ssize_t seamldr_version_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + const struct seamldr_info *info = seamldr_get_info(); + + if (!info) + return -ENXIO; + + return sysfs_emit(buf, "%u.%u.%02u\n", info->major_version, + info->minor_version, + info->update_version); +} + +static ssize_t num_remaining_updates_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + const struct seamldr_info *info = seamldr_get_info(); + + if (!info) + return -ENXIO; + + return sysfs_emit(buf, "%u\n", info->num_remaining_updates); +} + +/* + * Open-code DEVICE_ATTR_RO to specify a different 'show' function for + * P-SEAMLDR version as version_show() is used for TDX Module version. + */ +static struct device_attribute dev_attr_seamldr_version = + __ATTR(version, 0444, seamldr_version_show, NULL); +static DEVICE_ATTR_RO(num_remaining_updates); + +static struct attribute *seamldr_attrs[] = { + &dev_attr_seamldr_version.attr, + &dev_attr_num_remaining_updates.attr, + NULL, +}; + +static struct attribute_group seamldr_group = { + .name = "seamldr", + .attrs = seamldr_attrs, +}; +#endif /* CONFIG_INTEL_TDX_MODULE_UPDATE */ + +static const struct attribute_group *tdx_host_groups[] = { + &tdx_host_group, +#ifdef CONFIG_INTEL_TDX_MODULE_UPDATE + &seamldr_group, +#endif + NULL, +}; static struct faux_device *fdev; -- 2.47.3