Skip to content

Commit 082f1bc

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/amd: Fully decode all combinations of alloc_paging_flags
Currently AMD does not support IOMMU_HWPT_ALLOC_PASID | IOMMU_HWPT_ALLOC_DIRTY_TRACKING It should be rejected. Instead it creates a V1 domain without dirty tracking support. Use a switch to fully decode the flags. Fixes: ce2cd17 ("iommu/amd: Enhance amd_iommu_domain_alloc_user()") Reviewed-by: Vasant Hegde <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 5a081f7 commit 082f1bc

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,24 +2554,24 @@ amd_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
25542554
if ((flags & ~supported_flags) || user_data)
25552555
return ERR_PTR(-EOPNOTSUPP);
25562556

2557-
/* Allocate domain with v2 page table if IOMMU supports PASID. */
2558-
if (flags & IOMMU_HWPT_ALLOC_PASID) {
2557+
switch (flags & supported_flags) {
2558+
case IOMMU_HWPT_ALLOC_DIRTY_TRACKING:
2559+
/* Allocate domain with v1 page table for dirty tracking */
2560+
if (!amd_iommu_hd_support(iommu))
2561+
break;
2562+
return do_iommu_domain_alloc(dev, flags, PD_MODE_V1);
2563+
case IOMMU_HWPT_ALLOC_PASID:
2564+
/* Allocate domain with v2 page table if IOMMU supports PASID. */
25592565
if (!amd_iommu_pasid_supported())
2560-
return ERR_PTR(-EOPNOTSUPP);
2561-
2566+
break;
25622567
return do_iommu_domain_alloc(dev, flags, PD_MODE_V2);
2568+
case 0:
2569+
/* If nothing specific is required use the kernel commandline default */
2570+
return do_iommu_domain_alloc(dev, 0, amd_iommu_pgtable);
2571+
default:
2572+
break;
25632573
}
2564-
2565-
/* Allocate domain with v1 page table for dirty tracking */
2566-
if (flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING) {
2567-
if (amd_iommu_hd_support(iommu))
2568-
return do_iommu_domain_alloc(dev, flags, PD_MODE_V1);
2569-
2570-
return ERR_PTR(-EOPNOTSUPP);
2571-
}
2572-
2573-
/* If nothing specific is required use the kernel commandline default */
2574-
return do_iommu_domain_alloc(dev, 0, amd_iommu_pgtable);
2574+
return ERR_PTR(-EOPNOTSUPP);
25752575
}
25762576

25772577
void amd_iommu_domain_free(struct iommu_domain *dom)

0 commit comments

Comments
 (0)