Re: [RFC PATCH 00/15] PCI/TSM: coco/tdx-guest: Implement TDX-Connect PCIe TDISP (phase2)
From: Edgecombe, Rick P
Date: Tue Nov 24 2026 - 14:41:57 EST
On Tue, 2026-11-24 at 14:01 +0800, Xiaoyao Li wrote:
> 1. The requirement of R8-R15 are reserved to 0 on TDG.DMAR.ACCEPT.
>
> This is the first leaf in TDCALL/SEAMCALL that explicitly requires some
> unused registers to be 0. Without justification of why it must to be such,
> we are going to propose to remove this requirement and it helps drop the
> PATCH 13.
Ah, ok so the problem is we need to make sure those registers are saved in the
wrapper, if we will set them to 0 before SEAMCALL. So the seamcall code doesn't
clobber the callers registers.
But I tend to think an ABI rejecting reserved input is a general good thing.
Since SEAMCALLs are not fast, I wonder why care about optimizing the wrappers to
save and restore the minimum. If we just always saved and restored the general
purpose registers, we wouldn't need so many wrappers. And then when TDX module
wanted to add new SEAMCALL ABI we wouldn't need to do the whole version
selection thing. Just pass a new bit or whatever. That would have simplified the
TDH.SYS.CONFIG changes for DPAMT and add-ons.
So I'm thinking that old seamcalls were maybe incorrect and this new way is
correct. Yes we would need a new patch, but what if it was a simplication patch
that got rid of all the seamcall variants and just always saved/restored?
Consider those premature optimization. Any problems?
>
> 2. Add 'TDI' to the names of TDG.DMAR.ACCEPT and TDG.DMAR.RELEASE and maybe
> rename 'DMRA' to 'DMA'
>
> TDG.MMIO.ACCEPT has already been renamed to TDG.TDI.MMIO.ACCEPT in the latest
> public TDX Connect API spec, to call out its scope is TDI. It's better to
> add 'TDI' to TDG.DMRA.* as well to make them consistent since TDG.DMAR.* also
> operate on TDI scope.
>
> Besides, DMAR means "DMA Remapping", which is an IOMMU capability. Without a
> virtual IOMMU for guest, the guest should just care about the DMA capability.
> So it looks DMA is more accurate than DMAR.
Ok.
>
> 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.
Yep.
>
> 4. TDX_PAGE_ALREADY_ACCEPTED is listed as the possible return code for
> TDG.TDI.MMIO.ACCEPT while the description of TDG.TDI.MMIO.ACCEPT reads:
>
> If the page is already MMIO_MAPPED, skip the page.
>
> They conflict with each other and lead to confusion.
I'd think if the page size is incorrect it should return
TDX_MMIO_ACCEPT_SIZE_MISMATCH. If it is already accepted it should return
TDX_PAGE_ALREADY_ACCEPTED. In the case of mismatched size but already accepted
page, ideally it would return TDX_PAGE_ALREADY_ACCEPTED, but it would be ok if
it returns TDX_MMIO_ACCEPT_SIZE_MISMATCH.