]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iommu/vt-d: Don't read VCCAP register unless it exists
authorDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 26 Nov 2020 11:13:51 +0000 (11:13 +0000)
committerWill Deacon <will@kernel.org>
Thu, 26 Nov 2020 14:50:24 +0000 (14:50 +0000)
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: 3375303e8287 ("iommu/vt-d: Add custom allocator for IOASID")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Liu Yi L <yi.l.liu@intel.com>
Cc: stable@vger.kernel.org # v5.7+
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/de32b150ffaa752e0cff8571b17dfb1213fbe71c.camel@infradead.org
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/intel/dmar.c
drivers/iommu/intel/iommu.c

index 11319e4dce4a113f4ee9a0bdb7567d533279a09e..b46dbfa6d0ed691c86a2970dda3c8d04baa35c26 100644 (file)
@@ -986,7 +986,8 @@ static int map_iommu(struct intel_iommu *iommu, u64 phys_addr)
                warn_invalid_dmar(phys_addr, " returns all ones");
                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 */
        map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap),
index 4d9b298002f00b8ed4b3e5b2da98e6dcb1d31ff4..30979c2c7082183c281424bf1ae91d43e1665d6e 100644 (file)
@@ -1833,7 +1833,7 @@ static void free_dmar_iommu(struct intel_iommu *iommu)
                if (ecap_prs(iommu->ecap))
                        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);
 
 #endif
@@ -3212,7 +3212,7 @@ static void register_pasid_allocator(struct intel_iommu *iommu)
         * is active. All vIOMMU allocators will eventually be calling the same
         * host allocator.
         */
-       if (!ecap_vcs(iommu->ecap) || !vccap_pasid(iommu->vccap))
+       if (!vccap_pasid(iommu->vccap))
                return;
 
        pr_info("Register custom PASID allocator\n");