**[Help]_bhyve:_bootrom_alloc:_vm_mmap_mapseg:_Inval id_argument_—_NVIDIA_passthrough_with_Corvin's_branch_on_F reeBSD_15.0**
Date: Thu, 04 Jun 2026 11:23:17 UTC
<https://www.reddit.com/r/freebsd/?f=flair_name%3A%22help%20needed%22>
Hi everyone,
I'm trying to get NVIDIA GPU passthrough working with bhyve on FreeBSD
15.0-RELEASE-p5, using Corvin Köhne's nvidia-wip branch:
https://github.com/Beckhoff/freebsd-src/tree/phab/corvink/15.0/nvidia-wip
The VM fails to start with the following error before the guest even boots:
bhyve: bootrom_alloc: vm_mmap_mapseg: Invalid argument
---
**Hardware**
- Motherboard: Gigabyte Z390 AORUS PRO
- CPU: Intel Core i9-9900K
- GPU: ZOTAC RTX 2080 Ti (0x10de:0x1e04, subvendor 0x19da, subdevice
0x2503)
---
**Host**
- FreeBSD 15.0-RELEASE-p5 (kernel GENERIC, amd64)
- vmm.ko compiled from Corvin's `phab/corvink/15.0/nvidia-wip` branch
- bhyve compiled from the same branch
- libvmmapi.so.6 produced by the Corvin branch build
---
**bhyve command**
---
bhyve-lin -S -c sockets=8,cores=1,threads=1 -m 32G -w -H -A \
-s 0,hostbridge \
-s
1,ahci-hd,/mnt/zroot-133/bhyve/img/Linux/Ubuntu-2404-KDE6-Wayland.img,bootindex=1
\
-s 7,passthru,5/0/0 \
-s 8:0,passthru,2/0/0 \
-s 8:1,passthru,2/0/1 \
-s 8:2,passthru,2/0/2 \
-s 8:3,passthru,2/0/3 \
-s 11,hda,play=/dev/dsp,rec=/dev/dsp \
-s 13,virtio-net,tap4 \
-s 14,virtio-9p,sharename=/ \
-s 29,fbuf,tcp=0.0.0.0:5900,w=1650,h=900,wait \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd \
vm0:4 < /dev/null 2>&1 &
---
**Root cause analysis (via ktrace)**
---
Tracing bhyve with `ktrace` reveals the following sequence:
1.
`openat("/dev/vmmctl", O_RDWR)` → success
2.
`ioctl(VM_MMAP_GETNEXT)` → success
3.
`ioctl(VM_MMAP_MEMSEG)` → **errno 22 (EINVAL)**
The failure is inside `bootrom_alloc()` → `vm_mmap_memseg()` when trying to
map the `VM_BOOTROM` memory segment.
Digging into `lib/libvmmapi/vmmapi.c`, the function `vm_alloc_memseg()`
first calls `vm_get_memseg()` to check if the segment already exists. If it
returns success with `len == 0` (segment not yet allocated), it should
proceed to call
`VM_ALLOC_MEMSEG` ioctl to create the segment. However, `VM_ALLOC_MEMSEG`
is **never called** in the ktrace output.
The result is that `seg->object == NULL` in the kernel when
`vm_mmap_memseg()` is later called for `VM_BOOTROM`, which returns
`EINVAL`.
---
**Workaround found**
---
Replacing `libvmmapi.so.6` (from the Corvin build) with the system stock
`libvmmapi.so.7` fixes the bootrom issue — the VM boots successfully.
However, this introduces a new problem: `bhyvectl --vm=name --create`
returns `Operation not permitted` (EPERM) because the stock libvmmapi uses
different ioctls that vmm.ko Corvin doesn't handle correctly.
What is the correct fix for `vm_alloc_memseg()` in the Corvin libvmmapi to
ensure `VM_ALLOC_MEMSEG` is properly called for `VM_BOOTROM`? Is there a
known patch or workaround that keeps compatibility with vmm.ko Corvin while
fixing the bootrom allocation?
Thanks!
---
*Relevant source: `lib/libvmmapi/vmmapi.c`, function `vm_alloc_memseg()`
and `vm_create_devmem()`*
*vmm kernel side: `sys/dev/vmm/vmm_mem.c`, function `vm_mmap_memseg()`*
--
Mario.