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: 3950f2485b ('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>
This commit is contained in:
Roger Pau Monne committed 2025-08-21 11:57:25 +02:00
1 parent 08b52c30be
commit c292772b49
5 files changed
+24 -6

No files matched your search

-2
View File
@@ -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();
+2
View File
@@ -74,4 +74,6 @@ bool pci_check_bar(const struct pci_dev *pdev, mfn_t start, mfn_t end);
struct rangeset;
int pci_sanitize_bar_memory(struct rangeset *r);
void pci_setup(void);
#endif /* __X86_PCI_H__ */
+16
View File
@@ -6,7 +6,10 @@
#include <xen/spinlock.h>
#include <xen/pci.h>
#include <asm/acpi.h>
#include <asm/io.h>
#include <xsm/xsm.h>
static DEFINE_SPINLOCK(pci_config_lock);
@@ -139,6 +142,19 @@ int pci_sanitize_bar_memory(struct rangeset *r)
return 0;
}
void __init pci_setup(void)
{
/*
* Ahead of any ACPI table parsing make sure we have control structures
* for PCI segment 0.
*/
if ( pci_add_segment(0) )
panic("Could not initialize PCI segment 0\n");
/* Parse ACPI MMCFG to see if other segments are available. */
acpi_mmcfg_init();
}
/*
* Local variables:
* mode: C
+3 -4
View File
@@ -1938,11 +1938,10 @@ void asmlinkage __init noreturn __start_xen(void)
setup_system_domains();
/*
* Ahead of any ACPI table parsing make sure we have control structures
* for PCI segment 0.
* Initialize PCI (create segment 0, setup MMCFG access) ahead of IOMMU
* setup, as devices in segment > 0 must also be discoverable.
*/
if ( pci_add_segment(0) )
panic("Could not initialize PCI segment 0\n");
pci_setup();
/*
* IOMMU-related ACPI table parsing has to happen before APIC probing, for
+3
View File
@@ -402,6 +402,9 @@ void __init acpi_mmcfg_init(void)
{
bool valid = true;
if ( acpi_disabled )
return;
/* MMCONFIG disabled */
if ((pci_probe & PCI_PROBE_MMCONF) == 0)
return;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.