bhyve usb passthrough - bhyve windows 10 guest

Hello everybody,
I recently installed windows 10 on 13.1 freebsd host following the instructions in the excelent article From 0 to Bhyve on FreeBSD 13.1 from klarasystems.com, except that I don't use the recommended desktop, but instead I use the i3 windows manager.
Everything works fine but I don't have access to usb devices from the windows guest.
Here is my /boot/loader.conf modified by adding the last two lines
Code:
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
cryptodev_load="YES"
zfs_load="YES"
kern.vty=vt
vmm_load="YES"
nmdm_load="YES"
#if_bridge_load="YES"
#if_tap_load="YES"
hw.vmm.amdvi.enable=1
pptdevs="3/0/3 3/0/4"
Here the result of the vm passthru
Code:
DEVICE     BHYVE ID     READY        DESCRIPTION
hostb0     0/0/0        No           Raven/Raven2 Root Complex
amdiommu0  0/0/2        No           Raven/Raven2 IOMMU
hostb1     0/1/0        No           Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
pcib1      0/1/2        No           Raven/Raven2 PCIe GPP Bridge [6:0]
pcib2      0/1/3        No           Raven/Raven2 PCIe GPP Bridge [6:0]
hostb2     0/8/0        No           Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
pcib3      0/8/1        No           Raven/Raven2 Internal PCIe GPP Bridge 0 to Bus A
pcib4      0/8/2        No           Raven/Raven2 Internal PCIe GPP Bridge 0 to Bus B
intsmb0    0/20/0       No           FCH SMBus Controller
isab0      0/20/3       No           FCH LPC Bridge
hostb3     0/24/0       No           Raven/Raven2 Device 24: Function 0
hostb4     0/24/1       No           Raven/Raven2 Device 24: Function 1
hostb5     0/24/2       No           Raven/Raven2 Device 24: Function 2
hostb6     0/24/3       No           Raven/Raven2 Device 24: Function 3
hostb7     0/24/4       No           Raven/Raven2 Device 24: Function 4
hostb8     0/24/5       No           Raven/Raven2 Device 24: Function 5
hostb9     0/24/6       No           Raven/Raven2 Device 24: Function 6
hostb10    0/24/7       No           Raven/Raven2 Device 24: Function 7
re0        1/0/0        No           RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
none0      2/0/0        No           RTL8821CE 802.11ac PCIe Wireless Network Adapter
vgapci0    3/0/0        No           Picasso/Raven 2 [Radeon Vega Series / Radeon Vega Mobile Series]
hdac0      3/0/1        No           Raven/Raven2/Fenghuang HDMI/DP Audio Controller
none1      3/0/2        No           Family 17h (Models 10h-1fh) Platform Security Processor
ppt0       3/0/3        Yes          Raven USB 3.1
ppt1       3/0/4        Yes          Raven USB 3.1
none2      3/0/5        No           ACP/ACP3X/ACP6x Audio Coprocessor
hdac1      3/0/6        No           Family 17h/19h HD Audio Controller
none3      3/0/7        No           Raven/Raven2/Renoir Non-Sensor Fusion Hub KMDF driver
ahci0      4/0/0        No           FCH SATA Controller [AHCI mode]
Here is the content of my uefi.conf.
Code:
:
loader="uefi"
graphics="yes"
xhci_mouse="yes"

cpu=2
cpu_sockets=1
cpu_cores=2

memory=4G

ahci_device_limit="8"

#network0_type="e1000"
network0_type="virtio-net"
network0_switch="public"

disk0_type="nvme"
disk0_name="disk0.img"

disk1_type="ahci-cd"
disk1_dev="custom"
disk1_name="/zroot/bhyve/virtio-win-0.1.221.iso"


passthru0="3/0/3"
passthru1="3/0/4"


utctime="no"
I don't know which the correct syntax for passthru should be.
I also tried something like
Code:
:
passthru0="3/0/3=0:8"
passthru1="3/0/4=0:8"
with no success.
(On windows guest on Device Manager/xhci usb I have: Bus/Device/Function 0/8/0)
I mention that I use an HP 255 G7 AMD Ryzen 3 laptop.

