Commit d76b42e9 authored by David Woodhouse's avatar David Woodhouse Committed by Will Deacon

iommu/vt-d: Don't read VCCAP register unless it exists

My virtual IOMMU implementation is whining that the guest is reading a
register that doesn't exist. Only read the VCCAP_REG if the corresponding
capability is set in ECAP_REG to indicate that it actually exists.

Fixes: 3375303e ("iommu/vt-d: Add custom allocator for IOASID")
Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: default avatarLiu Yi L <yi.l.liu@intel.com>
Cc: stable@vger.kernel.org # v5.7+
Acked-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/de32b150ffaa752e0cff8571b17dfb1213fbe71c.camel@infradead.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent e2be2a83
...@@ -986,7 +986,8 @@ static int map_iommu(struct intel_iommu *iommu, u64 phys_addr) ...@@ -986,7 +986,8 @@ static int map_iommu(struct intel_iommu *iommu, u64 phys_addr)
warn_invalid_dmar(phys_addr, " returns all ones"); warn_invalid_dmar(phys_addr, " returns all ones");
goto unmap; goto unmap;
} }
iommu->vccap = dmar_readq(iommu->reg + DMAR_VCCAP_REG); if (ecap_vcs(iommu->ecap))
iommu->vccap = dmar_readq(iommu->reg + DMAR_VCCAP_REG);
/* the registers might be more than one page */ /* the registers might be more than one page */
map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap),
......
...@@ -1833,7 +1833,7 @@ static void free_dmar_iommu(struct intel_iommu *iommu) ...@@ -1833,7 +1833,7 @@ static void free_dmar_iommu(struct intel_iommu *iommu)
if (ecap_prs(iommu->ecap)) if (ecap_prs(iommu->ecap))
intel_svm_finish_prq(iommu); intel_svm_finish_prq(iommu);
} }
if (ecap_vcs(iommu->ecap) && vccap_pasid(iommu->vccap)) if (vccap_pasid(iommu->vccap))
ioasid_unregister_allocator(&iommu->pasid_allocator); ioasid_unregister_allocator(&iommu->pasid_allocator);
#endif #endif
...@@ -3212,7 +3212,7 @@ static void register_pasid_allocator(struct intel_iommu *iommu) ...@@ -3212,7 +3212,7 @@ static void register_pasid_allocator(struct intel_iommu *iommu)
* is active. All vIOMMU allocators will eventually be calling the same * is active. All vIOMMU allocators will eventually be calling the same
* host allocator. * host allocator.
*/ */
if (!ecap_vcs(iommu->ecap) || !vccap_pasid(iommu->vccap)) if (!vccap_pasid(iommu->vccap))
return; return;
pr_info("Register custom PASID allocator\n"); pr_info("Register custom PASID allocator\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment