Re: [RFC PATCH 00/15] PCI/TSM: coco/tdx-guest: Implement TDX-Connect PCIe TDISP (phase2)

From: Xu Yilun

Date: Mon Nov 30 2026 - 06:01:05 EST


On Thu, Nov 26, 2026 at 04:15:03PM +0800, Xiaoyao Li wrote:
> On 11/26/2026 11:11 AM, Duan, Zhenzhong wrote:
> >> 3. TDG.TDI.MMIO.ACCEPT requires TDI to be in the ASSIGNED/ACCEPTED/RUN
> >> state.
> >> After TDI is bound by host via TDH.TDI.BIND, the state is BOUND. It
> >> requires
> >> guest to call TDG.TDI.RD read the TDI_GET_BIND_SESSION_ID, which changes
> >> TDI
> >> from BOUND state to ASSIGNED.
> >>
> >> This is a hard dependency for TDG.TDI.MMIO.ACCEPT not to fail and it's
> >> not
> >> mentioned in patch 12 where the call to read TDI_GET_BIND_SESSION_ID is
> >> added.
> >>
> >> The SESSION_ID is used to ensure the host doesn't bind a new TDI after
> >> guest attests the TDI without guest's awareness because the SESSION_ID
> >> is
> >> verified in the following TDG.TDI.START. And making the read of
> >> TDI_GET_BIND_SESSION_ID to change the state machine of TDI from BOUND to
> >> ASSIGNED, make it mandatory for the implementation.
> >>
> >> But it doesn't make sense to assign additional semantic to a metadata
> >> reading
> >> behavior in a specific phase. Instead, we want to propose introducing a
> >> new
> >> dedicated TDG call, e.g., TDG.TDI.LOCK, which needs to be called by the
> >> guest
> >> to lock the TDI after it's bound by the host, and it returns
> >> TDI_GET_BIND_SESSION_ID on success.
> > What TDG.TDI.LOCK locks?
> > Or is it essentially a renaming of TDG.TDI.RD(TDI_GET_BIND_SESSION_ID)
> > to make the state transition(BOUND -> ASSIGNED) explicit?
>
> It's not a rename of TDG.TDI.RD(TDI_GET_BIND_SESSION_ID), but a replacement of
> the semantic of transitioning the TDI from BOUND to ASSIGNED.

I have concern that we need to explicitly expose TDX module internal
state to the guest, though without the proposal the internal state can
still impact the guest if it doesn't do attestation as expected: The
evidence hash verification fails if TDG.TDI.RD(TDI_GET_BIND_SESSION_ID)
is not executed.

To the guest, the correct way is to get the bind session id (like an epoch)
first, then retrieve evidences. Otherwise, the guest can't tell if the
host unbinds & rebinds the TDI during/after attestation and finally accepts
a different TDI from what is attested. So the internal state doesn't
impact the happy path and the guest can pretent it doesn't exists.

But now we want explicit the BOUND to ASSIGNED state, I have to wonder
if the ASSIGNED state is really necessary. The TDX module uses it to
ensure that the evidence matches the bind session, but I don't see it
fully reaches the goal. It prevents rebind before attestation, but it
can't prevent rebind during/after attestation. And it doesn't have to,
the final TDH.TDI.START catches all the rebind attempt.

So could we just drop the ASSIGNED state, a sane guest knows what to do
to prevent attack. It can also choose to be lazy to do no attestation
and just accept, the TDX module can't prevent that.

>
> TDG.TDI.RD(TDI_GET_BIND_SESSION_ID) is still supported, and can be called
> anytime. When TDI has valid BIND_SESSION_ID, it returns the session ID.
> Otherewise return error.
>
> > Clarifying this will help determine whether "LOCK" or something like
> > "ACCEPT_BIND" / "ASSIGN" better reflects the underlying operation.
>
> Yeah. It looks "LOCK" doesn't sound good. Because guest cannot lock anything,
> and the host can still unbind the current TDI and bind a new one.
>
> TDG.TDI.ACCEPT_BIND or just TDG.TDI.ACCEPT?