Search code examples
windowsdriverequivalentvfio

Is there a Windows user space API similar to VFIO for Linux for writing drivers for custom hardware?


As part of learning about FPGA design have some boards with Xilinx Kintex-7 or Artix-7 FPGAs where the FPGAs have a PCIe connection to the PC they are installed in. The FPGA designs expose a PCIe endpoint to the PC such that:

  • The vendor and sub-vendor IDs set to values for which Linux and Windows don't have any built in driver for.
  • The PCIe endpoints contain both simple memory mapped registers in the BAR, and sometimes DMA engines.

Under Alma Linux 8 have found when the IOMMU is enabled then the VFIO API can be used to write a user level driver for the custom hardware, including the use of DMA. Where using VFIO offers the following advantages for development:

  1. Once have bound the vfio-pci driver to the custom PCIe device, can access the PCIe device from just a regular user process without needing any elevated capabilities. bind_device_to_vfio.sh is the script created which needs sudo to bind the vfio-pci driver and then give user permission to the IOMMU group file which the user space application opens to order to gain access to the custom device, and map the PCIe BARs.
  2. Avoids needing to create an out-of-tree Kernel module for the custom device, meaning:
    • Simplifies debugging; with Kernel modules haven't found a way of single stepping.
    • Avoids tainting of the Kernel.
    • When secure boot is enabled avoids needing to sign an out-of-tree Kernel module.
  3. With the IOMMU enabled, the hardware protects against FPGA or DMA software driver bugs which would otherwise overwrite incorrect physically memory addresses.

The PCs in which have the FPGA boards fitted can dual boot in either Linux or Windows (10 or 11), and would like to investigate writing user space drivers for Windows as well as Linux.

For reference, vfio_access.c is the current code am using under Linux which uses VFIO and which would like to try and perform the equivalent functionality in Windows.

I have tried searching for variations on "Windows equivalent of Linux VFIO for user space drivers", but rather than finding an API for Windows only seem to find search results about running a Windows VM inside a Linux host. I'm not sure if I'm using the wrong search terms, or if Windows doesn't provide the equivalent of VFIO.


Solution

  • I will answer my question with a "No", in that Windows doesn't provide an equivalent mechanism to the Linux VFIO for a user space driver to access custom hardware.

    On looking at DPDK, which uses VFIO under Linux, the Install Drivers section of the Getting Started Guide for Windows contains:

    Certain kernel-mode drivers are required to run DPDK applications. Refer to Windows documentation in dpdk-kmods repository for common instructions on system setup, driver build and installation. The drivers are not signed, so signature enforcement has to be disabled.

    Warning : Disabling driver signature enforcement weakens OS security. It is discouraged in production environments.

    And the status to the DPDK porting on Windows page contains:

    It requires yet unsigned kernel-mode drivers to run (except mlx5).