From nobody Sun Feb 8 14:11:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532379112598111.08680655910473; Mon, 23 Jul 2018 13:51:52 -0700 (PDT) Received: from localhost ([::1]:36528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhho7-0004B8-GW for importer@patchew.org; Mon, 23 Jul 2018 16:51:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJ5-0002FR-Bp for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJ4-0003m9-Bc for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:47 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:39346) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJ4-0003l5-4s; Mon, 23 Jul 2018 16:19:46 -0400 Received: by mail-oi0-x22f.google.com with SMTP id d189-v6so3478995oib.6; Mon, 23 Jul 2018 13:19:46 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m7-v6sm7925228oia.32.2018.07.23.13.19.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=77/Mr19kR4KMcOef0GYjYQNyN9hp5TSPMcEQAMoXKjo=; b=R/QvGOVqA5ipCUYXxbNbr9QZOhvBr59f539iIy/KQ0MPQwsY+bXi3r1fPfgptIXV0w yF+huWivmldsAB7CY39V7+K/o7Hg4U7a7NUoVUz3jUvIW/jyTUz6atvI01syC7SIFsvU ReM0W2IJJT68aHA27/UyMtumbeCgg0GIJHuC0Y7hoderkZl+Fd8OJjxmUREwl+9pgzwl QzBHKW6+i1BgbM2GNmQZv9zualWINAtaiEbDAakqRuV3DMZGpML+0Tiv2nCX+YVvmcd6 rMpokkSmhqsF70srAvJP8ev7ZjhNt5+V0WR9wbuB80lnPAVlzZbmSX3pb/RTKdFUdeq+ 8V3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=77/Mr19kR4KMcOef0GYjYQNyN9hp5TSPMcEQAMoXKjo=; b=WGme6ZPrNv0mrxv+udANvjKQcQiRiccGrAoxqrFk/2lHrC+8osi6FdpbNsH9b8Qmz3 VCNgKB+T8n4u227jIb1H9Ziif9s/RRIz7GAaZ9K8WjOo2TSAkn7LAAcBitjA6zFRxqp3 M6EbLkP/saN3F8yqjt/MiRd9iM4D1BvMDxDL1dKpvsmBkeo7ktCbemTD0/LcjyqMFoZG R/2YzA3Qwjs4rHxn4pXCxWVKKMNUQhvOlguENjKOBIpCOB9+K+Ul5W2trApFoSgZ0nm4 2n2mGcnQWX2PdNF+2DuGKPQTYC63p3RtvJXG6rD7bfB8yuHXHp39wSPo9YsuX6sgayIP HRcg== X-Gm-Message-State: AOUpUlFQoJ132KPcQUolZVBmn9RGqzyqQ/9jn/hLbJqgMLp2J1/j7kEw YzZqrSeaU5EVBqNmIcDVpamjwpbXTTI= X-Google-Smtp-Source: AAOMgpdwmPw2fl6hj+qOTcH4OqoatrGUc2uSH9Jvn4BQCnhZGIKGlemgUys12RN0+S2tL2i53KWtZw== X-Received: by 2002:aca:66a5:: with SMTP id m37-v6mr294634oik.139.1532377184931; Mon, 23 Jul 2018 13:19:44 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:45 -0500 Message-Id: <20180723201748.25573-37-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22f Subject: [Qemu-devel] [PATCH 36/99] ahci: fix PxCI register race X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: John Snow Fixes: https://bugs.launchpad.net/qemu/+bug/1769189 AHCI presently signals completion prior to the PxCI register being cleared to indicate completion. If a guest driver attempts to issue a new command in its IRQ handler, it might be surprised to learn there is still a command pending. In the case of Windows 10's boot driver, it will actually poll the IRQ register hoping to find out when the command is done running -- which will never happen, as there isn't a command running. Fix this: clear PxCI in ahci_cmd_done and not in the asynchronous BH. Because it now runs synchronously, we don't need to check if the command is actually done by spying on the ATA registers. We know it's done. CC: qemu-stable Reported-by: Fran=C3=A7ois Guerraz Tested-by: Bruce Rogers Signed-off-by: John Snow Reviewed-by: Stefan Hajnoczi Reviewed-by: Jeff Cody Message-id: 20180531004323.4611-3-jsnow@redhat.com Signed-off-by: John Snow (cherry picked from commit 5694c7eacce6b263ad7497cc1bb76aad746cfd4e) Signed-off-by: Michael Roth --- hw/ide/ahci.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index e22d7be05f..18b9a9c18b 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -532,13 +532,6 @@ static void ahci_check_cmd_bh(void *opaque) qemu_bh_delete(ad->check_bh); ad->check_bh =3D NULL; =20 - if ((ad->busy_slot !=3D -1) && - !(ad->port.ifs[0].status & (BUSY_STAT|DRQ_STAT))) { - /* no longer busy */ - ad->port_regs.cmd_issue &=3D ~(1 << ad->busy_slot); - ad->busy_slot =3D -1; - } - check_cmd(ad->hba, ad->port_no); } =20 @@ -1425,6 +1418,12 @@ static void ahci_cmd_done(IDEDMA *dma) =20 trace_ahci_cmd_done(ad->hba, ad->port_no); =20 + /* no longer busy */ + if (ad->busy_slot !=3D -1) { + ad->port_regs.cmd_issue &=3D ~(1 << ad->busy_slot); + ad->busy_slot =3D -1; + } + /* update d2h status */ ahci_write_fis_d2h(ad); =20 --=20 2.17.1