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

From: Edgecombe, Rick P

Date: Mon Nov 30 2026 - 17:00:26 EST


On Thu, 2026-11-26 at 16:09 +0800, Xiaoyao Li wrote:
> > I think saving and restoring general purpose registers across a seamcall
> > would
> > not be a big overhead given the amount of other work happening during a
> > seamcall. Probably small enough that we could not even have to measure it to
> > make the case for the patch. Any counter points?
>
> No. It looks doable to me.
>
> IIUC, you want us to set aside the decision of whether to remove the
> requirement
> of "R8-R15 are reserved to 0 on TDG.DMAR.ACCEPT". But to explore the direction
> of unifying the SEAMCALL/TDCALL helper to always save and restore the
> registers.
> If the unification is accepted, then whether "R8-R15 are reserved to 0 on
> TDG.DMAR.ACCEPT" won't matter much. Is my understand correct?
>
> <snip>

Let's try it. How about a small pre-req series to go ahead.

<snip>
>
> >
> > In the past discussion on private memory accept, someone made the point that
> > re- accepting memory should be fixed in the caller because it could be a
> > weakness used to attack the guest. If the kernel is confused, the host could
> > zero memory for the guest as part of some attack, or the new caller of
> > accept could be surprised by un-zeroed memory. This came up when the memory
> > hot replug bug that was eventually fixed in qemu partly to avoid allowing
> > survival of re-accepting memory in the guest. (and caught by the already
> > accepted error code). We discussed if the guest could handle the error by
> > simply re-zeroing the memory after a double accept. But then the debate was
> > whether this would cover up bugs.
> >
> > I think a similar case could be made for MMIO, which is probably the purpose
> > of this error?
>
> 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.

Re-accept normal memory error could then just zero the memory on re-accept. I
raised this as a possibility, but there were security concerns IIRC. Either the
first user or second gets surprised with the host in control.

>
> > 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
> lifetime, guest kernel only needs to accept the private MMIO once after the
> device is locked and accepted.

We would need the host to not be able to zap the MMIO PTE and map something else
there.

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

I don't think the latter is established.

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