From 1e03e407845c5d698f82a262312bca5aa2406d59 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Wed, 5 Nov 2014 19:35:22 +1100 Subject: [PATCH 1/3] Provide the missing LIBUSB_LOG_LEVEL_* for older libusb or FreeBSD. Providing just the needed value as a defined. Signed-off-by: Chris Johns Signed-off-by: Gerd Hoffmann --- hw/usb/host-libusb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index d2d161bc6e..032a0e4414 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -143,6 +143,12 @@ static void usb_host_attach_kernel(USBHostDevice *s); /* ------------------------------------------------------------------------ */ +#ifndef LIBUSB_LOG_LEVEL_WARNING /* older libusb didn't define these */ +#define LIBUSB_LOG_LEVEL_WARNING 2 +#endif + +/* ------------------------------------------------------------------------ */ + #define CONTROL_TIMEOUT 10000 /* 10 sec */ #define BULK_TIMEOUT 0 /* unlimited */ #define INTR_TIMEOUT 0 /* unlimited */ From f2ad97ff81da51c064b9e87720ff48a0874f45d4 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 7 Nov 2014 10:41:25 +0100 Subject: [PATCH 2/3] xhci: add sanity checks to xhci_lookup_uport Also catch xhci_lookup_uport failures in post_load. https://bugzilla.redhat.com/show_bug.cgi?id=1074219 Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 2930b72c1d..9a942cfad4 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2262,6 +2262,9 @@ static USBPort *xhci_lookup_uport(XHCIState *xhci, uint32_t *slot_ctx) int i, pos, port; port = (slot_ctx[1]>>16) & 0xFF; + if (port < 1 || port > xhci->numports) { + return NULL; + } port = xhci->ports[port-1].uport->index+1; pos = snprintf(path, sizeof(path), "%d", port); for (i = 0; i < 5; i++) { @@ -3706,6 +3709,12 @@ static int usb_xhci_post_load(void *opaque, int version_id) xhci_mask64(ldq_le_pci_dma(pci_dev, dcbaap + 8 * slotid)); xhci_dma_read_u32s(xhci, slot->ctx, slot_ctx, sizeof(slot_ctx)); slot->uport = xhci_lookup_uport(xhci, slot_ctx); + if (!slot->uport) { + /* should not happen, but may trigger on guest bugs */ + slot->enabled = 0; + slot->addressed = 0; + continue; + } assert(slot->uport && slot->uport->dev); for (epid = 1; epid <= 31; epid++) { From 79ae25af1569a50a0ec799901a1bb280c088f121 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 10 Nov 2014 12:14:22 +0100 Subject: [PATCH 3/3] usb-host: fix usb_host_speed_compat tyops Signed-off-by: Gerd Hoffmann Reviewed-by: Gonglei --- hw/usb/host-libusb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 032a0e4414..a5f9dab0cd 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -749,13 +749,13 @@ static void usb_host_speed_compat(USBHostDevice *s) udev->speedmask = (1 << udev->speed); if (udev->speed == USB_SPEED_SUPER && compat_high) { - udev->speedmask |= USB_SPEED_HIGH; + udev->speedmask |= USB_SPEED_MASK_HIGH; } if (udev->speed == USB_SPEED_SUPER && compat_full) { - udev->speedmask |= USB_SPEED_FULL; + udev->speedmask |= USB_SPEED_MASK_FULL; } if (udev->speed == USB_SPEED_HIGH && compat_full) { - udev->speedmask |= USB_SPEED_FULL; + udev->speedmask |= USB_SPEED_MASK_FULL; } }