From nobody Mon Feb 9 07:43:33 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 1655908833027765.3912518603977; Wed, 22 Jun 2022 07:40:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.354002.581035 (Exim 4.92) (envelope-from ) id 1o41WO-0006VI-4a; Wed, 22 Jun 2022 14:39:56 +0000 Received: by outflank-mailman (output) from mailman id 354002.581035; Wed, 22 Jun 2022 14:39:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o41WO-0006VB-1r; Wed, 22 Jun 2022 14:39:56 +0000 Received: by outflank-mailman (input) for mailman id 354002; Wed, 22 Jun 2022 14:39:54 +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 1o41WM-0004Nu-OP for xen-devel@lists.xenproject.org; Wed, 22 Jun 2022 14:39:54 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 2cc5fc79-f239-11ec-b725-ed86ccbb4733; Wed, 22 Jun 2022 16:39:52 +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 C111ED6E; Wed, 22 Jun 2022 07:39:52 -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 482D03F792; Wed, 22 Jun 2022 07:39:51 -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: 2cc5fc79-f239-11ec-b725-ed86ccbb4733 From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu Subject: [PATCH 5/8] xen/evtchn: don't close the static event channel. Date: Wed, 22 Jun 2022 15:38:02 +0100 Message-Id: <91656930b5bfd49e40ff5a9d060d7643e6311f4f.1655903088.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: 1655908833564100001 Content-Type: text/plain; charset="utf-8" Guest can request the Xen to close the event channels. Ignore the request from guest to close the static channels as static event channels should not be closed. Add the new bool variable "is_static" in "struct evtchn" to mark the event channel static when creating the event channel. Signed-off-by: Rahul Singh --- xen/arch/arm/domain_build.c | 2 +- xen/common/event_channel.c | 15 +++++++++++---- xen/include/xen/event.h | 4 ++-- xen/include/xen/sched.h | 1 + 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 5f97d9d181..89195b042c 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, 0); + rc =3D evtchn_alloc_unbound(&alloc, 0, false); 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 84f0055a5a..cedc98ccaf 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -294,7 +294,8 @@ void evtchn_free(struct domain *d, struct evtchn *chn) * 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) +int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc, evtchn_port_t port, + bool is_static) { struct evtchn *chn; struct domain *d; @@ -330,6 +331,7 @@ int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc,= evtchn_port_t port) evtchn_write_lock(chn); =20 chn->state =3D ECS_UNBOUND; + chn->is_static =3D is_static; if ( (chn->u.unbound.remote_domid =3D alloc->remote_dom) =3D=3D DOMID_= SELF ) chn->u.unbound.remote_domid =3D current->domain->domain_id; evtchn_port_init(d, chn); @@ -368,7 +370,7 @@ static void double_evtchn_unlock(struct evtchn *lchn, s= truct evtchn *rchn) * allocate the specified lport. */ int evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind, struct domain= *ld, - evtchn_port_t lport) + evtchn_port_t lport, bool is_static) { struct evtchn *lchn, *rchn; struct domain *rd; @@ -423,6 +425,7 @@ int evtchn_bind_interdomain(evtchn_bind_interdomain_t *= bind, struct domain *ld, lchn->u.interdomain.remote_dom =3D rd; lchn->u.interdomain.remote_port =3D rport; lchn->state =3D ECS_INTERDOMAIN; + lchn->is_static =3D is_static; evtchn_port_init(ld, lchn); =20 rchn->u.interdomain.remote_dom =3D ld; @@ -659,6 +662,9 @@ int evtchn_close(struct domain *d1, int port1, bool gue= st) rc =3D -EINVAL; goto out; } + /* Guest cannot close a static event channel. */ + if ( chn1->is_static && guest ) + goto out; =20 switch ( chn1->state ) { @@ -1238,7 +1244,7 @@ long cf_check do_event_channel_op(int cmd, XEN_GUEST_= HANDLE_PARAM(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, 0); + rc =3D evtchn_alloc_unbound(&alloc_unbound, 0, false); if ( !rc && __copy_to_guest(arg, &alloc_unbound, 1) ) rc =3D -EFAULT; /* Cleaning up here would be a mess! */ break; @@ -1248,7 +1254,8 @@ long cf_check do_event_channel_op(int cmd, XEN_GUEST_= HANDLE_PARAM(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, current->domain,= 0); + rc =3D evtchn_bind_interdomain(&bind_interdomain, current->domain, + 0, false); 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 8eae9984a9..71ad4c5bfd 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -73,12 +73,12 @@ 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, - evtchn_port_t port); + evtchn_port_t port, bool is_static); =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); + evtchn_port_t port, bool is_stati= c); =20 /* Unmask a local event-channel port. */ int evtchn_unmask(unsigned int port); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 463d41ffb6..da823c8091 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -119,6 +119,7 @@ struct evtchn unsigned char priority; /* FIFO event channels only. */ unsigned short notify_vcpu_id; /* VCPU for local delivery notification= */ uint32_t fifo_lastq; /* Data for identifying last queue. */ + bool is_static; /* Static event channels. */ =20 #ifdef CONFIG_XSM union { --=20 2.25.1