From: Baolu Lu <baolu.lu@linux.intel.com>
To: Xu Yilun <yilun.xu@linux.intel.com>
Cc: baolu.lu@linux.intel.com, iommu@lists.linux.dev, x86@kernel.org,
linux-coco@lists.linux.dev, kvm@vger.kernel.org,
Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>,
Kiryl Shutsemau <kas@kernel.org>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
xiaoyao.li@intel.com, Chao Gao <chao.gao@intel.com>,
Binbin Wu <binbin.wu@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/9] iommu/vt-d: Add interface for tdx-host when enabling trusted DMA
Date: Tue, 24 Nov 2026 15:47:16 +0800 [thread overview]
Message-ID: <9ab1e5b7-fa03-473a-a251-91153fe5c7b3@linux.intel.com> (raw)
In-Reply-To: <awRW3ESp3sBoxtJ9@yilunxu-OptiPlex-7050>
On 11/23/2026 11:08 PM, Xu Yilun wrote:
>> Add a per-device interface so that an IOMMU is put into Secure TDX Mode
>> only when a device behind it needs trusted DMA. tdx-host tracks how many
>> devices use each IOMMU and calls into the VT-d driver only for the first
>> and the last of them:
>>
>> - dmar_tdxc_get_params() looks up the DMAR unit translating the device
> I think tdxc is not a good name since "TDX Connect" is not preferred as
> a technical term. These APIs would be used by x86/tdx, so can we at
> least avoid using tdxc for these APIs?
I'm open to this. I used the dmar_tdxc_* prefix because the VT-d spec
calls this feature "TDX Connect Support". Since these are interfaces for
the tdx-host module, I'm fine with renaming them to dmar_tdx_*.
>
> [...]
>
>> +static void dmar_tdxc_fill_params(struct dmar_drhd_unit *drhd,
>> + struct dmar_tdxc_params *params)
>> +{
>> + params->reg_base_addr = drhd->reg_base_addr;
>> + params->node = drhd->iommu->node;
>> + /*
>> + * params->drhd stays valid because trusted DMA-capable units are
>> + * never hot-removed.
>> + */
>> + params->drhd = drhd;
> Why we store drhd in the params, any information to expose to TDX via
> drhd?
>
> [...]
>
>> +/*
>> + * dmar_tdxc_get_params() - Get the IOMMU information for a device
>> + * @dev: PCI device that will use trusted DMA
>> + * @params: Filled in on success
>> + *
>> + * Look up the IOMMU that translates @dev and return what tdx-host needs
>> + * to issue TDH.IOMMU.SETUP and TDH.IOMMU.CLEAR on it. This only reads
>> + * information and doesn't change any state. Devices behind the same
>> + * IOMMU get the same @params->reg_base_addr.
>> + *
>> + * Return 0 on success and error code on failure.
>> + */
>> +int dmar_tdxc_get_params(struct pci_dev *pdev, struct dmar_tdxc_params *params)
>> +{
>> + struct dmar_drhd_unit *drhd = dmar_tdxc_find_drhd(pdev);
>> +
>> + if (IS_ERR(drhd))
>> + return PTR_ERR(drhd);
>> +
>> + dmar_tdxc_fill_params(drhd, params);
>> +
>> + return 0;
>> +}
>> +EXPORT_SYMBOL_FOR_MODULES(dmar_tdxc_get_params, "tdx-host");
>> +
>> +/*
>> + * dmar_tdxc_acquire() - Acquire an IOMMU for TDH.IOMMU.SETUP
>> + * @dev: PCI device that will use trusted DMA
>> + * @params: Returned by dmar_tdxc_get_params() for @dev
>> + *
>> + * Call this right before issuing TDH.IOMMU.SETUP for the first user of
>> + * the IOMMU. On success, the caller must issue TDH.IOMMU.SETUP and call
>> + * dmar_tdxc_release() if it fails. The caller owns the per-IOMMU refcount
>> + * and must serialize all calls for the same IOMMU.
>> + *
>> + * Return: 0 on success and error code on failure.
>> + */
>> +int dmar_tdxc_acquire(struct pci_dev *pdev,
>> + const struct dmar_tdxc_params *params)
>> +{
>> + struct dmar_drhd_unit *drhd = params->drhd;
>> + struct intel_iommu *iommu = drhd->iommu;
>> + int ret;
>> +
>> + if (WARN_ON(dmar_tdxc_find_drhd(pdev) != drhd))
> We can get drhd via pci_dev, then why we require callers to input
> this info and judge? Like an intelligence test?
The drhd was there so the VT-d driver could check that @pdev and @params
match. But you're right that the check only exists because the API takes
both. I'll drop drhd from the params and make acquire()/release() take
only the pci_dev, so there's nothing to mismatch.
Thanks,
baolu
next prev parent reply other threads:[~2026-11-24 7:47 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 4:30 [PATCH v3 0/9] coco/tdx-host: Introduce trusted DMA initialization support Lu Baolu
2026-11-12 4:30 ` [PATCH v3 1/9] x86/virt/tdx: Add SEAMCALL wrappers for IOMMU setup/clear Lu Baolu
2026-11-18 11:02 ` Binbin Wu
2026-11-23 4:03 ` Baolu Lu
2026-11-23 9:55 ` Xu Yilun
2026-11-24 5:46 ` Baolu Lu
2026-11-24 8:07 ` Tian, Kevin
2026-11-12 4:30 ` [PATCH v3 2/9] x86/virt/tdx: Read global metadata for trusted IOMMU Lu Baolu
2026-11-18 13:39 ` Binbin Wu
2026-11-23 4:09 ` Baolu Lu
2026-11-24 8:13 ` Tian, Kevin
2026-11-12 4:30 ` [PATCH v3 3/9] x86/virt/tdx: Export Dynamic PAMT helpers to tdx-host Lu Baolu
2026-11-23 10:25 ` Xu Yilun
2026-11-23 16:28 ` Edgecombe, Rick P
2026-11-24 6:07 ` Baolu Lu
2026-11-12 4:30 ` [PATCH v3 4/9] iommu/vt-d: Add interface for tdx-host when enabling trusted DMA Lu Baolu
2026-11-23 15:08 ` Xu Yilun
2026-11-24 7:47 ` Baolu Lu [this message]
2026-11-12 4:30 ` [PATCH v3 5/9] iommu/vt-d: Block GCMD and ECMD while acquired by the TDX module Lu Baolu
2026-11-12 4:30 ` [PATCH v3 6/9] iommu/vt-d: Refuse system suspend " Lu Baolu
2026-11-12 4:30 ` [PATCH v3 7/9] coco/tdx-host: Add skeleton to support PCI link encryption Lu Baolu
2026-11-18 7:16 ` Chao Gao
2026-11-23 3:30 ` Baolu Lu
2026-11-23 15:26 ` Xu Yilun
2026-11-19 2:52 ` Binbin Wu
2026-11-23 4:18 ` Baolu Lu
2026-11-23 15:43 ` Xu Yilun
2026-11-12 4:30 ` [PATCH v3 8/9] coco/tdx-host: Rename tdx-host.c to main.c Lu Baolu
2026-11-12 4:30 ` [PATCH v3 9/9] coco/tdx-host: Enable trusted DMA on IOMMUs on device connect Lu Baolu
2026-11-18 8:11 ` Chao Gao
2026-11-23 4:51 ` Baolu Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9ab1e5b7-fa03-473a-a251-91153fe5c7b3@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=chao.gao@intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=kas@kernel.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=rick.p.edgecombe@intel.com \
--cc=x86@kernel.org \
--cc=xiaoyao.li@intel.com \
--cc=yilun.xu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox