iommu/vt-d: Add a check for 1GB page support
authorSohil Mehta <sohil.mehta@intel.com>
Wed, 20 Dec 2017 19:59:25 +0000 (11:59 -0800)
committerJoerg Roedel <jroedel@suse.de>
Wed, 17 Jan 2018 14:02:50 +0000 (15:02 +0100)
Add a check to verify IOMMU 1GB page support. If the CPU supports 1GB
pages but the IOMMU does not support it then disable SVM by not
allocating PASID tables.

Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel-svm.c
include/linux/intel-iommu.h

index 6643277e321e22bb6cb40c8648b2026217d6569d..e9a56ad09a7613d5bc74996a1d229f9e79ec5cef 100644 (file)
@@ -41,6 +41,10 @@ int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu)
        struct page *pages;
        int order;
 
+       if (cpu_feature_enabled(X86_FEATURE_GBPAGES) &&
+                       !cap_fl1gp_support(iommu->cap))
+               return -EINVAL;
+
        /* Start at 2 because it's defined as 2^(1+PSS) */
        iommu->pasid_max = 2 << ecap_pss(iommu->ecap);
 
index f3274d9f46a252a9abc332dc0621ec3fc02ef4aa..a56bab114f3903c8e3bef8ac9849d2a6f1951f38 100644 (file)
@@ -84,6 +84,7 @@
  * Decoding Capability Register
  */
 #define cap_pi_support(c)      (((c) >> 59) & 1)
+#define cap_fl1gp_support(c)   (((c) >> 56) & 1)
 #define cap_read_drain(c)      (((c) >> 55) & 1)
 #define cap_write_drain(c)     (((c) >> 54) & 1)
 #define cap_max_amask_val(c)   (((c) >> 48) & 0x3f)