From nobody Mon Feb 9 11:07:23 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; 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=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1662500359009945.1301793455682; Tue, 6 Sep 2022 14:39:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.400106.641736 (Exim 4.92) (envelope-from ) id 1oVgHe-0006Ue-KG; Tue, 06 Sep 2022 21:39:02 +0000 Received: by outflank-mailman (output) from mailman id 400106.641736; Tue, 06 Sep 2022 21:39:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oVgHe-0006UT-H0; Tue, 06 Sep 2022 21:39:02 +0000 Received: by outflank-mailman (input) for mailman id 400106; Tue, 06 Sep 2022 21:39:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oVgGU-0000Cs-EE for xen-devel@lists.xenproject.org; Tue, 06 Sep 2022 21:37:50 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id bd567900-2de9-11ed-af93-0125da4c0113; Tue, 06 Sep 2022 15:42:24 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5BAFF1A2D; Tue, 6 Sep 2022 06:42:30 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A5B613F7B4; Tue, 6 Sep 2022 06:42:22 -0700 (PDT) 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: bd567900-2de9-11ed-af93-0125da4c0113 From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: rahul.singh@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , Julien Grall Subject: [PATCH v4 4/7] xen/evtchn: modify evtchn_alloc_unbound to allocate specified port Date: Tue, 6 Sep 2022 14:40:42 +0100 Message-Id: <1be278df2743b89e4b3a14e73b5e3a9064b2269a.1662462034.git.rahul.singh@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1662500359562100002 Content-Type: text/plain; charset="utf-8" Currently evtchn_alloc_unbound() always allocates the next available port. Static event channel support for dom0less domains requires allocating a specified port. Modify the evtchn_alloc_unbound() to accept the port number as an argument and allocate the specified port if available. If the port number argument is zero, the next available port will be allocated. Signed-off-by: Rahul Singh Acked-by: Jan Beulich Reviewed-by: Julien Grall --- Changes in v4: - no changes Changes in v3: - fix minor comments in commit msg Changes in v2: - fix minor comments --- xen/arch/arm/domain_build.c | 2 +- xen/common/event_channel.c | 17 ++++++++++++----- xen/include/xen/event.h | 3 ++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index fde133cd94..707e247f6a 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3171,7 +3171,7 @@ static int __init alloc_xenstore_evtchn(struct domain= *d) =20 alloc.dom =3D d->domain_id; alloc.remote_dom =3D hardware_domain->domain_id; - rc =3D evtchn_alloc_unbound(&alloc); + rc =3D evtchn_alloc_unbound(&alloc, 0); if ( rc ) { printk("Failed allocating event channel for domain\n"); diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 565ab71881..f546e81758 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -317,11 +317,15 @@ static int evtchn_get_port(struct domain *d, evtchn_p= ort_t port) return rc ?: port; } =20 -int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) +/* + * If port is zero get the next free port and allocate. If port is non-zero + * allocate the specified port. + */ +int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc, evtchn_port_t port) { struct evtchn *chn; struct domain *d; - int port, rc; + int rc; domid_t dom =3D alloc->dom; =20 d =3D rcu_lock_domain_by_any_id(dom); @@ -330,8 +334,11 @@ int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) =20 write_lock(&d->event_lock); =20 - if ( (port =3D get_free_port(d)) < 0 ) - ERROR_EXIT_DOM(port, d); + port =3D rc =3D evtchn_get_port(d, port); + if ( rc < 0 ) + ERROR_EXIT(rc); + rc =3D 0; + chn =3D evtchn_from_port(d, port); =20 rc =3D xsm_evtchn_unbound(XSM_TARGET, d, chn, alloc->remote_dom); @@ -1222,7 +1229,7 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PA= RAM(void) arg) struct evtchn_alloc_unbound alloc_unbound; if ( copy_from_guest(&alloc_unbound, arg, 1) !=3D 0 ) return -EFAULT; - rc =3D evtchn_alloc_unbound(&alloc_unbound); + rc =3D evtchn_alloc_unbound(&alloc_unbound, 0); if ( !rc && __copy_to_guest(arg, &alloc_unbound, 1) ) rc =3D -EFAULT; /* Cleaning up here would be a mess! */ break; diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index f3021fe304..f31963703f 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -72,7 +72,8 @@ void evtchn_free(struct domain *d, struct evtchn *chn); int evtchn_allocate_port(struct domain *d, unsigned int port); =20 /* Allocate a new event channel */ -int __must_check evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc); +int __must_check evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc, + evtchn_port_t port); =20 /* Unmask a local event-channel port. */ int evtchn_unmask(unsigned int port); --=20 2.25.1