From nobody Fri Nov 29 04:50:14 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; dkim=pass; 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=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1651265880; cv=none; d=zohomail.com; s=zohoarc; b=kTkVUqCCuu2q3i+roS8/19wuNnsStRGB0HtKLk4jnHFqjXu9Zl372ymjpxFW0YMPrL/KSp/bgkPTqWjyop0uvbbVN5BDJliYKD2kMPy+y7OJmuUbvIm8Iq1w1g9vG9BxTtpVJVrfZp+f+C0SjWBvziDMMQ2TRdpzUYy/70LSTYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651265880; h=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; bh=wxo0mACUABd/u3QBCmxQO7Qj1u82ZdAtZ+zxnqB/rbU=; b=LKihOXLgkBfPFUHo0t5FSxHl+E4p9f4v5OaYMpdAj0AYSjIAV4KLgIekK7F7GaeP6R755EiePE0+M2Im0hGS7hfnjWfbLUegW9iXisAPiT1g3OO6ZH8qCmTYHhquBK8xLMblkaq28bVeqop561IKv+UwrIJiSkEEnhtp39qdi5E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1651265880085335.84309908462535; Fri, 29 Apr 2022 13:58:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.317704.537184 (Exim 4.92) (envelope-from ) id 1nkXgK-0007lm-P3; Fri, 29 Apr 2022 20:57:40 +0000 Received: by outflank-mailman (output) from mailman id 317704.537184; Fri, 29 Apr 2022 20:57:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nkXgK-0007lP-Kw; Fri, 29 Apr 2022 20:57:40 +0000 Received: by outflank-mailman (input) for mailman id 317704; Fri, 29 Apr 2022 20:57:39 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nkXgJ-0007P4-Cb for xen-devel@lists.xenproject.org; Fri, 29 Apr 2022 20:57:39 +0000 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0041747c-c7ff-11ec-a405-831a346695d4; Fri, 29 Apr 2022 22:57:38 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4DD73B83794; Fri, 29 Apr 2022 20:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5E9EC385B0; Fri, 29 Apr 2022 20:57:35 +0000 (UTC) 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: 0041747c-c7ff-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651265856; bh=mE2HS7cDM2V9DWF5yzqxb8sXkvTRkVIrepnZA+OkhKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G4HvHg9HPiKKsbtcHa7IGELkoLHK9uN02Pbp1q123bahHC1v2EDOjAD8y1VRvK8pd 6A0/a7cg8Rh+bMtslA9g3G51G1lEKr/823JV+w1HIRzWqR23c8J3XNIbaIqCf8FjO1 28D3qS370JWOgtWaFlt3D/9FbTtxTO6gPQHFXFfG3KHhUCTB8U3sN803YsuNa1gflz cHPNSjHUcBkdt3OJiRgyG1vRMbLT29nlE6C1GUp/WSfqAAVdl5fA/lSeIkzur3K+t3 ncvdrcAeefYBH1S763t56I9typP+lgODqFmX0yGdqvBDn3OxksKKCP4FkHQf08B7Ss 3ITQqIj+bJhlw== From: Stefano Stabellini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, jgross@suse.com, Bertrand.Marquis@arm.com, julien@xen.org, Volodymyr_Babchuk@epam.com, Luca Miccio , Stefano Stabellini , Bertrand Marquis , Jan Beulich Subject: [PATCH v5 4/7] xen/arm: configure dom0less domain for enabling xenstore after boot Date: Fri, 29 Apr 2022 13:57:29 -0700 Message-Id: <20220429205732.2030094-4-sstabellini@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1651265881128100009 Content-Type: text/plain; charset="utf-8" From: Luca Miccio Export evtchn_alloc_unbound and make it __must_check. If "xen,enhanced" is enabled, then add to dom0less domains: - the hypervisor node in device tree - the xenstore event channel The xenstore event channel is also used for the first notification to let the guest know that xenstore has become available. Signed-off-by: Luca Miccio Signed-off-by: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Jan Beulich Acked-by: Jan Beulich Reviewed-by: Bertrand Marquis --- I removed Bertrand's reviewed-by due to merging this patch with "xen: export evtchn_alloc_unbound" Changes in v5: - merge with "xen: export evtchn_alloc_unbound" - __must_check Changes in v3: - use evtchn_alloc_unbound Changes in v2: - set HVM_PARAM_STORE_PFN to ~0ULL at domain creation - in alloc_xenstore_evtchn do not call _evtchn_alloc_unbound xen: export evtchn_alloc_unbound It will be used during dom0less domains construction. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 37 +++++++++++++++++++++++++++++++++++++ xen/common/event_channel.c | 2 +- xen/include/xen/event.h | 3 +++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a877ccf585..249efbf804 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -27,6 +27,7 @@ #include #include #include +#include =20 #include #include @@ -2809,6 +2810,8 @@ static int __init prepare_dtb_domU(struct domain *d, = struct kernel_info *kinfo) int ret; =20 kinfo->phandle_gic =3D GUEST_PHANDLE_GIC; + kinfo->gnttab_start =3D GUEST_GNTTAB_BASE; + kinfo->gnttab_size =3D GUEST_GNTTAB_SIZE; =20 addrcells =3D GUEST_ROOT_ADDRESS_CELLS; sizecells =3D GUEST_ROOT_SIZE_CELLS; @@ -2883,6 +2886,13 @@ static int __init prepare_dtb_domU(struct domain *d,= struct kernel_info *kinfo) goto err; } =20 + if ( kinfo->dom0less_enhanced ) + { + ret =3D make_hypervisor_node(d, kinfo, addrcells, sizecells); + if ( ret ) + goto err; + } + ret =3D fdt_end_node(kinfo->fdt); if ( ret < 0 ) goto err; @@ -3149,6 +3159,25 @@ static int __init construct_domain(struct domain *d,= struct kernel_info *kinfo) return 0; } =20 +static int __init alloc_xenstore_evtchn(struct domain *d) +{ + evtchn_alloc_unbound_t alloc; + int rc; + + alloc.dom =3D d->domain_id; + alloc.remote_dom =3D hardware_domain->domain_id; + rc =3D evtchn_alloc_unbound(&alloc); + if ( rc ) + { + printk("Failed allocating event channel for domain\n"); + return rc; + } + + d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN] =3D alloc.port; + + return 0; +} + static int __init construct_domU(struct domain *d, const struct dt_device_node *node) { @@ -3213,6 +3242,14 @@ static int __init construct_domU(struct domain *d, if ( rc < 0 ) return rc; =20 + if ( kinfo.dom0less_enhanced ) + { + rc =3D alloc_xenstore_evtchn(d); + if ( rc < 0 ) + return rc; + d->arch.hvm.params[HVM_PARAM_STORE_PFN] =3D ~0ULL; + } + return rc; } =20 diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index ffb042a241..2f6a89f52d 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -289,7 +289,7 @@ void evtchn_free(struct domain *d, struct evtchn *chn) xsm_evtchn_close_post(chn); } =20 -static int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) +int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) { struct evtchn *chn; struct domain *d; diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index 21c95e14fd..f3021fe304 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -71,6 +71,9 @@ void evtchn_free(struct domain *d, struct evtchn *chn); /* Allocate a specific event channel port. */ 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); + /* Unmask a local event-channel port. */ int evtchn_unmask(unsigned int port); =20 --=20 2.25.1