Skip to content

Commit 29f5474

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/amd: Add missing domain type checks
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: 1364679 ("iommu: Add IOMMU SVA domain support") Signed-off-by: Jason Gunthorpe <[email protected]> Reviewed-by: Vasant Hegde <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 8ec4e2b commit 29f5474

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
20742074
{
20752075
struct io_pgtable_ops *pgtbl_ops;
20762076
struct protection_domain *domain;
2077-
int pgtable = amd_iommu_pgtable;
2077+
int pgtable;
20782078
int mode = DEFAULT_PGTABLE_LEVEL;
20792079
int ret;
20802080

@@ -2091,6 +2091,10 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
20912091
mode = PAGE_MODE_NONE;
20922092
} else if (type == IOMMU_DOMAIN_UNMANAGED) {
20932093
pgtable = AMD_IOMMU_V1;
2094+
} else if (type == IOMMU_DOMAIN_DMA || type == IOMMU_DOMAIN_DMA_FQ) {
2095+
pgtable = amd_iommu_pgtable;
2096+
} else {
2097+
return NULL;
20942098
}
20952099

20962100
switch (pgtable) {

0 commit comments

Comments
 (0)