RE: [RFC PATCH 06/15] virt: tdx-guest: Support TDI bind and unbind operations

From: Tian, Kevin

Date: Wed Nov 11 2026 - 04:48:25 EST


> From: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Sent: Wednesday, November 11, 2026 8:16 AM
>
> On Tue, Nov 10, 2026 at 10:25:07PM +0000, Edgecombe, Rick P wrote:
> > On Tue, 2026-11-10 at 15:57 -0400, Jason Gunthorpe wrote:
> > > On Tue, Nov 10, 2026 at 06:55:41PM +0000, Edgecombe, Rick P wrote:
> > >
> > > > Additionally, we should probably see if Jason has any opinion on the
> types of
> > > > errors that guest TSM would like to handle.
> > >
> > > Not at this point :\ And perhaps not at all.
> > >
> > > Most of this stuff will end up routing through userspace so it has to
> > > be compressed into a errno.'
> > >
> > > The various VMM to guest specs like GHCI are going to define their own
> > > contracts, and it is up to Intel to ensure that the full route from
> > >   this code -> attestation subsystem -> uapi -> vmm -> GHCI
> > >
> > > Preserves whatever semantics have been defined in the spec.
> > >
> > > I don't know the answer to the EBUSY question, other than
> > > TSM/attestation will return that to userspace. Can your VMM and GHCI
> > > sort it out?

GHCI doesn't define a EBUSY error code. So it's more a TD internal policy.

A status byte in the GHCI data buffer indicates whether the requested
operation is completed by the VMM (successfully or with error). It's
unreasonable to poll it indefinitely so the polling will be capped by a
timeout. Then a 2nd request comes and observes previous request
still in progress, then -EBUSY is returned.

Such failures (timeout or busy) before attestation passes are just
returned to userspace, as Jason suggested. it's fine.

The interesting case is about such failures after attest e.g. unlock
which is supposed to be a void operation. Maybe we don't need do
anything special in tsm core - the secure firmware maintains the
state machine so future lock will fail if the current state is not
unlocked.

Anyway the success or error code from GHCI is just a hint and
untrusted.

> >
> > Kevin and Yilun are analyzing what kind of errors we should expect the VMM
> to
> > handle. But some of the cases Zhenzhong listed seem like they could be
> > situations trusted IO guests could encounter generally. Like the example
> > "[device] firmware hangs during lock/unlock". In that case unification in TSM
> > could be nice.

As long as we rely on the secure firmware to manage the TDI state machine
properly, it doesn't matter whether an uncompleted lock/unlock is caused
by device firmware hang, or any intermediate software layer serving the
GHCI call.

Generally for errors which confine to an assigned device, the guest just
keeps running. In the end the related driver stack in the guest will capture
the device error and quarantine the device in its own way.

So the TD just needs to handle errors according to the GHCI spec:

[GHCI general]
TDG.VP.VMCALL_INVALID_OPERAND
TDG.VP.VMCALL_SUBFUNC_UNSUPPORTED

[TDCM specific]
TDX_MODULE_ERROR
TDXIO_DEVICE_ERROR
SPDM_MESSAGE_ERROR
IDE_KM_MESSAGE_ERROR
TDISP_MESSAGE_ERROR
INVALID_STATE

For general errors let's follow the convention already established.

for TDCM specific ones they are not useful then let's just return a
single errno (e.g. -EIO) for all of them to userspace.

> >
> > For errors that indicate uncooperative or buggy host, we elsewhere warn in
> the
> > TDX wrappers. But in coco, not handling an error in the caller can be an
> avenue
> > to attack the guest. So I guess we would commonly need to handle these
> errors in
> > the callers.
>
> Any failure to attest should just propogate to guest userspace and
> userspace wil fail the attestation and not enable the device. This is
> fine.
>
> All failure classes, including the cases where the guest is checking
> digests/etc to confirm the host has done the right thing can work like
> this.

Agree

>
> > Zhenzhong had previously suggested a bool to set a device as bugged for the
> > purpose of trying to continue guest execution as well as possible in the face
> of
> > host issues.
>
> It does not seem necessary to me, userspace is responsible. Since no
> device evidence could possibly have been logged the VM would fail
> attestation anyhow.
>

Yeah - as said even for errors after attest passes we could rely on secure
firmware to do the right thing. Userspace requests unlock and downgrade
the trust level to DISABLED. Failures will be caught in next attempt if
unlock doesn't complete successfully.

We don't need the guest kernel to explicitly mark the buggy state. :)