Bug 275760 - bhyve: xhci not working on linux guests
Summary: bhyve: xhci not working on linux guests
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bhyve (show other bugs)
Version: 14.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-virtualization (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-14 09:20 UTC by Corvin Köhne
Modified: 2024-05-06 15:15 UTC (History)
6 users (show)

See Also:


Attachments
ubuntu boot bhyve log (16.85 KB, application/zstd)
2023-12-14 09:42 UTC, Corvin Köhne
no flags Details
xhci mouse proposed fix (592 bytes, patch)
2023-12-19 11:21 UTC, Peter Grehan
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Corvin Köhne freebsd_committer freebsd_triage 2023-12-14 09:20:52 UTC
On newer linux versions the guest may fail to use xhci,tablet device. The issues exists in 13.2 and 14.0 with the latest debian installer image and latest ubuntu 22.04. bhyve logs the following errors:
```
pci_xhci: portregs_write to unpowered port 1
```

I've found an illumos bug [1] fixing the same issue. Unfortunately, the illumos fix causes the warning to disappear but the issue still exists.

[1] https://www.illumos.org/issues/14623
Comment 1 Corvin Köhne freebsd_committer freebsd_triage 2023-12-14 09:42:00 UTC
Created attachment 247042 [details]
ubuntu boot bhyve log

I've enabled xhci_debug in bhyve and attached the log.
Comment 2 Slava 2023-12-18 02:31:18 UTC
Hello,

I can confirm that the same issue happens in Fedora 39 and Ubuntu 23.10 Live media bhyve guests.  

I spoke to someone on IRC about this and they suggested opening a bug report for it; looks like you beat me to it.  I'll be happy to help test.

Thank you
Comment 3 Peter Grehan freebsd_committer freebsd_triage 2023-12-19 11:21:01 UTC
Created attachment 247158 [details]
xhci mouse proposed fix

Would you be able to try this patch ? Works on Ubuntu 23.10, and doesn't break anything on Ubuntu 22.04 and Windows 10. As a side-effect it also fixes the error messages about port-power.

The USB3 spec mandates that the endpoint size for super-speed devices is 512, so the size field has to be 9, not 8. Linux only recently started checking this.
Comment 4 Andreas Kempe 2023-12-19 14:48:14 UTC
(In reply to Peter Grehan from comment #3)
This patch did the trick for my Gentoo VM running Linux 6.1.66 on 13.2-RELEASE-p8. No more errors in the dmesg and the mouse is working. Thank you!
Comment 5 Andrew Heybey 2023-12-20 02:02:50 UTC
(In reply to Peter Grehan from comment #3)
Thanks much, this patch also works for me.  It fixes an Ubuntu 22.04 VM whose mouse stopped working after a kernel upgrade a week or so ago.
Comment 6 Slava 2023-12-21 04:36:08 UTC
(In reply to Peter Grehan from comment #3)
The patch is working for me on Fedora 39.  Thank you very much Peter!
Comment 7 Corvin Köhne freebsd_committer freebsd_triage 2024-01-08 12:21:28 UTC
It's working for me too! Thanks!

Reviewed-by: corvink
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-01-14 11:21:57 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0c243cd4a3671bf728f33378ac593c08d8367bc2

commit 0c243cd4a3671bf728f33378ac593c08d8367bc2
Author:     Peter Grehan <grehan@FreeBSD.org>
AuthorDate: 2024-01-14 11:27:12 +0000
Commit:     Peter Grehan <grehan@FreeBSD.org>
CommitDate: 2024-01-14 11:38:55 +0000

    Fix issue with Linux guest XHCI tablet probing.

    The USB3 spec mandates that the device-descriptor max packet size
    be 512 bytes, which requires a field size of 9 since it is a
    power-of-2.

    Linux kernels recently started validating this field, resulting in
    the table not being probed and the cursor not working in bhyve VNC.

    Reviewed by:    corvink
    PR:             275760
    MFC after:      1 week

 usr.sbin/bhyve/usb_mouse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 9 Christopher Hall 2024-01-25 04:11:19 UTC
I just ran into this problem. I saw the patch was just an 08→09 byte change. I found this byte on line 19170 in emacs hexl mode and changed it so:

  % cmp -xl bhyve.orig bhyve 
  0001917b 08 09

Now the mouse is working with xhci_mouse="yes" using the vm-bhyve pkg
the VM is Ubuntu 22.04.3 LTS
Comment 10 commit-hook freebsd_committer freebsd_triage 2024-01-28 09:03:20 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2ee407b6068a994bba45597c995c5ea76eec9cf3

commit 2ee407b6068a994bba45597c995c5ea76eec9cf3
Author:     Peter Grehan <grehan@FreeBSD.org>
AuthorDate: 2024-01-14 11:27:12 +0000
Commit:     Peter Grehan <grehan@FreeBSD.org>
CommitDate: 2024-01-28 09:01:49 +0000

    Fix issue with Linux guest XHCI tablet probing.

    The USB3 spec mandates that the device-descriptor max packet size
    be 512 bytes, which requires a field size of 9 since it is a
    power-of-2.

    Linux kernels recently started validating this field, resulting in
    the table not being probed and the cursor not working in bhyve VNC.

    PR:             275760

    (cherry picked from commit 0c243cd4a3671bf728f33378ac593c08d8367bc2)

 usr.sbin/bhyve/usb_mouse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 11 commit-hook freebsd_committer freebsd_triage 2024-01-28 09:05:23 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=48214dfab80155c03b9b22aca9f9810774c151e9

commit 48214dfab80155c03b9b22aca9f9810774c151e9
Author:     Peter Grehan <grehan@FreeBSD.org>
AuthorDate: 2024-01-14 11:27:12 +0000
Commit:     Peter Grehan <grehan@FreeBSD.org>
CommitDate: 2024-01-28 09:03:25 +0000

    Fix issue with Linux guest XHCI tablet probing.

    The USB3 spec mandates that the device-descriptor max packet size
    be 512 bytes, which requires a field size of 9 since it is a
    power-of-2.

    Linux kernels recently started validating this field, resulting in
    the table not being probed and the cursor not working in bhyve VNC.

    PR:             275760

    (cherry picked from commit 0c243cd4a3671bf728f33378ac593c08d8367bc2)

 usr.sbin/bhyve/usb_mouse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)