Skip to contentSkip to conversation

pci: fix PCI resource reserve capability on BE

PATCH In review Michael S. Tsirkin 3 participants 3 messages Oct 20, 2021 – Oct 29, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: fix PCI resource reserve capability on BE

PCI resource reserve capability should use LE format as all other PCI things. If we don't then seabios won't boot:

=== PCI new allocation pass #1 ===
PCI: check devices
PCI: QEMU resource reserve cap: size 10000000000000 type io
PCI: secondary bus 1 size 10000000000000 type io
PCI: secondary bus 1 size 00200000 type mem
PCI: secondary bus 1 size 00200000 type prefmem === PCI new allocation pass #2 ===
PCI: out of I/O address space

This became more important since we started reserving IO by default, previously no one noticed.

Fixes e2a6290aab ("hw/pcie-root-port: Fix hotplug for PCI devices requiring IO")
Fixes 226263fb5c ("hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port")
Fixes 6755e618d0 ("hw/pci: add PCI resource reserve capability to legacy PCI bridge")
---
 hw/pci/pci_bridge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
hw/pci/pci_bridge.c +5 -5
index d1f902ee86..da34c8ebcd 100644
@@ -448,11 +448,11 @@ int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
     PCIBridgeQemuCap cap = {
             .len = cap_len,
             .type = REDHAT_PCI_CAP_RESOURCE_RESERVE,
-            .bus_res = res_reserve.bus,
-            .io = res_reserve.io,
-            .mem = res_reserve.mem_non_pref,
-            .mem_pref_32 = res_reserve.mem_pref_32,
-            .mem_pref_64 = res_reserve.mem_pref_64
+            .bus_res = cpu_to_le32(res_reserve.bus),
+            .io = cpu_to_le64(res_reserve.io),
+            .mem = cpu_to_le32(res_reserve.mem_non_pref),
+            .mem_pref_32 = cpu_to_le32(res_reserve.mem_pref_32),
+            .mem_pref_64 = cpu_to_le64(res_reserve.mem_pref_64)
     };
 
     int offset = pci_add_capability(dev, PCI_CAP_ID_VNDR,
Signature · 1 line
MST
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Michael S. Tsirkin

PCI resource reserve capability should use LE format as all other PCI things. If we don't then seabios won't boot:

=== PCI new allocation pass #1 ===
PCI: check devices
PCI: QEMU resource reserve cap: size 10000000000000 type io
PCI: secondary bus 1 size 10000000000000 type io
PCI: secondary bus 1 size 00200000 type mem
PCI: secondary bus 1 size 00200000 type prefmem === PCI new allocation pass #2 ===
PCI: out of I/O address space

This became more important since we started reserving IO by default, previously no one noticed.

Fixes e2a6290aab ("hw/pcie-root-port: Fix hotplug for PCI devices requiring IO")
Fixes 226263fb5c ("hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port")
Fixes 6755e618d0 ("hw/pci: add PCI resource reserve capability to legacy PCI bridge")
Quoted 3 lines
---
 hw/pci/pci_bridge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 38 lines · Michael S. Tsirkin

PCI resource reserve capability should use LE format as all other PCI things. If we don't then seabios won't boot:

=== PCI new allocation pass #1 ===
PCI: check devices
PCI: QEMU resource reserve cap: size 10000000000000 type io
PCI: secondary bus 1 size 10000000000000 type io
PCI: secondary bus 1 size 00200000 type mem
PCI: secondary bus 1 size 00200000 type prefmem === PCI new allocation pass #2 ===
PCI: out of I/O address space

This became more important since we started reserving IO by default, previously no one noticed.

Fixes e2a6290aab ("hw/pcie-root-port: Fix hotplug for PCI devices requiring IO")
Fixes 226263fb5c ("hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port")
Fixes 6755e618d0 ("hw/pci: add PCI resource reserve capability to legacy PCI bridge")
---
  hw/pci/pci_bridge.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
hw/pci/pci_bridge.c +0 -3
index d1f902ee86..da34c8ebcd 100644
@@ -448,11 +448,11 @@ int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
      PCIBridgeQemuCap cap = {
              .len = cap_len,
              .type = REDHAT_PCI_CAP_RESOURCE_RESERVE,
-            .bus_res = res_reserve.bus,
-            .io = res_reserve.io,
-            .mem = res_reserve.mem_non_pref,

hw/pci/pci_bridge.c int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset, · line 458

Quoted 10 lines
hw/pci/pci_bridge.c +5 -2
-            .mem_pref_32 = res_reserve.mem_pref_32,
-            .mem_pref_64 = res_reserve.mem_pref_64
+            .bus_res = cpu_to_le32(res_reserve.bus),
+            .io = cpu_to_le64(res_reserve.io),
+            .mem = cpu_to_le32(res_reserve.mem_non_pref),
+            .mem_pref_32 = cpu_to_le32(res_reserve.mem_pref_32),
+            .mem_pref_64 = cpu_to_le64(res_reserve.mem_pref_64)
      };
 
      int offset = pci_add_capability(dev, PCI_CAP_ID_VNDR,
Cc qemu-stable (in case MichaelR is planning a 6.1.1, too)

Thomas