Re: [PATCH v3 1/9] x86/virt/tdx: Add SEAMCALL wrappers for IOMMU setup/clear

From: Binbin Wu

Date: Wed Nov 18 2026 - 06:02:30 EST


On 11/12/2026 12:30 PM, Lu Baolu wrote:
[...]

> +
> +/* No cache flush is needed; hardware keeps caches coherent across KeyIDs. */

Nit:
It's a bit confusing without the all the background.
Once Rick's patch [1] removes tdx_clflush_page() and its comment, a reader may wonder
why this wrapper explains the cache flush but the others don't.

Is it better to drop the comment and explain it in the change log?

[1] https://lore.kernel.org/all/20261015191710.3632302-2-rick.p.edgecombe@xxxxxxxxx/


> +u64 tdh_iommu_setup(u64 reg_base, struct tdx_iommu_mt_param *param,
> + 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.
> + */
> + do {
> + ret = seamcall_ret(TDH_IOMMU_SETUP, &args);
> + } while (ret == TDX_INTERRUPTED_RESUMABLE);
> +
> + *tdx_iommu_id = args.rcx;
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_FOR_MODULES(tdh_iommu_setup, "tdx-host");
> +
> +u64 tdh_iommu_clear(u64 tdx_iommu_id)
> +{
> + struct tdx_module_args args = {
> + .rcx = tdx_iommu_id,
> + };
> + u64 ret;
> +
> + /*
> + * Don't retry on TDX_OPERAND_BUSY. See the comment in
> + * tdh_iommu_setup().
> + */
> + do {
> + ret = seamcall(TDH_IOMMU_CLEAR, &args);
> + } while (ret == TDX_INTERRUPTED_RESUMABLE);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_FOR_MODULES(tdh_iommu_clear, "tdx-host");