Re: [RFC PATCH 00/15] PCI/TSM: coco/tdx-guest: Implement TDX-Connect PCIe TDISP (phase2)
From: Xiaoyao Li
Date: Mon Nov 30 2026 - 01:35:39 EST
On 11/27/2026 4:13 PM, Tian, Kevin wrote:
>> From: Li, Xiaoyao <xiaoyao.li@xxxxxxxxx>
>> Sent: Thursday, November 26, 2026 4:10 PM
>>
>> On 11/26/2026 1:47 AM, Edgecombe, Rick P wrote:
>>> On Wed, 2026-11-25 at 16:32 +0800, Xiaoyao Li wrote:
>>>> On 11/25/2026 3:41 AM, Edgecombe, Rick P wrote:
>>>>> 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.
>
> TDG.VM.RD/WR and TDG.VP.RD/WR require RCX must be 0, so it's not
> the first example.
I missed them. Thanks for catching this!
I think they are reserved to 0 because their host SEAMCALL counterpart,
TDH.MNG.RD/WR and TDH.VP.RD/WR, have R10 defined to identify the TD and VCPU.
But for guest TDCALL, no need for such identifier. It is reasonable to reserve
the R10 on TDG.VM.RD/WR and TDG.VP.RD/WR to make the API consistent with host
side SEAMCALL and reserve the ability for future extension.
...
>>
>> Re-accept of memory has the effect to reset the memory content 0. But re-
>> accept
>> of MMIO doesn't do any harm, as I see it.
>
> dumb question - why would the guest want to re-accept a memory, in
> different sizes? is there a concrete example?
No. It's not telling that the guest wants to re-accept a memory, but telling
that the success of re-accepting a memory has the semantic of "the memory is
initialized to zero". This "resetting to 0" behavior sometimes causes problem so
we don't want re-accept of memory to return success, but return an error code of
TDX_PAGE_ALEARDY_ACCEPTED.
But for MMIO, re-accept has no such additional semantic. It looks OK to return
success for MMIO re-accept.
>>
>>> The guest could get confused about which MMIO address is mapped at a
>>> particular GPA?
>>
>> I'm not sure. Guest doesn't care the mapping between MMIO and GPA. The
>> TSM and
>> secure firmware will help validate that the host VMM has mapped the GPA to
>> the
>> correct MMIO resource of the corresponding haredware device. And MMIO
>> cannot be
>> converted between shared/private back and forth runtime. During the
>
> is it true? when the device transitions from locked to unlocked it then goes
> from private to shared?
My wording of "runtime" seems not that accurate. Let's say it this way. There
are two states of a device, bound and unbound. During the lifetime of each
state, whether the MMIO is private and shared is determined and we cannot change
part of the MMIO into a different shared/private state.
>> lifetime,
>> guest kernel only needs to accept the private MMIO once after the device is
>> locked and accepted.
>>
>>> There must be some trusting intended as part of the operation or
>>> why even have the MMIO accept in the guest in the first place.
>>
>> We have two reasons:
>> 1. the same for the page accept. Accepting the page/MMIO by the guest
>> prevents
>> host from mapping a new page/MMIO to the GPA without guest's awareness.
>>
>> 2. TDX module will validate that the host maps the correct MMIO resource to
>> the
>> GPA.
>>
>>> So I think if we don't need the error, why even need the MMIO accept call
>> at
>>> all? But we probably want both.
>>
>> The ALREADY_ACCEPT error code and MMIO accept are two things. We care
>> if the
>> MMIO is accepted or not, but we don't care how many times the MMIO is
>> accepted.
>>
>>> And I also don't see a major simplicity benefit to dropping error. What is
>> the
>>> savings?
>>
>> It makes the guest code simpler that the guest doesn't need to implement
>> the
>> skipping itself.
>
> simpler compared to treating ALREADY_ACCEPT as success?
yes. If re-accept of MMIO will return ALREADY_ACCEPT. Even by treating it as
success, guest code still needs something like below:
diff --git a/arch/x86/coco/tdx/tdx_connect.c b/arch/x86/coco/tdx/tdx_connect.c
index 01c12b459570..da049ea30764 100644
--- a/arch/x86/coco/tdx/tdx_connect.c
+++ b/arch/x86/coco/tdx/tdx_connect.c
@@ -69,7 +69,10 @@ int tdx_mcall_tdi_mmio_accept(struct pci_dev *dev,
.r9 = size >> PAGE_SHIFT,
};
- ret = __tdcall(TDG_TDI_MMIO_ACCEPT, &args);
+ do {
+ ret = __tdcall_ret(TDG_TDI_MMIO_ACCEPT, &args);
+ } while (TDCALL_RETURN_CODE(ret) == TDX_PAGE_ALREADY_ACCEPTED);
+
if (!ret)
return 0;