Commit 8464b273 authored by Alexander Graf's avatar Alexander Graf Committed by Kevin Wolf
Browse files

ahci: fix win7 hang on boot



When AHCI executes an asynchronous IDE command, it checked DRDY without
checking either DRQ or BSY.  This sometimes caused interrupt to be sent
before command is actually completed.

This resulted in a race condition: if guest then managed to access the
device before command has completed, it would hang waiting for an
interrupt.
This was observed with windows 7 guests.

To fix, check for DRQ or BSY in additiona to DRDY, if set,
the command is asynchronous so delay the interrupt until
asynchronous done callback is invoked.

Reported-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Tested-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent 1841f880
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -961,7 +961,8 @@ static int handle_cmd(AHCIState *s, int port, int slot)
        /* We're ready to process the command in FIS byte 2. */
        ide_exec_cmd(&s->dev[port].port, cmd_fis[2]);

        if (s->dev[port].port.ifs[0].status & READY_STAT) {
        if ((s->dev[port].port.ifs[0].status & (READY_STAT|DRQ_STAT|BUSY_STAT)) ==
            READY_STAT) {
            ahci_write_fis_d2h(&s->dev[port], cmd_fis);
        }
    }