public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 00/22] Runtime TDX module update support
@ 2026-03-15 13:58 Chao Gao
  2026-03-15 13:58 ` [PATCH v5 01/22] x86/virt/tdx: Move low level SEAMCALL helpers out of <asm/tdx.h> Chao Gao
                   ` (21 more replies)
  0 siblings, 22 replies; 80+ messages in thread
From: Chao Gao @ 2026-03-15 13:58 UTC (permalink / raw)
  To: kvm, linux-coco, linux-doc, linux-kernel, x86
  Cc: binbin.wu, dan.j.williams, dave.hansen, ira.weiny, kai.huang, kas,
	nik.borisov, paulmck, pbonzini, reinette.chatre, rick.p.edgecombe,
	sagis, seanjc, tony.lindgren, vannapurve, vishal.l.verma,
	yilun.xu, Chao Gao, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Jonathan Corbet, Shuah Khan, Thomas Gleixner

Hi Reviewers,

With this posting, I'm hoping to collect more Reviewed-by or Acked-by tags.

Please note these changes:

  Patch 18 handles a CPU erratum that clears the active VMCS after
  P-SEAMLDR calls. Because of this erratum, patch 6 now exposes seamldr
  attributes during device probe rather than creation as unconditional
  exposure would be unsafe.

  Patch 22 adds error logging for update failures. It's kind of
  nice-to-have, so it is placed last for easy removal if necessary.

For transparency, I should note that I used an Intel-operated AI tool to
help proofread this cover-letter and commit messages.

Changelog:
v4->v5:
 - s/TDX Module/TDX module/g [Binbin/Dave]
 - drop is_vmalloc_addr() checking [Dave/Rick]
 - protect lockstep control data with a lock [Dave]
 - clarify why raw_spinlock is used [Dave/Kai]
 - drop patches that check all CPUs are online and updates are not exhausted [Dave]
 - register seamldr attributes in device probe
 - use devm_add_action_or_reset for seamldr deinit [Yilun]
 - remove global tdx_fw [Yilun]
 - clarify request_firmware() doesn't take filename from userspace [Rick]
 - drop unnecessary checks when populating an update request [Rick]
 - rewrite the commit message for the skeleton patch
 - rewrite the commit message for the "update-sensitive operations" handling patch
 - other minor code changes, changelog improvements and typo fixes [Binbin/Yan etc]
 - collect review tags from Yilun/Rick/Kai/Binbin
 - v4: https://lore.kernel.org/kvm/20260212143606.534586-1-chao.gao@intel.com/

This series adds support for runtime TDX module updates that preserve
running TDX guests. It is also available at:

  https://github.com/gaochaointel/linux-dev/commits/tdx-module-updates-v5/

== Background ==

Intel TDX isolates Trusted Domains (TDs), or confidential guests, from the
host. A key component of Intel TDX is the TDX module, which enforces
security policies to protect the memory and CPU states of TDs from the
host. However, the TDX module is software that requires updates.

== Problems ==

Currently, the TDX module is loaded by the BIOS at boot time, and the only
way to update it is through a reboot, which results in significant system
downtime. Users expect the TDX module to be updatable at runtime without
disrupting TDX guests.

== Solution ==

On TDX platforms, P-SEAMLDR[1] is a component within the protected SEAM
range. It is loaded by the BIOS and provides the host with functions to
install a TDX module at runtime.

Implement a TDX module update facility via the fw_upload mechanism. Given
that there is variability in which module update to load based on features,
fix levels, and potentially reloading the same version for error recovery
scenarios, the explicit userspace chosen payload flexibility of fw_upload
is attractive.

