From d7008408d0fa4247e4daa8f4633da47f8baccedc Mon Sep 17 00:00:00 2001 From: Xiaoguang Wu Date: Sun, 21 Oct 2018 01:17:18 +0800 Subject: [PATCH] DM USB: xHCI: fix issue: crash when plug device during UOS booting This issue is result from reporting interrupt when the interrupt ability of virtual xHCI is disabled. As Event Ring State Machine showed in Figure 20 of xHCI spec, following rules should be followed: 1 when RS bit of USBCMD register is zero, Event Ring should not be accessed; 2 when INTE bit of USBCMD register is zero, Interrupt should not be sent. Tracked-On: #1566 Signed-off-by: Xiaoguang Wu Reviewed-by: Liang Yang Acked-by: Yu Wang --- devicemodel/hw/pci/xhci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/devicemodel/hw/pci/xhci.c b/devicemodel/hw/pci/xhci.c index 70f364019..3fb520602 100644 --- a/devicemodel/hw/pci/xhci.c +++ b/devicemodel/hw/pci/xhci.c @@ -1043,6 +1043,12 @@ pci_xhci_change_port(struct pci_xhci_vdev *xdev, int port, int usb_speed, if (!need_intr) return 0; + if (!(xdev->opregs.usbcmd & XHCI_CMD_INTE)) + need_intr = 0; + + if (!(xdev->opregs.usbcmd & XHCI_CMD_RS)) + return 0; + /* make an event for the guest OS */ pci_xhci_set_evtrb(&evtrb, port,