Bug 290920 - FreeBSD 15 Regression: BHyve PCI Passthrough Broken on 15-STABLE (No GSI/Interrupt Remapping Failure)
Summary: FreeBSD 15 Regression: BHyve PCI Passthrough Broken on 15-STABLE (No GSI/Inte...
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-STABLE
Hardware: amd64 Any
: --- Affects Many People
Assignee: Bojan Novković
URL:
Keywords: regression, uefi
Depends on:
Blocks:
 
Reported: 2025-11-09 20:13 UTC by dan
Modified: 2026-09-09 13:05 UTC (History)
20 users (show)

See Also:
markj: needs_errata+


Attachments
Logs/configs (177.94 KB, text/plain)
2025-12-07 01:17 UTC, dan
no flags Details
Potential segment mapping fix (1.45 KB, patch)
2025-12-10 18:11 UTC, Bojan Novković
no flags Details | Diff
vm_iommu_{un}map check fix. (960 bytes, patch)
2025-12-13 15:44 UTC, Bojan Novković
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dan 2025-11-09 20:13:09 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256722

Having same issues as this thread, I normally boot from refind usb stick on r720 to nvme EFI. I have tried freebsd-BETA5, freebsd 15 stable etc nothing seems to work for loader.conf options or kernel options.

I can reboot with 14.3 release or 14 stable kernel and no issues. I can even install freebsd 15 kernel and boot from 14.3 kernel.old fine with all same files in /boot as freebsd 15.

There must be some regression with kernel in 15 up with EFI. For me it hits that framebuffer at beginning of boot, then machine just reboots itself.
Comment 1 Ed Maste freebsd_committer freebsd_triage 2025-11-10 16:06:50 UTC
Unfortunately that does not provide any information to help debug. The EFI framebuffer information is the last thing printed by the loader before the kernel starts booting. The only information we have is that the system restarted before the kernel produced any output.
Comment 2 Dave Hayes 2025-11-10 19:40:01 UTC
So with the same issue hitting 14 and 15 ... what exactly do you need to debug this issue?
Comment 3 dan 2025-11-10 20:40:09 UTC
Yeah it is elusive bug for sure, what I can confirm is it must have been a PR into EFI kernel code itself, as booting FreeBSD 14 kernel with same /boot environment of FreeBSD 15 fixes it. Then again Dell r720 firmware is so old, won't get fixes for any new UEFI code, so problematic for people still running it in home lab.

The only fix I could do for this was to create a FreeBSD 15-BETA5 memstick, set its bios to boot in BIOS mode, boot the USB stick and modify /boot/loader.conf
with vfs.root.mountfrom="zfs:zroot/ROOT/default", to boot from nvme drives. Essentially just getting rid of refind completely and coping my own /boot environment to USB stick.

After more testing on FreeBSD 15-BETA5, I found at least 2 more issues. Modifying /etc/pkg/FreeBSD.conf to pull latest ports, I found programs like dhcpcd to hang, killall dhcpcd does nothing, a firm "kill -9 <of each pid>" was needed.

Last one is quite a serious one with bhyve, same environment for vm-bhyve I had on FreeBSD 14, I can confirm passthrough is broken on guests. In /boot/loader.conf:
pptdevs="9/0/0 10/0/0 66/0/0" works fine, I can confirm the 2 USB ports and nvidia GPU are available for passthrough, however when passing it through on guest it is not working for any of them. 2 USB(zigbee and zwave) sticks are missing on home assistant, and ubuntu VM with nvidia GPU, mind you I had to use FreeBSD 14 stable for nvidia patches.

Checking USB stick passthrough on home assistant:

# dmesg | grep -i xhci
[    0.745789] xhci_hcd 0000:00:06.0: xHCI Host Controller
[    0.748133] xhci_hcd 0000:00:06.0: new USB bus registered, assigned bus number 1
[    0.756495] xhci_hcd 0000:00:06.0: hcc params 0x014051c7 hci version 0x100 quirks 0x0000000100000090
[    0.763687] xhci_hcd 0000:00:06.0: xHCI Host Controller
[    0.766148] xhci_hcd 0000:00:06.0: new USB bus registered, assigned bus number 2
[    0.769165] xhci_hcd 0000:00:06.0: Host supports USB 3.0 SuperSpeed
[    1.500133] xhci_hcd 0000:00:06.0: Host took too long to start, waited 32000 microseconds.
[    1.656982] xhci_hcd 0000:00:06.0: startup error -19
[    1.659106] xhci_hcd 0000:00:06.0: USB bus 2 deregistered
[    1.662286] xhci_hcd 0000:00:06.0: remove, state 1
[    1.670295] xhci_hcd 0000:00:06.0: USB bus 1 deregistered
[    1.671337] xhci_hcd 0000:00:07.0: xHCI Host Controller
[    1.672184] xhci_hcd 0000:00:07.0: new USB bus registered, assigned bus number 1
[    1.678468] xhci_hcd 0000:00:07.0: hcc params 0x014051c7 hci version 0x100 quirks 0x0000000100000090
[    1.680689] xhci_hcd 0000:00:07.0: xHCI Host Controller
[    1.681523] xhci_hcd 0000:00:07.0: new USB bus registered, assigned bus number 2
[    1.682613] xhci_hcd 0000:00:07.0: Host supports USB 3.0 SuperSpeed
[    1.685692] xhci_hcd 0000:00:07.0: Host took too long to start, waited 32000 microseconds.
[    2.412808] xhci_hcd 0000:00:07.0: startup error -19
[    2.414863] xhci_hcd 0000:00:07.0: USB bus 2 deregistered
[    2.417269] xhci_hcd 0000:00:07.0: remove, state 1
[    2.425292] xhci_hcd 0000:00:07.0: USB bus 1 deregistered
[    2.428056] xhci_hcd 0000:00:09.0: xHCI Host Controller
[    2.430338] xhci_hcd 0000:00:09.0: new USB bus registered, assigned bus number 1
[    2.435170] xhci_hcd 0000:00:09.0: hcc params 0x03401281 hci version 0x100 quirks 0x000000000000b930
[    2.440101] xhci_hcd 0000:00:09.0: xHCI Host Controller
[    2.442350] xhci_hcd 0000:00:09.0: new USB bus registered, assigned bus number 2
[    2.445446] xhci_hcd 0000:00:09.0: Host supports USB 3.0 SuperSpeed
[    2.454254] usb usb1: Product: xHCI Host Controller
[    2.456179] usb usb1: Manufacturer: Linux 6.12.51-haos xhci-hcd
[    2.474092] usb usb2: Product: xHCI Host Controller
[    2.476031] usb usb2: Manufacturer: Linux 6.12.51-haos xhci-hcd
[    2.704998] usb 2-1: new SuperSpeed USB device number 2 using xhci_hcd
# dmesg | grep -i usb
[    0.310422] ACPI: bus type USB registered
[    0.311371] usbcore: registered new interface driver usbfs
[    0.312082] usbcore: registered new interface driver hub
[    0.312358] usbcore: registered new device driver usb
[    0.748133] xhci_hcd 0000:00:06.0: new USB bus registered, assigned bus number 1
[    0.766148] xhci_hcd 0000:00:06.0: new USB bus registered, assigned bus number 2
[    0.769165] xhci_hcd 0000:00:06.0: Host supports USB 3.0 SuperSpeed
[    1.659106] xhci_hcd 0000:00:06.0: USB bus 2 deregistered
[    1.670295] xhci_hcd 0000:00:06.0: USB bus 1 deregistered
[    1.672184] xhci_hcd 0000:00:07.0: new USB bus registered, assigned bus number 1
[    1.681523] xhci_hcd 0000:00:07.0: new USB bus registered, assigned bus number 2
[    1.682613] xhci_hcd 0000:00:07.0: Host supports USB 3.0 SuperSpeed
[    2.414863] xhci_hcd 0000:00:07.0: USB bus 2 deregistered
[    2.425292] xhci_hcd 0000:00:07.0: USB bus 1 deregistered
[    2.430338] xhci_hcd 0000:00:09.0: new USB bus registered, assigned bus number 1
[    2.442350] xhci_hcd 0000:00:09.0: new USB bus registered, assigned bus number 2
[    2.445446] xhci_hcd 0000:00:09.0: Host supports USB 3.0 SuperSpeed
[    2.448159] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.12
[    2.451450] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.454254] usb usb1: Product: xHCI Host Controller
[    2.456179] usb usb1: Manufacturer: Linux 6.12.51-haos xhci-hcd
[    2.458520] usb usb1: SerialNumber: 0000:00:09.0
[    2.460786] hub 1-0:1.0: USB hub found
[    2.464830] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    2.468061] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.12
[    2.471267] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.474092] usb usb2: Product: xHCI Host Controller
[    2.476031] usb usb2: Manufacturer: Linux 6.12.51-haos xhci-hcd
[    2.478394] usb usb2: SerialNumber: 0000:00:09.0
[    2.480588] hub 2-0:1.0: USB hub found
[    2.484681] usbcore: registered new interface driver usblp
[    2.487332] usbcore: registered new interface driver usb-storage
[    2.489765] usbcore: registered new interface driver usbserial_generic
[    2.492948] usbserial: USB Serial support registered for generic
[    2.557619] usbcore: registered new interface driver usbhid
[    2.559706] usbhid: USB HID core driver
[    2.704998] usb 2-1: new SuperSpeed USB device number 2 using xhci_hcd
[    2.721813] usb 2-1: New USB device found, idVendor=fb5d, idProduct=0001, bcdDevice= 0.00
[    2.725380] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    2.728498] usb 2-1: Product: HID Tablet
[    2.730828] usb 2-1: Manufacturer: BHYVE
[    2.733740] usb 2-1: SerialNumber: 01
[    2.739082] input: BHYVE HID Tablet as /devices/pci0000:00/0000:00:09.0/usb2/2-1/2-1:1.0/0003:FB5D:0001.0001/input/input4
[    2.745058] hid-generic 0003:FB5D:0001.0001: input,hidraw0: USB HID v10.01 Mouse [BHYVE HID Tablet] on usb-0000:00:

