Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 372BAC433E0 for ; Thu, 4 Jun 2020 11:13:37 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0CEE3206C3 for ; Thu, 4 Jun 2020 11:13:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CEE3206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jgnoD-0004WY-Hh; Thu, 04 Jun 2020 11:13:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jgnoC-0004WT-FG for xen-devel@lists.xenproject.org; Thu, 04 Jun 2020 11:13:16 +0000 X-Inumbo-ID: 6234bd4c-a654-11ea-8993-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6234bd4c-a654-11ea-8993-bc764e2007e4; Thu, 04 Jun 2020 11:13:14 +0000 (UTC) Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: oDor9dntqjX/CZq4EOWuvzz9MMJkD1I0M0gt1qCcqHU8OYVP/SXpQfJUsnrYO80Au6Z92f+w7x QGsytnEB2UhRDZmMNQO1Y68PX/sPqhaAnkKn51Kb6NxsQ1Mb8wsSZe8HkZOoVtRyEfUug/RxsX /tjKRvMNCQHdi5gRfSjXcKcl05ZzxHdtE/N7ThPYcvnejsDuLLHAxlsUNHZD1vb0bR8cr0X96b J56Rr4V4xod7gtciHGhqDVDpwdZgJNaTxMS20JoCSuJLKu8kDP0OR8dGgK0e48n/w01py8m+C5 ng4= X-SBRS: 2.7 X-MesageID: 19460865 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,472,1583211600"; d="scan'208,217";a="19460865" Subject: Re: handle_pio looping during domain shutdown, with qemu 4.2.0 in stubdom To: Jan Beulich , =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?= References: <20200604014621.GA203658@mail-itl> <4dcc0092-6f6d-5d63-06cb-15b2fec244db@suse.com> From: Andrew Cooper Message-ID: Date: Thu, 4 Jun 2020 12:13:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <4dcc0092-6f6d-5d63-06cb-15b2fec244db@suse.com> Content-Type: multipart/alternative; boundary="------------DCC7A6CAB5EFD944658332FB" Content-Language: en-GB X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" --------------DCC7A6CAB5EFD944658332FB Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On 04/06/2020 08:08, Jan Beulich wrote: > On 04.06.2020 03:46, Marek Marczykowski-Górecki wrote: >> Then, we get the main issue: >> >> (XEN) d3v0 handle_pio port 0xb004 read 0x0000 >> (XEN) d3v0 Weird PIO status 1, port 0xb004 read 0xffff >> (XEN) domain_crash called from io.c:178 >> >> Note, there was no XEN_DOMCTL_destroydomain for domain 3 nor its stubdom >> yet. But XEN_DMOP_remote_shutdown for domain 3 was called already. > I'd guess an issue with the shutdown deferral logic. Did you / can > you check whether XEN_DMOP_remote_shutdown managed to pause all > CPUs (I assume it didn't, since once they're paused there shouldn't > be any I/O there anymore, and hence no I/O emulation)? The vcpu in question is talking to Qemu, so will have v->defer_shutdown intermittently set, and skip the pause in domain_shutdown() I presume this lack of pause is to allow the vcpu in question to still be scheduled to consume the IOREQ reply?  (Its fairly opaque logic with 0 clarifying details). What *should* happen is that, after consuming the reply, the vcpu should notice and pause itself, at which point it would yield to the scheduler.  This is the purpose of vcpu_{start,end}_shutdown_deferral(). Evidentially, this is not happening. Marek: can you add a BUG() after the weird PIO printing?  That should confirm whether we're getting into handle_pio() via the handle_hvm_io_completion() path, or via the vmexit path (at which case, we're fully re-entering the guest). I suspect you can drop the debugging of XEN_DOMCTL_destroydomain - I think its just noise atm. However, it would be very helpful to see the vcpus which fall into domain_shutdown()'s "else if ( v->defer_shutdown ) continue;" path. > Another question though: In 4.13 the log message next to the > domain_crash() I assume you're hitting is "Weird HVM ioemulation > status", not "Weird PIO status", and the debugging patch you > referenced doesn't have any change there. Andrew's recent > change to master, otoh, doesn't use the word "weird" anymore. I > can therefore only guess that the value logged is still > hvmemul_do_pio_buffer()'s return value, i.e. X86EMUL_UNHANDLEABLE. > Please confirm. It's the first draft of the patch which I did, before submitting to xen-devel.  We do have X86EMUL_UNHANDLEABLE at this point, but its not terribly helpful - there are loads of paths which fail silently with this error. ~Andrew --------------DCC7A6CAB5EFD944658332FB Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 8bit
On 04/06/2020 08:08, Jan Beulich wrote:
On 04.06.2020 03:46, Marek Marczykowski-Górecki wrote:
Then, we get the main issue:

    (XEN) d3v0 handle_pio port 0xb004 read 0x0000
    (XEN) d3v0 Weird PIO status 1, port 0xb004 read 0xffff
    (XEN) domain_crash called from io.c:178

Note, there was no XEN_DOMCTL_destroydomain for domain 3 nor its stubdom
yet. But XEN_DMOP_remote_shutdown for domain 3 was called already.
I'd guess an issue with the shutdown deferral logic. Did you / can
you check whether XEN_DMOP_remote_shutdown managed to pause all
CPUs (I assume it didn't, since once they're paused there shouldn't
be any I/O there anymore, and hence no I/O emulation)?

The vcpu in question is talking to Qemu, so will have v->defer_shutdown intermittently set, and skip the pause in domain_shutdown()

I presume this lack of pause is to allow the vcpu in question to still be scheduled to consume the IOREQ reply?  (Its fairly opaque logic with 0 clarifying details).

What *should* happen is that, after consuming the reply, the vcpu should notice and pause itself, at which point it would yield to the scheduler.  This is the purpose of vcpu_{start,end}_shutdown_deferral().

Evidentially, this is not happening.

Marek: can you add a BUG() after the weird PIO printing?  That should confirm whether we're getting into handle_pio() via the handle_hvm_io_completion() path, or via the vmexit path (at which case, we're fully re-entering the guest).

I suspect you can drop the debugging of XEN_DOMCTL_destroydomain - I think its just noise atm.

However, it would be very helpful to see the vcpus which fall into domain_shutdown()'s "else if ( v->defer_shutdown ) continue;" path.

Another question though: In 4.13 the log message next to the
domain_crash() I assume you're hitting is "Weird HVM ioemulation
status", not "Weird PIO status", and the debugging patch you
referenced doesn't have any change there. Andrew's recent
change to master, otoh, doesn't use the word "weird" anymore. I
can therefore only guess that the value logged is still
hvmemul_do_pio_buffer()'s return value, i.e. X86EMUL_UNHANDLEABLE.
Please confirm.

It's the first draft of the patch which I did, before submitting to xen-devel.  We do have X86EMUL_UNHANDLEABLE at this point, but its not terribly helpful - there are loads of paths which fail silently with this error.

~Andrew
--------------DCC7A6CAB5EFD944658332FB--