* [PATCH for-rc] iommu/amd: Add missing domain type checks
@ 2023-04-25 19:04 Jason Gunthorpe
2023-04-26 8:49 ` Tian, Kevin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2023-04-25 19:04 UTC (permalink / raw)
To: iommu, Joerg Roedel, Robin Murphy, Suravee Suthikulpanit,
Will Deacon
Cc: Lu Baolu, Jean-Philippe Brucker, Joerg Roedel, Kevin Tian,
Tony Zhu, Yi Liu, Zhangfei Gao
Drivers are supposed to list the domain types they support in their
domain_alloc() ops so when we add new domain types, like BLOCKING or SVA,
they don't start breaking.
This ended up providing an empty UNMANAGED domain when the core code asked
for a BLOCKING domain, which happens to be the fallback for drivers that
don't support it, but this is completely wrong for SVA.
Check for the DMA types AMD supports and reject every other kind.
Fixes: 136467962e49 ("iommu: Add IOMMU SVA domain support")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/amd/iommu.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index c72a0173db2029..17ea44a79c7af9 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2067,7 +2067,7 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
{
struct io_pgtable_ops *pgtbl_ops;
struct protection_domain *domain;
- int pgtable = amd_iommu_pgtable;
+ int pgtable;
int mode = DEFAULT_PGTABLE_LEVEL;
int ret;
@@ -2084,6 +2084,10 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
mode = PAGE_MODE_NONE;
} else if (type == IOMMU_DOMAIN_UNMANAGED) {
pgtable = AMD_IOMMU_V1;
+ } else if (type == IOMMU_DOMAIN_DMA || type == IOMMU_DOMAIN_DMA_FQ) {
+ pgtable = amd_iommu_pgtable;
+ } else {
+ return NULL;
}
switch (pgtable) {
base-commit: 4f933b868392945c9b0e32b499b0bb39beab8a28
--
2.40.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* RE: [PATCH for-rc] iommu/amd: Add missing domain type checks
2023-04-25 19:04 [PATCH for-rc] iommu/amd: Add missing domain type checks Jason Gunthorpe
@ 2023-04-26 8:49 ` Tian, Kevin
2023-04-28 5:24 ` Vasant Hegde
2023-05-22 15:29 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Tian, Kevin @ 2023-04-26 8:49 UTC (permalink / raw)
To: Jason Gunthorpe, iommu@lists.linux.dev, Joerg Roedel,
Robin Murphy, Suravee Suthikulpanit, Will Deacon
Cc: Lu Baolu, Jean-Philippe Brucker, Rodel, Jorg, Zhu, Tony,
Liu, Yi L, Zhangfei Gao
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Wednesday, April 26, 2023 3:04 AM
>
> Drivers are supposed to list the domain types they support in their
> domain_alloc() ops so when we add new domain types, like BLOCKING or
> SVA,
> they don't start breaking.
>
> This ended up providing an empty UNMANAGED domain when the core code
> asked
> for a BLOCKING domain, which happens to be the fallback for drivers that
> don't support it, but this is completely wrong for SVA.
>
> Check for the DMA types AMD supports and reject every other kind.
>
> Fixes: 136467962e49 ("iommu: Add IOMMU SVA domain support")
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH for-rc] iommu/amd: Add missing domain type checks
2023-04-25 19:04 [PATCH for-rc] iommu/amd: Add missing domain type checks Jason Gunthorpe
2023-04-26 8:49 ` Tian, Kevin
@ 2023-04-28 5:24 ` Vasant Hegde
2023-05-22 15:29 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Vasant Hegde @ 2023-04-28 5:24 UTC (permalink / raw)
To: Jason Gunthorpe, iommu, Joerg Roedel, Robin Murphy,
Suravee Suthikulpanit, Will Deacon
Cc: Lu Baolu, Jean-Philippe Brucker, Joerg Roedel, Kevin Tian,
Tony Zhu, Yi Liu, Zhangfei Gao
On 4/26/2023 12:34 AM, Jason Gunthorpe wrote:
> Drivers are supposed to list the domain types they support in their
> domain_alloc() ops so when we add new domain types, like BLOCKING or SVA,
> they don't start breaking.
>
> This ended up providing an empty UNMANAGED domain when the core code asked
> for a BLOCKING domain, which happens to be the fallback for drivers that
> don't support it, but this is completely wrong for SVA.
>
> Check for the DMA types AMD supports and reject every other kind.
>
> Fixes: 136467962e49 ("iommu: Add IOMMU SVA domain support")
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Thanks! Patch looks good to me.
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH for-rc] iommu/amd: Add missing domain type checks
2023-04-25 19:04 [PATCH for-rc] iommu/amd: Add missing domain type checks Jason Gunthorpe
2023-04-26 8:49 ` Tian, Kevin
2023-04-28 5:24 ` Vasant Hegde
@ 2023-05-22 15:29 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2023-05-22 15:29 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: iommu, Robin Murphy, Suravee Suthikulpanit, Will Deacon, Lu Baolu,
Jean-Philippe Brucker, Joerg Roedel, Kevin Tian, Tony Zhu, Yi Liu,
Zhangfei Gao
On Tue, Apr 25, 2023 at 04:04:15PM -0300, Jason Gunthorpe wrote:
> drivers/iommu/amd/iommu.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
Applied for 6.4, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-22 15:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-25 19:04 [PATCH for-rc] iommu/amd: Add missing domain type checks Jason Gunthorpe
2023-04-26 8:49 ` Tian, Kevin
2023-04-28 5:24 ` Vasant Hegde
2023-05-22 15:29 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox