From nobody Mon Feb 9 02:43:21 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 1662568771694217.92184542032192; Wed, 7 Sep 2022 09:39:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.402085.644083 (Exim 4.92) (envelope-from ) id 1oVy4x-000339-9P; Wed, 07 Sep 2022 16:39:07 +0000 Received: by outflank-mailman (output) from mailman id 402085.644083; Wed, 07 Sep 2022 16:39:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oVy4x-000332-5k; Wed, 07 Sep 2022 16:39:07 +0000 Received: by outflank-mailman (input) for mailman id 402085; Wed, 07 Sep 2022 16:39:06 +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 1oVxxG-0007z7-5L for xen-devel@lists.xenproject.org; Wed, 07 Sep 2022 16:31:10 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7a5220fd-2eca-11ed-af93-0125da4c0113; Wed, 07 Sep 2022 18:31:09 +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 B3EAD13D5; Wed, 7 Sep 2022 09:31:14 -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 5515B3F71A; Wed, 7 Sep 2022 09:31:07 -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: 7a5220fd-2eca-11ed-af93-0125da4c0113 From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Julien Grall Subject: [PATCH v5 5/7] xen/evtchn: modify evtchn_bind_interdomain to support static evtchn Date: Wed, 7 Sep 2022 17:27:36 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1662568773129100003 Content-Type: text/plain; charset="utf-8" Static event channel support will be added for dom0less domains. Modify evtchn_bind_interdomain to support static evtchn. It is necessary to have access to the evtchn_bind_interdomain function to do that, so make evtchn_bind_interdomain global and also make it __must_check. Currently evtchn_bind_interdomain() always allocates the next available local port. Static event channel support for dom0less domains requires allocating a specified port. Modify the evtchn_bind_interdomain 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. Currently evtchn_bind_interdomain() finds the local domain from "current->domain" pointer. evtchn_bind_interdomain() will be called from the XEN to create static event channel during domain creation. "current" pointer is not valid at that time, therefore modify the evtchn_bind_interdomain() to pass domain as an argument. Signed-off-by: Rahul Singh Acked-by: Jan Beulich Reviewed-by: Julien Grall --- Changes in v5: - no changes Changes in v4: - no changes Changes in v3: - fix minor comments in commit msg Changes in v2: - Merged patches related to evtchn_bind_interdomain in one patch --- xen/common/event_channel.c | 20 ++++++++++++++------ xen/include/xen/event.h | 5 +++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index f546e81758..f5e0b12d15 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -381,11 +381,16 @@ static void double_evtchn_unlock(struct evtchn *lchn,= struct evtchn *rchn) evtchn_write_unlock(rchn); } =20 -static int evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind) +/* + * If lport is zero get the next free port and allocate. If port is non-ze= ro + * allocate the specified lport. + */ +int evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind, struct domain= *ld, + evtchn_port_t lport) { struct evtchn *lchn, *rchn; - struct domain *ld =3D current->domain, *rd; - int lport, rc; + struct domain *rd; + int rc; evtchn_port_t rport =3D bind->remote_port; domid_t rdom =3D bind->remote_dom; =20 @@ -405,8 +410,11 @@ static int evtchn_bind_interdomain(evtchn_bind_interdo= main_t *bind) write_lock(&ld->event_lock); } =20 - if ( (lport =3D get_free_port(ld)) < 0 ) - ERROR_EXIT(lport); + lport =3D rc =3D evtchn_get_port(ld, lport); + if ( rc < 0 ) + ERROR_EXIT(rc); + rc =3D 0; + lchn =3D evtchn_from_port(ld, lport); =20 rchn =3D _evtchn_from_port(rd, rport); @@ -1239,7 +1247,7 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PA= RAM(void) arg) struct evtchn_bind_interdomain bind_interdomain; if ( copy_from_guest(&bind_interdomain, arg, 1) !=3D 0 ) return -EFAULT; - rc =3D evtchn_bind_interdomain(&bind_interdomain); + rc =3D evtchn_bind_interdomain(&bind_interdomain, current->domain,= 0); if ( !rc && __copy_to_guest(arg, &bind_interdomain, 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 f31963703f..8eae9984a9 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -75,6 +75,11 @@ int evtchn_allocate_port(struct domain *d, unsigned int = port); int __must_check evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc, evtchn_port_t port); =20 +/* Bind an event channel port to interdomain */ +int __must_check evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind, + struct domain *ld, + evtchn_port_t port); + /* Unmask a local event-channel port. */ int evtchn_unmask(unsigned int port); =20 --=20 2.25.1