Skip to content

pci_passthru

Alonso Cárdenas edited this page Oct 23, 2025 · 1 revision

PCI passthru

bhyve supports passing of host PCI devices to a virtual machine for its exclusive use of them. You can read more information about it at the following url https://wiki.freebsd.org/bhyve/pci_passthru

Requirements

  • A virtual machine for testing
  • A device with MSI/MSI-x support in the host

Virtual machine for testing

In this guide, I will use a Manjaro Linux guest but any linux-based distribution works too. I have changed some Global Settings entries.

  • cpus: 2
  • memory.size: 3072M
  • memory.wired: true
image

Keep on mind that memory.wired must be changed to true when you want to pass host device to virtual machine guest. Otherwise it will fail. Try to add passthru device to Manajaro from Bhyvemgr, you will see something like the following:

image

The main reason is that no ppt devices was configured in your host. Now, it is time to configure one.

Identify a device with MSI/MSI-x support

We can use pciconf command to identify what device includes MSI/MSI-x support. In this case, a wireless device with MSI support will be used.

# pciconf -lc iwlwifi0

iwlwifi0@pci0:2:0:0:	class=0x028000 rev=0x78 hdr=0x00 vendor=0x8086 device=0x24fd subvendor=0x8086 subdevice=0x0050
    cap 01[c8] = powerspec 3  supports D0 D3  current D0
    cap 05[d0] = MSI supports 1 message, 64 bit enabled with 1 message
    cap 10[40] = PCI-Express 2 endpoint max data 128(128) FLR RO NS
                 max read 128
                 link x1(x1) speed 2.5(2.5) ASPM L1(L1) ClockPM enabled
    ecap 0001[100] = AER 1 0 fatal 0 non-fatal 1 corrected
    ecap 0003[140] = Serial 1 3cf011ffff150ac2
    ecap 0018[14c] = LTR 1
    ecap 001e[154] = L1 PM Substates 1

Pay attention to value after of at symbol (pci0:2:0:0). This value is used to configure a ppt device. We have two ways to mark this device like a ppt one:

Add entry to /boot/loader.conf file

# echo pptdevs="2/0/0" >> /boot/loader.conf

Reboot your host and you will see a ppt0 device instead of iwlwifi0 one (persistent configuration). Using this method, iwlwifi0 device will be available to passthru to virtual machine guests.

Using devctl

# devctl detach pci0:2:0:0
# devctl clear driver -f pci0:2:0:0
# devctl set driver -f pci0:2:0:0 ppt

This method doesn't need reboot your host but you will need run these commands each time you want to use iwlwifi0 device in your guests.

Try to add a passthru device from Bhyvemgr again.

image image

Testing

Time to run Manjaro virtual machine. When it is ready, check if the device was detected from your guest. In my case, I am using a wifi device Intel Wireless 8265 / 8275. It uses an iwlwifi driver.

# dmesg | grep iwlwifi

[    3.725352] iwlwifi 0000:00:0e.0: Detected crf-id 0xbadcafe, cnv-id 0x10 wfpm id 0x80000000
[    3.725410] iwlwifi 0000:00:0e.0: PCI dev 24fd/0050, rev=0x230, rfid=0xd55555d5
[    3.725413] iwlwifi 0000:00:0e.0: Detected Intel(R) Dual Band Wireless AC 8265
[    3.858955] iwlwifi 0000:00:0e.0: loaded firmware version 36.c8e8e144.0 8265-36.ucode op_mode iwlmvm
[    4.211764] iwlwifi 0000:00:0e.0: base HW address: 3c:f0:11:15:0a:c2, OTP minor version: 0x4
[    4.315173] iwlwifi 0000:00:0e.0 wlp0s14: renamed from wlan0
[    5.317995] iwlwifi 0000:00:0e.0: Registered PHC clock: iwlwifi-PTP, with index: 0
# lspci | grep Wireless

00:0e.0 Network controller: Intel Corporation Wireless 8265 / 8275 (rev 78)

Notes

The ppt devices can not be used for two or more guests running in the same time.

Clone this wiki locally