From nobody Sat Feb 7 09:46:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1611735479; cv=none; d=zohomail.com; s=zohoarc; b=YuciLhzPMjubI+K083ccY7XYoDOy1ldE9oIl2rxskTF5R0xz/P8tAGu7kBUaiCbd3J7XPJc4I3FqO3rkpuA/NsqsYypIGLNcTjcUHZTU7suscxBquhzNGyvTwio5xKcwjJ/GulGQIztYYMXI/m3E9fmCqgBc0lhYBu4pGV4fz4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611735479; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/EhjnIXtH6FCpQuS23+dXB+OzQ2jjIr1Cjqu713u57k=; b=YiqZFngeF1RFr0Urohjxhi6hWTjHLz1DmUr9mvVXdCmJN7htzKNyziowgdjRw37EWlImuNUKR1oi1U1AiGMAFyNiU8Zft3gRJKaFekGoS1SUY4dNgIu/MHVRbv9R25KlDPCh7jRPzDJli51fM4ZhAs69No3cGmT6EpIrueDiD6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1611735479047408.2474710774518; Wed, 27 Jan 2021 00:17:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.75810.136608 (Exim 4.92) (envelope-from ) id 1l4g1J-00064l-KO; Wed, 27 Jan 2021 08:17:45 +0000 Received: by outflank-mailman (output) from mailman id 75810.136608; Wed, 27 Jan 2021 08:17:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4g1J-00064d-HH; Wed, 27 Jan 2021 08:17:45 +0000 Received: by outflank-mailman (input) for mailman id 75810; Wed, 27 Jan 2021 08:17:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4g1H-00064K-UX for xen-devel@lists.xenproject.org; Wed, 27 Jan 2021 08:17:43 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 74e8d0d5-38aa-4695-8ed7-f6f2e3badaee; Wed, 27 Jan 2021 08:17:43 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 20104B73C; Wed, 27 Jan 2021 08:17:42 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 74e8d0d5-38aa-4695-8ed7-f6f2e3badaee X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611735462; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/EhjnIXtH6FCpQuS23+dXB+OzQ2jjIr1Cjqu713u57k=; b=aF26Ta4+ijGUcgekgJavvUN5V1x+CHjb6/vDd/lflDu3kCmhJK9mUTl63im1eKh0yeDw3t hj4+edcUxHNeSdsow8r4LX7+06r96K9mGCMEMT+aLGkKv2ZlNi/tig3Rq4D/1aOjYIoZB/ l0pEA1pc313PlvHBZOWqDobDAhCn7Xo= Subject: [PATCH v5 6/6] evtchn: drop acquiring of per-channel lock from send_guest_{global,vcpu}_virq() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Wei Liu , Stefano Stabellini References: <306e62e8-9070-2db9-c959-858465c50c1d@suse.com> Message-ID: <5c3e705a-d028-dc9e-0f22-cb2e55f250f7@suse.com> Date: Wed, 27 Jan 2021 09:17:42 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <306e62e8-9070-2db9-c959-858465c50c1d@suse.com> Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" The per-vCPU virq_lock, which is being held anyway, together with there not being any call to evtchn_port_set_pending() when v->virq_to_evtchn[] is zero, provide sufficient guarantees. Undo the lock addition done for XSA-343 (commit e045199c7c9c "evtchn: address races with evtchn_reset()"). Update the description next to struct evtchn_port_ops accordingly. Signed-off-by: Jan Beulich --- v4: Move to end of series, for being the most controversial change. v3: Re-base. v2: New. --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -812,7 +812,6 @@ void send_guest_vcpu_virq(struct vcpu *v unsigned long flags; int port; struct domain *d; - struct evtchn *chn; =20 ASSERT(!virq_is_global(virq)); =20 @@ -823,12 +822,7 @@ void send_guest_vcpu_virq(struct vcpu *v goto out; =20 d =3D v->domain; - chn =3D evtchn_from_port(d, port); - if ( evtchn_read_trylock(chn) ) - { - evtchn_port_set_pending(d, v->vcpu_id, chn); - evtchn_read_unlock(chn); - } + evtchn_port_set_pending(d, v->vcpu_id, evtchn_from_port(d, port)); =20 out: read_unlock_irqrestore(&v->virq_lock, flags); @@ -857,11 +851,7 @@ void send_guest_global_virq(struct domai goto out; =20 chn =3D evtchn_from_port(d, port); - if ( evtchn_read_trylock(chn) ) - { - evtchn_port_set_pending(d, chn->notify_vcpu_id, chn); - evtchn_read_unlock(chn); - } + evtchn_port_set_pending(d, chn->notify_vcpu_id, chn); =20 out: read_unlock_irqrestore(&v->virq_lock, flags); --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -193,9 +193,16 @@ int evtchn_reset(struct domain *d, bool * Low-level event channel port ops. * * All hooks have to be called with a lock held which prevents the channel - * from changing state. This may be the domain event lock, the per-channel - * lock, or in the case of sending interdomain events also the other side's - * per-channel lock. Exceptions apply in certain cases for the PV shim. + * from changing state. This may be + * - the domain event lock, + * - the per-channel lock, + * - in the case of sending interdomain events the other side's per-channel + * lock, + * - in the case of sending non-global vIRQ-s the per-vCPU virq_lock (in + * combination with the ordering enforced through how the vCPU's + * virq_to_evtchn[] gets updated), + * - in the case of sending global vIRQ-s vCPU 0's virq_lock. + * Exceptions apply in certain cases for the PV shim. */ struct evtchn_port_ops { void (*init)(struct domain *d, struct evtchn *evtchn);