ahci fix: windows boots fine. need to review with kwolf
PATCH 1/1 ahci fix: windows boots fine. need to review with kwolf
From: Alexander Graf <[email protected]>
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.
--- hw/ide/ahci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/ide/ahci.c +2 -1
@@ -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); } }
Signature · 1 line
MST
Quoted 11 lines · Michael S. Tsirkin
From: Alexander Graf <[email protected]>
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.
Quoted 8 lines
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 Michael S. Tsirkin <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>Tested-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>
Sorry about the subject, forgot to update it.
I reposted with a fixed subject.
Quoted 20 lines
--- hw/ide/ahci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/ide/ahci.c +2
-1@@ -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); } }Signature · 1 line
MST