So its like ppt driver not being initialized correctly for passing through 2 USB sticks that works on FreeBSD 14. I have confirmed same problem with FreeBSD 15 stable.

My config on FreeBSD 15 host is: 

router:/usr/local/etc # grep ppt /boot/loader.conf
pptdevs="9/0/0 10/0/0 66/0/0"
router:/usr/local/etc #

9 and 10 are USB sticks for home assistant, 66 is nvidia GPU.

router:/usr/local/etc # grep passthru /vm/ha/ha.conf
passthru0="9/0/0"
passthru1="10/0/0"
router:/usr/local/etc #

router:/usr/local/etc # tail -5 /vm/ubuntu/ubuntu.conf
# Passthru nvidia card
passthru0="66/0/0"
bhyve_options="-A -H -P"
router:/usr/local/etc #

router:/usr/local/etc # tail -10 /vm/ha/vm-bhyve.log
Nov 10 14:14:52:  [primary disk dev: file]
Nov 10 14:14:52: initialising network device tap1
Nov 10 14:14:52: setting mtu of tap1 to 9000
Nov 10 14:14:52: adding tap1 -> br0 (services addm)
Nov 10 14:14:52: bring up tap1 -> br0 (services addm)
Nov 10 14:14:52: booting
Nov 10 14:14:52:  [bhyve options: -c 10,sockets=1,cores=10 -m 16G -AHPw -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd -U a5811c38-567e-11ed-bdeb-e2335bf65f00 -u -S]
Nov 10 14:14:52:  [bhyve devices: -s 0,hostbridge -s 31,lpc -s 4:0,nvme,/vm/ha/disk0.img -s 5:0,virtio-net,tap1,mac=58:9c:11:0c:5a:a9 -s 6:0,passthru,9/0/0 -s 7:0,passthru,10/0/0 -s 8:0,fbuf,tcp=192.168.0.1:5915 -s 9:0,xhci,tablet]
Nov 10 14:14:52:  [bhyve console: -l com1,stdio]
Nov 10 14:14:52: starting bhyve (run 1)
router:/usr/local/etc #

router:/usr/local/etc # pciconf -lv|grep ppt
ppt0@pci0:9:0:0:        class=0x0c0330 rev=0x02 hdr=0x00 vendor=0x1912 device=0x0015 subvendor=0x1912 subdevice=0x0015
ppt1@pci0:10:0:0:       class=0x0c0330 rev=0x02 hdr=0x00 vendor=0x1912 device=0x0015 subvendor=0x1912 subdevice=0x0015
ppt2@pci0:66:0:0:       class=0x030200 rev=0xa1 hdr=0x00 vendor=0x10de device=0x1db4 subvendor=0x10de subdevice=0x1214
router:/usr/local/etc #
Comment 4 dan 2025-11-10 20:57:23 UTC
I am going to snapshot back to FreeBSD 14, I can't live without my passthroughs for my smart home lol.
Comment 5 dan 2025-11-11 01:15:13 UTC
Back on FreeBSD 14 stable:

