]> xenbits.xensource.com Git - xen.git/commitdiff
x86/IOMMU: mark IOMMU / intremap not in use when ACPI tables are missing
authorJan Beulich <jbeulich@suse.com>
Thu, 4 Nov 2021 13:44:01 +0000 (14:44 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 4 Nov 2021 13:44:01 +0000 (14:44 +0100)
x2apic_bsp_setup() gets called ahead of iommu_setup(), and since x2APIC
mode (physical vs clustered) depends on iommu_intremap, that variable
needs to be set to off as soon as we know we can't / won't enable
interrupt remapping, i.e. in particular when parsing of the respective
ACPI tables failed. Move the turning off of iommu_intremap from AMD
specific code into acpi_iommu_init(), accompanying it by clearing of
iommu_enable.

Take the opportunity and also fully skip ACPI table parsing logic on
VT-d when both "iommu=off" and "iommu=no-intremap" are in effect anyway,
like was already the case for AMD.

The tag below only references the commit uncovering a pre-existing
anomaly.

Fixes: d8bd82327b0f ("AMD/IOMMU: obtain IVHD type to use earlier")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/drivers/passthrough/amd/pci_amd_iommu.c
xen/drivers/passthrough/vtd/dmar.c
xen/drivers/passthrough/x86/iommu.c
xen/include/asm-x86/acpi.h

index 03228a99520c56f28925585eb075da516a0c1b1d..9642bba43a2691ffce780ebb781cc6e827208985 100644 (file)
@@ -183,9 +183,6 @@ int __init acpi_ivrs_init(void)
 {
     int rc;
 
-    if ( !iommu_enable && !iommu_intremap )
-        return 0;
-
     rc = amd_iommu_get_supported_ivhd_type();
     if ( rc < 0 )
         return rc;
@@ -193,10 +190,7 @@ int __init acpi_ivrs_init(void)
     ivhd_type = rc;
 
     if ( (amd_iommu_detect_acpi() !=0) || (iommu_found() == 0) )
-    {
-        iommu_intremap = iommu_intremap_off;
         return -ENODEV;
-    }
 
     iommu_init_ops = &_iommu_init_ops;
 
index d5ee3675998b58da8aac5c5472f7387987889dc9..33a12b2ae976513f32bba3d260c063aa3c130197 100644 (file)
@@ -777,11 +777,7 @@ static int __init acpi_parse_dmar(struct acpi_table_header *table)
     dmar = (struct acpi_table_dmar *)table;
     dmar_flags = dmar->flags;
 
-    if ( !iommu_enable && !iommu_intremap )
-    {
-        ret = -EINVAL;
-        goto out;
-    }
+    ASSERT(iommu_enable || iommu_intremap);
 
     if ( !dmar->width )
     {
index 01dbd9b098e77160988c33e97c225be910cfa3d0..b2284ae0014323c365b590ab592fdf70be0b964e 100644 (file)
@@ -41,6 +41,24 @@ enum iommu_intremap __read_mostly iommu_intremap = iommu_intremap_full;
 bool __read_mostly iommu_intpost;
 #endif
 
+void __init acpi_iommu_init(void)
+{
+    int ret;
+
+    if ( !iommu_enable && !iommu_intremap )
+        return;
+
+    ret = acpi_dmar_init();
+    if ( ret == -ENODEV )
+        ret = acpi_ivrs_init();
+
+    if ( ret )
+    {
+        iommu_enable = false;
+        iommu_intremap = iommu_intremap_off;
+    }
+}
+
 int __init iommu_hardware_setup(void)
 {
     struct IO_APIC_route_entry **ioapic_entries = NULL;
index 7032f3a001dae622f18a3dd51491b6ce024b8d54..9a9cc4c2403a8194b0e724b0e61f2b7c4e31bbda 100644 (file)
@@ -141,16 +141,10 @@ extern u32 x86_acpiid_to_apicid[];
 extern u32 pmtmr_ioport;
 extern unsigned int pmtmr_width;
 
+void acpi_iommu_init(void);
 int acpi_dmar_init(void);
 int acpi_ivrs_init(void);
 
-static inline int acpi_iommu_init(void)
-{
-    int ret = acpi_dmar_init();
-
-    return ret == -ENODEV ? acpi_ivrs_init() : ret;
-}
-
 void acpi_mmcfg_init(void);
 
 /* Incremented whenever we transition through S3. Value is 1 during boot. */