Re: [PATCH v2 10/31] x86/virt/tdx: Add extra memory to TDX Module for Extensions

From: Xu Yilun

Date: Thu Apr 23 2026 - 23:30:26 EST


On Thu, Apr 23, 2026 at 10:29:31PM +0000, Huang, Kai wrote:
> On Thu, 2026-04-23 at 17:05 +0000, Edgecombe, Rick P wrote:
> > On Thu, 2026-04-23 at 00:59 +0000, Huang, Kai wrote:
> > > Ditto here.  I don't think we should introduce any more cond_resched().
> > >
> > > Btw, I think technically we can reuse the seamcall_ir_resched() you introduced
> > > later, albeit in which a local '_args' is used as a copy of the original 'args',
> > > but that has no harm for the case where we can just use the 'args' to loop.
> > >
> > > I am wondering whether we can just use that here, or we just get rid of that
> > > helper (then open retry by the callers of these SEAMCALL wrappers), since there
> > > will be more cases where we need to manually set 'resume=1' in the SEAMCALL
> > > input 'args' when retrying TDX_INTERRUPTED_RESUMABLE.
> >
> > I kind of like the latter option to open code more of this stuff. The stacks of
> > seamcall wrapper macros is already too much.
>
> Agreed.
>
> And SEAMCALL *users* can actually come up with their own version of wrapper(s)
> to do the retry. E.g., currently seamcall_ir_resched() is only used for IOMMU
> SEAMCALLs, and we can put this wrapper in the IOMMU code or coco/tdx-host.

After we have introduced TDX Module Extension, irq preemptable
EXT-SEAMCALLs become a common concept. It is irq preemptable so that the
secure world remembers and resumes the context, no need for host to
remind via resume lag.

Today there are 3 EXT-SEAMCALLs, TDH_SPDM_CONNECT/DISCONNECT/MNG,
irq preemption handling is a general requirement for them, and I think
it is still true for any further EXT-SEAMCALLs.

So I think a general helper for EXT-SEAMCALLs makes sense.

TDH.IOMMU.SETUP, however, is another case. It is not a EXT-SEAMCALL but
happened to follow the same irq-retry handling process. To avoid code
duplication we have:

/*
* seamcall_ret_ir_exec() aliases seamcall_ret_ir_resched() for
* documentation purposes. It documents the TDX Module extension
* seamcalls that are long running / hard-irq preemptible flows that
* generate events. The calls using seamcall_ret_ir_resched() are long
* running flows, that periodically yield.
*/
#define seamcall_ret_ir_exec seamcall_ret_ir_resched

TDH.IOMMU.SETUP uses seamcall_ret_ir_resched(), and EXT-SEAMCALLs use
seamcall_ret_ir_exec().

How do you think?