[SLOF] [PATCH] pci-phb: Set pci-max-mem64 to the correct value

Thomas Huth thuth at redhat.com
Fri Apr 28 14:34:27 AEST 2017

When running QEMU with a virtio device attached to a PCI bridge,
SLOF currently fails to initialize the device correctly. For example,
with the following command line:

 qemu-system-ppc64 -nographic -nodefaults -serial mon:stdio \
               -device pci-bridge,bus=pci.0,id=b1,chassis_nr=1 \
               -device virtio-net-pci,netdev=n1,bus=b1 -netdev user,id=n1

SLOF prints this error message during its PCI scan:

 Device does not support virtio 1.0 0
 virtio-net-open failedexiting

This happens because the virtio driver code can not access the
memory region of the device, because the bridge is configured
in the wrong way. The problem is that SLOF currently sets the
pci-max-mem64 variable to the size of the 64-bit PCI address space,
but it should be set to the end address of the 64-bit space instead.
The pci-max-mem64 is used for the memory limit register of the PCI
bridge (see pci-bridge-set-mem-base) during PCI scan, and using
a wrong value here blocks all memory accesses to the devices behind
the bridge.
So fix this issue by calculating the pci-max-mem64 value correctly.

Signed-off-by: Thomas Huth <thuth at redhat.com>
 board-qemu/slof/pci-phb.fs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/board-qemu/slof/pci-phb.fs b/board-qemu/slof/pci-phb.fs
index fc2341c..6dfb2e6 100644
--- a/board-qemu/slof/pci-phb.fs
+++ b/board-qemu/slof/pci-phb.fs
@@ -261,9 +261,9 @@ setup-puid
             r> + pci-max-mmio !                 \ calc max MMIO address
          3000000 OF                             \ 64-bit memory space?
-	    decode-64 pci-next-mem64 !
-	    decode-64 drop                      \ Forget the parent address
-	    decode-64 pci-max-mem64 !
+            decode-64 dup >r pci-next-mem64 !
+            decode-64 drop                      \ Forget the parent address
+            decode-64 r> + pci-max-mem64 !

More information about the SLOF mailing list