x86/x2APIC: defer probe until after IOMMU ACPI table parsing
authorJan Beulich <jbeulich@suse.com>
Fri, 3 Dec 2021 10:36:10 +0000 (11:36 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 3 Dec 2021 10:36:10 +0000 (11:36 +0100)
While commit 46c4061cd2bf ("x86/IOMMU: mark IOMMU / intremap not in use
when ACPI tables are missing") deals with apic_x2apic_probe() as called
from x2apic_bsp_setup(), the check_x2apic_preenabled() path is similarly
affected: The call needs to occur after acpi_iommu_init(), such that
iommu_intremap getting disabled there can be properly taken into account
by apic_x2apic_probe().

Note that, for the time being (further cleanup patches following),
reversing the order of the calls to generic_apic_probe() and
acpi_boot_init() is not an option:
- acpi_process_madt() calls clustered_apic_check() and hence relies on
  genapic to have got filled before,
- generic_bigsmp_probe() (called from acpi_process_madt()) needs to
  occur after generic_apic_probe(),
- acpi_parse_madt() (called from acpi_process_madt()) calls
  acpi_madt_oem_check(), which wants to be after generic_apic_probe().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/acpi/boot.c
xen/arch/x86/setup.c
xen/drivers/passthrough/x86/iommu.c

index 24702d041c9c64e990f181745f980e99138e87d0..cc4bbc0284fa5deae7f419b6d9e3bae738eaa0b8 100644 (file)
@@ -742,8 +742,6 @@ int __init acpi_boot_init(void)
 
        acpi_mmcfg_init();
 
-       acpi_iommu_init();
-
        erst_init();
 
        acpi_hest_init();
index 723bd49c766fa530dd5766d0589bfb6f1c47aa92..f40a9fe5d3516dfa085e2c328a1514c6604e169b 100644 (file)
@@ -1664,15 +1664,30 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
     dmi_scan_machine();
 
-    generic_apic_probe();
-
     mmio_ro_ranges = rangeset_new(NULL, "r/o mmio ranges",
                                   RANGESETF_prettyprint_hex);
 
     xsm_multiboot_init(module_map, mbi);
 
+    /*
+     * IOMMU-related ACPI table parsing may require some of the system domains
+     * to be usable, e.g. for pci_hide_device()'s use of dom_xen.
+     */
     setup_system_domains();
 
+    /*
+     * IOMMU-related ACPI table parsing has to happen before APIC probing, for
+     * check_x2apic_preenabled() to be able to observe respective findings, in
+     * particular iommu_intremap having got turned off.
+     */
+    acpi_iommu_init();
+
+    /*
+     * APIC probing needs to happen before general ACPI table parsing, as e.g.
+     * generic_bigsmp_probe() may occur only afterwards.
+     */
+    generic_apic_probe();
+
     acpi_boot_init();
 
     if ( smp_found_config )
index b2284ae0014323c365b590ab592fdf70be0b964e..f11280f4b208597a1eaab1dbe78f5f857cc6d4a3 100644 (file)
@@ -43,14 +43,17 @@ bool __read_mostly iommu_intpost;
 
 void __init acpi_iommu_init(void)
 {
-    int ret;
+    int ret = -ENODEV;
 
     if ( !iommu_enable && !iommu_intremap )
         return;
 
-    ret = acpi_dmar_init();
-    if ( ret == -ENODEV )
-        ret = acpi_ivrs_init();
+    if ( !acpi_disabled )
+    {
+        ret = acpi_dmar_init();
+        if ( ret == -ENODEV )
+            ret = acpi_ivrs_init();
+    }
 
     if ( ret )
     {