0
votes

I am trying to implement bare metal PCIE device discovery on QEMU AArch64 virt device. I know, that ECAM area is mapped to 0x3f000000 memory address, and I expect to see there this table.

But when I perform a reading of 4 bytes (MCFG signature) from 0x3f000000 address, I get a synchronous exception.

What am I doing wrong? Is there something I have to perform before accessing PCIE memory mapped area?

QEMU_CMD = qemu-system-aarch64 \
    -machine virt \
    -m 1024M \
    -cpu cortex-a53 \
    -serial stdio \
    -device virtio-gpu-pci \
    -vnc :0 \
    -netdev user,id=n1 -device virtio-net-pci,netdev=n1
1
What is the QEMU command line?unixsmurf
@unixsmurf added to the post's bodyIlja Kartašov

1 Answers

1
votes

You're looking at the wrong address. The virt board only puts the ECAM at the 0x3f00_0000 address if it is not using the physical address space above-4GB (which is not the default; QEMU only avoids highmem usage if the user passed -machine highmem=off).

You can check this by asking QEMU to dump the dtb instead of running the guest, by adding "-machine dumpdtb=/tmp/dump.dtb" to your commandline, then disassembling the dtb with "dtc -I dtb -O dts /tmp/dump.dtb | less", and looking at the dtb for the pci controller.

More generally, a guest running in the QEMU "virt" board should not hardcode any addresses of devices, but should always read the dtb that QEMU generates and passes to the guest to determine where in the address space devices are placed. If your code did this it wouldn't have run into this error.