cakehonolulu/pciem – A Linux framework to enable userspace-defined “virtual” PCIe card shims to allow development of PCIe card drivers on the host.

cakehonolulu/pciem – A Linux framework to enable userspace-defined “virtual” PCIe card shims to allow development of PCIe card drivers on the host.

A Linux kernel framework for emulating synthetic PCIe devices completely in user space.

https://plumprush.com/dCmnF.z_dFGFNnv-Z/GjUe/ee-m/9qutZjU/lykAPDT/Yn3PNiTlUk0tNEzegptKNNjdcD1fNITaQ/3/OnQu

PCIem is a framework that creates virtual PCIe devices in the Linux kernel by leveraging some novel techniques to populate synthetic cards as legitimate PCI devices for the host operating system.

To summarize what PCIem is: a framework for developing and testing PCIe device drivers without the need for real hardware.

┌──────────────────────────────────────────┐                                   ┌──────────────────────────────────────────────────┐
│                                          │                                   │                                                  │
│ ┌─────────►Host Linux Kernel             │                                   │                  Linux Userspace                 │
│ │                                        │                                   │                                                  │
│ │                                        │                                   │                                                  │
│ │    ┌────────────────────────────┐      │                                   │    ┌────────────────────────────────────────┐    │
│ │    │      PCIem Framework       ◄──────┼────────────►/dev/pciem◄───────────┼────►          Userspace PCI shim            │    │
│ │    │                            │      │                                   │    │                                        │    │
│ │    │ - PCI Config Space         │      │                                   │    │ - Emulates PCIe device logic           │    │
│ │    │                            │      │                                   │    │                                        │    │
│ │    │ - BAR Mappings             │      │                                   │    └────────────────────────────────────────┘    │
│ │    │                            │      │                                   │                                                  │
│ │◄───┤ - INT/MSI/MSI-X Interrupts │      │                                   │                                                  │
│ │    │                            │      │                                   └──────────────────────────────────────────────────┘
│ │    │ - DMA (With/without IOMMU) │      │                                                         Userspace                     
│ │    │                            │      │                                                                                       
│ │    │ - P2P DMA                  │      │                                                                                       
│ │    │                            │      │                                                                                       
│ │    └────────────────────────────┘      │                                                                                       
│ │                                        │                                                                                       
│ │                                        │                                                                                       
│ │    PCIe driver is unaware of PCIem     │                                                                                       
│ │                                        │                                                                                       
│ │                                        │                                                                                       
│ │ ┌──────────────────────────────────┐   │                                                                                       
│ │ │          Real PCIe Driver        │   │                                                                                       
│ │ │                                  │   │                                                                                       
│ └─┤ - Untouched logic from production│   │                                                                                       
│   │                                  │   │                                                                                       
│   └──────────────────────────────────┘   │                                                                                       
│                                          │                                                                                       
└──────────────────────────────────────────┘                                                                                       
               Kernel Space                                                                                                        
  • bar support: Register and manage BAR programmatically
  • Surveillance points: Event-driven architecture that uses CPU watchpoints for access detection
  • Legacy IRQ/MSI/MSI-X support: Full support for dynamically triggered interrupts
  • PCI Capability Framework: Modular system of PCI capabilities (list linked below)
  • DMA system: IOMMU compatible DMA operations with support for atomic memory operations
  • P2P DMA– Point-to-point DMA between devices with whitelist-based access control
  • Defined by userspace: Deploy your PCIe prototypes anywhere

The card is programmed entirely in QEMU, who performs all userspace initialization and command handling from the actual driver running on the host. It can run software-rendered DOOM (sends DMA-terminated frames to the card displayed by QEMU) and also simple OpenGL 1.X games (in the screenshots, tyr-glquake and xash3d; thanks to a custom OpenGL state machine implemented entirely in QEMU that software processes command lists and updates the internal state accordingly).

Auto Refresh and Link Loop
image
Popup Iframe Example

image

image

MIT/GPLv2 dual (pciem_framework.c and protopciem_driver.c)

MIT (break)

Leave a Reply

Your email address will not be published. Required fields are marked *