On Thu, 14 May 2020 16:38:17 +0100, Alexandru Elisei wrote: > kvmtool uses the Linux-only dt property 'linux,pci-probe-only' to prevent > it from trying to reassign the BARs. Let's make the BARs reassignable so we > can get rid of this band-aid. > > During device configuration, Linux can assign a region resource to a BAR > that temporarily overlaps with another device. This means that the code > that emulates BAR reassignment must be aware of all the registered PCI > devices. Because of this, and to avoid re-implementing the same code for > each emulated device, the algorithm for activating/deactivating emulation > as BAR addresses change lives completely inside the PCI code. Each device > registers two callback functions which are called when device emulation is > activated (for example, to activate emulation for a newly assigned BAR > address), respectively, when device emulation is deactivated (a previous > BAR address is changed, and emulation for that region must be deactivated). > > [...] Applied to kvmtool (master), thanks! [01/12] ioport: mmio: Use a mutex and reference counting for locking https://git.kernel.org/will/kvmtool/c/09577ac58fef [02/12] pci: Add helpers for BAR values and memory/IO space access https://git.kernel.org/will/kvmtool/c/2f6384f924d7 [03/12] virtio/pci: Get emulated region address from BARs https://git.kernel.org/will/kvmtool/c/e539f3e425fb [04/12] vfio: Reserve ioports when configuring the BAR https://git.kernel.org/will/kvmtool/c/a05e576f7fd8 [05/12] pci: Limit configuration transaction size to 32 bits https://git.kernel.org/will/kvmtool/c/6ea32ebdb84b [06/12] vfio/pci: Don't write configuration value twice https://git.kernel.org/will/kvmtool/c/e1d0285c89ae [07/12] Don't allow more than one framebuffers https://git.kernel.org/will/kvmtool/c/cbf3d16fccba [08/12] pci: Implement callbacks for toggling BAR emulation https://git.kernel.org/will/kvmtool/c/5a8e4f25dd7b [09/12] pci: Toggle BAR I/O and memory space emulation https://git.kernel.org/will/kvmtool/c/46e04130d264 [10/12] pci: Implement reassignable BARs https://git.kernel.org/will/kvmtool/c/465edc9d0fab [11/12] arm/fdt: Remove 'linux,pci-probe-only' property https://git.kernel.org/will/kvmtool/c/ad5e9056de0c [12/12] vfio: Trap MMIO access to BAR addresses which aren't page aligned https://git.kernel.org/will/kvmtool/c/b4fc4f605fc6 Cheers, -- Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev