Why is USB pass-through to a VM often unreliable? Like specifically what is it about the protocol or implementations or whatever that makes it difficult to do?
Conversation
Notices
-
Embed this notice
Hailey (hailey@hails.org)'s status on Monday, 29-Dec-2025 04:40:26 JST
Hailey
-
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Monday, 29-Dec-2025 04:40:19 JST
✧✦Catherine✦✧
@erikarn @hailey I don't believe there are any hubs with 3-to-2 TTs, do you have an example?
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Monday, 29-Dec-2025 04:40:20 JST
Adrian Chadd <verified.png>
@hailey ie, depending upon if you plug in a USB-3, USB-2, or USB-1 device, your XHCI USB-3 controller may actually be speaking that itself, or it may be speaking USB-3 only and USB-2 / USB-1 via a translation hub that will handle translating USB-2/USB-1 to USB-3. (or USB-1 to USB-2 for EHCI.)
So suddenly your device ID and topology can change based on the /type of device you plugged in/!
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Monday, 29-Dec-2025 04:40:21 JST
Adrian Chadd <verified.png>
@hailey Now all the devices on a given controller kind of look like a LAN with automatically enumerated endpoint and device IDs. The USB controller doesn't REALLY care about all the devices its speaking to, it's just given a set of transfers to do to endpoints and when it issues the transfers it hopes to heck they're there.
But like, when you plug in hubs, those are store and forward things. And these days doing USB2 or USB1 on a USB-3 port can actually end up with a "hub" doing translation!
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Monday, 29-Dec-2025 04:40:22 JST
Adrian Chadd <verified.png>
@hailey Now, that means all the hub/port control between that controller and your device needs to be done by the host, then you need to basically proxy all of the USB transfers from the host to the guest.
But there's no standardised "paravirtualised USB" stuff. So the VM has to basically take your device, "fake" a USB controller and port, and then have those USB transfers to/from that particular device into the VM via this fake USB controller.
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Monday, 29-Dec-2025 04:40:24 JST
Adrian Chadd <verified.png>
@hailey ok so
at the top level, before usb-c, it's mostly easy to move the whole controller into the VM. That's a mostly self contained thing. It's doubly easy if it's behind an IO-MMU which virtualises all the DMA addressing.
however, moving a USB device is problematic. All the hub and port control would be done by your host OS. You'd have to tell the host OS to pass something in by rule, eg "hey any mass storage device on this physical controller? please map to the VM."
-
Embed this notice
Hailey (hailey@hails.org)'s status on Monday, 29-Dec-2025 04:40:25 JST
Hailey
@erikarn yes please!
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Monday, 29-Dec-2025 04:40:26 JST
Adrian Chadd <verified.png>
@hailey i kinda know? do you REALLY want to know? like really really REALLY really? :P
-
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Monday, 29-Dec-2025 05:15:42 JST
✧✦Catherine✦✧
@erikarn @hailey there *are* USB 3 TTs (VL670/671), you can't get them on the open market, I have the devboards and most devices don't work thru them due to rampant protocol violations they have
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Monday, 29-Dec-2025 05:15:43 JST
Adrian Chadd <verified.png>
@whitequark @hailey I'll have to go dig to see if I misquoted and the USB-3 things are doing to 3 to 3 only and what they do when you plug a usb-3 hub into a usb-2 port.
There /are/ weird shenanigans though!
-
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Monday, 29-Dec-2025 06:18:46 JST
✧✦Catherine✦✧
@erikarn anyway @hailey two things I'd like to add:
1. is that USB is designed around the hardware responding in a fixed and very small amount of time to any request (this is also why until a few years ago, there were zero galvanic isolators for USB 2 high-speed, and musicians just suffered instead). virtualizing hardware that's so tightly based on meeting fixing timings is inherently fraught
2. while there is usb-over-ip, in linux in particular the problem is that... -
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Monday, 29-Dec-2025 06:18:48 JST
Adrian Chadd <verified.png>
@whitequark @hailey oh /lord/ ew ;p
-
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Monday, 29-Dec-2025 06:19:47 JST
✧✦Catherine✦✧
@erikarn @hailey it exposes the "hardware" side of the *HCI drivers to "anything that can happen to packets on the network", which these drivers are suuuper not designed for, and they'll happily panic your kernel if something goes slightly wrong. I'm shocked that WSL's USB support is as stable as it is, must've taken a lot of work to get there
-
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Monday, 29-Dec-2025 06:52:37 JST
✧✦Catherine✦✧
@erikarn @hailey it's more complicated than that
for the USB host case, you have a "VHCI", but the rest of the USB stack is still used basically as-is. it is fully and completely unprepared for the hardware to behave in unexpected ways, e.g. for packet loss
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Monday, 29-Dec-2025 06:52:39 JST
Adrian Chadd <verified.png>
@whitequark @hailey also holy crap usb-over-ip in linux isn't virtualising the endpoints, but is .. exposing hardware? oh holy crap
-
Embed this notice
Adrian Chadd <verified.png> (erikarn@mstdn.social)'s status on Monday, 29-Dec-2025 06:52:40 JST
Adrian Chadd <verified.png>
@whitequark @hailey oh yeah i forgot to mention how utterly bonkers the timing can be.
It's not always the controller either. Like, you can submit a buffer for completion to the controller and context switch / copy it - this is what userland libusb + ugen devices do! - if you can do it to a process then you can do it to a VM! - but the devices themselves are also very latency sensitive and in a lot of cases shit the bed if your transfers aren't setup fast enough!
-
Embed this notice