aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2015-06-12 05:15:49 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2015-06-12 06:31:25 -0400
commitc83b2f20fdde578bded3dfc4405c5db7a039c694 (patch)
tree1404bcf4db4542ee2a9d1b11e75c678557000176
parentbd00c606a6f60ca015a62bdbf671eadd48a4ca82 (diff)
iommu/vt-d: Only enable extended context tables if PASID is supported
Although the extended tables are theoretically a completely orthogonal feature to PASID and anything else that *uses* the newly-available bits, some of the early hardware has problems even when all we do is enable them and use only the same bits that were in the old context tables. For now, there's no motivation to support extended tables unless we're going to use PASID support to do SVM. So just don't use them unless PASID support is advertised too. Also add a command-line bailout just in case later chips also have issues. The equivalent problem for PASID support has already been fixed with the upcoming VT-d spec update and commit bd00c606a ("iommu/vt-d: Change PASID support to bit 40 of Extended Capability Register"), because the problematic platforms use the old definition of the PASID-capable bit, which is now marked as reserved and meaningless. So with this change, we'll magically start using ECS again only when we see the new hardware advertising "hey, we have PASID support and we actually tested it this time" on bit 40. The VT-d hardware architect has promised that we are not going to have any reason to support ECS *without* PASID any time soon, and he'll make sure he checks with us before changing that. In the future, if hypothetical new features also use new bits in the context tables and can be seen on implementations *without* PASID support, we might need to add their feature bits to the ecs_enabled() macro. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r--Documentation/kernel-parameters.txt6
-rw-r--r--drivers/iommu/intel-iommu.c18
2 files changed, 21 insertions, 3 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index f6befa9855c1..491bb15620fc 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1481,6 +1481,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1481 By default, super page will be supported if Intel IOMMU 1481 By default, super page will be supported if Intel IOMMU
1482 has the capability. With this option, super page will 1482 has the capability. With this option, super page will
1483 not be supported. 1483 not be supported.
1484 ecs_off [Default Off]
1485 By default, extended context tables will be supported if
1486 the hardware advertises that it has support both for the
1487 extended tables themselves, and also PASID support. With
1488 this option set, extended tables will not be used even
1489 on hardware which claims to support them.
1484 1490
1485 intel_idle.max_cstate= [KNL,HW,ACPI,X86] 1491 intel_idle.max_cstate= [KNL,HW,ACPI,X86]
1486 0 disables intel_idle and fall back on acpi_idle. 1492 0 disables intel_idle and fall back on acpi_idle.
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 2ffe58969944..5ecfaf29933a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -422,6 +422,14 @@ static int dmar_map_gfx = 1;
422static int dmar_forcedac; 422static int dmar_forcedac;
423static int intel_iommu_strict; 423static int intel_iommu_strict;
424static int intel_iommu_superpage = 1; 424static int intel_iommu_superpage = 1;
425static int intel_iommu_ecs = 1;
426
427/* We only actually use ECS when PASID support (on the new bit 40)
428 * is also advertised. Some early implementations — the ones with
429 * PASID support on bit 28 — have issues even when we *only* use
430 * extended root/context tables. */
431#define ecs_enabled(iommu) (intel_iommu_ecs && ecap_ecs(iommu->ecap) && \
432 ecap_pasid(iommu->ecap))
425 433
426int intel_iommu_gfx_mapped; 434int intel_iommu_gfx_mapped;
427EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped); 435EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped);
@@ -465,6 +473,10 @@ static int __init intel_iommu_setup(char *str)
465 printk(KERN_INFO 473 printk(KERN_INFO
466 "Intel-IOMMU: disable supported super page\n"); 474 "Intel-IOMMU: disable supported super page\n");
467 intel_iommu_superpage = 0; 475 intel_iommu_superpage = 0;
476 } else if (!strncmp(str, "ecs_off", 7)) {
477 printk(KERN_INFO
478 "Intel-IOMMU: disable extended context table support\n");
479 intel_iommu_ecs = 0;
468 } 480 }
469 481
470 str += strcspn(str, ","); 482 str += strcspn(str, ",");
@@ -669,7 +681,7 @@ static inline struct context_entry *iommu_context_addr(struct intel_iommu *iommu
669 struct context_entry *context; 681 struct context_entry *context;
670 u64 *entry; 682 u64 *entry;
671 683
672 if (ecap_ecs(iommu->ecap)) { 684 if (ecs_enabled(iommu)) {
673 if (devfn >= 0x80) { 685 if (devfn >= 0x80) {
674 devfn -= 0x80; 686 devfn -= 0x80;
675 entry = &root->hi; 687 entry = &root->hi;
@@ -806,7 +818,7 @@ static void free_context_table(struct intel_iommu *iommu)
806 if (context) 818 if (context)
807 free_pgtable_page(context); 819 free_pgtable_page(context);
808 820
809 if (!ecap_ecs(iommu->ecap)) 821 if (!ecs_enabled(iommu))
810 continue; 822 continue;
811 823
812 context = iommu_context_addr(iommu, i, 0x80, 0); 824 context = iommu_context_addr(iommu, i, 0x80, 0);
@@ -1141,7 +1153,7 @@ static void iommu_set_root_entry(struct intel_iommu *iommu)
1141 unsigned long flag; 1153 unsigned long flag;
1142 1154
1143 addr = virt_to_phys(iommu->root_entry); 1155 addr = virt_to_phys(iommu->root_entry);
1144 if (ecap_ecs(iommu->ecap)) 1156 if (ecs_enabled(iommu))
1145 addr |= DMA_RTADDR_RTT; 1157 addr |= DMA_RTADDR_RTT;
1146 1158
1147 raw_spin_lock_irqsave(&iommu->register_lock, flag); 1159 raw_spin_lock_irqsave(&iommu->register_lock, flag);