From nobody Sun May 19 01:15:18 2024 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 1662023654603449.64950592239154; Thu, 1 Sep 2022 02:14:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.396361.636483 (Exim 4.92) (envelope-from ) id 1oTgGc-0005T3-NE; Thu, 01 Sep 2022 09:13:42 +0000 Received: by outflank-mailman (output) from mailman id 396361.636483; Thu, 01 Sep 2022 09:13:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTgGc-0005Sw-K8; Thu, 01 Sep 2022 09:13:42 +0000 Received: by outflank-mailman (input) for mailman id 396361; Thu, 01 Sep 2022 09:13:41 +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 1oTgGb-000527-3D for xen-devel@lists.xenproject.org; Thu, 01 Sep 2022 09:13:41 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 5dbec31a-29d6-11ed-82f2-63bd783d45fa; Thu, 01 Sep 2022 11:13:39 +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 91EC6D6E; Thu, 1 Sep 2022 02:13:45 -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 1AEC63F766; Thu, 1 Sep 2022 02:13:38 -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: 5dbec31a-29d6-11ed-82f2-63bd783d45fa From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Julien Grall , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v3 1/7] xen/evtchn: Make sure all buckets below d->valid_evtchns are allocated Date: Thu, 1 Sep 2022 10:13:00 +0100 Message-Id: <2b7be7ea9f2f06939ebc185490196f20614b6a3b.1662023183.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: 1662023656497100001 Content-Type: text/plain; charset="utf-8" From: Julien Grall Since commit 01280dc19cf3 "evtchn: simplify port_is_valid()", the event channels code assumes that all the buckets below d->valid_evtchns are always allocated. This assumption hold in most of the situation because a guest is not allowed to chose the port. Instead, it will be the first free from port 0. When static event channel support will be added for dom0less domains user can request to allocate the evtchn port numbers that are scattered in nature. The existing implementation of evtchn_allocate_port() is not able to deal with such situation and will end up to override bucket or/and leave some bucket unallocated. The latter will result to a droplet crash if the event channel belongs to an unallocated bucket. This can be solved by making sure that all the buckets below d->valid_evtchns are allocated. There should be no impact for most of the situation but LM/LU as only one bucket would be allocated. For LM/LU, we may end up to allocate multiple buckets if ports in use are sparse. A potential alternative is to check that the bucket is valid in is_port_valid(). This should still possible to do it without taking per-domain lock but will result a couple more of memory access. Signed-off-by: Julien Grall Signed-off-by: Rahul Singh Reviewed-by: Michal Orzel --- Changes in v3: - fix comments in commit msg. - modify code related to d->valid_evtchns and {read,write}_atomic() Changes in v2: - new patch in this version to avoid the security issue --- xen/common/event_channel.c | 55 ++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index c2c6f8c151..80b06d9743 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -193,6 +193,15 @@ static struct evtchn *alloc_evtchn_bucket(struct domai= n *d, unsigned int port) return NULL; } =20 +/* + * Allocate a given port and ensure all the buckets up to that ports + * have been allocated. + * + * The last part is important because the rest of the event channel code + * relies on all the buckets up to d->valid_evtchns to be valid. However, + * event channels may be sparsed when restoring a domain during Guest + * Transparent Migration and Live Update. + */ int evtchn_allocate_port(struct domain *d, evtchn_port_t port) { if ( port > d->max_evtchn_port || port >=3D max_evtchns(d) ) @@ -207,30 +216,36 @@ int evtchn_allocate_port(struct domain *d, evtchn_por= t_t port) } else { - struct evtchn *chn; - struct evtchn **grp; + unsigned int alloc_port =3D read_atomic(&d->valid_evtchns); =20 - if ( !group_from_port(d, port) ) + do { - grp =3D xzalloc_array(struct evtchn *, BUCKETS_PER_GROUP); - if ( !grp ) - return -ENOMEM; - group_from_port(d, port) =3D grp; - } + struct evtchn *chn; + struct evtchn **grp; =20 - chn =3D alloc_evtchn_bucket(d, port); - if ( !chn ) - return -ENOMEM; - bucket_from_port(d, port) =3D chn; + if ( !group_from_port(d, alloc_port) ) + { + grp =3D xzalloc_array(struct evtchn *, BUCKETS_PER_GROUP); + if ( !grp ) + return -ENOMEM; + group_from_port(d, alloc_port) =3D grp; + } =20 - /* - * d->valid_evtchns is used to check whether the bucket can be - * accessed without the per-domain lock. Therefore, - * d->valid_evtchns should be seen *after* the new bucket has - * been setup. - */ - smp_wmb(); - write_atomic(&d->valid_evtchns, d->valid_evtchns + EVTCHNS_PER_BUC= KET); + chn =3D alloc_evtchn_bucket(d, alloc_port); + if ( !chn ) + return -ENOMEM; + bucket_from_port(d, alloc_port) =3D chn; + + /* + * d->valid_evtchns is used to check whether the bucket can be + * accessed without the per-domain lock. Therefore, + * d->valid_evtchns should be seen *after* the new bucket has + * been setup. + */ + smp_wmb(); + alloc_port +=3D EVTCHNS_PER_BUCKET; + write_atomic(&d->valid_evtchns, alloc_port); + } while ( port >=3D alloc_port ); } =20 write_atomic(&d->active_evtchns, d->active_evtchns + 1); --=20 2.25.1 From nobody Sun May 19 01:15:18 2024 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 1662023664917851.7070200294421; Thu, 1 Sep 2022 02:14:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.396371.636494 (Exim 4.92) (envelope-from ) id 1oTgH3-00064C-Vy; Thu, 01 Sep 2022 09:14:09 +0000 Received: by outflank-mailman (output) from mailman id 396371.636494; Thu, 01 Sep 2022 09:14:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTgH3-000645-Si; Thu, 01 Sep 2022 09:14:09 +0000 Received: by outflank-mailman (input) for mailman id 396371; Thu, 01 Sep 2022 09:14:08 +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 1oTgH2-000527-8t for xen-devel@lists.xenproject.org; Thu, 01 Sep 2022 09:14:08 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 6e0f5312-29d6-11ed-82f2-63bd783d45fa; Thu, 01 Sep 2022 11:14:06 +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 09029D6E; Thu, 1 Sep 2022 02:14:13 -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 6B4363F766; Thu, 1 Sep 2022 02:14:05 -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: 6e0f5312-29d6-11ed-82f2-63bd783d45fa From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Stanislav Kinsburskii , Julien Grall Subject: [PATCH v3 2/7] xen/evtchn: Add an helper to reserve/allocate a port Date: Thu, 1 Sep 2022 10:13:01 +0100 Message-Id: <4f8f5abdb7d9dfb241794375d3705524b5b53490.1662023183.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: 1662023666508100001 Content-Type: text/plain; charset="utf-8" In a follow-up patch we will want to either reserve or allocate a port for various event channel helpers. A new wrapper is introduced to either reserve a given port or allocate a fresh one if zero. Take the opportunity to replace the open-coded version in evtchn_bind_virq(). Signed-off-by: Stanislav Kinsburskii Signed-off-by: Julien Grall Signed-off-by: Rahul Singh Acked-by: Jan Beulich --- Changes in v3: - minor comments in commit msg Changes in v2: - new patch in this version --- xen/common/event_channel.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 80b06d9743..ef4da0781d 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -305,6 +305,18 @@ void evtchn_free(struct domain *d, struct evtchn *chn) xsm_evtchn_close_post(chn); } =20 +static int evtchn_get_port(struct domain *d, evtchn_port_t port) +{ + int rc; + + if ( port !=3D 0 ) + rc =3D evtchn_allocate_port(d, port); + else + rc =3D get_free_port(d); + + return rc ?: port; +} + int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) { struct evtchn *chn; @@ -462,19 +474,10 @@ int evtchn_bind_virq(evtchn_bind_virq_t *bind, evtchn= _port_t port) if ( read_atomic(&v->virq_to_evtchn[virq]) ) ERROR_EXIT(-EEXIST); =20 - if ( port !=3D 0 ) - { - if ( (rc =3D evtchn_allocate_port(d, port)) !=3D 0 ) - ERROR_EXIT(rc); - } - else - { - int alloc_port =3D get_free_port(d); - - if ( alloc_port < 0 ) - ERROR_EXIT(alloc_port); - port =3D alloc_port; - } + port =3D rc =3D evtchn_get_port(d, port); + if ( rc < 0 ) + ERROR_EXIT(rc); + rc =3D 0; =20 chn =3D evtchn_from_port(d, port); =20 --=20 2.25.1 From nobody Sun May 19 01:15:18 2024 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 1662023682244128.14180164056359; Thu, 1 Sep 2022 02:14:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.396374.636505 (Exim 4.92) (envelope-from ) id 1oTgHL-0006YX-6T; Thu, 01 Sep 2022 09:14:27 +0000 Received: by outflank-mailman (output) from mailman id 396374.636505; Thu, 01 Sep 2022 09:14:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTgHL-0006YQ-3P; Thu, 01 Sep 2022 09:14:27 +0000 Received: by outflank-mailman (input) for mailman id 396374; Thu, 01 Sep 2022 09:14:25 +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 1oTgHJ-000527-UK for xen-devel@lists.xenproject.org; Thu, 01 Sep 2022 09:14:25 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 789bd957-29d6-11ed-82f2-63bd783d45fa; Thu, 01 Sep 2022 11:14: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 A8EE1D6E; Thu, 1 Sep 2022 02:14: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 9C9DF3F766; Thu, 1 Sep 2022 02:14:23 -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: 789bd957-29d6-11ed-82f2-63bd783d45fa From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH v3 3/7] xen/evtchn: restrict the maximum number of evtchn supported for domUs Date: Thu, 1 Sep 2022 10:13:02 +0100 Message-Id: <4ae16201df27aee274a3d740128812b118c252b3.1662023183.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: 1662023682653100001 Content-Type: text/plain; charset="utf-8" Restrict the maximum number of evtchn supported for domUs to avoid allocating a large amount of memory in Xen. Set the default value of max_evtchn_port to 1023. The value of 1023 should be sufficient for domUs guests because on ARM we don't bind physical interrupts to event channels. The only use of the evtchn port is inter-domain communications. Signed-off-by: Rahul Singh Reviewed-by: Michal Orzel --- Changes in v3: - added in commit msg why we set the max_evtchn_port value to 1023. - added the comment in code also why we set the max_evtchn_port to 1023 - remove the define and set the value to 1023 in code directly. Changes in v2: - new patch in the version --- xen/arch/arm/domain_build.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 3fd1186b53..fde133cd94 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3277,7 +3277,13 @@ void __init create_domUs(void) struct xen_domctl_createdomain d_cfg =3D { .arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE, .flags =3D XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap, - .max_evtchn_port =3D -1, + /* + * The default of 1023 should be sufficient for domUs guests + * because on ARM we don't bind physical interrupts to event + * channels. The only use of the evtchn port is inter-domain + * communications. + */ + .max_evtchn_port =3D 1023, .max_grant_frames =3D -1, .max_maptrack_frames =3D -1, .grant_opts =3D XEN_DOMCTL_GRANT_version(opt_gnttab_max_versio= n), --=20 2.25.1 From nobody Sun May 19 01:15:18 2024 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 1662023959584971.106583979588; Thu, 1 Sep 2022 02:19:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.396391.636543 (Exim 4.92) (envelope-from ) id 1oTgLm-0007zA-OH; Thu, 01 Sep 2022 09:19:02 +0000 Received: by outflank-mailman (output) from mailman id 396391.636543; Thu, 01 Sep 2022 09:19: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 1oTgLm-0007yP-Fb; Thu, 01 Sep 2022 09:19:02 +0000 Received: by outflank-mailman (input) for mailman id 396391; Thu, 01 Sep 2022 09:19: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 1oTgHj-000527-FP for xen-devel@lists.xenproject.org; Thu, 01 Sep 2022 09:14:51 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 87ac2b65-29d6-11ed-82f2-63bd783d45fa; Thu, 01 Sep 2022 11:14:49 +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 E92B5D6E; Thu, 1 Sep 2022 02:14:55 -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 580393F766; Thu, 1 Sep 2022 02:14:48 -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: 87ac2b65-29d6-11ed-82f2-63bd783d45fa 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 , Julien Grall Subject: [PATCH v3 4/7] xen/evtchn: modify evtchn_alloc_unbound to allocate specified port Date: Thu, 1 Sep 2022 10:13:03 +0100 Message-Id: <1327a2cf71f7d3b38a57124831e057f18685d24a.1662023183.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: 1662023961672100002 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 Reviewed-by: Julien Grall Acked-by: Jan Beulich --- 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 ef4da0781d..b464f09d2a 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 From nobody Sun May 19 01:15:18 2024 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 1662023966448657.7792994653312; Thu, 1 Sep 2022 02:19:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.396387.636520 (Exim 4.92) (envelope-from ) id 1oTgLl-0007So-0j; Thu, 01 Sep 2022 09:19:01 +0000 Received: by outflank-mailman (output) from mailman id 396387.636520; Thu, 01 Sep 2022 09:19:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTgLk-0007Ro-St; Thu, 01 Sep 2022 09:19:00 +0000 Received: by outflank-mailman (input) for mailman id 396387; Thu, 01 Sep 2022 09:19:00 +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 1oTgI5-000527-2e for xen-devel@lists.xenproject.org; Thu, 01 Sep 2022 09:15:13 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 949126c1-29d6-11ed-82f2-63bd783d45fa; Thu, 01 Sep 2022 11:15:11 +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 9BC8ED6E; Thu, 1 Sep 2022 02:15:17 -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 23B3F3F766; Thu, 1 Sep 2022 02:15:10 -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: 949126c1-29d6-11ed-82f2-63bd783d45fa From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Julien Grall Subject: [PATCH v3 5/7] xen/evtchn: modify evtchn_bind_interdomain to support static evtchn Date: Thu, 1 Sep 2022 10:13:04 +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: 1662023967517100001 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 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 b464f09d2a..19832002aa 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 From nobody Sun May 19 01:15:18 2024 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 1662023960080584.8394086990019; Thu, 1 Sep 2022 02:19:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.396390.636538 (Exim 4.92) (envelope-from ) id 1oTgLm-0007tP-A3; Thu, 01 Sep 2022 09:19:02 +0000 Received: by outflank-mailman (output) from mailman id 396390.636538; Thu, 01 Sep 2022 09:19: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 1oTgLm-0007s2-4m; Thu, 01 Sep 2022 09:19:02 +0000 Received: by outflank-mailman (input) for mailman id 396390; Thu, 01 Sep 2022 09:19:00 +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 1oTgIW-000527-N5 for xen-devel@lists.xenproject.org; Thu, 01 Sep 2022 09:15:40 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id a4e5316f-29d6-11ed-82f2-63bd783d45fa; Thu, 01 Sep 2022 11:15:38 +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 E65E3D6E; Thu, 1 Sep 2022 02:15:44 -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 BF0D23F766; Thu, 1 Sep 2022 02:15:37 -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: a4e5316f-29d6-11ed-82f2-63bd783d45fa From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH v3 6/7] xen/arm: introduce xen-evtchn dom0less property Date: Thu, 1 Sep 2022 10:13:05 +0100 Message-Id: <3899ada4cc8217b45eab4f8d85492b0d5a6a9580.1662023183.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: 1662023961698100005 Content-Type: text/plain; charset="utf-8" Introduce a new sub-node under /chosen node to establish static event channel communication between domains on dom0less systems. An event channel will be created beforehand to allow the domains to send notifications to each other. Signed-off-by: Rahul Singh --- Changes in v3: - use device-tree used_by to find the domain id of the evtchn node. - add new static_evtchn_create variable in struct dt_device_node to hold the information if evtchn is already created. - fix minor comments Changes in v2: - no change --- docs/misc/arm/device-tree/booting.txt | 64 ++++++++++++- xen/arch/arm/domain_build.c | 128 ++++++++++++++++++++++++++ xen/arch/arm/include/asm/setup.h | 1 + xen/arch/arm/setup.c | 2 + xen/include/xen/device_tree.h | 13 +++ 5 files changed, 207 insertions(+), 1 deletion(-) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index 98253414b8..edef98e6d1 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -212,7 +212,7 @@ with the following properties: enable only selected interfaces. =20 Under the "xen,domain" compatible node, one or more sub-nodes are present -for the DomU kernel and ramdisk. +for the DomU kernel, ramdisk and static event channel. =20 The kernel sub-node has the following properties: =20 @@ -254,11 +254,44 @@ The ramdisk sub-node has the following properties: property because it will be created by the UEFI stub on boot. This option is needed only when UEFI boot is used. =20 +The static event channel sub-node has the following properties: + +- compatible + + "xen,evtchn" + +- xen,evtchn + + The property is tuples of two numbers + (local-evtchn link-to-foreign-evtchn) where: + + local-evtchn is an integer value that will be used to allocate local p= ort + for a domain to send and receive event notifications to/from the remote + domain. Maximum supported value is 2^17 for FIFO ABI and 4096 for 2L A= BI. + It is recommended to use low event channel IDs. + + link-to-foreign-evtchn is a single phandle to a remote evtchn to which + local-evtchn will be connected. =20 Example =3D=3D=3D=3D=3D=3D=3D =20 chosen { + + module@0 { + compatible =3D "multiboot,kernel", "multiboot,module"; + xen,uefi-binary =3D "..."; + bootargs =3D "..."; + + }; + + /* one sub-node per local event channel */ + ec1: evtchn@1 { + compatible =3D "xen,evtchn-v1"; + /* local-evtchn link-to-foreign-evtchn */ + xen,evtchn =3D <0xa &ec2>; + }; + domU1 { compatible =3D "xen,domain"; #address-cells =3D <0x2>; @@ -277,6 +310,23 @@ chosen { compatible =3D "multiboot,ramdisk", "multiboot,module"; reg =3D <0x0 0x4b000000 0xffffff>; }; + + /* one sub-node per local event channel */ + ec2: evtchn@2 { + compatible =3D "xen,evtchn-v1"; + /* local-evtchn link-to-foreign-evtchn */ + xen,evtchn =3D <0xa &ec1>; + }; + + ec3: evtchn@3 { + compatible =3D "xen,evtchn-v1"; + xen,evtchn =3D <0xb &ec5>; + }; + + ec4: evtchn@4 { + compatible =3D "xen,evtchn-v1"; + xen,evtchn =3D <0xc &ec6>; + }; }; =20 domU2 { @@ -296,6 +346,18 @@ chosen { compatible =3D "multiboot,ramdisk", "multiboot,module"; reg =3D <0x0 0x4d000000 0xffffff>; }; + + /* one sub-node per local event channel */ + ec5: evtchn@5 { + compatible =3D "xen,evtchn-v1"; + /* local-evtchn link-to-foreign-evtchn */ + xen,evtchn =3D <0xb &ec3>; + }; + + ec6: evtchn@6 { + compatible =3D "xen,evtchn-v1"; + xen,evtchn =3D <0xd &ec4>; + }; }; }; =20 diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 707e247f6a..4b24261825 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -33,6 +33,8 @@ #include #include =20 +#define STATIC_EVTCHN_NODE_SIZE_CELLS 2 + static unsigned int __initdata opt_dom0_max_vcpus; integer_param("dom0_max_vcpus", opt_dom0_max_vcpus); =20 @@ -3052,6 +3054,131 @@ void __init evtchn_allocate(struct domain *d) d->arch.hvm.params[HVM_PARAM_CALLBACK_IRQ] =3D val; } =20 +static int __init get_evtchn_dt_property(const struct dt_device_node *np, + uint32_t *port, uint32_t *phandle) +{ + const __be32 *prop =3D NULL; + uint32_t len; + + prop =3D dt_get_property(np, "xen,evtchn", &len); + if ( !prop ) + { + printk(XENLOG_ERR "xen,evtchn property should not be empty.\n"); + return -EINVAL; + } + + if ( !len || len < dt_cells_to_size(STATIC_EVTCHN_NODE_SIZE_CELLS) ) + { + printk(XENLOG_ERR "xen,evtchn property value is not valid.\n"); + return -EINVAL; + } + + *port =3D dt_next_cell(1, &prop); + *phandle =3D dt_next_cell(1, &prop); + + return 0; +} + +static int __init alloc_domain_evtchn(struct dt_device_node *node) +{ + int rc; + uint32_t domU1_port, domU2_port, remote_phandle; + struct dt_device_node *remote_node; + struct evtchn_alloc_unbound alloc_unbound; + struct evtchn_bind_interdomain bind_interdomain; + struct domain *d1 =3D NULL, *d2 =3D NULL; + + if ( dt_device_static_evtchn_created(node) ) + return 0; + + rc =3D get_evtchn_dt_property(node, &domU1_port, &remote_phandle); + if ( rc ) + return rc; + + remote_node =3D dt_find_node_by_phandle(remote_phandle); + if ( !remote_node ) + { + printk(XENLOG_ERR + "evtchn: could not find remote evtchn phandle\n"); + return -EINVAL; + } + + rc =3D get_evtchn_dt_property(remote_node, &domU2_port, &remote_phandl= e); + if ( rc ) + return rc; + + if ( node->phandle !=3D remote_phandle ) + { + printk(XENLOG_ERR "xen,evtchn property is not setup correctly.\n"); + return -EINVAL; + } + + d1 =3D get_domain_by_id(dt_get_parent(node)->used_by); + d2 =3D get_domain_by_id(dt_get_parent(remote_node)->used_by); + + if ( !d1 || !d2 ) + { + printk(XENLOG_ERR "evtchn: could not find domains\n" ); + return -EINVAL; + } + + alloc_unbound.dom =3D d1->domain_id; + alloc_unbound.remote_dom =3D d2->domain_id; + + rc =3D evtchn_alloc_unbound(&alloc_unbound, domU1_port); + if ( rc < 0 ) + { + printk(XENLOG_ERR + "evtchn_alloc_unbound() failure (Error %d) \n", rc); + return rc; + } + + bind_interdomain.remote_dom =3D d1->domain_id; + bind_interdomain.remote_port =3D domU1_port; + + rc =3D evtchn_bind_interdomain(&bind_interdomain, d2, domU2_port); + if ( rc < 0 ) + { + printk(XENLOG_ERR + "evtchn_bind_interdomain() failure (Error %d) \n", rc); + return rc; + } + + dt_device_set_static_evtchn_created(node); + dt_device_set_static_evtchn_created(remote_node); + + return 0; +} + +void __init process_static_evtchn_node(struct dt_device_node *node) +{ + if ( dt_device_is_compatible(node, "xen,evtchn-v1") ) + { + if ( alloc_domain_evtchn(node) !=3D 0 ) + panic("Could not set up domains evtchn\n"); + } +} + +void __init alloc_static_evtchn(void) +{ + struct dt_device_node *node, *evtchn_node; + struct dt_device_node *chosen =3D dt_find_node_by_path("/chosen"); + + BUG_ON(chosen =3D=3D NULL); + + if ( hardware_domain ) + dt_device_set_used_by(chosen, hardware_domain->domain_id); + + dt_for_each_child_node(chosen, node) + { + if ( hardware_domain ) + process_static_evtchn_node(node); + + dt_for_each_child_node(node, evtchn_node) + process_static_evtchn_node(evtchn_node); + } +} + static void __init find_gnttab_region(struct domain *d, struct kernel_info *kinfo) { @@ -3364,6 +3491,7 @@ void __init create_domUs(void) panic("Error creating domain %s\n", dt_node_name(node)); =20 d->is_console =3D true; + dt_device_set_used_by(node, d->domain_id); =20 if ( construct_domU(d, node) !=3D 0 ) panic("Could not set up domain %s\n", dt_node_name(node)); diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index 5815ccf8c5..5ee28b270f 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -106,6 +106,7 @@ int acpi_make_efi_nodes(void *fdt, struct membank tbl_a= dd[]); =20 void create_domUs(void); void create_dom0(void); +void alloc_static_evtchn(void); =20 void discard_initial_modules(void); void fw_unreserved_regions(paddr_t s, paddr_t e, diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 6e0398f3f6..cf15d359d2 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -1077,6 +1077,8 @@ void __init start_xen(unsigned long boot_phys_offset, if ( acpi_disabled ) create_domUs(); =20 + alloc_static_evtchn(); + /* * This needs to be called **before** heap_init_late() so modules * will be scrubbed (unless suppressed). diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 430a1ef445..5579c875d2 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -82,6 +82,7 @@ struct dt_device_node { dt_phandle phandle; char *full_name; domid_t used_by; /* By default it's used by dom0 */ + bool_t static_evtchn_created; =20 struct dt_property *properties; struct dt_device_node *parent; @@ -317,6 +318,18 @@ static inline bool_t dt_property_name_is_equal(const s= truct dt_property *pp, return !dt_prop_cmp(pp->name, name); } =20 +static inline void +dt_device_set_static_evtchn_created(struct dt_device_node *device) +{ + device->static_evtchn_created =3D true; +} + +static inline bool_t +dt_device_static_evtchn_created(const struct dt_device_node *device) +{ + return device->static_evtchn_created; +} + /** * dt_find_compatible_node - Find a node based on type and one of the * tokens in its "compatible" property --=20 2.25.1 From nobody Sun May 19 01:15:18 2024 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 1662023960540181.27753630960558; Thu, 1 Sep 2022 02:19:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.396386.636516 (Exim 4.92) (envelope-from ) id 1oTgLk-0007Px-PG; Thu, 01 Sep 2022 09:19:00 +0000 Received: by outflank-mailman (output) from mailman id 396386.636516; Thu, 01 Sep 2022 09:19:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTgLk-0007Pq-Lq; Thu, 01 Sep 2022 09:19:00 +0000 Received: by outflank-mailman (input) for mailman id 396386; Thu, 01 Sep 2022 09:19:00 +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 1oTgJ1-000527-8K for xen-devel@lists.xenproject.org; Thu, 01 Sep 2022 09:16:11 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id b7533f13-29d6-11ed-82f2-63bd783d45fa; Thu, 01 Sep 2022 11:16: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 08D65D6E; Thu, 1 Sep 2022 02:16:16 -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 F099D3F766; Thu, 1 Sep 2022 02:16:08 -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: b7533f13-29d6-11ed-82f2-63bd783d45fa From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH v3 7/7] xen/arm: introduce new xen,enhanced property value Date: Thu, 1 Sep 2022 10:13:06 +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: 1662023961658100001 Content-Type: text/plain; charset="utf-8" Introduce a new "xen,enhanced" dom0less property value "no-xenstore" to disable xenstore interface for dom0less guests. Signed-off-by: Rahul Singh --- Changes in v3: - new patch in this version --- docs/misc/arm/device-tree/booting.txt | 4 ++++ xen/arch/arm/domain_build.c | 10 +++++++--- xen/arch/arm/include/asm/kernel.h | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index edef98e6d1..87f57f8889 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -204,6 +204,10 @@ with the following properties: - "disabled" Xen PV interfaces are disabled. =20 + - no-xenstore + Xen PV interfaces, including grant-table will be enabled for the VM but + xenstore will be disabled for the VM. + If the xen,enhanced property is present with no value, it defaults to "enabled". If the xen,enhanced property is not present, PV interfaces are disabled. diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 4b24261825..8dd9984225 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3336,10 +3336,14 @@ static int __init construct_domU(struct domain *d, (rc =3D=3D 0 && !strcmp(dom0less_enhanced, "enabled")) ) { if ( hardware_domain ) - kinfo.dom0less_enhanced =3D true; + kinfo.dom0less_xenstore =3D true; else - panic("Tried to use xen,enhanced without dom0\n"); + panic("Tried to use xen,enhanced without dom0 without no-xenst= ore\n"); } + else if ( rc =3D=3D 0 && !strcmp(dom0less_enhanced, "no-xenstore") ) + kinfo.dom0less_xenstore =3D false; + + kinfo.dom0less_enhanced =3D true; =20 if ( vcpu_create(d, 0) =3D=3D NULL ) return -ENOMEM; @@ -3379,7 +3383,7 @@ static int __init construct_domU(struct domain *d, if ( rc < 0 ) return rc; =20 - if ( kinfo.dom0less_enhanced ) + if ( kinfo.dom0less_xenstore ) { ASSERT(hardware_domain); rc =3D alloc_xenstore_evtchn(d); diff --git a/xen/arch/arm/include/asm/kernel.h b/xen/arch/arm/include/asm/k= ernel.h index c4dc039b54..3d7fa94910 100644 --- a/xen/arch/arm/include/asm/kernel.h +++ b/xen/arch/arm/include/asm/kernel.h @@ -39,6 +39,9 @@ struct kernel_info { /* Enable PV drivers */ bool dom0less_enhanced; =20 + /* Enable Xenstore */ + bool dom0less_xenstore; + /* GIC phandle */ uint32_t phandle_gic; =20 --=20 2.25.1