summaryrefslogtreecommitdiffstats
path: root/drivers/iommu/intel-iommu.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-12-28 23:54:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-28 23:54:57 -0500
commit457fa3469a65a524be04412f5cd497fa3b11c9fd (patch)
treee826786d7838668595dfac115ced53b32e5c97b9 /drivers/iommu/intel-iommu.c
parentb07039b79c9ea64c1eacda1e01d645082e4a0d5d (diff)
parentfbc4904c287778ddb74bf6060ac9dec51992fc53 (diff)
Merge tag 'char-misc-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH: "Here is the big set of char and misc driver patches for 4.21-rc1. Lots of different types of driver things in here, as this tree seems to be the "collection of various driver subsystems not big enough to have their own git tree" lately. Anyway, some highlights of the changes in here: - binderfs: is it a rule that all driver subsystems will eventually grow to have their own filesystem? Binder now has one to handle the use of it in containerized systems. This was discussed at the Plumbers conference a few months ago and knocked into mergable shape very fast by Christian Brauner. Who also has signed up to be another binder maintainer, showing a distinct lack of good judgement :) - binder updates and fixes - mei driver updates - fpga driver updates and additions - thunderbolt driver updates - soundwire driver updates - extcon driver updates - nvmem driver updates - hyper-v driver updates - coresight driver updates - pvpanic driver additions and reworking for more device support - lp driver updates. Yes really, it's _finally_ moved to the proper parallal port driver model, something I never thought I would see happen. Good stuff. - other tiny driver updates and fixes. All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (116 commits) MAINTAINERS: add another Android binder maintainer intel_th: msu: Fix an off-by-one in attribute store stm class: Add a reference to the SyS-T document stm class: Fix a module refcount leak in policy creation error path char: lp: use new parport device model char: lp: properly count the lp devices char: lp: use first unused lp number while registering char: lp: detach the device when parallel port is removed char: lp: introduce list to save port number bus: qcom: remove duplicated include from qcom-ebi2.c VMCI: Use memdup_user() rather than duplicating its implementation char/rtc: Use of_node_name_eq for node name comparisons misc: mic: fix a DMA pool free failure ptp: fix an IS_ERR() vs NULL check genwqe: Fix size check binder: implement binderfs binder: fix use-after-free due to ksys_close() during fdget() bus: fsl-mc: remove duplicated include files bus: fsl-mc: explicitly define the fsl_mc_command endianness misc: ti-st: make array read_ver_cmd static, shrinks object size ...
Diffstat (limited to 'drivers/iommu/intel-iommu.c')
-rw-r--r--drivers/iommu/intel-iommu.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 0ad67d65bbce..63b6ce78492a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -184,6 +184,7 @@ static int rwbf_quirk;
184 */ 184 */
185static int force_on = 0; 185static int force_on = 0;
186int intel_iommu_tboot_noforce; 186int intel_iommu_tboot_noforce;
187static int no_platform_optin;
187 188
188#define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry)) 189#define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
189 190
@@ -503,6 +504,7 @@ static int __init intel_iommu_setup(char *str)
503 pr_info("IOMMU enabled\n"); 504 pr_info("IOMMU enabled\n");
504 } else if (!strncmp(str, "off", 3)) { 505 } else if (!strncmp(str, "off", 3)) {
505 dmar_disabled = 1; 506 dmar_disabled = 1;
507 no_platform_optin = 1;
506 pr_info("IOMMU disabled\n"); 508 pr_info("IOMMU disabled\n");
507 } else if (!strncmp(str, "igfx_off", 8)) { 509 } else if (!strncmp(str, "igfx_off", 8)) {
508 dmar_map_gfx = 0; 510 dmar_map_gfx = 0;
@@ -1471,7 +1473,8 @@ static void iommu_enable_dev_iotlb(struct device_domain_info *info)
1471 if (info->pri_supported && !pci_reset_pri(pdev) && !pci_enable_pri(pdev, 32)) 1473 if (info->pri_supported && !pci_reset_pri(pdev) && !pci_enable_pri(pdev, 32))
1472 info->pri_enabled = 1; 1474 info->pri_enabled = 1;
1473#endif 1475#endif
1474 if (info->ats_supported && !pci_enable_ats(pdev, VTD_PAGE_SHIFT)) { 1476 if (!pdev->untrusted && info->ats_supported &&
1477 !pci_enable_ats(pdev, VTD_PAGE_SHIFT)) {
1475 info->ats_enabled = 1; 1478 info->ats_enabled = 1;
1476 domain_update_iotlb(info->domain); 1479 domain_update_iotlb(info->domain);
1477 info->ats_qdep = pci_ats_queue_depth(pdev); 1480 info->ats_qdep = pci_ats_queue_depth(pdev);
@@ -2895,6 +2898,13 @@ static int iommu_should_identity_map(struct device *dev, int startup)
2895 if (device_is_rmrr_locked(dev)) 2898 if (device_is_rmrr_locked(dev))
2896 return 0; 2899 return 0;
2897 2900
2901 /*
2902 * Prevent any device marked as untrusted from getting
2903 * placed into the statically identity mapping domain.
2904 */
2905 if (pdev->untrusted)
2906 return 0;
2907
2898 if ((iommu_identity_mapping & IDENTMAP_AZALIA) && IS_AZALIA(pdev)) 2908 if ((iommu_identity_mapping & IDENTMAP_AZALIA) && IS_AZALIA(pdev))
2899 return 1; 2909 return 1;
2900 2910
@@ -4722,14 +4732,54 @@ const struct attribute_group *intel_iommu_groups[] = {
4722 NULL, 4732 NULL,
4723}; 4733};
4724 4734
4735static int __init platform_optin_force_iommu(void)
4736{
4737 struct pci_dev *pdev = NULL;
4738 bool has_untrusted_dev = false;
4739
4740 if (!dmar_platform_optin() || no_platform_optin)
4741 return 0;
4742
4743 for_each_pci_dev(pdev) {
4744 if (pdev->untrusted) {
4745 has_untrusted_dev = true;
4746 break;
4747 }
4748 }
4749
4750 if (!has_untrusted_dev)
4751 return 0;
4752
4753 if (no_iommu || dmar_disabled)
4754 pr_info("Intel-IOMMU force enabled due to platform opt in\n");
4755
4756 /*
4757 * If Intel-IOMMU is disabled by default, we will apply identity
4758 * map for all devices except those marked as being untrusted.
4759 */
4760 if (dmar_disabled)
4761 iommu_identity_mapping |= IDENTMAP_ALL;
4762
4763 dmar_disabled = 0;
4764#if defined(CONFIG_X86) && defined(CONFIG_SWIOTLB)
4765 swiotlb = 0;
4766#endif
4767 no_iommu = 0;
4768
4769 return 1;
4770}
4771
4725int __init intel_iommu_init(void) 4772int __init intel_iommu_init(void)
4726{ 4773{
4727 int ret = -ENODEV; 4774 int ret = -ENODEV;
4728 struct dmar_drhd_unit *drhd; 4775 struct dmar_drhd_unit *drhd;
4729 struct intel_iommu *iommu; 4776 struct intel_iommu *iommu;
4730 4777
4731 /* VT-d is required for a TXT/tboot launch, so enforce that */ 4778 /*
4732 force_on = tboot_force_iommu(); 4779 * Intel IOMMU is required for a TXT/tboot launch or platform
4780 * opt in, so enforce that.
4781 */
4782 force_on = tboot_force_iommu() || platform_optin_force_iommu();
4733 4783
4734 if (iommu_init_mempool()) { 4784 if (iommu_init_mempool()) {
4735 if (force_on) 4785 if (force_on)