Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CC6ECC433F5 for ; Thu, 17 Mar 2022 08:46:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.291424.494571 (Exim 4.92) (envelope-from ) id 1nUllS-0002Qh-Vk; Thu, 17 Mar 2022 08:45:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 291424.494571; Thu, 17 Mar 2022 08:45:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nUllS-0002Qa-SO; Thu, 17 Mar 2022 08:45:46 +0000 Received: by outflank-mailman (input) for mailman id 291424; Thu, 17 Mar 2022 08:45:46 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nUllS-0002QS-7u for xen-devel@lists.xenproject.org; Thu, 17 Mar 2022 08:45:46 +0000 Received: from smarthost01a.ixn.mail.zen.net.uk (smarthost01a.ixn.mail.zen.net.uk [212.23.1.20]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a241d435-a5ce-11ec-8eba-a37418f5ba1a; Thu, 17 Mar 2022 09:45:45 +0100 (CET) Received: from [82.70.146.41] (helo=pear.davidvrabel.org.uk) by smarthost01a.ixn.mail.zen.net.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUllP-00059Y-Ub; Thu, 17 Mar 2022 08:45:43 +0000 Received: from apple.davidvrabel.org.uk ([82.70.146.43]) by pear.davidvrabel.org.uk with esmtp (Exim 4.92) (envelope-from ) id 1nUllO-00071h-Pd; Thu, 17 Mar 2022 08:45:43 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a241d435-a5ce-11ec-8eba-a37418f5ba1a Message-ID: <0811ec9b-2bf0-89cc-027c-3edd56e1c990@cantab.net> Date: Thu, 17 Mar 2022 08:45:43 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-GB To: Juergen Gross , Raphael Ning , xen-devel@lists.xenproject.org Cc: Raphael Ning , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , David Vrabel References: <6b84a20b2753130cc62406a0fd14d2708f6f504b.1647455219.git.raphning@amazon.com> From: David Vrabel In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 82.70.146.43 X-SA-Exim-Mail-From: dvrabel@cantab.net Subject: Re: [XEN PATCH] evtchn/fifo: Don't set PENDING bit if guest misbehaves X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on pear.davidvrabel.org.uk) X-Originating-smarthost01a-IP: [82.70.146.41] Feedback-ID: 82.70.146.41 On 17/03/2022 06:28, Juergen Gross wrote: > On 16.03.22 19:38, Raphael Ning wrote: >> From: Raphael Ning >> >> Currently, evtchn_fifo_set_pending() will mark the event as PENDING even >> if it fails to lock the FIFO event queue(s), or if the guest has not >> initialized the FIFO control block for the target vCPU. A well-behaved >> guest should never trigger either of these cases. > > Is this true even for the resume case e.g. after a migration? > > The guests starts on the new host with no FIFO control block for any > vcpu registered, so couldn't an event get lost with your patch in case > it was sent before the target vcpu's control block gets registered? An event that is PENDING but not LINKED is not reachable by the guest so it won't ever see such an event, so the event is lost whether the P bit is set or not. Guests ensure that event channels are not bound to VCPUs that don't (yet) have FIFO control blocks. For example, in Linux xen_irq_resume() reinitializes the control blocks (in xen_evtchn_resume()) before restoring any of the event channels. David