Skip to content

Add preliminary Intel TDX support [v2] #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jul 25, 2025
Merged

Conversation

jakecorrenti
Copy link
Member

This pull request adds support for Intel Trust Domain eXtensions (TDX), another hardware Trusted Execution Environment architecture.

Note: this pull request does not support attestation.

@jakecorrenti
Copy link
Member Author

jakecorrenti commented Jun 13, 2025

There are two outstanding issues, but the limitations are documented in the README:

  • giving the VM more than 3072 mib of memory causes an error because the guest exits with VcpuExit::MemoryFault, then tries to conver the region at MMIO_START to private.
  • giving the VM more than 1 processor leads to only the BSP being active. The APs fail to wake up

@jakecorrenti jakecorrenti force-pushed the tdx-v2 branch 2 times, most recently from a8c3e57 to f60a0f3 Compare June 20, 2025 14:37
@jakecorrenti
Copy link
Member Author

@tylerfanelli @MatiasVara @slp feel free to review whenever you're ready. I'm just trying to figure out how to debug the issues I listed above at the moment.

@jakecorrenti jakecorrenti marked this pull request as ready for review June 30, 2025 21:22
@jakecorrenti jakecorrenti force-pushed the tdx-v2 branch 5 times, most recently from 7376e1e to 6ec624b Compare July 2, 2025 21:35
jakecorrenti added a commit to jakecorrenti/libkrunfw that referenced this pull request Jul 2, 2025
Update the binary so a TDX guest does not attempt attestation.

Generated from work done in containers/libkrun#355

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
@jakecorrenti jakecorrenti linked an issue Jul 2, 2025 that may be closed by this pull request
@slp
Copy link
Collaborator

slp commented Jul 24, 2025

@jakecorrenti LGTM, could you please rebase it?

In the IOAPIC constructor, only enable the SPLIT IRQCHIP capability on
non-tdx flavors. The TDX flavor will enable the necessary capabilities
for the system on Vm creation.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
TDX requires the IRQCHIP to be split between the guest and the host.
Enable the functionality in the launch-tee test.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
@jakecorrenti
Copy link
Member Author

jakecorrenti commented Jul 24, 2025

Accidentally committed the launch-tee binary. TDX machine is rebooting, so I need to wait for that to be done before I can fix it

Fixed!

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Some of the pre-existing feature checks in the `vmm` crate, whether
`tee` or `amd-sev`, are not compatible with the `tdx` feature.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Ensure the -tdx flavor links with the correct libkrunfw flavor, which in
this case is libkrunfw-tdx.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
The registers and APIC state on TDX systems are considered "protected",
therefore we cannot configure them at all through the KVM API.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Adds a new `inteltdx` module and implements a TDX implementation for `Vm::new()`

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
TDX requires the number of 4k pages and the number of vCPUs to be
specified in the boot parameters differently than the other `tee`
architectures.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
TDX starts execution in 32-bit protected mode, not 16-bit real mode.
Change the reset vector to reflect that.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Retrieve the TDX capabilities KVM supports with the current TDX module
the system has loaded and perform TDX specific VM initialization.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
After the vCPUs have been created with KVM, add them to the TDX
launcher and then do the necessary initialization.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Initialize the guest private memory for each of the measured regions
created.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Set up the worker thread so the TDX guest is able to convert memory from
shared -> private or private -> shared when a hypercall is made or a
memory fault occurs.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
When the vCPU exits with VcpuExit::MemoryFault, ensure that we are
checking the exit flag has the private bit set to 1 before attempting to
convert any memory.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Document how to compile and install the TDX flavor of libkrun. Also
document the limitations of multiprocessing and memory.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Do not attest with the libkrun-tdx flavor.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Copy link
Collaborator

@slp slp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@slp slp merged commit 6e1c448 into containers:main Jul 25, 2025
6 checks passed
@slp slp mentioned this pull request Jul 25, 2025
slp pushed a commit to containers/libkrunfw that referenced this pull request Jul 31, 2025
Update the binary so a TDX guest does not attempt attestation.

Generated from work done in containers/libkrun#355

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support Intel TDX
2 participants