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 46ACCC433E0 for ; Tue, 16 Jun 2020 14:03:26 +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 1D22A20810 for ; Tue, 16 Jun 2020 14:03:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D22A20810 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 1jlCB6-0001xn-5u; Tue, 16 Jun 2020 14:03:04 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jlCB4-0001xi-LD for xen-devel@lists.xenproject.org; Tue, 16 Jun 2020 14:03:02 +0000 X-Inumbo-ID: 165d980a-afda-11ea-b8e8-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 165d980a-afda-11ea-b8e8-12813bfff9fa; Tue, 16 Jun 2020 14:03:00 +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 83B12AC51; Tue, 16 Jun 2020 14:03:03 +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> <86e29001-4b33-de46-0675-0107a2e2b386@suse.com> <00c201d63e72$a9d28bb0$fd77a310$@xen.org> <00c401d63e74$cf5c4ef0$6e14ecd0$@xen.org> From: Jan Beulich Message-ID: Date: Tue, 16 Jun 2020 16:02:58 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <00c401d63e74$cf5c4ef0$6e14ecd0$@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" Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 09.06.2020 17:44, Paul Durrant wrote: >> From: Jan Beulich >> Sent: 09 June 2020 16:33 >> >> On 09.06.2020 17:28, Paul Durrant wrote: >>>> From: Jan Beulich >>>> Sent: 09 June 2020 16:08 >>>> >>>> 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? >>> >>> I guess the idea is that it should tolerate the emulator kicking the >>> event channel spuriously. I don't know whether this was the case at >>> one time, but it seems reasonable to be robust against waking up >>> from wait_on_xen_event_channel() before state has made it to >>> IORESP_READY. >> >> But such wakeup is taken care of by "goto recheck", not by the main >> loop in the function. > > Oh yes, sorry, I misread. It would be nice to get rid of the goto. I've done this in a pair of patches - first one doing as I suggested, second one doing as you suggested: Getting rid of the label and converting the fake loop put in place by the 1st one into a real loop again. I think it's better in two steps. But this isn't for 4.14, so I won't submit the pair right away. Jan