x86/hvmloader: fix order of PCI vs MTRR initialization

After some recent change the order of MTRR vs PCI initialization is
inverted.  MTRR will get initialization ahead of PCI scanning and sizing of
MMIO regions.  As a result when setting up MTRRs the MMIO window below 4GB
will always have the same size, and there will be no window above 4GB.
This results in malformed and incomplete MTRRs being setup.

Fix by making sure PCI is initialized ahead of MTRR, also add a comment to
notice the ordering dependency.

Fixes: 2c3dffbaa3 ('tools/hvmloader: Replace LAPIC_ID() with cpu_to_apicid[]')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com>
This commit is contained in:
Roger Pau Monne committed 2025-05-28 10:23:35 +02:00
1 parent d965e2ee07
commit cfd5232431
1 file changed
+7 -1
+7 -1
View File
@@ -341,10 +341,16 @@ int main(void)
printf("CPU speed is %u MHz\n", get_cpu_mhz());
/*
* PCI setup must be done before SMP initialization, as the later also does
* the MTRR setup and so the size of the PCI MMIO windows must be known at
* that point.
*/
pci_setup();
smp_initialise();
apic_setup();
pci_setup();
perform_tests();
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.