Home assistant VM:
For zigbee and zwave USB sticks:
# lsusb
Bus 005 Device 001: ID 1d6b:0002 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
Bus 003 Device 001: ID 1d6b:0002 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
Bus 001 Device 001: ID 1d6b:0002 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
Bus 006 Device 001: ID 1d6b:0003 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
Bus 001 Device 002: ID 303a:4001 Nabu Casa ZWA-2
Bus 004 Device 001: ID 1d6b:0003 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
Bus 002 Device 001: ID 1d6b:0003 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
Bus 003 Device 002: ID 10c4:ea60 Itead Sonoff Zigbee 3.0 USB Dongle Plus V2
Bus 006 Device 002: ID fb5d:0001 BHYVE HID Tablet

Ubuntu VM:
With Nvidia GPU:
ubuntu:~ # nvidia-smi
Mon Nov 10 19:12:54 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.95.05              Driver Version: 580.95.05      CUDA Version: 13.0     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  Tesla V100-PCIE-16GB           Off |   00000000:00:06.0 Off |                    0 |
| N/A   82C    P0             55W /  250W |   12778MiB /  16384MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A            1150      C   python3                                1268MiB |
|    0   N/A  N/A            1766      C   /usr/local/bin/ollama                 11506MiB |
+-----------------------------------------------------------------------------------------+
ubuntu:~ #

No issues. Maybe the vmm.ko driver on FreeBSD 15? No idea....
Comment 6 dan 2025-11-11 01:59:40 UTC
sys/dev/vmm/vmm.c is suspect here:

Symptom: The GPU failed with "no GSI" / "can't derive routing". GSI (Global System Interrupt) is a Linux concept, but it means the physical interrupt signal from the passed-through PCI device (GPU or USB controller) is not being correctly mapped by the hypervisor into a signal the guest OS can understand.

Commits touching the core interrupt handling between the host's IOMMU hardware (VT-d/AMD-Vi) and the virtualized environment are the prime suspects. Look for PRs that:

Refactor or clean up the MSI/MSI-X handling within the vmm driver.

Update core IOMMU register access or error handling code.

Change the logic for x2APIC or IO-APIC interrupt injection into the guest.
Comment 7 John Baldwin freebsd_committer freebsd_triage 2025-11-14 17:53:50 UTC
For PCI passthrough, there are several potential things that it would be good to confirm:

1) Is the host an AMD system or Intel?  (I think it's AMD from some of the comments.)

2) For the Nvidia GPU, there was a recent commit in 15:

commit effcd0ded0ef1c92bef29c1e9bbf517c97bb45b8
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: Thu Mar 17 13:11:14 2022 +0100
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: Tue Sep 16 08:55:09 2025 +0200

    bhyve: assign a valid INTPIN to NVIDIA GPUs
    
    When passing an NVIDIA GPU to a Linux VM, the GPU driver refuses to work and
    complains about a missing IRQ:
    
    [ 77.208984] NVRM: Can't find an IRQ for your NVIDIA card!
    [ 77.212697] NVRM: Please check your BIOS settings.
    [ 77.212699] NVRM: [Plug & Play OS] should be set to NO
    [ 77.212700] NVRM: [Assign IRQ to VGA] should be set to YES
    [ 77.212702] nvidia: probe of 0000:00:07.0 failed with error -1
...

However, this commit isn't present in 14.  You could try reverting that commit locally perhaps?

3) For the USB pass through, it would be really handy to have a full Linux dmesg (and lspci output perhaps) inside the guest when booted under 14 vs booted under 15.
Comment 8 Andrey Pevnev 2025-12-03 00:08:04 UTC
I may have a similar issue, not sure yet. Host is a FreeBSD 14.3-STABLE running pfSense as a VM, couple NICs are in passthrough mode from host to VM

ppt0@pci0:7:0:0:        class=0x020000 rev=0x01 hdr=0x00 vendor=0x8086 device=0x10fb subvendor=0x8086 subdevice=0x0003
ppt1@pci0:7:0:1:        class=0x020000 rev=0x01 hdr=0x00 vendor=0x8086 device=0x10fb subvendor=0x8086 subdevice=0x0003
ppt2@pci0:9:0:0:        class=0x020000 rev=0x01 hdr=0x00 vendor=0x8086 device=0x1563 subvendor=0x8086 subdevice=0x0022
ppt3@pci0:9:0:1:        class=0x020000 rev=0x01 hdr=0x00 vendor=0x8086 device=0x1563 subvendor=0x8086 subdevice=0x0022


NICs are both ix driver controlled
 Ethernet Controller X550
 82599ES 10-Gigabit SFI/SFP+ Network Connection

installing 15.0-STABLE (buildworld/installworld/buildkernel/installkernel) and pfSense can no longer see any traffic. VM sees the NICs as before, can see link status going UP/DOWN but absolutely no traffic, no arp, no nothing.

Revert back to 14.3-STABLE (installworld/kernel) - all is good again, no other changes.

