From nobody Mon Feb 9 19:52:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1559564919; cv=none; d=zoho.com; s=zohoarc; b=Qj6hQg1fDiRVYdracFh+2izK/K2zjsIz2m5mG4R+iq/9V6lSisyB4JM75ZxipPCIeTLZkKDdZwUow29ZpVegmgzQ/YyHe1wOuzUDjvbs1a/FGgZBe+3nBL+w68JnC2MOJl3rw2MELG0U+/RZB/rNqwXrLMOKU61Hru+SCn0A38U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559564919; 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:ARC-Authentication-Results; bh=2CV4wM1JDXZRnZ49uSPLtD+eUrRThU5ZlgezyriezYs=; b=k72zIGMvhf6Rh4RSBUGjchJVozdY9v9X4ub6+WGecGoeYXuyc8LbQYIPCPc7Qm/l/XAkhd3D2UYOEoqyUibfzmU+wUXXVs/x+CUI0ibJiF/C+WfIGn+UHOxROkQ5D8NH6bG4dFQPKM25Kbqo62cDMK77HNYt+jlxYzgF3DB0xZo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1559564919229542.1271292001747; Mon, 3 Jun 2019 05:28:39 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXm3h-0002iT-5I; Mon, 03 Jun 2019 12:27:25 +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.89) (envelope-from ) id 1hXm3g-0002iO-Hb for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 12:27:24 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id eed7ffe6-85fa-11e9-9be6-cfe6b1c824ea; Mon, 03 Jun 2019 12:27:21 +0000 (UTC) X-Inumbo-ID: eed7ffe6-85fa-11e9-9be6-cfe6b1c824ea Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@MIAPEX02MSOL01.citrite.net Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=23.29.105.83; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 23.29.105.83 as permitted sender) identity=mailfrom; client-ip=23.29.105.83; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:23.29.105.83 ip4:162.221.156.50 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@MIAPEX02MSOL01.citrite.net) identity=helo; client-ip=23.29.105.83; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@MIAPEX02MSOL01.citrite.net"; x-conformance=sidf_compatible IronPort-SDR: Ty6Phr2GVWEJclTFj3bkiAoX+IXq1C/E2PNA2X5FzranmkKpNahXp8EVnHB+2w1xlvBz6jDfTj 5tFIC+PCeg9iyNVYAOJV0CckG5f/RxfhUAn2K2SDpH8bPYcc8gH999DnQHZCc8X7KMCA2hiwvw YXqB5FWpwilYGEl0UwgNIr5PlXI2flawlvb5AEDUXNE4nLw6Qgm1jD5U9OSClyDDHhAwoJWqDN ArLIFanoqC3QBZxcndKGCj5E0cdAAYXk8O9C3mqzJfWUWffMusuvoyKna40GAyars+hJYX4HGn uzA= X-SBRS: 2.7 X-MesageID: 1239336 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 23.29.105.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.60,546,1549947600"; d="scan'208";a="1239336" From: Andrew Cooper To: Xen-devel Date: Mon, 3 Jun 2019 13:25:27 +0100 Message-ID: <1559564728-17167-5-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> References: <1559564728-17167-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/5] xen/vm-event: Fix interactions with the vcpu list X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Petre Pircalabu , Andrew Cooper , Tamas K Lengyel , Razvan Cojocaru Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" vm_event_resume() should use domain_vcpu(), rather than opencoding it without its Spectre v1 safety. vm_event_wake_blocked() can't ever be invoked in a case where d->vcpu is NULL, so drop the outer if() and reindent, fixing up style issues. The comment, which is left alone, is false. This algorithm still has starvation issues when there is an asymetric rate of generated events. However, the existing logic is sufficiently complicated and fragile that I don't think I've followed it fully, and because we're trying to obsolete this interface, the safest course of action is to leave it alone, rather than to end up making things subtly different. Therefore, no practical change that callers would notice. Signed-off-by: Andrew Cooper Acked-by: Razvan Cojocaru --- CC: Razvan Cojocaru CC: Tamas K Lengyel CC: Petre Pircalabu --- xen/common/vm_event.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index dcba98c..72f42b4 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -119,34 +119,29 @@ static unsigned int vm_event_ring_available(struct vm= _event_domain *ved) static void vm_event_wake_blocked(struct domain *d, struct vm_event_domain= *ved) { struct vcpu *v; - unsigned int avail_req =3D vm_event_ring_available(ved); + unsigned int i, j, k, avail_req =3D vm_event_ring_available(ved); =20 if ( avail_req =3D=3D 0 || ved->blocked =3D=3D 0 ) return; =20 /* We remember which vcpu last woke up to avoid scanning always linear= ly * from zero and starving higher-numbered vcpus under high load */ - if ( d->vcpu ) + for ( i =3D ved->last_vcpu_wake_up + 1, j =3D 0; j < d->max_vcpus; i++= , j++ ) { - int i, j, k; - - for (i =3D ved->last_vcpu_wake_up + 1, j =3D 0; j < d->max_vcpus; = i++, j++) - { - k =3D i % d->max_vcpus; - v =3D d->vcpu[k]; - if ( !v ) - continue; + k =3D i % d->max_vcpus; + v =3D d->vcpu[k]; + if ( !v ) + continue; =20 - if ( !(ved->blocked) || avail_req =3D=3D 0 ) - break; + if ( !ved->blocked || avail_req =3D=3D 0 ) + break; =20 - if ( test_and_clear_bit(ved->pause_flag, &v->pause_flags) ) - { - vcpu_unpause(v); - avail_req--; - ved->blocked--; - ved->last_vcpu_wake_up =3D k; - } + if ( test_and_clear_bit(ved->pause_flag, &v->pause_flags) ) + { + vcpu_unpause(v); + avail_req--; + ved->blocked--; + ved->last_vcpu_wake_up =3D k; } } } @@ -382,11 +377,10 @@ static int vm_event_resume(struct domain *d, struct v= m_event_domain *ved) } =20 /* Validate the vcpu_id in the response. */ - if ( (rsp.vcpu_id >=3D d->max_vcpus) || !d->vcpu[rsp.vcpu_id] ) + v =3D domain_vcpu(d, rsp.vcpu_id); + if ( !v ) continue; =20 - v =3D d->vcpu[rsp.vcpu_id]; - /* * In some cases the response type needs extra handling, so here * we call the appropriate handlers. --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel