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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 195AFC433E0 for ; Tue, 9 Jun 2020 15:08:08 +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 E448820734 for ; Tue, 9 Jun 2020 15:08:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E448820734 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.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 1jifqz-0001S3-4z; Tue, 09 Jun 2020 15:07:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jifqx-0001Rv-Qs for xen-devel@lists.xenproject.org; Tue, 09 Jun 2020 15:07:51 +0000 X-Inumbo-ID: fc6bb7f0-aa62-11ea-bca7-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fc6bb7f0-aa62-11ea-bca7-bc764e2007e4; Tue, 09 Jun 2020 15:07:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C39DBACC3; Tue, 9 Jun 2020 15:07:53 +0000 (UTC) Subject: Re: [PATCH-for-4.14] ioreq: handle pending emulation racing with ioreq server destruction To: paul@xen.org References: <20200608094619.28336-1-paul@xen.org> <4d63c9c7-f4e8-4c56-7778-df17b3c5254b@suse.com> <002a01d63d84$9c351430$d49f3c90$@xen.org> From: Jan Beulich Message-ID: <86e29001-4b33-de46-0675-0107a2e2b386@suse.com> Date: Tue, 9 Jun 2020 17:07:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <002a01d63d84$9c351430$d49f3c90$@xen.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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@lists.xenproject.org, 'Paul Durrant' , =?UTF-8?Q?=27Marek_Marczykowski-G=c3=b3recki=27?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 08.06.2020 13:04, Paul Durrant wrote: >> From: Jan Beulich >> Sent: 08 June 2020 11:58 >> >> On 08.06.2020 11:46, Paul Durrant wrote: >>> --- a/xen/arch/x86/hvm/ioreq.c >>> +++ b/xen/arch/x86/hvm/ioreq.c >>> @@ -109,15 +109,7 @@ static void hvm_io_assist(struct hvm_ioreq_vcpu *sv, uint64_t data) >>> ioreq_t *ioreq = &v->arch.hvm.hvm_io.io_req; >>> >>> if ( hvm_ioreq_needs_completion(ioreq) ) >>> - { >>> - ioreq->state = STATE_IORESP_READY; >>> ioreq->data = data; >>> - } >>> - else >>> - ioreq->state = STATE_IOREQ_NONE; >>> - >>> - msix_write_completion(v); >>> - vcpu_end_shutdown_deferral(v); >>> >>> sv->pending = false; >>> } >> >> With this, is the function worth keeping at all? > > I did think about that, but it is called in more than one place. So, > in the interest of trying to make back-porting straightforward, I > thought it best to keep it simple. Fair enough, but going forward I still think it would be nice to get rid of the function. To do this sufficiently cleanly, the main question I have is: Why is hvm_wait_for_io() implemented as a loop? Hasn't this become pointless with the XSA-262 fix? Switching this to a do {} while(false) construct (seeing that the only caller has already checked sv->pending) would look to allow moving what is now in hvm_io_assist() immediately past this construct, at the expense of a local variable holding ~0ul initially and then in the common case p->data. Thoughts? (I'll be happy to make such a patch, I'm just checking whether I'm overlooking something crucial.) Jan