]> Git Repo - qemu.git/commitdiff
uhci: Don't allow the guest to set port-enabled when there is no dev connected
authorHans de Goede <[email protected]>
Sat, 17 Nov 2012 11:11:50 +0000 (12:11 +0100)
committerGerd Hoffmann <[email protected]>
Wed, 21 Nov 2012 13:55:54 +0000 (14:55 +0100)
It is possible for device disconnect and the guest trying to reset the port
(because of USB xact errors prior to the disconnect getting signaled) to race,
when we hit this race, the guest will write the port-control register with its
pre-disconnect value + the reset bit set, after which we have a disconnected
device with its port-enabled bit set in its port-control register, which
is no good :)

Signed-off-by: Hans de Goede <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
hw/usb/hcd-uhci.c

index ef326330d30b55c954ee2021e5d82d71e41cf772..078be2ad6a0bf9939e86082c614b54a92d6d52a2 100644 (file)
@@ -556,6 +556,10 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
                 }
             }
             port->ctrl &= UHCI_PORT_READ_ONLY;
+            /* enabled may only be set if a device is connected */
+            if (!(port->ctrl & UHCI_PORT_CCS)) {
+                val &= ~UHCI_PORT_EN;
+            }
             port->ctrl |= (val & ~UHCI_PORT_READ_ONLY);
             /* some bits are reset when a '1' is written to them */
             port->ctrl &= ~(val & UHCI_PORT_WRITE_CLEAR);
This page took 0.033017 seconds and 4 git commands to generate.