* [PATCH] x86/hvmloader: fix order of PCI vs MTRR initialization
@ 2025-05-27 8:55 Roger Pau Monne
2025-05-27 10:27 ` Andrew Cooper
2025-05-27 15:00 ` Anthoine Bourgeois
0 siblings, 2 replies; 3+ messages in thread
From: Roger Pau Monne @ 2025-05-27 8:55 UTC (permalink / raw)
To: xen-devel; +Cc: Roger Pau Monne, Jan Beulich, Andrew Cooper, Anthony PERARD
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: 2c3dffbaa324 ('tools/hvmloader: Replace LAPIC_ID() with cpu_to_apicid[]')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
tools/firmware/hvmloader/hvmloader.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
index 4e330fc1e241..6d23150fc9fd 100644
--- a/tools/firmware/hvmloader/hvmloader.c
+++ b/tools/firmware/hvmloader/hvmloader.c
@@ -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();
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/hvmloader: fix order of PCI vs MTRR initialization
2025-05-27 8:55 [PATCH] x86/hvmloader: fix order of PCI vs MTRR initialization Roger Pau Monne
@ 2025-05-27 10:27 ` Andrew Cooper
2025-05-27 15:00 ` Anthoine Bourgeois
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2025-05-27 10:27 UTC (permalink / raw)
To: Roger Pau Monne, xen-devel; +Cc: Jan Beulich, Anthony PERARD
On 27/05/2025 9:55 am, Roger Pau Monne wrote:
> 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: 2c3dffbaa324 ('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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/hvmloader: fix order of PCI vs MTRR initialization
2025-05-27 8:55 [PATCH] x86/hvmloader: fix order of PCI vs MTRR initialization Roger Pau Monne
2025-05-27 10:27 ` Andrew Cooper
@ 2025-05-27 15:00 ` Anthoine Bourgeois
1 sibling, 0 replies; 3+ messages in thread
From: Anthoine Bourgeois @ 2025-05-27 15:00 UTC (permalink / raw)
To: Roger Pau Monne; +Cc: xen-devel, Jan Beulich, Andrew Cooper, Anthony PERARD
On Tue, May 27, 2025 at 10:55:04AM +0200, Roger Pau Monne wrote:
>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: 2c3dffbaa324 ('tools/hvmloader: Replace LAPIC_ID() with cpu_to_apicid[]')
>Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-27 15:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 8:55 [PATCH] x86/hvmloader: fix order of PCI vs MTRR initialization Roger Pau Monne
2025-05-27 10:27 ` Andrew Cooper
2025-05-27 15:00 ` Anthoine Bourgeois
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.