In rare cases, TDX Module updates may cause TD management operations to fail if they occur during phases of the TD lifecycle that are sensitive to update compatibility. But not all combinations of P-SEAMLDR, kernel, and TDX Module have the capability to detect and prevent said incompatibilities. Completely disabling TDX Module updates on platforms without the capability would be overkill, as these incompatibility cases are rare and can be addressed by userspace through coordinated scheduling of updates and TD management operations. To set clear expectations for TDX Module updates, expose the capability to detect and prevent these incompatibility cases via sysfs and document the compatibility criteria and indications when those criteria are violated. Signed-off-by: Chao Gao --- v3: - new, based on a reference patch from Dan Williams --- .../ABI/testing/sysfs-devices-faux-tdx-host | 45 +++++++++++++++++++ drivers/virt/coco/tdx-host/tdx-host.c | 13 ++++++ 2 files changed, 58 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-devices-faux-tdx-host b/Documentation/ABI/testing/sysfs-devices-faux-tdx-host index a3f155977016..81cb13e91f2a 100644 --- a/Documentation/ABI/testing/sysfs-devices-faux-tdx-host +++ b/Documentation/ABI/testing/sysfs-devices-faux-tdx-host @@ -29,3 +29,48 @@ Description: (RO) Report the number of remaining updates that can be performed. 4.2 "SEAMLDR.INSTALL" for more information. The documentation is available at: https://cdrdv2-public.intel.com/739045/intel-tdx-seamldr-interface-specification.pdf + +What: /sys/devices/faux/tdx_host/firmware/seamldr_upload +Contact: linux-coco@lists.linux.dev +Description: (Directory) The seamldr_upload directory implements the + fw_upload sysfs ABI, see + Documentation/ABI/testing/sysfs-class-firmware for the general + description of the attributes @data, @cancel, @error, @loading, + @remaining_size, and @status. This ABI facilitates "Compatible + TDX Module Updates". A compatible update is one that meets the + following criteria: + + Does not interrupt or interfere with any current TDX + operation or TD VM. + + Does not invalidate any previously consumed Module metadata + values outside of the TEE_TCB_SVN_2 field (updated Security + Version Number) in TD Quotes. + + Does not require validation of new Module metadata fields. By + implication, new Module features and capabilities are only + available by installing the Module at reboot (BIOS or EFI + helper loaded). + + See tdx_host/compat_capable and + tdx_host/firmware/seamldr_upload/error. For details. + +What: /sys/devices/faux/tdx_host/compat_capable +Contact: linux-coco@lists.linux.dev +Description: (RO) When present this attribute returns "1" to indicate that + the current seamldr, kernel, and TDX Module combination can + detect when an update conforms with the "Compatible TDX Module + Updates" criteria in the tdx_host/firmware/seamldr_upload description. + When this attribute is missing it is indeterminate whether an + update will violate the criteria. + +What: /sys/devices/faux/tdx_host/firmware/seamldr_upload/error +Contact: linux-coco@lists.linux.dev +Description: (RO) See Documentation/ABI/testing/sysfs-class-firmware for + baseline expectations for this file. Updates that fail + compatibility checks end with the "device-busy" error in the + : format of this attribute. When this is + signalled current TDs and the current TDX Module stay running. + Other failures may result in all TDs being lost and further + TDX operations becoming impossible. This occurs when + /sys/devices/faux/tdx_host/version becomes unreadable. diff --git a/drivers/virt/coco/tdx-host/tdx-host.c b/drivers/virt/coco/tdx-host/tdx-host.c index 06487de2ebfe..8cc48e276533 100644 --- a/drivers/virt/coco/tdx-host/tdx-host.c +++ b/drivers/virt/coco/tdx-host/tdx-host.c @@ -45,8 +45,21 @@ static ssize_t version_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(version); +static ssize_t compat_capable_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + const struct tdx_sys_info *tdx_sysinfo = tdx_get_sysinfo(); + + if (!tdx_sysinfo) + return -ENXIO; + + return sysfs_emit(buf, "%i\n", tdx_supports_update_compatibility(tdx_sysinfo)); +} +static DEVICE_ATTR_RO(compat_capable); + static struct attribute *tdx_host_attrs[] = { &dev_attr_version.attr, + &dev_attr_compat_capable.attr, NULL, }; -- 2.47.3