* [PATCH v2 0/3] Cleanup around iommu_set_fault_handler()
@ 2025-11-06 20:34 Jason Gunthorpe
2025-11-06 20:34 ` [PATCH v2 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Jason Gunthorpe @ 2025-11-06 20:34 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner,
iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky,
linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma,
linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar,
Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit,
Chen-Yu Tsai, Will Deacon, Yong Wu
Cc: Lu Baolu, patches
report_iommu_fault() is an older API that has been superseded by
iommu_report_device_fault() which is capable to support PRI.
Only four external drivers consume this via iommu_set_fault_handler()
drivers/remoteproc/omap_remoteproc.c
drivers/remoteproc/qcom_q6v5_adsp.c
drivers/gpu/drm/msm
drivers/infiniband/hw/usnic
Remove the use in usnic as the iommu driver logging is good enough these
days.
Remove generation support from the AMD iommu driver since msm and two
remoteproc drivers are not used on AMD x86 CPUs.
Fail iommu_set_fault_handler() if the underlying iommu driver does not
support it.
v2:
- Revise commit messages
- Move report_iommu_fault_supported into the struct iommu_ops
- Put back the pr_err in the AMD driver
v1: https://patch.msgid.link/r/0-v1-391058a85f30+14b-iommu_set_fault_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Jason Gunthorpe (3):
RDMA/usnic: Remove iommu_set_fault_handler()
iommu/amd: Don't call report_iommu_fault()
iommu: Allow drivers to say if they use report_iommu_fault()
drivers/infiniband/hw/usnic/usnic_uiom.c | 13 -------------
drivers/iommu/amd/iommu.c | 7 -------
drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 +
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 1 +
drivers/iommu/iommu.c | 6 +++++-
drivers/iommu/ipmmu-vmsa.c | 1 +
drivers/iommu/mtk_iommu.c | 1 +
drivers/iommu/mtk_iommu_v1.c | 1 +
drivers/iommu/omap-iommu.c | 1 +
drivers/iommu/rockchip-iommu.c | 1 +
drivers/iommu/sun50i-iommu.c | 1 +
include/linux/iommu.h | 3 +++
12 files changed, 16 insertions(+), 21 deletions(-)
base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
--
2.43.0
^ permalink raw reply [flat|nested] 15+ messages in thread* [PATCH v2 1/3] RDMA/usnic: Remove iommu_set_fault_handler() 2025-11-06 20:34 [PATCH v2 0/3] Cleanup around iommu_set_fault_handler() Jason Gunthorpe @ 2025-11-06 20:34 ` Jason Gunthorpe 2025-11-17 6:37 ` Tian, Kevin 2025-11-06 20:34 ` [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() Jason Gunthorpe 2025-11-06 20:34 ` [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe 2 siblings, 1 reply; 15+ messages in thread From: Jason Gunthorpe @ 2025-11-06 20:34 UTC (permalink / raw) To: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu Cc: Lu Baolu, patches The handler in usnic just prints a fault report message, the iommu drivers all do a better job of that these days. Just remove the use of this old API. Acked-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/infiniband/hw/usnic/usnic_uiom.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c index 3fbf99757b1148..f7fb6246c83aba 100644 --- a/drivers/infiniband/hw/usnic/usnic_uiom.c +++ b/drivers/infiniband/hw/usnic/usnic_uiom.c @@ -51,17 +51,6 @@ ((void *) &((struct usnic_uiom_chunk *) 0)->page_list[1] - \ (void *) &((struct usnic_uiom_chunk *) 0)->page_list[0])) -static int usnic_uiom_dma_fault(struct iommu_domain *domain, - struct device *dev, - unsigned long iova, int flags, - void *token) -{ - usnic_err("Device %s iommu fault domain 0x%p va 0x%lx flags 0x%x\n", - dev_name(dev), - domain, iova, flags); - return -ENOSYS; -} - static void usnic_uiom_put_pages(struct list_head *chunk_list, int dirty) { struct usnic_uiom_chunk *chunk, *tmp; @@ -450,8 +439,6 @@ struct usnic_uiom_pd *usnic_uiom_alloc_pd(struct device *dev) return ERR_CAST(domain); } - iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL); - spin_lock_init(&pd->lock); INIT_LIST_HEAD(&pd->devs); -- 2.43.0 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* RE: [PATCH v2 1/3] RDMA/usnic: Remove iommu_set_fault_handler() 2025-11-06 20:34 ` [PATCH v2 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe @ 2025-11-17 6:37 ` Tian, Kevin 0 siblings, 0 replies; 15+ messages in thread From: Tian, Kevin @ 2025-11-17 6:37 UTC (permalink / raw) To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu@lists.linux.dev, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu Cc: Lu Baolu, patches@lists.linux.dev > From: Jason Gunthorpe <jgg@nvidia.com> > Sent: Friday, November 7, 2025 4:35 AM > > The handler in usnic just prints a fault report message, the iommu drivers > all do a better job of that these days. Just remove the use of this old > API. > > Acked-by: Jason Gunthorpe <jgg@nvidia.com> > Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() 2025-11-06 20:34 [PATCH v2 0/3] Cleanup around iommu_set_fault_handler() Jason Gunthorpe 2025-11-06 20:34 ` [PATCH v2 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe @ 2025-11-06 20:34 ` Jason Gunthorpe 2025-11-08 11:17 ` Vasant Hegde 2025-11-17 6:38 ` Tian, Kevin 2025-11-06 20:34 ` [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe 2 siblings, 2 replies; 15+ messages in thread From: Jason Gunthorpe @ 2025-11-06 20:34 UTC (permalink / raw) To: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu Cc: Lu Baolu, patches This old style API is only used by drivers/gpu/drm/msm, drivers/remoteproc/omap_remoteproc.c, and drivers/remoteproc/qcom_q6v5_adsp.c none are used on x86 HW. Remove the dead code to discourage new users. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/iommu/amd/iommu.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 2e1865daa1cee8..d4d9a5dbfa6333 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -854,13 +854,6 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu, PCI_FUNC(devid), domain_id); goto out; } - - if (!report_iommu_fault(&dev_data->domain->domain, - &pdev->dev, address, - IS_WRITE_REQUEST(flags) ? - IOMMU_FAULT_WRITE : - IOMMU_FAULT_READ)) - goto out; } if (__ratelimit(&dev_data->rs)) { -- 2.43.0 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() 2025-11-06 20:34 ` [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() Jason Gunthorpe @ 2025-11-08 11:17 ` Vasant Hegde 2025-11-18 18:57 ` Jason Gunthorpe 2025-11-17 6:38 ` Tian, Kevin 1 sibling, 1 reply; 15+ messages in thread From: Vasant Hegde @ 2025-11-08 11:17 UTC (permalink / raw) To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu Cc: Lu Baolu, patches On 11/7/2025 2:04 AM, Jason Gunthorpe wrote: > This old style API is only used by drivers/gpu/drm/msm, > drivers/remoteproc/omap_remoteproc.c, and > drivers/remoteproc/qcom_q6v5_adsp.c none are used on x86 HW. > > Remove the dead code to discourage new users. > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> > --- > drivers/iommu/amd/iommu.c | 7 ------- > 1 file changed, 7 deletions(-) > > diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c > index 2e1865daa1cee8..d4d9a5dbfa6333 100644 > --- a/drivers/iommu/amd/iommu.c > +++ b/drivers/iommu/amd/iommu.c > @@ -854,13 +854,6 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu, > PCI_FUNC(devid), domain_id); > goto out; > } If you're planning to respin this series, could you please update the comment above the if condition? -Vasant > - > - if (!report_iommu_fault(&dev_data->domain->domain, > - &pdev->dev, address, > - IS_WRITE_REQUEST(flags) ? > - IOMMU_FAULT_WRITE : > - IOMMU_FAULT_READ)) > - goto out; > } > > if (__ratelimit(&dev_data->rs)) { ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() 2025-11-08 11:17 ` Vasant Hegde @ 2025-11-18 18:57 ` Jason Gunthorpe 0 siblings, 0 replies; 15+ messages in thread From: Jason Gunthorpe @ 2025-11-18 18:57 UTC (permalink / raw) To: Vasant Hegde Cc: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu, Lu Baolu, patches On Sat, Nov 08, 2025 at 04:47:02PM +0530, Vasant Hegde wrote: > > @@ -854,13 +854,6 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu, > > PCI_FUNC(devid), domain_id); > > goto out; > > } > > If you're planning to respin this series, could you please update the comment > above the if condition? Done Thanks, Jason ^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() 2025-11-06 20:34 ` [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() Jason Gunthorpe 2025-11-08 11:17 ` Vasant Hegde @ 2025-11-17 6:38 ` Tian, Kevin 2025-11-18 18:58 ` Jason Gunthorpe 1 sibling, 1 reply; 15+ messages in thread From: Tian, Kevin @ 2025-11-17 6:38 UTC (permalink / raw) To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu@lists.linux.dev, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu Cc: Lu Baolu, patches@lists.linux.dev > From: Jason Gunthorpe <jgg@nvidia.com> > Sent: Friday, November 7, 2025 4:35 AM > > This old style API is only used by drivers/gpu/drm/msm, > drivers/remoteproc/omap_remoteproc.c, and > drivers/remoteproc/qcom_q6v5_adsp.c none are used on x86 HW. > > Remove the dead code to discourage new users. > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > --- > drivers/iommu/amd/iommu.c | 7 ------- > 1 file changed, 7 deletions(-) > > diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c > index 2e1865daa1cee8..d4d9a5dbfa6333 100644 > --- a/drivers/iommu/amd/iommu.c > +++ b/drivers/iommu/amd/iommu.c > @@ -854,13 +854,6 @@ static void amd_iommu_report_page_fault(struct > amd_iommu *iommu, > PCI_FUNC(devid), > domain_id); > goto out; > } > - > - if (!report_iommu_fault(&dev_data->domain- > >domain, > - &pdev->dev, address, > - IS_WRITE_REQUEST(flags) ? > - > IOMMU_FAULT_WRITE : > - > IOMMU_FAULT_READ)) > - goto out; > } > > if (__ratelimit(&dev_data->rs)) { > -- > 2.43.0 > Remove amd_iommu_report_page_fault() too? ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() 2025-11-17 6:38 ` Tian, Kevin @ 2025-11-18 18:58 ` Jason Gunthorpe 2025-11-18 23:58 ` Tian, Kevin 0 siblings, 1 reply; 15+ messages in thread From: Jason Gunthorpe @ 2025-11-18 18:58 UTC (permalink / raw) To: Tian, Kevin Cc: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu@lists.linux.dev, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu, Lu Baolu, patches@lists.linux.dev On Mon, Nov 17, 2025 at 06:38:51AM +0000, Tian, Kevin wrote: > > From: Jason Gunthorpe <jgg@nvidia.com> > > Sent: Friday, November 7, 2025 4:35 AM > > > > This old style API is only used by drivers/gpu/drm/msm, > > drivers/remoteproc/omap_remoteproc.c, and > > drivers/remoteproc/qcom_q6v5_adsp.c none are used on x86 HW. > > > > Remove the dead code to discourage new users. > > > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > > --- > > drivers/iommu/amd/iommu.c | 7 ------- > > 1 file changed, 7 deletions(-) > > > > diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c > > index 2e1865daa1cee8..d4d9a5dbfa6333 100644 > > --- a/drivers/iommu/amd/iommu.c > > +++ b/drivers/iommu/amd/iommu.c > > @@ -854,13 +854,6 @@ static void amd_iommu_report_page_fault(struct > > amd_iommu *iommu, > > PCI_FUNC(devid), > > domain_id); > > goto out; > > } > > - > > - if (!report_iommu_fault(&dev_data->domain- > > >domain, > > - &pdev->dev, address, > > - IS_WRITE_REQUEST(flags) ? > > - > > IOMMU_FAULT_WRITE : > > - > > IOMMU_FAULT_READ)) > > - goto out; > > } > > > > if (__ratelimit(&dev_data->rs)) { > > Remove amd_iommu_report_page_fault() too? I don't understand this remark? amd_iommu_report_page_fault() generates the dmesg logging on iommu faults? Jason ^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() 2025-11-18 18:58 ` Jason Gunthorpe @ 2025-11-18 23:58 ` Tian, Kevin 2025-11-20 19:35 ` Jason Gunthorpe 0 siblings, 1 reply; 15+ messages in thread From: Tian, Kevin @ 2025-11-18 23:58 UTC (permalink / raw) To: Jason Gunthorpe Cc: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu@lists.linux.dev, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu, Lu Baolu, patches@lists.linux.dev > From: Jason Gunthorpe <jgg@nvidia.com> > Sent: Wednesday, November 19, 2025 2:59 AM > > On Mon, Nov 17, 2025 at 06:38:51AM +0000, Tian, Kevin wrote: > > > From: Jason Gunthorpe <jgg@nvidia.com> > > > Sent: Friday, November 7, 2025 4:35 AM > > > > > > This old style API is only used by drivers/gpu/drm/msm, > > > drivers/remoteproc/omap_remoteproc.c, and > > > drivers/remoteproc/qcom_q6v5_adsp.c none are used on x86 HW. > > > > > > Remove the dead code to discourage new users. > > > > > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > > > --- > > > drivers/iommu/amd/iommu.c | 7 ------- > > > 1 file changed, 7 deletions(-) > > > > > > diff --git a/drivers/iommu/amd/iommu.c > b/drivers/iommu/amd/iommu.c > > > index 2e1865daa1cee8..d4d9a5dbfa6333 100644 > > > --- a/drivers/iommu/amd/iommu.c > > > +++ b/drivers/iommu/amd/iommu.c > > > @@ -854,13 +854,6 @@ static void > amd_iommu_report_page_fault(struct > > > amd_iommu *iommu, > > > PCI_FUNC(devid), > > > domain_id); > > > goto out; > > > } > > > - > > > - if (!report_iommu_fault(&dev_data->domain- > > > >domain, > > > - &pdev->dev, address, > > > - IS_WRITE_REQUEST(flags) ? > > > - > > > IOMMU_FAULT_WRITE : > > > - > > > IOMMU_FAULT_READ)) > > > - goto out; > > > } > > > > > > if (__ratelimit(&dev_data->rs)) { > > > > Remove amd_iommu_report_page_fault() too? > > I don't understand this remark? > > amd_iommu_report_page_fault() generates the dmesg logging on iommu > faults? > sorry I meant generating the dmesg logging same as other error types in iommu_print_event(). No need for a separate function. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() 2025-11-18 23:58 ` Tian, Kevin @ 2025-11-20 19:35 ` Jason Gunthorpe 0 siblings, 0 replies; 15+ messages in thread From: Jason Gunthorpe @ 2025-11-20 19:35 UTC (permalink / raw) To: Tian, Kevin Cc: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu@lists.linux.dev, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu, Lu Baolu, patches@lists.linux.dev On Tue, Nov 18, 2025 at 11:58:39PM +0000, Tian, Kevin wrote: > > > > - > > > > - if (!report_iommu_fault(&dev_data->domain- > > > > >domain, > > > > - &pdev->dev, address, > > > > - IS_WRITE_REQUEST(flags) ? > > > > - > > > > IOMMU_FAULT_WRITE : > > > > - > > > > IOMMU_FAULT_READ)) > > > > - goto out; > > > > } > > > > > > > > if (__ratelimit(&dev_data->rs)) { > > > > > > Remove amd_iommu_report_page_fault() too? > > > > I don't understand this remark? > > > > amd_iommu_report_page_fault() generates the dmesg logging on iommu > > faults? > > sorry I meant generating the dmesg logging same as other error > types in iommu_print_event(). No need for a separate function. Okay, that does make sense, but this driver is kinda broken because it is using pdev = pci_get_domain_bus_and_slot(iommu->pci_seg->id, PCI_BUS_NUM(devid), devid & 0xff); if (pdev) dev_data = dev_iommu_priv_get(&pdev->dev); Which is UAF racy on dev_data. Fixing that is troublesome.. Really all the fault handling here needs some attention, all the events that have BDFs should all print the same, using a pci print or using raw BDFs. Translation fault shouldn't be special.. Too big for this series, so I'll leave it.. Thanks, Jason ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() 2025-11-06 20:34 [PATCH v2 0/3] Cleanup around iommu_set_fault_handler() Jason Gunthorpe 2025-11-06 20:34 ` [PATCH v2 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe 2025-11-06 20:34 ` [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() Jason Gunthorpe @ 2025-11-06 20:34 ` Jason Gunthorpe 2025-11-08 11:20 ` Vasant Hegde ` (2 more replies) 2 siblings, 3 replies; 15+ messages in thread From: Jason Gunthorpe @ 2025-11-06 20:34 UTC (permalink / raw) To: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu Cc: Lu Baolu, patches report_iommu_fault() is an older API that has been superseded by iommu_report_device_fault() which is capable to support PRI. Only two external drivers consume this, drivers/remoteproc and drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for now protect against accidentally mix and matching the wrong components. The iommu drivers support either the old iommu_set_fault_handler() via the driver calling report_iommu_fault(), or they are newer server focused drivers that call iommu_report_device_fault(). Include a flag in the iommu_ops if the driver calls report_iommu_fault() and block iommu_set_fault_handler() for domain's of iommu drivers that can't support it. Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 1 + drivers/iommu/arm/arm-smmu/qcom_iommu.c | 1 + drivers/iommu/iommu.c | 6 +++++- drivers/iommu/ipmmu-vmsa.c | 1 + drivers/iommu/mtk_iommu.c | 1 + drivers/iommu/mtk_iommu_v1.c | 1 + drivers/iommu/omap-iommu.c | 1 + drivers/iommu/rockchip-iommu.c | 1 + drivers/iommu/sun50i-iommu.c | 1 + include/linux/iommu.h | 3 +++ 10 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 4ced4b5bee4df3..f68a0576b9a3a6 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1643,6 +1643,7 @@ static const struct iommu_ops arm_smmu_ops = { .get_resv_regions = arm_smmu_get_resv_regions, .def_domain_type = arm_smmu_def_domain_type, .owner = THIS_MODULE, + .report_iommu_fault_supported = true, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = arm_smmu_attach_dev, .map_pages = arm_smmu_map_pages, diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index c5be95e560317e..173d5957796790 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -597,6 +597,7 @@ static const struct iommu_ops qcom_iommu_ops = { .probe_device = qcom_iommu_probe_device, .device_group = generic_device_group, .of_xlate = qcom_iommu_of_xlate, + .report_iommu_fault_supported = true, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = qcom_iommu_attach_dev, .map_pages = qcom_iommu_map, diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 59244c744eabd2..8d9086a37671e1 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2005,6 +2005,9 @@ EXPORT_SYMBOL_GPL(iommu_group_has_isolated_msi); * This function should be used by IOMMU users which want to be notified * whenever an IOMMU fault happens. * + * This is a legacy API not supported by all drivers. New users should look + * to using domain->iopf_handler for the modern API. + * * The fault handler itself should return 0 on success, and an appropriate * error code otherwise. */ @@ -2012,7 +2015,8 @@ void iommu_set_fault_handler(struct iommu_domain *domain, iommu_fault_handler_t handler, void *token) { - if (WARN_ON(!domain || domain->cookie_type != IOMMU_COOKIE_NONE)) + if (WARN_ON(!domain || domain->cookie_type != IOMMU_COOKIE_NONE || + !domain->owner->report_iommu_fault_supported)) return; domain->cookie_type = IOMMU_COOKIE_FAULT_HANDLER; diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index ffa892f6571406..04a5836bf36000 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -884,6 +884,7 @@ static const struct iommu_ops ipmmu_ops = { .device_group = IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_IOMMU_DMA) ? generic_device_group : generic_single_device_group, .of_xlate = ipmmu_of_xlate, + .report_iommu_fault_supported = true, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = ipmmu_attach_device, .map_pages = ipmmu_map, diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 0e0285348d2b8e..ccf6fdeb64a261 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1018,6 +1018,7 @@ static const struct iommu_ops mtk_iommu_ops = { .of_xlate = mtk_iommu_of_xlate, .get_resv_regions = mtk_iommu_get_resv_regions, .owner = THIS_MODULE, + .report_iommu_fault_supported = true, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = mtk_iommu_attach_device, .map_pages = mtk_iommu_map, diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 10cc0b1197e801..3dd6222d210921 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -581,6 +581,7 @@ static const struct iommu_ops mtk_iommu_v1_ops = { .release_device = mtk_iommu_v1_release_device, .device_group = generic_device_group, .owner = THIS_MODULE, + .report_iommu_fault_supported = true, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = mtk_iommu_v1_attach_device, .map_pages = mtk_iommu_v1_map, diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 5c6f5943f44b1f..7ba67600f32915 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1723,6 +1723,7 @@ static const struct iommu_ops omap_iommu_ops = { .release_device = omap_iommu_release_device, .device_group = generic_single_device_group, .of_xlate = omap_iommu_of_xlate, + .report_iommu_fault_supported = true, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = omap_iommu_attach_dev, .map_pages = omap_iommu_map, diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 0861dd469bd866..932b5a62bac572 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1173,6 +1173,7 @@ static const struct iommu_ops rk_iommu_ops = { .release_device = rk_iommu_release_device, .device_group = generic_single_device_group, .of_xlate = rk_iommu_of_xlate, + .report_iommu_fault_supported = true, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = rk_iommu_attach_device, .map_pages = rk_iommu_map, diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index de10b569d9a940..13c37b1be481d7 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -848,6 +848,7 @@ static const struct iommu_ops sun50i_iommu_ops = { .domain_alloc_paging = sun50i_iommu_domain_alloc_paging, .of_xlate = sun50i_iommu_of_xlate, .probe_device = sun50i_iommu_probe_device, + .report_iommu_fault_supported = true, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = sun50i_iommu_attach_device, .flush_iotlb_all = sun50i_iommu_flush_iotlb_all, diff --git a/include/linux/iommu.h b/include/linux/iommu.h index c30d12e16473df..941e4971b05fd3 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -659,6 +659,8 @@ __iommu_copy_struct_to_user(const struct iommu_user_data *dst_data, * no user domain for each PASID and the I/O page faults are * forwarded through the user domain attached to the device * RID. + * @report_iommu_fault_supported: True if the domain supports + * iommu_set_fault_handler() */ struct iommu_ops { bool (*capable)(struct device *dev, enum iommu_cap); @@ -710,6 +712,7 @@ struct iommu_ops { struct iommu_domain *release_domain; struct iommu_domain *default_domain; u8 user_pasid_table:1; + u8 report_iommu_fault_supported:1; }; /** -- 2.43.0 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() 2025-11-06 20:34 ` [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe @ 2025-11-08 11:20 ` Vasant Hegde 2025-11-17 6:43 ` Tian, Kevin 2025-11-18 1:30 ` Chaoyi Chen 2 siblings, 0 replies; 15+ messages in thread From: Vasant Hegde @ 2025-11-08 11:20 UTC (permalink / raw) To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu Cc: Lu Baolu, patches On 11/7/2025 2:04 AM, Jason Gunthorpe wrote: > report_iommu_fault() is an older API that has been superseded by > iommu_report_device_fault() which is capable to support PRI. > > Only two external drivers consume this, drivers/remoteproc and > drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for > now protect against accidentally mix and matching the wrong components. > > The iommu drivers support either the old iommu_set_fault_handler() via the > driver calling report_iommu_fault(), or they are newer server focused > drivers that call iommu_report_device_fault(). > > Include a flag in the iommu_ops if the driver calls report_iommu_fault() > and block iommu_set_fault_handler() for domain's of iommu drivers that > can't support it. > > Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> -Vasant ^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() 2025-11-06 20:34 ` [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe 2025-11-08 11:20 ` Vasant Hegde @ 2025-11-17 6:43 ` Tian, Kevin 2025-11-18 1:30 ` Chaoyi Chen 2 siblings, 0 replies; 15+ messages in thread From: Tian, Kevin @ 2025-11-17 6:43 UTC (permalink / raw) To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu@lists.linux.dev, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu Cc: Lu Baolu, patches@lists.linux.dev > From: Jason Gunthorpe <jgg@nvidia.com> > Sent: Friday, November 7, 2025 4:35 AM > > @@ -1643,6 +1643,7 @@ static const struct iommu_ops arm_smmu_ops = { > .get_resv_regions = arm_smmu_get_resv_regions, > .def_domain_type = arm_smmu_def_domain_type, > .owner = THIS_MODULE, > + .report_iommu_fault_supported = true, '_supported' could be removed. Reviewed-by: Kevin Tian <kevin.tian@intel.com> ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() 2025-11-06 20:34 ` [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe 2025-11-08 11:20 ` Vasant Hegde 2025-11-17 6:43 ` Tian, Kevin @ 2025-11-18 1:30 ` Chaoyi Chen 2025-11-18 19:00 ` Jason Gunthorpe 2 siblings, 1 reply; 15+ messages in thread From: Chaoyi Chen @ 2025-11-18 1:30 UTC (permalink / raw) To: Jason Gunthorpe, AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu Cc: Lu Baolu, patches Hello Jason, On 11/7/2025 4:34 AM, Jason Gunthorpe wrote: > report_iommu_fault() is an older API that has been superseded by > iommu_report_device_fault() which is capable to support PRI. > > Only two external drivers consume this, drivers/remoteproc and > drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for > now protect against accidentally mix and matching the wrong components. > > The iommu drivers support either the old iommu_set_fault_handler() via the > driver calling report_iommu_fault(), or they are newer server focused > drivers that call iommu_report_device_fault(). > > Include a flag in the iommu_ops if the driver calls report_iommu_fault() > and block iommu_set_fault_handler() for domain's of iommu drivers that > can't support it. > > Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> > Reviewed-by: Kevin Tian <kevin.tian@intel.com> Sorry for the noise. Sometimes non-IOMMU drivers, such as DRM devices, also want to handle IOMMU fault events, so they might use iommu_set_fault_handler() before. What API should they use as an alternative now? Thank you. -- Best, Chaoyi ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() 2025-11-18 1:30 ` Chaoyi Chen @ 2025-11-18 19:00 ` Jason Gunthorpe 0 siblings, 0 replies; 15+ messages in thread From: Jason Gunthorpe @ 2025-11-18 19:00 UTC (permalink / raw) To: Chaoyi Chen Cc: AngeloGioacchino Del Regno, Christian Benvenuti, Heiko Stuebner, iommu, Jernej Skrabec, Joerg Roedel, Leon Romanovsky, linux-arm-kernel, linux-arm-msm, linux-mediatek, linux-rdma, linux-rockchip, linux-sunxi, Matthias Brugger, Nelson Escobar, Rob Clark, Robin Murphy, Samuel Holland, Suravee Suthikulpanit, Chen-Yu Tsai, Will Deacon, Yong Wu, Lu Baolu, patches On Tue, Nov 18, 2025 at 09:30:29AM +0800, Chaoyi Chen wrote: > Hello Jason, > > On 11/7/2025 4:34 AM, Jason Gunthorpe wrote: > > report_iommu_fault() is an older API that has been superseded by > > iommu_report_device_fault() which is capable to support PRI. > > > > Only two external drivers consume this, drivers/remoteproc and > > drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for > > now protect against accidentally mix and matching the wrong components. > > > > The iommu drivers support either the old iommu_set_fault_handler() via the > > driver calling report_iommu_fault(), or they are newer server focused > > drivers that call iommu_report_device_fault(). > > > > Include a flag in the iommu_ops if the driver calls report_iommu_fault() > > and block iommu_set_fault_handler() for domain's of iommu drivers that > > can't support it. > > > > Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > > Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> > > Reviewed-by: Kevin Tian <kevin.tian@intel.com> > > Sorry for the noise. Sometimes non-IOMMU drivers, such as DRM > devices, also want to handle IOMMU fault events, so they might use > iommu_set_fault_handler() before. What API should they use as an > alternative now? The new flow is through iommu_report_device_fault() which an end user can access by setting domain->iopf_handler currently. Jason ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2025-11-20 19:35 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-11-06 20:34 [PATCH v2 0/3] Cleanup around iommu_set_fault_handler() Jason Gunthorpe 2025-11-06 20:34 ` [PATCH v2 1/3] RDMA/usnic: Remove iommu_set_fault_handler() Jason Gunthorpe 2025-11-17 6:37 ` Tian, Kevin 2025-11-06 20:34 ` [PATCH v2 2/3] iommu/amd: Don't call report_iommu_fault() Jason Gunthorpe 2025-11-08 11:17 ` Vasant Hegde 2025-11-18 18:57 ` Jason Gunthorpe 2025-11-17 6:38 ` Tian, Kevin 2025-11-18 18:58 ` Jason Gunthorpe 2025-11-18 23:58 ` Tian, Kevin 2025-11-20 19:35 ` Jason Gunthorpe 2025-11-06 20:34 ` [PATCH v2 3/3] iommu: Allow drivers to say if they use report_iommu_fault() Jason Gunthorpe 2025-11-08 11:20 ` Vasant Hegde 2025-11-17 6:43 ` Tian, Kevin 2025-11-18 1:30 ` Chaoyi Chen 2025-11-18 19:00 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).