Re: [PATCH v3 1/9] x86/virt/tdx: Add SEAMCALL wrappers for IOMMU setup/clear
From: Baolu Lu
Date: Wed Dec 02 2026 - 03:45:54 EST
On 12/2/2026 3:26 PM, Xiaoyao Li wrote:
On 11/24/2026 1:46 PM, Baolu Lu wrote:
+ u64 *tdx_iommu_id)
+{
+ struct tdx_module_args args = {
+ .rcx = reg_base,
+ .rdx = __pa(param),
+ };
+ u64 ret;
+
+ /*
+ * Retry only on TDX_INTERRUPTED_RESUMABLE:
+ *
+ * - TDX_INTERRUPTED_RESUMABLE guarantees forward progress between
+ * calls.
+ * - On TDX_INTERRUPTED_RESUMABLE, all registers except RAX remain
+ * unchanged.
+ *
+ * The ABI spec also allows retrying on TDX_OPERAND_BUSY, but that
+ * status doesn't guarantee forward progress, so retrying could spin
+ * forever. The host serializes all TDH.IOMMU.SETUP and
+ * TDH.IOMMU.CLEAR calls for an IOMMU, so the TDX module should never
+ * report the operand as busy.
Many SEAMCALLs return TDX_OPERAND_BUSY, and this is the generally expected
handling. I don't think we don't need the comment if nothing special.
I'd like to keep a shorter note. It's the usual handling for TDX folks,
but people outside TDX may read this path too.
Can we check in what cases it returns TDX_OPERAND_BUSY? Can some SEAMCALLs other
than TDH.IOMMU.SETUP/CLEAR contend resources with TDH.IOMMU.SETUP/CLEAR and can
lead to TDX_OPERAND_BUSY? If so, the statement of "the host serializes all
TDH.IOMMU.SETUP and TDH.IOMMU.CLEAR calls for an IOMMU, so the TDX module should
never report the operand as busy" is not true.
You're right. Host-side serialization only covers SETUP/CLEAR against
each other. It says nothing about other SEAMCALLs that may contend for
the same TDX module resources, so the "should never report busy" is not
true.
The handling stays the same: retry only on TDX_INTERRUPTED_RESUMABLE,
which guarantees forward progress. TDX_OPERAND_BUSY makes no such
guarantee, so it is returned to the caller as a failure rather than
retried. tdx-host then fails the SETUP and releases the IOMMU, or logs
the CLEAR failure and leaves the IOMMU in TDX mode.
I'll drop the serialization statement and reduce the comment to:
/*
* Retry only on TDX_INTERRUPTED_RESUMABLE, which guarantees forward
* progress and leaves all registers but RAX unchanged. Other errors,
* including TDX_OPERAND_BUSY, are returned to the caller.
*/
Thanks,
baolu