From nobody Tue Apr 23 21:10:28 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=1641603107; cv=none; d=zohomail.com; s=zohoarc; b=DUIfMtQiuA9osRTfLaIQ6otqgAzLwSovC7o7g7JvMgaJW9QqRfW9u9N4+n5PkX4CT9/z4KCLLJdmv2Qf9zQbruv9p/YLrAaWbrTOqa0hhw85PVwtpZbpvDYWQaRc4BgeywHta/WSfiP5wYk3dkjgBBY7M2/6TW7tpzgtA4xtebQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641603107; 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=l661i6AZ0opuJHXjJd61MS3xJv13eO7ccBAguyfoyZo=; b=cODTkgcu55ioX/Vp7d72O5rE6Fo1S/2JKGEORXhwSTFIrFwEZ3TKBMbnvc7ZAG2qlJcIndPcM8PWWMJK2B4hb6JAgtxHgC6SBZzoRC70RhS6Wg/dkPj2sissqO4tufm67OAT1rQP/8nYZKnOeB4wRRsC44zNpC8/Gjw1oIhIq/g= 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 1641603107277189.0800724731589; Fri, 7 Jan 2022 16:51:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.254735.436594 (Exim 4.92) (envelope-from ) id 1n5zx7-0003r1-Ub; Sat, 08 Jan 2022 00:51:25 +0000 Received: by outflank-mailman (output) from mailman id 254735.436594; Sat, 08 Jan 2022 00:51:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5zx7-0003qu-RR; Sat, 08 Jan 2022 00:51:25 +0000 Received: by outflank-mailman (input) for mailman id 254735; Sat, 08 Jan 2022 00:51:24 +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 1n5zx6-0003o0-FP for xen-devel@lists.xenproject.org; Sat, 08 Jan 2022 00:51:24 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 195d5f2d-701d-11ec-81c1-a30af7de8005; Sat, 08 Jan 2022 01:51:23 +0100 (CET) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 0C34461F20; Sat, 8 Jan 2022 00:51:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 358F3C36AEB; Sat, 8 Jan 2022 00:51:21 +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: 195d5f2d-701d-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641603081; bh=Evoa4GFz1qTowYJne3oUn6qfMxpVbs6Xo5ayW1kl7h4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vOsLVvbpkAZ7i2npsV+5gqf+gRfFetMK++NyRJJGyZ7nGBm7bqiXez4VEAmd5RFxo culRQ1eMpDrzSPjiWuQI6NIZES7j1Bhq+bmpygf1CuYt1yxAH1btgf6PfeWUb+lolk ZHsTJWE1df5l0EkGRWMLnEhgs3TQ5Kxf98Cc882VwHF/Fcqikt+o555k9LBtMm4WaT qLoqtmBNPudBbRe936mNuwxATMXkiQjwkpDRyEZD2orVe1f/2igPykiZ+bqt4NAHul y3cvYO5Jl/2qnudfzRD9Qa/8wdz9NLmyoYXrngVqXRxtt0KjaFqFStlwb6RgC+ygcO kFmGllZw/9J/w== From: Stefano Stabellini To: jgross@suse.com Cc: boris.ostrovsky@oracle.com, xen-devel@lists.xenproject.org, sstabellini@kernel.org, Luca Miccio , Stefano Stabellini Subject: [LINUX PATCH 1/2] xen: introduce XENFEAT_xenstore_late_init Date: Fri, 7 Jan 2022 16:51:18 -0800 Message-Id: <20220108005119.3820799-1-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: 1641603107831100001 Content-Type: text/plain; charset="utf-8" From: Luca Miccio Add the new XENFEAT_xenstore_late_init flag to the features header file. Signed-off-by: Luca Miccio Signed-off-by: Stefano Stabellini --- include/xen/interface/features.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/xen/interface/features.h b/include/xen/interface/featu= res.h index 53f760378e39..2b121b53394f 100644 --- a/include/xen/interface/features.h +++ b/include/xen/interface/features.h @@ -97,6 +97,11 @@ #define XENFEAT_not_direct_mapped 16 #define XENFEAT_direct_mapped 17 =20 +/* + * The xenstore interface should be initialized only after receiving a + * xenstore event channel notification. + */ +#define XENFEAT_xenstore_late_init 18 #define XENFEAT_NR_SUBMAPS 1 =20 #endif /* __XEN_PUBLIC_FEATURES_H__ */ --=20 2.25.1 From nobody Tue Apr 23 21:10:28 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=1641603099; cv=none; d=zohomail.com; s=zohoarc; b=BWdGyq+Sqd4pPzACROorpmrY5t9UcOyr+VIJYiNhj9Ya40AXRzbdLR/g9ji5qx44XMJPsVo6R0tdG2bzK0e0e/MOXqE9pSpnJCNZO/k3lwOvOOaSXulNJ5nkz2nhxoXQl7hHB2mt2LaEEpTFmIhzVdsun42Wh79/O0DGWTI+sYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641603099; 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=c1IJQ0lyx6geNjeybft9F13pnG/rjumVDfs7XOqUZSc=; b=YexXIP/WtFaCzWTjPL1isakzV9Lf08u3EdUcwDYPaL7OxDBtN8QfKnyRDdi/wxch4hLr+iYmNSrkYdjkGh6rZGUZuyBTTeM0rvO43YgeaRfRWP4QknoIW7WFDfDJhQZN1dS1JXWvCMk8qPPPCIxrENXtCWjRtJIsMVJ33aNb5Tg= 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 1641603099843276.6587808791826; Fri, 7 Jan 2022 16:51:39 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.254736.436598 (Exim 4.92) (envelope-from ) id 1n5zx8-0003u9-7e; Sat, 08 Jan 2022 00:51:26 +0000 Received: by outflank-mailman (output) from mailman id 254736.436598; Sat, 08 Jan 2022 00:51:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5zx8-0003ss-33; Sat, 08 Jan 2022 00:51:26 +0000 Received: by outflank-mailman (input) for mailman id 254736; Sat, 08 Jan 2022 00:51:24 +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 1n5zx6-0003U9-Fm for xen-devel@lists.xenproject.org; Sat, 08 Jan 2022 00:51:24 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 19929110-701d-11ec-9ce5-af14b9085ebd; Sat, 08 Jan 2022 01:51:23 +0100 (CET) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 6D36362033; Sat, 8 Jan 2022 00:51:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0B6AC36AEF; Sat, 8 Jan 2022 00:51:21 +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: 19929110-701d-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641603081; bh=Jru6tGMavNUeuCFUXUd/nBaH97FS3SVNSYf32+ByzXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HApksTU2rBHZBr+HoBqka+9zxnzSJuPolt2ZWa6jxuykcjrdlrX0Fu2aR9Vm3OHD7 HYDvXWHkomHaIcLBZ3c7Vqe2ZrIAL2+1uMiqn5TPvEj5Bnfw93J7M28PPBRSNQSqlH ViH8QOmb7/P/PsaAVolfMY+6dVj5fcWQ3tmVYc0CdONbPNhs+g6Y9+2FjCLTWVXaBv /9U9TOXuywIY1GLX9P57FlyJe+4wq1CvTayvVeI9BmxJIq5Q/6ELl/yFMxA3sgydoj vjAos/HzXTmSGwd8dU0rnj3t1YfRmIQobBnX1Xs2+O02E6Jbk/dOYTZUrPJaLYdf36 ZlJ2Wsh6a0Rpw== From: Stefano Stabellini To: jgross@suse.com Cc: boris.ostrovsky@oracle.com, xen-devel@lists.xenproject.org, sstabellini@kernel.org, Luca Miccio , Stefano Stabellini Subject: [LINUX PATCH 2/2] xen: add support for XENFEAT_xenstore_late_init Date: Fri, 7 Jan 2022 16:51:19 -0800 Message-Id: <20220108005119.3820799-2-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: 1641603101645100001 Content-Type: text/plain; charset="utf-8" From: Luca Miccio XENFEAT_xenstore_late_init requires xenstore to be initialized later, after receiving an event channel notification on the xenstore event channel (which is available since boot). This patch adds support for delaying the Xenstore initialization as required when XENFEAT_xenstore_late_init is set. Signed-off-by: Luca Miccio Signed-off-by: Stefano Stabellini --- drivers/xen/xenbus/xenbus_probe.c | 78 ++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_= probe.c index fe360c33ce71..d4a982a883b7 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -65,6 +65,7 @@ #include "xenbus.h" =20 =20 +static int late_init_irq; int xen_store_evtchn; EXPORT_SYMBOL_GPL(xen_store_evtchn); =20 @@ -750,6 +751,17 @@ static void xenbus_probe(void) { xenstored_ready =3D 1; =20 + if (xen_feature(XENFEAT_xenstore_late_init)) { + xen_store_interface =3D xen_remap(xen_store_gfn << XEN_PAGE_SHIFT, + XEN_PAGE_SIZE); + /* + * Now it is safe to free the IRQ used for xenstore late + * initialization. No need to unbind: it is about to be + * bound again. + */ + free_irq(late_init_irq, &xb_waitq); + } + /* * In the HVM case, xenbus_init() deferred its call to * xs_init() in case callbacks were not operational yet. @@ -798,20 +810,23 @@ static int __init xenbus_probe_initcall(void) { /* * Probe XenBus here in the XS_PV case, and also XS_HVM unless we - * need to wait for the platform PCI device to come up. + * need to wait for the platform PCI device to come up or + * XENFEAT_xenstore_late_init is set. */ if (xen_store_domain_type =3D=3D XS_PV || (xen_store_domain_type =3D=3D XS_HVM && - !xs_hvm_defer_init_for_callback())) + !xs_hvm_defer_init_for_callback() && + !xen_feature(XENFEAT_xenstore_late_init))) xenbus_probe(); =20 /* - * For XS_LOCAL, spawn a thread which will wait for xenstored - * or a xenstore-stubdom to be started, then probe. It will be - * triggered when communication starts happening, by waiting - * on xb_waitq. + * For XS_LOCAL or domains with XENFEAT_xenstore_late_init, spawn a + * thread which will wait for xenstored or a xenstore-stubdom to be + * started, then probe. It will be triggered when communication + * starts happening, by waiting on xb_waitq. */ - if (xen_store_domain_type =3D=3D XS_LOCAL) { + if (xen_store_domain_type =3D=3D XS_LOCAL || + xen_feature(XENFEAT_xenstore_late_init) ) { struct task_struct *probe_task; =20 probe_task =3D kthread_run(xenbus_probe_thread, NULL, @@ -907,6 +922,24 @@ static struct notifier_block xenbus_resume_nb =3D { .notifier_call =3D xenbus_resume_cb, }; =20 +static irqreturn_t xenbus_late_init(int irq, void *unused) +{ + int err =3D 0; + uint64_t v =3D 0; + + err =3D hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); + if (err) + return IRQ_HANDLED; + xen_store_evtchn =3D (int)v; + err =3D hvm_get_parameter(HVM_PARAM_STORE_PFN, &v); + if (err || !v || !~v) + return IRQ_HANDLED; + xen_store_gfn =3D (unsigned long)v; + + wake_up(&xb_waitq); + return IRQ_HANDLED; +} + static int __init xenbus_init(void) { int err; @@ -929,6 +962,36 @@ static int __init xenbus_init(void) if (xen_pv_domain() && xen_start_info->store_evtchn) xenstored_ready =3D 1; =20 + /* + * If a domain has been configured to initialize xenstore later + * (e.g. dom0less domains), wait until the xenstore event channel is + * triggered for the first time. The IRQ handler will take care for + * initializing xenstore common variabiles that, in a standard + * scenario, are configured here. + */ + if (xen_feature(XENFEAT_xenstore_late_init)) { + if (xen_store_domain_type !=3D XS_HVM || xen_feature(XENFEAT_dom0)) { + pr_err("xenstore_late_init not supported this domain\n"); + return -EINVAL; + } + + err =3D hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); + if (err < 0) { + pr_err("xenstore_late_init err=3D%d\n", err); + return err; + } + + err =3D bind_evtchn_to_irqhandler(v, xenbus_late_init, + 0, "xenstore_late_init", &xb_waitq); + if (err < 0) { + pr_err("xenstore_late_init couldn't bind irq err=3D%d\n", err); + return err; + } + + late_init_irq =3D err; + goto out_late_init; + } + switch (xen_store_domain_type) { case XS_LOCAL: err =3D xenstored_local_init(); @@ -995,6 +1058,7 @@ static int __init xenbus_init(void) } } =20 +out_late_init: if ((xen_store_domain_type !=3D XS_LOCAL) && (xen_store_domain_type !=3D XS_UNKNOWN)) xen_resume_notifier_register(&xenbus_resume_nb); --=20 2.25.1