While it seems like we can choose any I/O virtual address for peripheral
authorpatrick <patrick@openbsd.org>
Fri, 25 Jun 2021 17:41:22 +0000 (17:41 +0000)
committerpatrick <patrick@openbsd.org>
Fri, 25 Jun 2021 17:41:22 +0000 (17:41 +0000)
commit415019cefb419ee80cf82fd1b09b724a4fddde9b
tree54c273b2056dee20428f159bf714adedd86b8dca
parent0eb03c1cebc3544bae74d71bf82a9398397e3ded
While it seems like we can choose any I/O virtual address for peripheral
devices, this isn't really the case.  It depends on the bus topology of
how devices are connected.  In the case of PCIe, devices are assigned
addresses (in PCI BARs) from the PCI address spaces.  Now if we take an
address from one of these address spaces for our IOVA, transfers from
from a PCI device to that address will terminate inside of the PCI bus.
This is because from the PCI buses' point-of-view, the address we chose
is part of its address space.  To make sure we don't allocate addresses
from there, reserve the PCI addresses in the IOVA.

Note that smmu(4) currently gives each device its own IOVA.  So the PCI
addresses will be reserved only in IOVA from PCI devices, and only the
addresses concerning the PCI bus it is connected to will be reserved.
All other devices behind an smmu(4) will not have any changes to their
IOVA.

ok kettenis@
12 files changed:
sys/arch/arm64/dev/acpiiort.c
sys/arch/arm64/dev/acpiiort.h
sys/arch/arm64/dev/acpipci.c
sys/arch/arm64/dev/apldart.c
sys/arch/arm64/dev/smmu.c
sys/arch/arm64/dev/smmu_acpi.c
sys/arch/arm64/dev/smmu_fdt.c
sys/arch/arm64/dev/smmuvar.h
sys/dev/fdt/dwpcie.c
sys/dev/fdt/pciecam.c
sys/dev/ofw/ofw_misc.c
sys/dev/ofw/ofw_misc.h