File 68a6ed85-x86-setup-MMCFG-ahead-of-IOMMU.patch of Package xen
# Commit c292772b4945d3a264a61c3c1920f1aebd17998b
# Date 2025-08-21 11:57:25 +0200
# Author Roger Pau Monne <roger.pau@citrix.com>
# Committer Roger Pau Monne <roger.pau@citrix.com>
x86/iommu: setup MMCFG ahead of IOMMU
Otherwise the PCI accesses to segments different than the first one done by
the IOMMU initialization code would silently fail by returning all ones.
Introduce a new helper, called pci_setup(), and move both the creation of
PCI segment 0 internal data structures, plus the parsing of ACPI MMCFG
table to it. This moves acpi_mmcfg_init() slightly earlier from
acpi_boot_init() into pci_setup().
Note that further work will be needed to support systems where access
methods to segments different than 0 is not discoverable by Xen.
Fixes: 3950f2485bbc ('x86/x2APIC: defer probe until after IOMMU ACPI table parsing')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
--- a/xen/arch/x86/acpi/boot.c
+++ b/xen/arch/x86/acpi/boot.c
@@ -748,8 +748,6 @@ int __init acpi_boot_init(void)
acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
- acpi_mmcfg_init();
-
erst_init();
acpi_hest_init();
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1898,6 +1898,12 @@ void asmlinkage __init noreturn __start_
setup_system_domains();
/*
+ * Initialize PCI (create segment 0, setup MMCFG access) ahead of IOMMU
+ * setup, as devices in segment > 0 must also be discoverable.
+ */
+ acpi_mmcfg_init();
+
+ /*
* 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.
--- a/xen/arch/x86/x86_64/mmconfig-shared.c
+++ b/xen/arch/x86/x86_64/mmconfig-shared.c
@@ -404,6 +404,9 @@ void __init acpi_mmcfg_init(void)
pci_segments_init();
+ if ( acpi_disabled )
+ return;
+
/* MMCONFIG disabled */
if ((pci_probe & PCI_PROBE_MMCONF) == 0)
return;