Same USB port appears as different buses when different devices are connected

I am trying to create a second USB VM for particularly sensitive USB devices. Based on the information at USB qubes | Qubes OS, and the general operation of USB devices on Linux, I was under the impression that a specific USB port would always correspond to the same USB bus (granting that the number may change between reboots).

However, when I plug a USB mouse into a specific USB port it consistently appears as being on bus 2. When I plug a USB flash drive into the same USB port (without rebooting anything) it consistently appears as being on bus 3. This causes an issue because the sensitive devices appear on bus 2, and I don’t want the VM which uses them to also take over my mouse. I am currently running Qubes 4.2. I suspect that there is simply something that I am misunderstanding from the documentation about how this works, and would appreciate if anyone can either explain why this behavior is happening or suggest an alternative strategy to make sure that the sensitive devices attach to a specific VM.

Based on your description, I assume you have assigned USB controller A to sys-usb-1, and USB controller B to sys-usb-2. So, in devices widget, when you plug in the mouse, it appears to be attached to sys-usb-1, and when you plug in the USB flash drive into the same slot, it appears to be attached to sys-usb-2? Is this what happened?

1 Like

Thank you for the clarifying question. I had been trying to gather information through my (single) sys-usb VM before making any configuration changes due to the sensitive nature of the configuration. Based on your question I decided that I needed to actually try it in order to get enough information to get help, which led me to discover that my hardware does not support the configuration I am trying to create. I have written details below in case it is helpful to others.

In sys-usb, it is not true that each USB Bus corresponds to exactly 1 physical controller. One of the busses is an emulated bus used to communicate pointer information. Additionally, it is possible for a single USB controller to appear as multiple busses. It looks like this is how the kernel manages the difference between USB 2.0 and 3.0 devices, so I would assume that this could also happen in a dom0 with no sys-usb, but I have not confirmed this.

On my machine, the emulated bus is consistently bus 1. It has a device named “Adomax Technology Co., Ltd QEMU Tablet” attached.

In order to get information about the number of physical controllers I had, I read the links of all of the usb controllers. Modifying the instructions at How to use USB devices | Qubes OS

$ for file in /sys/bus/usb/devices/usb*; do
    readlink $file
  done
../../../devices/pci0000:00/0000:00:05.0/usb1
../../../devices/pci0000:00/0000:00:06.0/usb2
../../../devices/pci0000:00/0000:00:06.0/usb3

Both usb2 and usb3 link to device 00:06.0, meaning they are communicating with the same USB controller. As it turns out, my machine only has a single physical controller, meaning that it is not possible for me to isolate the sensitive devices from other devices as I wanted, since their data has to be processed by the same VM (sys-usb).

To clarify my starting point, here is the terminal output which prompted my original problem description. All commands are run on sys-usb as created by the installer.

No USB devices attached:

$ lsusb
Bus 003 Device 002: ID 05e3:0749 Genesys Logic, Inc. SD Card Reader and Writer
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Mouse attached, third item in the list. Note that it is on bus 2:

$ lsusb
Bus 003 Device 002: ID 05e3:0749 Genesys Logic, Inc. SD Card Reader and Writer
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 004: ID 045e:07a5 Microsoft Corp. Wireless Receiver 1461C
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Flash drive attached, second item in the list. Note that it is on bus 3:

Bus 003 Device 002: ID 05e3:0749 Genesys Logic, Inc. SD Card Reader and Writer
Bus 003 Device 003: ID 13fe:6300 Phison Electronics Corp. SP Mobile C31 (64GB)
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
1 Like

It’s sad to hear that you only have one physical USB controller. An easy way to check the number of controllers you have is to go to the settings of sys-usb and check how many PCI devices are attached to it.

1 Like