Hmmm.... Wondering if this could be eventually used to emulate a PCIe card using another device, like a RaspberryPi or something more powerful... Thinking the idea of a card you could stick in a machine, anything from a 1x to 16x slot, that emulates a network card (you could run VPN or other stuff on the card and offload it from the host) or storage (running something with enough power to run ZFS and a few disks, and show to the host as a single disk, allowing ZFS on devices that would not support it). but this is probably not something easy...
So just to be clear, you have to boot up the physical machine with a kernel command-line argument to reserve some RAM for this to work? And the amount of RAM you reserve is for BAR memory? If you wanted multiple PCIem devices (can you do that?) you'd need to reserve RAM for each of them?
that is a huge win if you are developing drivers or even real hardware. it allows to iterate on protokols just with the press of a button
How is that better than emulating the device in QEMU or with something like libvfio-user (which also works on top of QEMU)?
very interesting work! I've been exploring a different idea on the side, using SPDK+libvfio-user [0] to emulate PCIe devices inside QEMU, which doesn't require a kernel module but it's a bit less flexible than this approach.
[0] https://movementarian.org/blog/posts/2025-08-27-vfio-user-cl...
I've been burned before by driver bugs that only manifested under very specific timing conditions or malformed responses from the device, tnx
Tangential question: PCIe is a pretty future-proof technology to learn/invest in, right? As in, it is very unlikely to become obsolete in the next 5-10 years (like USB)?
vhci-hcd for USB has been so useful for usb development. Especially for testing usb driver code in CI.
How would I do this under macOS?
That's pretty much the Linux equivalent of Device Simulation Framework we had for Windows back in 2000's.
In the presentation below, only the USB capabilities of it is discussed, but it was able to simulate PCI devices too.
https://download.microsoft.com/download/5/b/9/5b97017b-e28a-...