Skip to content

Commit

Permalink
iommu/vt-d: Enhance capability check for nested parent domain allocation
Browse files Browse the repository at this point in the history
This adds the scalable mode check before allocating the nested parent domain
as checking nested capability is not enough. User may turn off scalable mode
which also means no nested support even if the hardware supports it.

Fixes: c97d1b2 ("iommu/vt-d: Add domain_alloc_user op")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Yi Liu <[email protected]>
Reviewed-by: Lu Baolu <[email protected]>
Reviewed-by: Kevin Tian <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
yiliu1765 authored and jgunthorpe committed Oct 26, 2023
1 parent 55a0165 commit a2cdecd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iommu/intel/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4095,7 +4095,7 @@ intel_iommu_domain_alloc_user(struct device *dev, u32 flags,
if (!iommu)
return ERR_PTR(-ENODEV);

if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ecap_nest(iommu->ecap))
if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !nested_supported(iommu))
return ERR_PTR(-EOPNOTSUPP);

dirty_tracking = (flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING);
Expand Down
2 changes: 2 additions & 0 deletions drivers/iommu/intel/iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ enum {
ecap_pasid((iommu)->ecap))
#define ssads_supported(iommu) (sm_supported(iommu) && \
ecap_slads((iommu)->ecap))
#define nested_supported(iommu) (sm_supported(iommu) && \
ecap_nest((iommu)->ecap))

struct pasid_entry;
struct pasid_state_entry;
Expand Down

0 comments on commit a2cdecd

Please sign in to comment.