From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: qemu-stable <qemu-stable@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 2/3] ahci: fix PxCI register race
Date: Thu, 31 May 2018 12:16:26 -0400 [thread overview]
Message-ID: <c45fbf71-447b-8903-2f8a-cf0535c7f892@redhat.com> (raw)
In-Reply-To: <20180531004323.4611-3-jsnow@redhat.com>
>From comments on the cover letter, I am adding:
Fixes: https://bugs.launchpad.net/qemu/+bug/1769189
On 05/30/2018 08:43 PM, John Snow wrote:
> 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.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
and:
CC: qemu-stable <qemu-stable@nongnu.org>
Reported-by: François Guerraz <kubrick@fgv6.net>
Tested-by: Bruce Rogers <brogers@suse.com>
(Stable note: only patch #2 here is strictly required.)
> ---
> 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 b7a6f68790..a9558e45e7 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 = NULL;
>
> - if ((ad->busy_slot != -1) &&
> - !(ad->port.ifs[0].status & (BUSY_STAT|DRQ_STAT))) {
> - /* no longer busy */
> - ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot);
> - ad->busy_slot = -1;
> - }
> -
> check_cmd(ad->hba, ad->port_no);
> }
>
> @@ -1425,6 +1418,12 @@ static void ahci_cmd_done(IDEDMA *dma)
>
> trace_ahci_cmd_done(ad->hba, ad->port_no);
>
> + /* no longer busy */
> + if (ad->busy_slot != -1) {
> + ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot);
> + ad->busy_slot = -1;
> + }
> +
> /* update d2h status */
> ahci_write_fis_d2h(ad);
>
>
next prev parent reply other threads:[~2018-05-31 16:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-31 0:43 [Qemu-devel] [PATCH 0/3] ahci: fix completion race condition John Snow
2018-05-31 0:43 ` [Qemu-devel] [PATCH 1/3] ahci: trim signatures on raise/lower John Snow
2018-05-31 14:56 ` Eric Blake
2018-05-31 15:38 ` John Snow
2018-05-31 16:00 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-31 0:43 ` [Qemu-devel] [PATCH 2/3] ahci: fix PxCI register race John Snow
2018-05-31 16:16 ` John Snow [this message]
2018-05-31 16:22 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-31 0:43 ` [Qemu-devel] [PATCH 3/3] ahci: don't schedule unnecessary BH John Snow
2018-05-31 16:22 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2018-05-31 8:01 ` [Qemu-devel] [Qemu-block] [PATCH 0/3] ahci: fix completion race condition Stefan Hajnoczi
2018-05-31 12:21 ` [Qemu-devel] " Bruce Rogers
2018-05-31 13:06 ` Philippe Mathieu-Daudé
2018-05-31 13:12 ` Bruce Rogers
2018-06-01 0:00 ` John Snow
2018-06-04 9:22 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c45fbf71-447b-8903-2f8a-cf0535c7f892@redhat.com \
--to=jsnow@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).