2026-05-07 11:35:18 +00:00
2026-05-07 11:34:16 +00:00
2026-05-07 11:34:16 +00:00
2026-05-07 11:34:16 +00:00
2026-05-07 11:34:16 +00:00
2026-05-07 11:35:18 +00:00

-----> provenance

tiny userspace nvme driver experiment. it uses vfio to take
ownership of an nvme pci controller to map bar0 into userspace and maps dma memory
through the iommu to create polling queues and issues nvme commands w/o the
kernel block layer

this is intentionally read only at the media command level. it still
resets/enables the controller and programs queue registers so use a sacrificial
nvme device that ISN'T mounted and is NOT your boot disk

-----> build

```
make
```

```
build/provenance
```
-----> build

find nvme controller:

```
lspci -nn | grep -i nvme
```

example BDF:

```
0000:01:00.0
```

check its iommu group:

```
readlink /sys/bus/pci/devices/0000:01:00.0/iommu_group
ls /sys/kernel/iommu_groups/<GROUP>/devices
```

the vfio group has to be viable. if unrelated active devices share the same iommu
group vfio can reject the device

bind the device to `vfio-pci`

```
BDF=0000:01:00.0

sudo modprobe vfio-pci
echo vfio-pci | sudo tee /sys/bus/pci/devices/$BDF/driver_override
echo $BDF | sudo tee /sys/bus/pci/devices/$BDF/driver/unbind
echo $BDF | sudo tee /sys/bus/pci/drivers_probe
```

confirm binding:

```
readlink /sys/bus/pci/devices/$BDF/driver
```
identify Controller

```
sudo build/provenance identify --pci 0000:01:00.0
```

Representative output is in `OUTPUT.txt`.

-----> namespace data

```
sudo build/provenance read \
  --pci 0000:01:00.0 \
  --nsid 1 \
  --lba 0 \
  --blocks 8 \
  --out sector.bin
```

this identifies the namespace first and uses the active lba to compute
the byte count to create one io cq/sq pair, then submits one nvme read command, polls
the completion queue, and writes the dma result to the output file.

-----> iova base

the default dma iova base is `0x100000000`

override it if your iommu/device setup needs a different range

```
sudo build/provenance identify --pci 0000:01:00.0 --iova-base 0x200000000
```
S
Description
tiny userspace nvme driver (WIP)
Readme 40 KiB
Languages
C 98.4%
Makefile 1.6%