Intel CPU
FreeBSD 14.3-STABLE stable/14-n272956-1fbba4fbf0f8 GENERIC amd64
FreeBSD clang version 19.1.7 (https://github.com/llvm/llvm-project.git llvmorg-19.1.7-0-gcd708029e0b2)
VT(efifb): resolution 800x600
CPU microcode: no matching update found
CPU: Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz (2693.68-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x306e4  Family=0x6  Model=0x3e  Stepping=4
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x7fbee3ff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
  AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
  AMD Features2=0x1<LAHF>
  Structured Extended Features=0x281<FSGSBASE,SMEP,ERMS>
  Structured Extended Features3=0x9c000400<MD_CLEAR,IBPB,STIBP,L1DFL,SSBD>
  XSAVE Features=0x1<XSAVEOPT>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID,VID,PostIntr
  TSC: P-state invariant, performance statistics
real memory  = 206158430208 (196608 MB)
avail memory = 200668577792 (191372 MB)
Comment 9 martin.larsson2 2025-12-04 14:30:53 UTC
After upgrading to FreeBSD 15, PCI passthrough of a Fresco Logic FL1100 USB 3.0 Host Controller (pci0:3:0:0) to a bhyve VM no longer functions.
The xHCI device is detected inside the Linux guest (Home Assistant OS), but USB enumeration fails and the controller becomes unresponsive. No USB devices appear (no /dev/ttyUSB*, /dev/ttyACM*, etc.) even when directly attached to the PCI card.

This configuration worked previously on FreeBSD 14.x on the same hardware.

I suspect this is related to recent changes involving bhyve PCI/USB/xHCI handling in FreeBSD 15, as the controller fails at the moment the guest tries to issue commands/drain the command ring.

Environment:

Host OS: FreeBSD 15 (fresh upgrade from 14.x)

Hypervisor: bhyve

Passed through device: Fresco Logic FL1100 USB 3.0 Host Controller
ppt0@pci0:3:0:0 vendor=0x1b73 device=0x1100

Guest OS: Home Assistant OS / Linux kernel 6.12.x

IOMMU/VT-d: Enabled

pptdevs entry in loader.conf:

pptdevs="3/0/0"


USB devices are physically connected to this PCI card (not motherboard USB).

Symptoms inside guest (Linux dmesg):
xhci_hcd 0000:00:06.0: xHCI Host Controller
xhci_hcd 0000:00:06.0: new USB bus registered
xhci_hcd 0000:00:06.0: Host supports USB 3.0 SuperSpeed
...
Workqueue: events xhci_handle_command_timeout
xhci_hcd 0000:00:06.0: Abort failed to stop command ring: -110
xhci_hcd 0000:00:06.0: xHCI host controller not responding, assume dead
xhci_hcd 0000:00:06.0: HC died; cleaning up
usb usb1-port1: couldn't allocate usb_device


lsusb only shows the two root hubs, no devices.
No /dev/serial/by-id, /dev/ttyUSB*, /dev/ttyACM* appears.
Comment 10 Lars Engels freebsd_committer freebsd_triage 2025-12-04 14:32:22 UTC
Having the same issue. Details on virtualization@

https://marc.info/?l=freebsd-virtualization&m=176485824804266&w=2
Comment 11 sporran-musing0p 2025-12-06 05:08:18 UTC
Same issue.
Upgrade 14.3 to 15 broke bhyve passthru.
(yes, homeassistant in bhyve, as many here do).

maybe release of a new bhyve update with the planned xhid per device passthru would be the solution.
I known there is a working patch for that.

would also save us the need to passthru whole controler.
Comment 12 Rich G 2025-12-06 16:03:50 UTC
Same issue for me, upgrading from amd64 14.3-RELEASE-p6 to 15.0-RELEASE using vm-bhyve.  My OPNSense bhyve guest starts without error and the two onboard network devices appear correctly in the guest, but packets don't seem to be moving.

CPU: Intel(R) Xeon(R) CPU E3-1280 V2 @ 3.60GHz
MoBo: Supermicro X9SCI-LN4
Passthru NICs: 2x (of 4) Intel 82574L (em driver)

vm-bhyve guest config file:
loader="bhyveload"
priority="1"
cpu="3"
memory="8G"
disk0_type="nvme"
disk0_name="disk0.img"
uuid="3b52dad1-c916-11ed-a8a9-002590247e86"
passthru0="3/0/0" # LAN
passthru1="5/0/0" # Modem

/boot/loader.conf:
boot_serial="YES"
comconsole_port="0x3e8"
console="comconsole"
autoboot_delay="3"
security.bsd.allow_destructive_dtrace="0"
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
cryptodev_load="YES"
zfs_load="YES"
coretemp_load="YES"
mlx4en_load="YES"
kern.racct.enable="1"
cpu_microcode_load="YES"
cpu_microcode_name="/boot/firmware/intel-ucode.bin"

# PCI passthrough of em2 and em3 to OPNSense
vmm_load="YES"
pptdevs="3/0/0 5/0/0"
Comment 13 Emrion 2025-12-06 16:15:43 UTC
Same here on 15.0-RELEASE. Intel proc, Realtek RTL8111/8168/8211∕8411 PCI NIC.
bhyve passthru ok, but the passthru NIC doesn't work inside the VM.
And, of course, all was perfectly working under 14.3-RELEASE.
Comment 14 dan 2025-12-07 01:17:40 UTC
Created attachment 265939 [details]
Logs/configs

Hi John,

I've created attachment of anything I figure might help be relevant, full commands  with no edits of VMs and main host.

Reason I am running 14 stable is to get at the Corvin patches, which was only committed to 14/15 stable and 16 current, USB passthrough works in 14 release but would fail to pass through nvidia GPU for reasons you listed unless using stable. Hopefully they were included in 15 release.

Appreciate you looking at this, seems a lot of people are having same issue running FreeBSD 15 as main host, seems a lot of people are going to be stuck on 14 unless they running 15 in a VM.
Comment 15 dan 2025-12-07 01:47:50 UTC
I'm not sure if anything else is relevant but I'll include my VM configs and what I have enabled in loader.conf if you can spot a change in 15.

########Home Assistant
/vm/ha/ha.conf:
loader="uefi"
graphics="yes"
graphics_listen="192.168.0.1"
graphics_port="5915"
xhci_mouse="yes"
cpu=10
cpu_sockets=1
cpu_cores=10
memory=16G
network0_type="virtio-net"
network0_switch="services"
disk0_type="nvme"
disk0_name="disk0.img"
# bhyve pci interrupt passthrough attempt fix on freebsd 15
#x2apic="yes"
uuid="a5811c38-567e-11ed-bdeb-e2335bf65f00"
network0_mac="58:9c:11:0c:5a:a9"
passthru0="9/0/0"
passthru1="10/0/0"

#######Ubuntu VM with Nvidia card passthrough
loader="uefi"
graphics="yes"
graphics_listen="192.168.0.1"
graphics_port="5906"
xhci_mouse="yes"
cpu=10
cpu_sockets=1
cpu_cores=10
memory=32G
network0_type="virtio-net"
network0_switch="services"
disk0_type="nvme"
disk0_name="disk0.img"
uuid="61496056-8da5-11ee-906d-e4434bf65f00"
network0_mac="58:9c:fc:0e:25:3f"
passthru0="66/0/0"
bhyve_options="-A -H -P"

######Loader.conf
/boot/loader.conf:
comconsole_speed="115200"
boot_multicons="YES"
boot_serial="YES"
vfs.root.mountfrom="zfs:zroot/ROOT/default"
kernels="kernel kernel.old"
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
cryptodev_load="YES"
zfs_load="YES"
#bhyve
#only need this one for AMD systems and put before vmm_load
#hw.vmm.amdvi.enable=1
vmm_load="YES"
nmdm_load="YES"
if_bridge_load="YES"
if_tap_load="YES"
#these needed for windows
hw.usb.usbhid.enable="1"
usbhid_load="YES"
pptdevs="9/0/0 10/0/0 66/0/0"
cc_htcp_load="YES"
cc_cubic_load="YES"
cc_dctcp_load="YES"
#NetFlix TCP RACK STACK
#tcp_rack_load="YES"
#net.link.ifqmaxlen=2048
#net.inet.tcp.soreceive_stream=1
vfs.zfs.arc.max=37748736000
Comment 16 Emrion 2025-12-07 11:35:18 UTC
(In reply to Emrion from comment #13)
I worked on the subject. I have to clarify what is this VM. It's a pfSense one, version 2.7.2-RELEASE (so, not up-to-date but that's not important). I don't use vm-bhyve, just bhyve command line.

The realtek NIC is set for DHCP, it's the "wan" side for the pfSense VM.

There is something random in this regression as most of the time, the NIC doesn't get an ip, but not always (I saw that with numerous tries to stop and restart the VM). Often, I have no connectivity despite it has a valid ip address, but in some occasions all seems to properly function.

What I've seen in the dmesg of the pfSense VM is, when it fails:
SRAT: Ignoring memory at addr 0xff000000
SRAT: Ignoring memory at addr 0xffc84000

I don't know if it's relevant.
Comment 17 martin.larsson2 2025-12-10 08:01:36 UTC
just FYI, the patch from https://marc.info/?l=freebsd-virtualization&m=176531257403805&w=2 worked for me. HASS(home assistant linux) usb over pci passthrough works again
Comment 18 John Baldwin freebsd_committer freebsd_triage 2025-12-10 15:08:43 UTC
(In reply to martin.larsson2 from comment #17)
Thanks for this detail.  I've added the author of the commit, but I'm not sure yet if we want to just restore the ordering or if we need to fix the kernel side to not care about the ordering.
Comment 19 Emrion 2025-12-10 17:26:16 UTC
(In reply to martin.larsson2 from comment #17)

Alas, it doesn't work in my case.
Once applyed, pfSense hangs on "Configuring Wan interface..." (the pass-thrued interface).
A ctrl-c puts pfSense in single user mode (?).
In a sense, it's worse than without the patch.

This patch may help in some configurations, but it's not the solution.
Comment 20 Bojan Novković freebsd_committer freebsd_triage 2025-12-10 18:11:26 UTC
Created attachment 266072 [details]
Potential segment mapping fix

Would you giving this patch a spin?
I am not sure if it'll fix the issue but it will definitely help narrow things down.
Comment 21 Emrion 2025-12-10 20:22:13 UTC
(In reply to Bojan Novković from comment #20)

Your patch works in the sense that the VM doesn't hang anymore.
However, I have the same problem as before. Sometimes the VM can access to the network and sometimes not.

I also tried a libvmmapi version with your commits 08c7dd2 and a4197ea reverted: same result.

I retried under 14.3-RELEASE and there is no trouble, that works 100% of the time.

So, I think that my problem is different, but related to changes in 15.0-RELEASE concerning virtualisation with bhyve.
Comment 22 dan 2025-12-11 07:01:57 UTC
(In reply to martin.larsson2 from comment #17)

Thanks Martin, I applied patch to FreeBSD 15 stable, now everything works again, home assistant passthroughs for USB, corvin for nvidia card.
Comment 23 dan 2025-12-11 08:35:53 UTC
(In reply to Bojan Novković from comment #20)

I appreciate you sending the patch. I tested it by first reverting my local vmmapi.c to the unpatched original, then rebuilding both libvmmapi and bhyve to ensure a fresh link:

Test Procedure:
cd /usr/src/lib/libvmmapi
make clean
cp vmmapi.c.old vmmapi.c # Revert to unpatched original
patch -p1 -d /usr/src < /root/freebsd-usb2.patch # Apply your patch
make && make install
cd /usr/src/usr.sbin/bhyve
make clean
make && make install

I have completed testing of your proposed patch for libvmmapi.c (using GPA as offset).

The testing confirms that the ordering of memory segment mapping remains the critical factor for my environment, and the proposed GPA-based offset patch introduces a new issue.

TEST RESULTS SUMMARY:

1. Your Patch (GPA Offset applied):
   - VM Boots: Yes
   - Passthrough Works: No
   - Guest Error Observed: PCI INT A: no GSI (interrupt routing failure)

2. Original Patch (High -> Low Ordering re-applied for verification):
   - VM Boots: Yes
   - Passthrough Works: Yes (Full functionality restored for GPU and USB)

CONCLUSION:

The original patch that forces the High Memory segment to be mapped before the Low Memory segment successfully resolves the passthrough issue on my updated 15.0 system.

The failure of the GPA-based patch to correctly set up the PCI interrupt routing (PCI INT A: no GSI) suggests that the explicit High -> Low ordering of the map updates is required by the VMM or IOMMU for proper initialization of passthrough devices, overriding any need for the GPA offset correction in this configuration.

I will continue using the ordering patch for now.
Comment 24 dan 2025-12-11 20:13:12 UTC
Feel free to submit any other patches for testing, I'll try to run them here locally to get this resolved. Would be nice to get at root cause so ordering does not get broken again for sure.

I would really love to see this and corvin patches make it into Release p1 and appreciate the effort.
Comment 25 Bojan Novković freebsd_committer freebsd_triage 2025-12-13 15:44:22 UTC
Created attachment 266160 [details]
vm_iommu_{un}map check fix.

(In reply to dan from comment #24)
Thank you, your help is greatly appreciated since I do not have a good way of testing potential fixes right now.

Speaking of potential fixes, I have another patch for you, this time a fix for a bug that was introduced in `vmm.c` between the releases. Please let me know if it helps.
Comment 26 Nuno Subtil 2025-12-13 16:06:18 UTC
(In reply to Bojan Novković from comment #25)

> Speaking of potential fixes, I have another patch for you, this time a fix for a bug that was introduced in `vmm.c` between the releases. Please let me know if it helps.

This patch seems to work for me. My test case is exposing a single NV GPU to a Linux VM.

(I had similar results otherwise as dan: the patch from https://marc.info/?l=freebsd-virtualization&m=176531257403805&w=2 also works, your earlier patch from comment #20 did not.)
Comment 27 dan 2025-12-14 02:51:47 UTC
(In reply to Bojan Novković from comment #25)

Works perfectly, thank you!

This patch successfully resolves the PCI passthrough failure (previously observed as 'PCI INT A: no GSI') for multiple device types, confirming the IOMMU mapping issue in vmm.c is corrected.

Testing Confirms Passthrough for:
* **NVIDIA GPU Passthrough** (Tesla V100)
* **USB Controller Passthrough** (via a PCI-e USB controller hosting Zigbee/Z-Wave dongles)

---

**Testing Procedure**
The environment was fully synchronized after patching vmm.c and reverting the previous libvmmapi workaround.

    1. Reverted local libvmmapi.c change to original source (restoring the userland to a clean state).
    2. Cleaned source, applied the new kernel patch, built, and installed.
    
    cd /usr/src
    git pull
    make clean cleanworld
    patch -p1 -d /usr/src < /root/freebsd-usb3.patch
    make -j$(sysctl -n hw.ncpu) buildworld
    make -j$(sysctl -n hw.ncpu) buildkernel
    make installkernel
    shutdown -r now
    etcupdate -p
    cd /usr/src; make installworld
    etcupdate -B
    make -DBATCH_DELETE_OLD_FILES delete-old delete-old-libs
    # Reverted the kernel patch for clean future git pulls:
    patch -p1 -R -d /usr/src < /root/freebsd-usb3.patch
    shutdown -r now

---

**Results (Inside Linux Guest VM)**

**1. GPU Passthrough Validation (nvidia-smi)**
    
    ubuntu:/data/remote/sunsaturn/home/dan # nvidia-smi
    Sat Dec 13 20:48:48 2025
    +-----------------------------------------------------------------------------------------+
    | NVIDIA-SMI 580.95.05        Driver Version: 580.95.05      CUDA Version: 13.0       |
    +-----------------------------------------+------------------------+----------------------+
    | GPU  Name                   Persistence-M | Bus-Id         Disp.A | Volatile Uncorr. ECC |
    | Fan  Temp             Perf          Pwr:Usage/Cap |            Memory-Usage | GPU-Util  Compute M. |
    |                                             |                        |              MIG M. |
    |=========================================+========================+======================|
    |   0  Tesla V100-PCIE-16GB              Off |   00000000:00:06.0 Off |                    0 |
    | N/A   49C    P0                  46W /  250W |    1272MiB /  16384MiB |      0%      Default |
    |                                             |                        |              N/A |
    +-----------------------------------------+------------------------+----------------------+
    
    +-----------------------------------------------------------------------------------------+
    | Processes:                                                                              |
    |  GPU   GI  CI               PID   Type  Process name                          GPU Memory |
    |        ID  ID                                                                    Usage |
    |=========================================================================================|
    |    0  N/A N/A             1193     C  python3                                1268MiB |
    +-----------------------------------------------------------------------------------------+
    ubuntu:/data/remote/sunsaturn/home/dan #
    

**2. USB Passthrough Validation (lsusb output)**
    
    # lsusb
    Bus 005 Device 001: ID 1d6b:0002 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
    Bus 003 Device 001: ID 1d6b:0002 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
    Bus 001 Device 001: ID 1d6b:0002 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
    Bus 006 Device 001: ID 1d6b:0003 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
    Bus 001 Device 002: ID 303a:4001 Nabu Casa ZWA-2
    Bus 004 Device 001: ID 1d6b:0003 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
    Bus 002 Device 001: ID 1d6b:0003 Linux 6.12.51-haos xhci-hcd xHCI Host Controller
    Bus 003 Device 002: ID 10c4:ea60 Itead Sonoff Zigbee 3.0 USB Dongle Plus V2
    Bus 006 Device 002: ID fb5d:0001 BHYVE HID Tablet
    #

This fix appears ready for commitment.
Comment 28 martin.larsson2 2025-12-15 13:39:18 UTC
I tried the latest patch without the others as well, and this worked best for me.
While the first one "worked" I noticed that about every third time i got I/O error  on usb devices on linux. This worked right away.
Comment 29 commit-hook freebsd_committer freebsd_triage 2025-12-15 15:44:27 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f1809eab82a796845f126b703c01d4a31ccf2193

commit f1809eab82a796845f126b703c01d4a31ccf2193
Author:     Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2025-12-13 14:53:45 +0000
Commit:     Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2025-12-15 15:41:57 +0000

    amd64/vmm.c: Fix an incorrect memory segment check in vm_iommu_{un}map

    This change fixes two checks that conflated memory mapping and memory
    segment idenitifers. In both cases the code iterates over all memory
    mappings but passes the index to `vm_memseg_sysmem`, which is wrong.

    Fix this by passing the memory mapping's segment identifier instead.

    Differential Revision:  https://reviews.freebsd.org/D54210
    Reviewed by:    markj
    Fixes:  c76c2a19ae37
    PR:     290920

 sys/amd64/vmm/vmm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Comment 30 commit-hook freebsd_committer freebsd_triage 2025-12-15 15:47:33 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4f7436bf297b93fd9e835ffca3d56288ce934dc5

commit 4f7436bf297b93fd9e835ffca3d56288ce934dc5
Author:     Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2025-12-13 14:53:45 +0000
Commit:     Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2025-12-15 15:47:00 +0000

    amd64/vmm.c: Fix an incorrect memory segment check in vm_iommu_{un}map

    This change fixes two checks that conflated memory mapping and memory
    segment idenitifers. In both cases the code iterates over all memory
    mappings but passes the index to `vm_memseg_sysmem`, which is wrong.

    Fix this by passing the memory mapping's segment identifier instead.

    Differential Revision:  https://reviews.freebsd.org/D54210
    Reviewed by:    markj
    Fixes:  c76c2a19ae37
    PR:     290920

    (cherry picked from commit f1809eab82a796845f126b703c01d4a31ccf2193)

 sys/amd64/vmm/vmm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Comment 31 Andrey Pevnev 2025-12-15 19:29:26 UTC
Tested good with NICs pass thru to pfSense VM, thank you!
Comment 32 martin.larsson2 2025-12-16 08:24:05 UTC
is it possible to get a patch fix for this to 15.0-RELEASE? I mean an official one that we can get with freebsd-update
Comment 33 Mark Johnston freebsd_committer freebsd_triage 2025-12-16 13:46:11 UTC
(In reply to martin.larsson2 from comment #32)
Yes, we will release an erratum patch for this soon.
Comment 34 martin.larsson2 2025-12-16 13:54:17 UTC
(In reply to Mark Johnston from comment #33)

thank you! and for the patch work!
Comment 35 Emrion 2025-12-16 17:15:36 UTC
Sorry, but the last patch doesn't work for me (both patches have been applied).
VM pfSense, realtek NIC, intel i5.
If you need more details or logs, please ask me.
Comment 36 Andrey Pevnev 2025-12-16 17:22:06 UTC
(In reply to Emrion from comment #35)
Don't apply anything manually, just git pull the latest stable/15 and rebuild
Comment 37 Emrion 2025-12-16 17:45:13 UTC
Hum, I'm on 15.0-RELEASE and don't want to join the STABLE branch on this machine.

I applied your patches on the 15.0-RELEASE sources. The patches applied without error and I compiled successfully vmm.ko and libvmmapi.so.7.

I just used make & make install. Is it not the way to go?
Comment 38 Andrey Pevnev 2025-12-16 18:04:58 UTC
(In reply to Emrion from comment #37)
Try just this one https://cgit.freebsd.org/src/commit/?id=4f7436bf297b93fd9e835ffca3d56288ce934dc5
Comment 39 commit-hook freebsd_committer freebsd_triage 2025-12-16 23:43:09 UTC
A commit in branch releng/15.0 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=04e9f1aab83a00e5b61aaed50fabf1cd69fb01cf

commit 04e9f1aab83a00e5b61aaed50fabf1cd69fb01cf
Author:     Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2025-12-13 14:53:45 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-12-16 16:01:22 +0000

    amd64/vmm.c: Fix an incorrect memory segment check in vm_iommu_{un}map

    This change fixes two checks that conflated memory mapping and memory
    segment idenitifers. In both cases the code iterates over all memory
    mappings but passes the index to `vm_memseg_sysmem`, which is wrong.

    Fix this by passing the memory mapping's segment identifier instead.

    Differential Revision:  https://reviews.freebsd.org/D54210
    Reviewed by:    markj
    Fixes:  c76c2a19ae37
    PR:     290920
    Approved by:    so
    Security:       FreeBSD-EN-25:20.vmm

    (cherry picked from commit f1809eab82a796845f126b703c01d4a31ccf2193)
    (cherry picked from commit 4f7436bf297b93fd9e835ffca3d56288ce934dc5)

 sys/amd64/vmm/vmm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Comment 40 Mark Johnston freebsd_committer freebsd_triage 2025-12-16 23:48:46 UTC
(In reply to Emrion from comment #37)
Note that installing from sys/modules/vmm will put the module in /boot/modules/ by default, and kldload will still prefer /boot/kernel/vmm.ko.
Comment 41 Emrion 2025-12-17 07:04:29 UTC
(In reply to Mark Johnston from comment #40)
That's the problem, I think. The second patch seems to not work too, but I never checked what actual module is loaded.
Anyway, I will update tonight and I will test once more.
Thanks.
Comment 42 Emrion 2025-12-17 18:13:46 UTC
The update to p1, thus the patch, works here as well.

I didn't know that a 'make install' doesn't update /boot/kernel files. It's weird for me...

Just after have compiled vmm.ko, I tested it with kldload /usr/obj/...
At this point, all was working, but to complete my test, I always rebooted after 'make install'. So, the non-patched vmm.ko was loaded in memory, making me believed the patch doesn't work.

Sorry for that.
Comment 43 dan 2026-04-16 12:41:14 UTC
While the previous patch works for single GPU passthrough (e.g. ~16GB VRAM devices), issues are observed when passing through larger VRAM GPUs or multiple GPUs simultaneously.

In these cases, the current static sizing of the bhyve PCI 64-bit MMIO window and the OVMF PCI MMIO allocation window becomes insufficient, leading to PCI BAR allocation failures during device assignment.

The changes below work as a workaround by increasing both the bhyve PCI EMUL_MEMSIZE64 and the OVMF PcdPciMmio64Size values. However, these values are currently implemented as fixed build-time constants.

From an upstream perspective, a more flexible approach would likely be required, such as per-VM configuration or dynamic sizing based on assigned PCI device BAR requirements,
as modern GPUs and multi-device passthrough increasingly exhaust the default MMIO window.

A value of 256GB was chosen empirically to accommodate multiple high-VRAM GPUs without encountering MMIO exhaustion in testing.

Workaround / Implementation Notes
Custom UEFI build (edk2-bhyve)

cd /usr/ports/sysutils/edk2
make clean
make FLAVOR=bhyve extract
rm files/patch-OvmfPkg_Bhyve_BhyveX64.dsc
cd work-bhyve/edk2-edk2-stable202508
cp OvmfPkg/Bhyve/BhyveX64.dsc OvmfPkg/Bhyve/BhyveX64.dsc.orig

Modify OvmfPkg/Bhyve/BhyveX64.dsc:

Change:
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x800000000

To:
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x8000000000

Then:

cd /usr/ports/sysutils/edk2
make FLAVOR=bhyve makepatch
cat files/patch-OvmfPkg_Bhyve_BhyveX64.dsc
make FLAVOR=bhyve clean
make FLAVOR=bhyve

Copy resulting firmware:
cp /usr/local/share/edk2-bhyve/BHYVE_UEFI.fd /vm/.config/

(In vm-bhyve config, set loader="uefi-custom")

bhyve patch (MMIO window increase)

cd /usr/src/usr.sbin/bhyve

Modify pci_emul.c:

Change:
#define PCI_EMUL_MEMSIZE64 (32*GB)

To:
#define PCI_EMUL_MEMSIZE64 (256*GB)

Then rebuild:

make clean
make -j$(sysctl -n hw.ncpu)
make install

Notes

This change increases the default PCI 64-bit MMIO aperture used for passthrough devices. It resolves BAR allocation failures observed with high-VRAM GPUs and multi-GPU passthrough setups,
but may not be appropriate as a universal default without further tuning or per-VM configurability.
Comment 44 dan 2026-04-16 13:04:13 UTC
Copy resulting firmware should read:
cp /usr/ports/sysutils/edk2/work-bhyve/stage/usr/local/share/edk2-bhyve/BHYVE_UEFI.fd /vm/.config/


I decided to get another nvidia v100 this time 32gb to add to my existing 16gb v100 in my server. I was amazed to see 32gb would not work at all without UEFI patch, and both GPUS would not work without bhyve patch, I hope this helps everyone. Hopefully these values can be made dynamic.
Comment 45 Paolo Invernizzi 2026-08-18 14:57:45 UTC
Another data point, this time on Intel, with a card generation that does not appear in this PR yet.

Summary: the December fix (D54210 / FreeBSD-EN-25:20.vmm) is present in the build I tested and does not fix this case. Same machine, same guest disk image, same NVIDIA driver: passthrough works on 14.2, fails on stock 15.1 with the "no GSI" signature described in this PR.

Hardware
  Host CPU: Intel Core i9-14900K (VT-d), HP Omen 45L
  GPU: NVIDIA GeForce RTX 4080 SUPER, AD103 [10de:2702], subsystem [103c:8cfd]
  Passed through with vm-bhyve: pptdevs="1/0/0 1/0/1", passthru0="1/0/0=2:0", passthru1="1/0/1=2:1"
  bhyve options: -c 8,sockets=1,cores=8,threads=1 -m 16GB -AHPw -U <uuid> -u -S

Host A (works): 14.2-RELEASE built from stock releng/14.2 plus exactly two patches from Corvin Koehne's phab/corvink/14.2/nvidia-wip branch ("apply nvidia gpu bar 0 quirk" and "add dummy read for nvidia gpu bar 0 mirror"). Nothing else.

Host B (fails): 15.1-RELEASE-p2 built from stock releng/15.1 (aadd58dddcbc, 2026-07-28), no patches. I verified that 4f7436bf297b93fd9e835ffca3d56288ce934dc5 (the vm_iommu_{un}map segment fix) is in this tree and that vm_iommu_map calls vm_memseg_sysmem(vm, mm->segid).

Guest evidence, identical guest in both cases (Ubuntu 24.04, driver 595.71.05):

  on 14.2
    /sys/bus/pci/devices/0000:00:02.0/msi_irqs -> 37
    /proc/interrupts -> "37: ... PCI-MSI-0000:00:02.0 0-edge nvidia"
    lspci -vv -> "Interrupt: pin A routed to IRQ 37"
    nvidia-smi -> GeForce RTX 4080 SUPER, 16376 MiB

  on 15.1
    /sys/bus/pci/devices/0000:00:02.0/msi_irqs -> empty
    /proc/interrupts -> no nvidia line
    lspci -vv -> "Interrupt: pin A routed to IRQ -2147483648"
    dmesg -> "nvidia 0000:00:02.0: can't derive routing for PCI INT A" / "PCI INT A: no GSI"
    dmesg -> "NVRM: GPU 0000:00:02.0: RmInitAdapter failed! (0x25:0x40:1776)"
    nvidia-smi -> "No devices were found"

The host side looks healthy on 15.1: vmm.ko loaded, ppt0/ppt1 attached, hw.vmm.iommu.initialized=1. No MSI vector is ever allocated in the guest.

Ruled out by testing on the failing host:
  - Guest OS and driver: Ubuntu 24.04 (kernel 6.8) with 580.159.03 and with 595.71.05, and Ubuntu 26.04 (kernel 7.0.0-28) with 595.71.05. Identical failure in all three.
  - Boot path: grub-bhyve direct kernel boot and UEFI bootrom (edk2-bhyve BHYVE_UEFI.fd).
  - Device state: full host reboot with the card not previously claimed by any guest.
  - bhyve userland: 15.1 carries only the INTPIN half of the NVIDIA quirk in pci_passthru_quirks.c. I ported the BAR 0 config-space-mirror trap from the 14.2 branch onto 15.1's passthru_set_bar_handler() framework. It is exercised (bhyve burns ~500% CPU on the trapped page) but the failure is unchanged. Note also that reverting the INTPIN assignment would not match the working setup: on 14.2 the guest also sees pin A.
  - MMIO window (comment #43): single GPU with a 16 GiB BAR, correctly assigned at 0x800000000, so the PCI_EMUL_MEMSIZE64 / PcdPciMmio64Size exhaustion does not apply here.

So on this Intel host the remaining difference between working and broken is the MSI setup path in vmm itself.

I am happy to act as a test bench. The machine is a development box with boot environments for both worlds, it rebuilds a kernel in about 20 minutes and switches between them with one reboot, and it has a ready Ubuntu 26.04 UEFI guest for testing. If a patch or an instrumented kernel would help, send it my way and I will report back.
Comment 46 Dries Michiels freebsd_committer freebsd_triage 2026-09-09 09:53:00 UTC
Today I got bitten by this bug aswell. Whats the status exactly thats blocking its commit?
Comment 47 Dries Michiels freebsd_committer freebsd_triage 2026-09-09 10:05:27 UTC
(In reply to Dries Michiels from comment #46)
I also have recent hardware as mentioned by Paolo, I also have the same bug and debug path followed as him.

Intel i7 14770k + nvidia A400 passing through to a debian virtual machine on STABLE-15.
Comment 48 Paolo Invernizzi 2026-09-09 10:26:00 UTC
I bisected it. Patch below, two lines in sys/amd64/vmm/x86.c, running here on releng/15.1 since August.

Correction to comment 45: my 14.2 tree also had bhyve_id changed to "KVMKVMKVM\0\0\0". That is required on this card: the NVIDIA driver only accepts Xen, VMware, Hyper-V and KVM ids, otherwise RmInitAdapter fails with 0x25:0x40:1776. No way around it.

With the KVM id, the first bad commit is e77e112a3e20 (advertise CPUID_BHYVE_FEAT_EXT_DEST_ID in leaf 0x40000001). Under a KVM id Linux reads that bit as KVM_FEATURE_CLOCKSOURCE, enables kvmclock and dies before console init. Clearing the bit, or booting the guest with no-kvmclock, fixes it. The MSI decode changes themselves are fine.

The patch is a hack, not a fix. Gating the leaf on bhyve's own id, or a per-VM hypervisor id option, would be the proper thing. I can test patches quickly here.

--- a/sys/amd64/vmm/x86.c
+++ b/sys/amd64/vmm/x86.c
@@ -53,7 +53,7 @@
-static const char bhyve_id[12] = "bhyve bhyve ";
+static const char bhyve_id[12] = "KVMKVMKVM\0\0\0";
@@ -612,7 +612,7 @@ x86_emulate_cpuid
              case CPUID_BHYVE_FEATURES:
-                     regs[0] = CPUID_BHYVE_FEAT_EXT_DEST_ID;
+                     regs[0] = 0; /* No features to advertise yet */
Comment 49 Dries Michiels freebsd_committer freebsd_triage 2026-09-09 13:05:23 UTC
Thanks! I just applied your patch, rebuild source and voila, A400 detected and showin in nvidia-smi. Thanks!