feat(tdx-attest): Rewrite TDX attestation in pure Rust#466
Merged
Conversation
kvinwang
force-pushed
the
musl-tdx-support
branch
3 times, most recently
from
January 26, 2026 15:07
5f3c006 to
7f82973
Compare
kvinwang
force-pushed
the
musl-tdx-support
branch
4 times, most recently
from
January 27, 2026 00:44
0f19412 to
aab4fd4
Compare
kvinwang
commented
Jan 27, 2026
kvinwang
force-pushed
the
musl-tdx-support
branch
7 times, most recently
from
January 27, 2026 01:47
fb83c10 to
d26b0f0
Compare
kvinwang
enabled auto-merge (squash)
January 27, 2026 01:48
Enable building with x86_64-unknown-linux-musl target by: 1. Vendoring minimal Linux kernel headers that are missing from MUSL: - linux/vm_sockets.h: vsock address family and sockaddr_vm struct - linux/types.h: kernel type aliases (__u8, __u32, __u64, etc.) - linux/ioctl.h: redirect to MUSL's sys/ioctl.h 2. Updating cfg conditions to include MUSL (target_env = "musl") alongside glibc (target_env = "gnu") 3. Modifying build.rs to prioritize vendored headers via include path This allows building statically-linked TDX attestation binaries using MUSL, which is useful for containerized deployments and systems without glibc. Tested: cargo build --target x86_64-unknown-linux-musl -p tdx-attest
Implement TDX attestation without C library dependencies: - get_quote: ConfigFS (Linux 6.7+) → VSock/QGS fallback - extend_rtmr: sysfs → ioctl fallback - get_report: ioctl via /dev/tdx_guest - get_supported_att_key_ids: returns Intel TDQE UUID Key changes: - Add vsock crate for QGS protocol communication - Probe availability before execution (separate NotSupported from errors) - Include original error context in error messages - Support both new dstack OS (ConfigFS/sysfs) and legacy 0.5.4 (VSock/ioctl) Tested on: - New dstack OS: ConfigFS for quote, sysfs for extend_rtmr - dstack 0.5.4: VSock for quote, ioctl for extend_rtmr
kvinwang
force-pushed
the
musl-tdx-support
branch
from
January 27, 2026 01:57
d26b0f0 to
d379b10
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tdx-attestin pure Rust, eliminating C code dependencytdx-attest-sysdependency fromtdx-attestChanges
tdx-attest/src/linux.rs: Complete rewrite with:
/dev/tdx_guest(legacy)tdx-attest/src/dummy.rs: Simplified stub implementation
tdx-attest/Cargo.toml: Replace
tdx-attest-syswithlibc+vsocktdx-attest/examples/test_tdx.rs: Test program with dcap-qvl verification
API
The public API:
get_quote(report_data: &[u8; 64]) -> Result<Vec<u8>>get_report(report_data: &[u8; 64]) -> Result<TdxReport>extend_rtmr(index: u32, event_type: u32, digest: [u8; 48]) -> Result<()>Test Results
dstack 0.6.0 (kernel 6.17.6-dstack)
dstack 0.5.4 (kernel 6.9.0-dstack)
Build Verification
cargo build -p tdx-attestcargo build --target x86_64-unknown-linux-musl -p tdx-attestdstack-attest,dstack-utilcargo clippy -p tdx-attest