From: Baolu Lu <baolu.lu@linux.intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: baolu.lu@linux.intel.com, jgg@nvidia.com, kevin.tian@intel.com,
robin.murphy@arm.com, joro@8bytes.org, will@kernel.org,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/3] iommu: Sort out domain user data
Date: Fri, 7 Mar 2025 15:03:35 +0800 [thread overview]
Message-ID: <16690409-1cb5-4b58-93fb-e5919ff1fc1f@linux.intel.com> (raw)
In-Reply-To: <Z8qKyvNyNU6dkN7V@Asurada-Nvidia>
On 2025/3/7 13:57, Nicolin Chen wrote:
> On Fri, Mar 07, 2025 at 10:28:20AM +0800, Baolu Lu wrote:
>> On 3/7/25 05:00, Nicolin Chen wrote:
>>> From: Robin Murphy<robin.murphy@arm.com>
> Robin had remarks here, wrt iommu_set_fault_handler():
>
>>> The fact is that all these cookie types are
>>> mutually exclusive, in the sense that combining them makes zero sense
>>> and/or would be catastrophic (iommu_set_fault_handler() on an SVA
>>> domain, anyone?) - the only combination which*might* be reasonable is
>>> perhaps a fault handler and an MSI cookie, but nobody's doing that at
>>> the moment, so let's rule it out as well for the sake of being clear and
>>> robust.
> [...]
>>> @@ -224,10 +234,10 @@ struct iommu_domain {
>>> phys_addr_t msi_addr);
>>> #endif
>>> - union { /* Pointer usable by owner of the domain */
>>> - struct iommufd_hw_pagetable *iommufd_hwpt; /* iommufd */
>>> - };
>>> - union { /* Fault handler */
>>> + union { /* cookie */
>>> + struct iommu_dma_cookie *iova_cookie;
>>> + struct iommu_dma_msi_cookie *msi_cookie;
>>> + struct iommufd_hw_pagetable *iommufd_hwpt;
>>> struct {
>>> iommu_fault_handler_t handler;
>>> void *handler_token;exs
>> My feeling is that IOMMU_COOKIE_FAULT_HANDLER isn't exclusive to
>> IOMMU_COOKIE_DMA_IOVA; both might be used for kernel DMA with a paging
>> domain.
>>
>> I am afraid that iommu_set_fault_handler() doesn't work anymore as the
>> domain's cookie type has already been set to IOMMU_COOKIE_DMA_IOVA.
> All three existing iommu_set_fault_handler() callers in the tree
> are UNMANAGED domain users:
> 5 451 drivers/gpu/drm/msm/msm_iommu.c <<msm_iommu_gpu_new>>
> iommu_set_fault_handler(iommu->domain, msm_fault_handler, iommu);
> 6 453 drivers/infiniband/hw/usnic/usnic_uiom.c <<usnic_uiom_alloc_pd>>
> iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL);
> 8 118 drivers/remoteproc/remoteproc_core.c <<rproc_enable_iommu>>
> iommu_set_fault_handler(domain, rproc_iommu_fault, rproc);
>
> On the other hand, IOMMU_COOKIE_DMA_IOVA is a private cookie for
> dma-iommu only.
>
> So, I think we are probably fine?
If all existing use cases are for UNMANAGED domains, that's fine. And
when iommu_set_fault_handler() is miss-used, we already have a WARN_ON()
there.
Thanks,
baolu
next prev parent reply other threads:[~2025-03-07 7:03 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 21:00 [PATCH v4 0/3] iommu: Clean up cookie and sw_msi in struct iommu_domain Nicolin Chen
2025-03-06 21:00 ` [PATCH v4 1/3] iommu: Sort out domain user data Nicolin Chen
2025-03-07 2:28 ` Baolu Lu
2025-03-07 5:57 ` Nicolin Chen
2025-03-07 7:03 ` Baolu Lu [this message]
2025-03-07 11:49 ` Robin Murphy
2025-03-07 15:32 ` Jason Gunthorpe
2025-03-17 19:37 ` Jason Gunthorpe
2025-03-06 21:00 ` [PATCH v4 2/3] iommufd: Move iommufd_sw_msi and related functions to driver.c Nicolin Chen
2025-03-12 7:37 ` Tian, Kevin
2025-03-17 20:20 ` Jason Gunthorpe
2025-03-06 21:00 ` [PATCH v4 3/3] iommu: Drop sw_msi from iommu_domain Nicolin Chen
2025-03-17 20:20 ` Jason Gunthorpe
2025-03-24 16:25 ` Nathan Chancellor
2025-03-24 16:40 ` Jason Gunthorpe
2025-03-24 16:55 ` Nicolin Chen
2025-03-24 17:05 ` Nicolin Chen
2025-03-24 17:07 ` Nathan Chancellor
2025-03-24 20:05 ` Jason Gunthorpe
2025-03-24 20:43 ` Nathan Chancellor
2025-03-24 21:38 ` Nicolin Chen
2025-03-24 22:29 ` Jason Gunthorpe
2025-03-24 22:45 ` Nicolin Chen
2025-03-17 20:21 ` [PATCH v4 0/3] iommu: Clean up cookie and sw_msi in struct iommu_domain Jason Gunthorpe
2025-03-20 23:16 ` Jason Gunthorpe
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=16690409-1cb5-4b58-93fb-e5919ff1fc1f@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/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