This design allows the kernel to accept a bitstream instead of loading a
named file from the filesystem, as the module selection and policy
enforcement for TDX modules are quite complex (see patch "coco/tdx-host:
Implement firmware upload sysfs ABI for TDX module updates"). By doing
so, much of this complexity is shifted out of the kernel. The kernel
needs to expose information, such as the TDX module version, to
userspace.  Userspace must understand the TDX module versioning scheme
and update policy to select the appropriate TDX module (see "TDX module
Versioning" below).

In the unlikely event the update fails, for example userspace picks an
incompatible update image, or the image is otherwise corrupted, all TDs
will experience SEAMCALL failures and be killed. The recovery of TD
operation from that event requires a reboot.

Given there is no mechanism to quiesce SEAMCALLs, the TDs themselves must
pause execution over an update. The most straightforward way to meet the
'pause TDs while update executes' constraint is to run the update in
stop_machine() context. All other evaluated solutions export more
complexity to KVM, or exports more fragility to userspace.

== How to test this series ==

First, load kvm-intel.ko and tdx-host.ko if they haven't been loaded:

 # modprobe -r kvm_intel
 # modprobe kvm_intel tdx=1
 # modprobe tdx-host

Then, use the userspace tool below to select the appropriate TDX module and
install it via the interfaces exposed by this series:

 # git clone https://github.com/intel/tdx-module-binaries
 # cd tdx-module-binaries
 # python version_select_and_load.py --update

this version changes the firmware directory name from seamldr_upload to
tdx_module, so, below change should be applied to version_select_and_load.py:

diff --git a/version_select_and_load.py b/version_select_and_load.py
index 2193bd8..6a3b604 100644
--- a/version_select_and_load.py
+++ b/version_select_and_load.py
@@ -38,7 +38,7 @@ except ImportError:
     print("Error: cpuid module is not installed. Please install it using 'pip install cpuid'")
     sys.exit(1)

-FIRMWARE_PATH = "/sys/class/firmware/seamldr_upload"
+FIRMWARE_PATH = "/sys/class/firmware/tdx_module"
 MODULE_PATH = "/sys/devices/faux/tdx_host"
 SEAMLDR_PATH = "/sys/devices/faux/tdx_host/seamldr"
 allow_debug = False


== Other information relevant to Runtime TDX module updates ==

=== TDX module versioning ===

Each TDX module is assigned a version number x.y.z, where x represents the
"major" version, y the "minor" version, and z the "update" version.

Runtime TDX module updates are restricted to Z-stream releases.

Note that Z-stream releases do not necessarily guarantee compatibility. A
new release may not be compatible with all previous versions. To address this,
Intel provides a separate file containing compatibility information, which
specifies the minimum module version required for a particular update. This
information is referenced by the tool to determine if two modules are
compatible.

=== TCB Stability ===

Updates change the TCB as viewed by attestation reports. In TDX there is
a distinction between launch-time version and current version where
runtime TDX module updates cause that latter version number to change,
subject to Z-stream constraints.

The concern that a malicious host may attack confidential VMs by loading
insecure updates was addressed by Alex in [3]. Similarly, the scenario
where some "theoretical paranoid tenant" in the cloud wants to audit
updates and stop trusting the host after updates until audit completion
was also addressed in [4]. Users not in the cloud control the host machine
and can manage updates themselves, so they don't have these concerns.

See more about the implications of current TCB version changes in
attestation as summarized by Dave in [5].

=== TDX module Distribution Model ===

At a high level, Intel publishes all TDX modules on the github [2], along
with a mapping_file.json which documents the compatibility information
about each TDX module and a userspace tool to install the TDX module. OS
vendors can package these modules and distribute them. Administrators
install the package and use the tool to select the appropriate TDX module
and install it via the interfaces exposed by this series.

[1]: https://cdrdv2.intel.com/v1/dl/getContent/733584
[2]: https://github.com/intel/tdx-module-binaries
[3]: https://lore.kernel.org/all/665c5ae0-4b7c-4852-8995-255adf7b3a2f@amazon.com/
[4]: https://lore.kernel.org/all/5d1da767-491b-4077-b472-2cc3d73246d6@amazon.com/
[5]: https://lore.kernel.org/all/94d6047e-3b7c-4bc1-819c-85c16ff85abf@intel.com/


Chao Gao (21):
  coco/tdx-host: Introduce a "tdx_host" device
  coco/tdx-host: Expose TDX module version
  x86/virt/seamldr: Introduce a wrapper for P-SEAMLDR SEAMCALLs
  x86/virt/seamldr: Retrieve P-SEAMLDR information
  coco/tdx-host: Expose P-SEAMLDR information via sysfs
  coco/tdx-host: Implement firmware upload sysfs ABI for TDX module
    updates
  x86/virt/seamldr: Allocate and populate a module update request
  x86/virt/seamldr: Introduce skeleton for TDX module updates
  x86/virt/seamldr: Abort updates if errors occurred midway
  x86/virt/seamldr: Shut down the current TDX module
  x86/virt/tdx: Reset software states during TDX module shutdown
  x86/virt/seamldr: Install a new TDX module
  x86/virt/seamldr: Do TDX per-CPU initialization after updates
  x86/virt/tdx: Restore TDX module state
  x86/virt/tdx: Update tdx_sysinfo and check features post-update
  x86/virt/tdx: Avoid updates during update-sensitive operations
  coco/tdx-host: Don't expose P-SEAMLDR features on CPUs with erratum
  x86/virt/tdx: Enable TDX module runtime updates
  coco/tdx-host: Document TDX module update compatibility criteria
  x86/virt/tdx: Document TDX module update
  x86/virt/seamldr: Log TDX module update failures

Kai Huang (1):
  x86/virt/tdx: Move low level SEAMCALL helpers out of <asm/tdx.h>

 .../ABI/testing/sysfs-devices-faux-tdx-host   |  75 ++++
 Documentation/arch/x86/tdx.rst                |  36 ++
 arch/x86/include/asm/cpufeatures.h            |   1 +
 arch/x86/include/asm/seamldr.h                |  37 ++
 arch/x86/include/asm/tdx.h                    |  65 +---
 arch/x86/include/asm/tdx_global_metadata.h    |   5 +
 arch/x86/include/asm/vmx.h                    |   1 +
 arch/x86/kvm/vmx/tdx_errno.h                  |   2 -
 arch/x86/virt/vmx/tdx/Makefile                |   2 +-
 arch/x86/virt/vmx/tdx/seamcall_internal.h     | 109 ++++++
 arch/x86/virt/vmx/tdx/seamldr.c               | 325 ++++++++++++++++++
 arch/x86/virt/vmx/tdx/tdx.c                   | 165 ++++++---
 arch/x86/virt/vmx/tdx/tdx.h                   |  11 +-
 arch/x86/virt/vmx/tdx/tdx_global_metadata.c   |  18 +
 drivers/virt/coco/Kconfig                     |   2 +
 drivers/virt/coco/Makefile                    |   1 +
 drivers/virt/coco/tdx-host/Kconfig            |  12 +
 drivers/virt/coco/tdx-host/Makefile           |   1 +
 drivers/virt/coco/tdx-host/tdx-host.c         | 228 ++++++++++++
 19 files changed, 995 insertions(+), 101 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-devices-faux-tdx-host
 create mode 100644 arch/x86/include/asm/seamldr.h
 create mode 100644 arch/x86/virt/vmx/tdx/seamcall_internal.h
 create mode 100644 arch/x86/virt/vmx/tdx/seamldr.c
 create mode 100644 drivers/virt/coco/tdx-host/Kconfig
 create mode 100644 drivers/virt/coco/tdx-host/Makefile
 create mode 100644 drivers/virt/coco/tdx-host/tdx-host.c

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 80+ messages in thread

end of thread, other threads:[~2026-03-23  2:15 UTC | newest]

Thread overview: 80+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15 13:58 [PATCH v5 00/22] Runtime TDX module update support Chao Gao
2026-03-15 13:58 ` [PATCH v5 01/22] x86/virt/tdx: Move low level SEAMCALL helpers out of <asm/tdx.h> Chao Gao
2026-03-16 12:41   ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 02/22] coco/tdx-host: Introduce a "tdx_host" device Chao Gao
2026-03-16 12:48   ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 03/22] coco/tdx-host: Expose TDX module version Chao Gao
2026-03-16 12:54   ` Kiryl Shutsemau
2026-03-18 21:37   ` Huang, Kai
2026-03-15 13:58 ` [PATCH v5 04/22] x86/virt/seamldr: Introduce a wrapper for P-SEAMLDR SEAMCALLs Chao Gao
2026-03-16 13:05   ` Kiryl Shutsemau
2026-03-17  0:43     ` Chao Gao
2026-03-17  9:59       ` Kiryl Shutsemau
2026-03-18  7:13   ` Xiaoyao Li
2026-03-18  9:34     ` Chao Gao
2026-03-19  3:02       ` Xiaoyao Li
2026-03-19  7:14         ` Chao Gao
2026-03-18 21:38   ` Huang, Kai
2026-03-15 13:58 ` [PATCH v5 05/22] x86/virt/seamldr: Retrieve P-SEAMLDR information Chao Gao
2026-03-16 13:12   ` Kiryl Shutsemau
2026-03-17  1:05     ` Chao Gao
2026-03-17 10:00       ` Kiryl Shutsemau
2026-03-18  7:53   ` Xiaoyao Li
2026-03-18  8:57     ` Chao Gao
2026-03-18 21:40   ` Huang, Kai
2026-03-15 13:58 ` [PATCH v5 06/22] coco/tdx-host: Expose P-SEAMLDR information via sysfs Chao Gao
2026-03-17 10:06   ` Kiryl Shutsemau
2026-03-17 15:34     ` Dave Hansen
2026-03-18  6:54     ` Chao Gao
2026-03-18  8:20       ` Xiaoyao Li
2026-03-18  9:10         ` Chao Gao
2026-03-18  9:28           ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 07/22] coco/tdx-host: Implement firmware upload sysfs ABI for TDX module updates Chao Gao
2026-03-17 10:20   ` Kiryl Shutsemau
2026-03-18  8:28     ` Chao Gao
2026-03-18 21:45   ` Huang, Kai
2026-03-15 13:58 ` [PATCH v5 08/22] x86/virt/seamldr: Allocate and populate a module update request Chao Gao
2026-03-17 10:59   ` Kiryl Shutsemau
2026-03-18  8:50     ` Chao Gao
2026-03-18 10:58       ` Kiryl Shutsemau
2026-03-19  7:24         ` Chao Gao
2026-03-19 12:58           ` Kiryl Shutsemau
2026-03-18 21:36   ` Huang, Kai
2026-03-15 13:58 ` [PATCH v5 09/22] x86/virt/seamldr: Introduce skeleton for TDX module updates Chao Gao
2026-03-18 22:11   ` Huang, Kai
2026-03-19 13:15   ` Kiryl Shutsemau
2026-03-20  8:10     ` Chao Gao
2026-03-15 13:58 ` [PATCH v5 10/22] x86/virt/seamldr: Abort updates if errors occurred midway Chao Gao
2026-03-19 13:19   ` Kiryl Shutsemau
2026-03-20  8:12     ` Chao Gao
2026-03-15 13:58 ` [PATCH v5 11/22] x86/virt/seamldr: Shut down the current TDX module Chao Gao
2026-03-19 13:24   ` Kiryl Shutsemau
2026-03-20  8:21     ` Chao Gao
2026-03-23  1:33       ` Chao Gao
2026-03-15 13:58 ` [PATCH v5 12/22] x86/virt/tdx: Reset software states during TDX module shutdown Chao Gao
2026-03-16  9:06   ` Huang, Kai
2026-03-17  8:27     ` Chao Gao
2026-03-17 11:08       ` Huang, Kai
2026-03-15 13:58 ` [PATCH v5 13/22] x86/virt/seamldr: Install a new TDX module Chao Gao
2026-03-19 13:32   ` Kiryl Shutsemau
2026-03-23  2:14     ` Chao Gao
2026-03-15 13:58 ` [PATCH v5 14/22] x86/virt/seamldr: Do TDX per-CPU initialization after updates Chao Gao
2026-03-19 13:33   ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 15/22] x86/virt/tdx: Restore TDX module state Chao Gao
2026-03-19 13:37   ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 16/22] x86/virt/tdx: Update tdx_sysinfo and check features post-update Chao Gao
2026-03-19 13:43   ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 17/22] x86/virt/tdx: Avoid updates during update-sensitive operations Chao Gao
2026-03-19 14:00   ` Kiryl Shutsemau
2026-03-20  8:00     ` Chao Gao
2026-03-15 13:58 ` [PATCH v5 18/22] coco/tdx-host: Don't expose P-SEAMLDR features on CPUs with erratum Chao Gao
2026-03-19 14:02   ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 19/22] x86/virt/tdx: Enable TDX module runtime updates Chao Gao
2026-03-19 14:03   ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 20/22] coco/tdx-host: Document TDX module update compatibility criteria Chao Gao
2026-03-19 14:04   ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 21/22] x86/virt/tdx: Document TDX module update Chao Gao
2026-03-19 14:05   ` Kiryl Shutsemau
2026-03-15 13:58 ` [PATCH v5 22/22] x86/virt/seamldr: Log TDX module update failures Chao Gao
2026-03-19 14:06   ` Kiryl Shutsemau
2026-03-20  8:31     ` Chao Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox