Skip to content

fix(tdx-attest): get quotes from QGS over vsock before configfs - #1660

Open
kvinwang wants to merge 1 commit into
nextfrom
fix/tdx-attest-prefer-vsock
Open

kvinwang wants to merge 1 commit into
nextfrom
fix/tdx-attest-prefer-vsock

Conversation

@kvinwang

Copy link
Copy Markdown
Collaborator

Problem

tdx-attest prefers configfs whenever it exists. The kernel's configfs path polls for the quote once a second (wait_for_quote_completion() in drivers/virt/coco/tdx-guest/tdx-guest.c sleeps MSEC_PER_SEC per check), so every quote takes at least 1 s even though QGS answers in a few milliseconds. The guest agent serializes quotes, so this is the root cause of the queue backlog addressed in #1659.

Change

  • Get the quote from QGS over vsock first when /etc/tdx-attest.conf sets a port.
  • Images ship port=4050 whether or not the host serves it, so a vsock failure falls back to configfs.
  • DCAP_TDX_QUOTE_CONFIGFS_PATH still forces configfs.

Measurements

Setup: tdxlab, dstack-0.6.5 image (kernel 6.18.59-dstack), 2 vCPU / 2 GB TDX CVM, host qgsd on vsock port 4050 with number_threads = 4 and PCCS pccs.phala.network. Sequential tdx_attest::get_quote() calls from a small binary inside the CVM, 64-byte report data:

Library / condition n min p50 max
next, configfs first 20 1.0236 s 1.0240 s 1.0492 s
this PR, vsock first 20 0.0043 s 0.0050 s 0.0082 s
this PR, vsock port unreachable (port=4051) → configfs 10 1.0236 s 1.0241 s 1.0291 s
this PR, no port configured → configfs 5 1.0107 s 1.0240 s 1.0241 s
this PR, DCAP_TDX_QUOTE_CONFIGFS_PATH set → configfs 5 1.0133 s 1.0240 s 1.0241 s

All quotes are 5243 bytes. A vsock quote passes dcap-qvl verify with status UpToDate, and its MRTD and RTMRs match configfs quotes.

End to end on the same CVM, a stock 0.6.5 guest agent with configfs hidden from its unit (so it takes the existing vsock path) produced:

Endpoint configfs vsock
serial /v1/Attest, n=20, avg 1.062 s 0.007 s
16 concurrent /v1/Attest, max 16.407 s 0.051 s

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 <wy721@qq.com>

This branch has not been deployed

No deployments
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.

1 participant