# bhyve passthrough USB controller



## SemFLY (Sep 30, 2018)

Hi 

I have motherboard and internal USB controller


```
# pciconf -lv | grep -B2 USB
xhci0@pci0:0:20:0:      class=0x0c0330 card=0x85341043 chip=0x8cb18086 rev=0x00 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '9 Series Chipset Family USB xHCI Controller'
    class      = serial bus
    subclass   = USB
--
ehci0@pci0:0:26:0:      class=0x0c0320 card=0x85341043 chip=0x8cad8086 rev=0x00 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '9 Series Chipset Family USB EHCI Controller'
    class      = serial bus
    subclass   = USB
--
ehci1@pci0:0:29:0:      class=0x0c0320 card=0x85341043 chip=0x8ca68086 rev=0x00 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '9 Series Chipset Family USB EHCI Controller'
    class      = serial bus
    subclass   = USB
```

One is controller I want pass-through in VM

Add string in loader.conf

```
# vim /boot/loader.conf
pptdevs="0/26/0"
```

But doesn't effect and device ppt0 don't load
`# pciconf -lv | grep ppt`

Why pass-through doesn't work, tell please ?


----------



## yuripv (Sep 30, 2018)

What you are doing seems to be correct, check that your host meets the requirements though: https://wiki.freebsd.org/bhyve/pci_passthru

Just to confirm:

```
$ grep pptdevs /boot/loader.conf
pptdevs="0/18/2"
$ pciconf -lv | grep -A4 ^ppt
ppt0@pci0:0:18:2:       class=0x0c0320 card=0xbc1115d9 chip=0x43961002 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'SB7x0/SB8x0/SB9x0 USB EHCI Controller'
    class      = serial bus
    subclass   = USB
```


----------



## SemFLY (Sep 30, 2018)

*yuripv,*

Hmm... looked Requirements

https://ark.intel.com/products/8080...Processor-8M-Cache-up-to-4-40-GHz-?q=i7-4790K
My processor Intel® Core™ i7-4790K Processor

Intel® Virtualization Technology (VT-x) ‡                                         Yes                                      
Intel® Virtualization Technology for Directed I/O (VT-d) ‡               Yes   

Motherboard ASUS Z97-K

But
`# acpidump -t | grep DMAR`
is empty

But
`# pciconf -lc | grep MSI
    cap 05[90] = MSI supports 1 message
    cap 05[80] = MSI supports 8 messages, 64 bit enabled with 1 message
    cap 05[8c] = MSI supports 1 message, 64 bit
    cap 05[60] = MSI supports 1 message, 64 bit enabled with 1 message
    cap 05[80] = MSI supports 1 message
    cap 05[80] = MSI supports 1 message
    cap 05[80] = MSI supports 1 message
    cap 05[80] = MSI supports 1 message enabled with 1 message
    cap 05[68] = MSI supports 1 message, 64 bit
    cap 05[68] = MSI supports 1 message, 64 bit enabled with 1 message
    cap 05[50] = MSI supports 1 message, 64 bit
    cap 10[70] = PCI-Express 2 endpoint MSI 1 max data 128(128)
    cap 11[b0] = MSI-X supports 4 messages, enabled`


My moterboard doesn't support DMAR, yes ?
What do you think ?


----------



## usdmatt (Oct 1, 2018)

Hmm I'd be concerned that the `acpidump` command mentioned in the bhyve wiki returns nothing. Is there anything in the BIOS to enable vt-d?

Have you got `vmm_load="YES"` in /boot/loader.conf. This loads the ppt driver on boot, which will then claim any devices it's configured to grab before the "real" driver gets a change to attach to it.


----------



## SirDice (Oct 1, 2018)

Judging by the card, chip and class IDs I suspect xhci0, ehci0 and ehci1 are one and the same device. As far as I know you can only pass-through the whole device, not parts of it.


----------



## yuripv (Oct 1, 2018)

They are separate devices (pci0:0:*26*:0), you must be thinking about multi-function ones, but even those can be passed through per function, e.g. Intel NICs with SR-IOV.


----------



## SemFLY (Oct 3, 2018)

Sorry for the long absence.

Add 
`vmm_load="YES" in /boot/loader.conf`

`# cat /boot/loader.conf
vmm_load="YES"
pptdevs="0/26/0"`

Result
`# pciconf -lv | grep ppt
ppt0@pci0:0:26:0:       class=0x0c0320 card=0x85341043 chip=0x8cad8086 rev=0x00 hdr=0x00`

Bhyve VM config

`# cat bhyve_vm
bhyve -c 1 -s 7,fbuf,tcp=192.168.52.22:5912,wait \
        -s 0,hostbridge \
        -s 3,ahci-hd,vitrual.hdd \
        -s 4,ahci-cd,virtio-win-0.1.96.iso \
        [B]-s 9,passthru,0/26/0 \[/B]
        -s 8,xhci,tablet \
        -s 10,virtio-net,tap11 \
        -s 31,lpc -l bootrom,BHYVE_UEFI.fd \
        -m 6G -H -S -w virtualVM`

But when VM start and connect via VNC, this message in console and VM stop
`# ./bhyve_vm
fbuf frame buffer base: 0x9c2800000 [sz 16777216]
bhyve: PCI device at 0/26/0 is not using the ppt(4) driver
#`


----------



## richardbader (Jul 5, 2019)

hey,
i've the same problem, you have solved yours?


----------



## Phishfry (Jul 5, 2019)

This post is about attempting to passthu a subset of onboard USB ports.
0/20/0, 0/26/0. 0/29/0 are common Intel USB addresses.
My findings have shown this is not possible to split these up.
You can passthru all three USB devices but you lose host USB then and have to administer bhyve via ssh. IE. no keyboard.
Adding an PCIe USB3 controller for passthru to each VM's USB worked.
Splitting up USB ports for passthru using a PCIe USB3 card was also not achievable.


----------



## SemFLY (Jul 21, 2019)

richardbader said:


> hey,
> i've the same problem, you have solved yours?



I used this orient nc-3u2pe controller, installed in pci-express slot in the server.
Work fine in VM Windows 10 Pro all usb flash and etc work excellent, uptime 115 days.

This is production HOST with 12 VM machines Windows 10 Pro.


----------

