diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 2f0cd1714923..ce0794e82e55 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -58,7 +58,6 @@ static int rwbf_quirk; */ static int force_on = 0; int intel_iommu_tboot_noforce; -static int no_platform_optin; #define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry)) @@ -251,7 +250,6 @@ static int __init intel_iommu_setup(char *str) } else if (!strncmp(str, "off", 3)) { dmar_policy = DMAR_USER_OFF; dmar_disabled = 1; - no_platform_optin = 1; pr_info("IOMMU disabled\n"); } else if (!strncmp(str, "igfx_off", 8)) { disable_igfx_iommu = 1; @@ -2491,20 +2489,23 @@ static bool has_external_pci(void) static int __init platform_optin_force_iommu(void) { - if (no_iommu || !dmar_platform_optin() || no_platform_optin || - !has_external_pci()) + if (!dmar_platform_optin() || !dmar_can_force_on(DMAR_FORCEON_PLATFORM)) return 0; - if (dmar_disabled) - pr_info("Intel-IOMMU force enabled due to platform opt in\n"); + if (!has_external_pci()) + return 0; /* * If Intel-IOMMU is disabled by default, we will apply identity * map for all devices except those marked as being untrusted. */ - if (dmar_disabled) + if (dmar_policy_off()) { + pr_info("Intel-IOMMU force enabled due to platform opt in\n"); iommu_set_default_passthrough(false); + } + /* No concurrent access to dmar_policy at this point. */ + dmar_policy = DMAR_FORCE_ON; dmar_disabled = 0; return 1;