From nobody Mon Feb 9 23:01:01 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529372765267207.98781143288647; Mon, 18 Jun 2018 18:46:05 -0700 (PDT) Received: from localhost ([::1]:38368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iV-0001Tr-4J for importer@patchew.org; Mon, 18 Jun 2018 21:45:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gQ-0008Op-Uy for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gP-0007YX-KU for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:47 -0400 Received: from mail-ot0-x22f.google.com ([2607:f8b0:4003:c0f::22f]:36644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gP-0007YM-Ec; Mon, 18 Jun 2018 21:43:45 -0400 Received: by mail-ot0-x22f.google.com with SMTP id c15-v6so20774538otl.3; Mon, 18 Jun 2018 18:43:44 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id c71-v6sm10091326oig.44.2018.06.18.18.43.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:43:42 -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=h1UmUBfQhjusbBLUXJjy6V+MBfN/TADKerAx9EztFVQ=; b=ZUpjGix0MLNvupxKlErSBbbnVCoTBSfJGtLFSsR3m0trZXFG7YsdjLXRsYoVRCxZv3 aF24pmp3zQmhCiXnZwj1dOP3pndELQMusWmlWMYFMvc7AYrw4cDD/im7NXu4wJaDff34 4SpDUheQUKvXaTbgzDLRWFLZQkZlnV+xtnZs/byhUHFDWzdkanZH53esFLcYoJ3LXDa7 fFegHwQul5Lgl6TOs1OHNF7fM1Qs9cid3XHzI63G/UymmiKpZzr6ovXLTlQcvWqjijQ9 txK4t6JP2LmfY0wu0/ZuEq8Lj0Ky4/J/BbUTnJ1R2j8vV510H+pXpphQZliz/HuOpPDO pW1Q== 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=h1UmUBfQhjusbBLUXJjy6V+MBfN/TADKerAx9EztFVQ=; b=cjpL5/1VEB7ErKfBXE6ISJpKwQWZuyOSg2x6D+BWDvII5+ZF7vPIXtTwxjgeA0jKpv 5lhRVhuShF337KE2TGKEjad/c5D+3DpEqKV8bYOuJ2MZoWrRE/yPtmVM5iTsdtm89RVW jiy9JInevcU0lvMnvb9RY+jLqS5gpBkqMRLu9pzMUvREO4F+4suq5Era9x/nWRN8JvpB aSijNAT9ZPnVQRbB2Zg8ZZiA0URxlPTempkPHDnfxdE2erF+63KvgJWTbHfxC7Y1ktkA j2R05xfWXhqq3LAdw75nGGVJ4IY0jFb9H7jRZhMORxrCNYzhX06CS3nBTBB9l1t3Pj9Q S5eA== X-Gm-Message-State: APt69E327NvTqxATPbWdWs/czJBVxOQ9X53Xlf/Wij0UWWzzusOL13N8 5reb7Tq/2eOvwIfZNGm/165lcbRO X-Google-Smtp-Source: ADUXVKJpF0da6MP4TjGBs73MbiOTXGg2DPWQmQLCNyaJ15WgKEARliT6n3dboSrD2IKm3blr8gr3Eg== X-Received: by 2002:a9d:3171:: with SMTP id v46-v6mr8710346otd.34.1529372623798; Mon, 18 Jun 2018 18:43:43 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:05 -0500 Message-Id: <20180619014319.28272-100-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22f Subject: [Qemu-devel] [PATCH 099/113] 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 373311f91a..0741f3405e 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -533,13 +533,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 @@ -1426,6 +1419,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.11.0