Blame SOURCES/kvm-ahci-fix-PxCI-register-race.patch

1bdc94
From 41f2bce1d8d55b1a35bd7456b4b13b5bc098745f Mon Sep 17 00:00:00 2001
1bdc94
From: John Snow <jsnow@redhat.com>
1bdc94
Date: Tue, 10 Jul 2018 23:06:15 +0200
1bdc94
Subject: [PATCH 32/89] ahci: fix PxCI register race
1bdc94
MIME-Version: 1.0
1bdc94
Content-Type: text/plain; charset=UTF-8
1bdc94
Content-Transfer-Encoding: 8bit
1bdc94
1bdc94
RH-Author: John Snow <jsnow@redhat.com>
1bdc94
Message-id: <20180710230616.11000-3-jsnow@redhat.com>
1bdc94
Patchwork-id: 81293
1bdc94
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 2/3] ahci: fix PxCI register race
1bdc94
Bugzilla: 1584914
1bdc94
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
1bdc94
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
1bdc94
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
1bdc94
1bdc94
Fixes: https://bugs.launchpad.net/qemu/+bug/1769189
1bdc94
1bdc94
AHCI presently signals completion prior to the PxCI register being
1bdc94
cleared to indicate completion. If a guest driver attempts to issue
1bdc94
a new command in its IRQ handler, it might be surprised to learn there
1bdc94
is still a command pending.
1bdc94
1bdc94
In the case of Windows 10's boot driver, it will actually poll the IRQ
1bdc94
register hoping to find out when the command is done running -- which
1bdc94
will never happen, as there isn't a command running.
1bdc94
1bdc94
Fix this: clear PxCI in ahci_cmd_done and not in the asynchronous BH.
1bdc94
Because it now runs synchronously, we don't need to check if the command
1bdc94
is actually done by spying on the ATA registers. We know it's done.
1bdc94
1bdc94
CC: qemu-stable <qemu-stable@nongnu.org>
1bdc94
Reported-by: François Guerraz <kubrick@fgv6.net>
1bdc94
Tested-by: Bruce Rogers <brogers@suse.com>
1bdc94
Signed-off-by: John Snow <jsnow@redhat.com>
1bdc94
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
1bdc94
Reviewed-by: Jeff Cody <jcody@redhat.com>
1bdc94
Message-id: 20180531004323.4611-3-jsnow@redhat.com
1bdc94
Signed-off-by: John Snow <jsnow@redhat.com>
1bdc94
(cherry picked from commit 5694c7eacce6b263ad7497cc1bb76aad746cfd4e)
1bdc94
Signed-off-by: John Snow <jsnow@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 hw/ide/ahci.c | 13 ++++++-------
1bdc94
 1 file changed, 6 insertions(+), 7 deletions(-)
1bdc94
1bdc94
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
1bdc94
index b7a6f68..a9558e4 100644
1bdc94
--- a/hw/ide/ahci.c
1bdc94
+++ b/hw/ide/ahci.c
1bdc94
@@ -532,13 +532,6 @@ static void ahci_check_cmd_bh(void *opaque)
1bdc94
     qemu_bh_delete(ad->check_bh);
1bdc94
     ad->check_bh = NULL;
1bdc94
 
1bdc94
-    if ((ad->busy_slot != -1) &&
1bdc94
-        !(ad->port.ifs[0].status & (BUSY_STAT|DRQ_STAT))) {
1bdc94
-        /* no longer busy */
1bdc94
-        ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot);
1bdc94
-        ad->busy_slot = -1;
1bdc94
-    }
1bdc94
-
1bdc94
     check_cmd(ad->hba, ad->port_no);
1bdc94
 }
1bdc94
 
1bdc94
@@ -1425,6 +1418,12 @@ static void ahci_cmd_done(IDEDMA *dma)
1bdc94
 
1bdc94
     trace_ahci_cmd_done(ad->hba, ad->port_no);
1bdc94
 
1bdc94
+    /* no longer busy */
1bdc94
+    if (ad->busy_slot != -1) {
1bdc94
+        ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot);
1bdc94
+        ad->busy_slot = -1;
1bdc94
+    }
1bdc94
+
1bdc94
     /* update d2h status */
1bdc94
     ahci_write_fis_d2h(ad);
1bdc94
 
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94