From 05a961c12faffa8ede811ec55fed4d390a070d2d Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Fri, 27 Nov 2026 00:42:41 -0800 Subject: [PATCH] fix(tdx-attest): get quotes from QGS over vsock before configfs The kernel's configfs TSM path waits for the quote with msleep_interruptible(MSEC_PER_SEC) in wait_for_quote_completion(), and the request is always still in flight on the first check. Every quote therefore takes at least a second, although QGS answers in a few milliseconds. The guest agent serializes quotes, so one-second quotes are what let its queue back up. Prefer vsock when /etc/tdx-attest.conf sets a port. Images ship the port whether or not the host serves it, so a vsock failure falls back to configfs when configfs exists. An explicit DCAP_TDX_QUOTE_CONFIGFS_PATH still selects configfs alone. Both paths reach the same host QGS and return the same QE-signed quote: vsock sends the guest's own TDREPORT, while configfs has the kernel and QEMU forward it. Signed-off-by: Kevin Wang --- CHANGELOG.md | 5 +++++ dstack/tdx-attest/src/linux.rs | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cced83c48..ec04fbef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- **TDX quotes go to QGS over vsock first.** When `/etc/tdx-attest.conf` + sets a port, `tdx-attest` asks QGS directly and falls back to configfs only + if that fails, or uses configfs alone when `DCAP_TDX_QUOTE_CONFIGFS_PATH` is + set. The kernel's configfs path polls once a second, so a quote took about + 1 s there and takes about 5 ms over vsock. - **`vmm-cli update --compose` takes an app compose file.** It sends the `app-compose.json` written by `vmm-cli compose` unchanged instead of a Docker Compose file patched into the stored one, and `--prelaunch-script` and diff --git a/dstack/tdx-attest/src/linux.rs b/dstack/tdx-attest/src/linux.rs index bde47ce34..c1100f4d9 100644 --- a/dstack/tdx-attest/src/linux.rs +++ b/dstack/tdx-attest/src/linux.rs @@ -166,17 +166,26 @@ static CONFIGFS_MKDIR_TRIED: Mutex = Mutex::new(false); /// Get a TDX quote for the given report data. /// /// Tries multiple methods in order: -/// 1. ConfigFS (Linux 6.7+) -/// 2. VSock to QGS service +/// 1. VSock to QGS service, when a port is configured and no configfs path is +/// forced through the environment +/// 2. ConfigFS (Linux 6.7+) +/// +/// VSock goes first because the kernel's configfs path polls for the quote +/// once a second, so a quote QGS returns in milliseconds takes a second there. pub fn get_quote(report_data: &TdxReportData) -> Result> { let _guard = TDX_LOCK.lock().map_err(|_| TdxAttestError::Busy)?; - if should_try_configfs() { - return get_quote_via_configfs(report_data); + if std::env::var_os(CONFIGFS_PATH_ENV).is_none() && is_vsock_available() { + match get_quote_via_vsock(report_data) { + Ok(quote) => return Ok(quote), + Err(err) if !should_try_configfs() => return Err(err), + // Images configure the port whether or not the host serves it. + Err(_) => {} + } } - if is_vsock_available() { - return get_quote_via_vsock(report_data); + if should_try_configfs() { + return get_quote_via_configfs(report_data); } Err(TdxAttestError::NotSupported(