Re: [PATCH v2 20/31] x86/virt/tdx: Add a helper to loop on TDX_INTERRUPTED_RESUMABLE

From: Xu Yilun

Date: Mon Jul 06 2026 - 07:34:17 EST


> > +static u64 __maybe_unused __seamcall_ir_resched(sc_func_t sc_func, u64 fn,
> > + struct tdx_module_args *args)
> > +{
> > + struct tdx_module_args _args;
> > + u64 r;
> > +
> > + while (1) {
> > + _args = *(args);
>
> Is this copying meant to ensure that every retry has the same input
> args? Perhaps a comment should be added so it's obvious that every retry
> will have the same input, and outputs from each retry are dropped.

Yes, that's the intent.

But now I've found this is not a good convention for INTERRUPTED_RESUMABLE.
If outputs are necessary why we drop them, if outputs are not useful why
we output them to overwrite inputs. The fact is that TDX module only
outputs all 0's to zero out the inputs, that makes no sense.

So we now switch to another existing convention - if there is valid
output, use the output to update the input for next loop, or keep the input
unchanged. This way we only need to:

do {
r = seamcall(TDH_XX_XX, &args);
} while (r == TDX_INTERRUPTED_RESUMABLE);

if (r != TDX_SUCCESS)
return -EFAULT;

https://lore.kernel.org/kvm/20260618081355.3253581-6-yilun.xu@xxxxxxxxxxxxxxx/
https://lore.kernel.org/kvm/20260618081355.3253581-5-yilun.xu@xxxxxxxxxxxxxxx/

>
> > + r = sc_retry(sc_func, fn, &_args);
> > + if (r != TDX_INTERRUPTED_RESUMABLE)
> > + break;
> > +
> > + cond_resched();
> > + }
> > +
> > + *args = _args;
> > +
> > + return r;
> > +}