Thanks in advance for any help.
 
Thanks for reply, SirDice
As I mentioned I don't use vbox, but bhyve and I understand that it is possible to passthrough usb devices with bhyve, but I don't know how to do it, especially how to edit the uefi.conf file. I don't know the correct syntax for
Code:
passthru0="..."
on uefi.conf.
Is necessary to write a
Code:
passthruX="..."
for each usb device listed in the result of vm passthru?
Are there devices that I should pass through besides those obviously labeled with "USB" ?
 
Oops. Only read USB pass-through, and remembered that other thread. Completely missed the bhyve(8) part of the question 😪
 
crinx , take a look at the discussions here, maybe it will help somehow:
 
Thanks for replying, _al.
Still no success. I didn't find yet an example of a conf file with more devices that are passed through.
In the second link you provided
Code:
passthru0="0/20/0"
I also found an example of conf file at github.com/churchers/vm-bhyve/sample-templates/config.sample where the syntax is
Code:
passthru0="6/0/0=2:0"
Which one is correct? But what if there are more devices for passing through?
 
I don't use vm(8) , so I can't help here. I use bhyve(8) directly.

I have two dedicated PCI devices (which I don't use on the host):
Code:
pciconf -vl
...
xhci2@pci0:134:0:0: class=0x0c0330 rev=0x03 hdr=0x00 vendor=0x1912 device=0x0014
subvendor=0x1912 subdevice=0x0014
vendor  = 'Renesas Technology Corp.'
device  = 'uPD720201 USB 3.0 Host Controller'
class  = serial bus
subclass  = USB

xhci3@pci0:216:0:0: class=0x0c0330 rev=0x03 hdr=0x00 vendor=0x1912 device=0x0014
subvendor=0x1912 subdevice=0x0014
vendor  = 'Renesas Technology Corp.'
device  = 'uPD720201 USB 3.0 Host Controller'
class  = serial bus
subclass  = USB

Devices are passed thru
(/boot/loader.conf) :
Code:
pptdevs="134/0/0 216/0/0"
And I start the virtual machine like this:
Code:
bhyve -c 8,sockets=2,cores=2,threads=2 -m 16G -H -w -S \
-s 0,hostbridge \
-s 3,ahci-cd,/neat/iso/Win10_21H1_Russian_x64.iso \
-s 4,ahci-hd,/neat/bsd1/vms/w10.img \
-s 5,virtio-net,tap0 \
-s 7,passthru,134/0/0 \
-s 9,passthru,216/0/0 \
-s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1200,wait \
-s 30,xhci,tablet \
-s 31,lpc \
-l com1,stdio \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
w10

Since you use a laptop, a solution with separate (dedicated) PCI USB XHCI devices will not work for you.

Which one is correct?
As for the syntax, I would look into the sysutils/vm-bhyve port source code.
 
passthru0="6/0/0=2:0"
Maybe you solved this but my guess is because of the slot number to passthru. Choose a bigger number like 20 just to test out.

Like this:
Code:
passthru="6/0/0=20:0"

The problem with vm-bhyve (AFAIK) is that you don't quite know which slots are being used... Or at least I don't know how to check that.

if not you could pass a direct bhyve option like:
Code:
bhyve_options="-s 8,hda,play=/dev/dsp1,rec=/dev/dsp1"

or in your case something like
Code:
bhyve_options="-s 9,passthru,216/0/0"
 
Hello Forum,
I finally manage to passthrough usb to the win10 guest.
Here is what worked for me:
After carefully reading wiki/freebsd.org/bhyve/pci_passthru (paying attention this time even to the LAST SENTENCE), in the /boot/loader.conf I reversed the order of two lines, namely, I put
Code:
hw.vmm.amdvi.enable=1
BEFORE
Code:
vmm_load="YES"
.
In uefi.conf I passed
Code:
passthru0="3/0/3=9:0"
And now it works.
This also works on another computer (not a laptop this time) with amd ryzen cpu also, on which I experienced initially the same problem.
So, I consider this problem solved, with an important takeaway for me: we need to read the excellent freebsd documentation carefully to the end.
 
Back
Top