From nobody Fri Nov 29 04:31:46 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=1648773556; cv=none; d=zohomail.com; s=zohoarc; b=gULluqu6SVIlCwAKLITgLEuM+hg/vhSvR04zUG4J0/+i3Jn33Q5FZZByvDjuE3INwVHwOaoxf/n/EPDndRA677OE/Cf/MDU6yqahnPbFeLpgm1gkYpsFqxbcZB7GoBLJg+czzSwfv301k0Q11+hQDAp/9e5YGWaZ3hZUngzKVxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648773556; 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=bIoe6WXBP3C2x0KTx5eV3O04RKkLDJtJVSZGRq77zJI=; b=ehn4OsPH3exnLL41eBDfbHsfh/fQeQ4/M3N9BQKpe/2jnsslC89sgV6yzvFUp9c4AqAESdKsj1qc0ZYqq+xZGuNeYQ2XZVS5DIC1FhQYdX7GXNP3FdumEVGT3/tH3t6CtT6oBS2KwIe9ruKGAFjGv+FkkfC/5xZj3z8t2gbAxPU= 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 1648773556034848.9321465665589; Thu, 31 Mar 2022 17:39:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297154.506098 (Exim 4.92) (envelope-from ) id 1na5JV-00087v-Hu; Fri, 01 Apr 2022 00:38:53 +0000 Received: by outflank-mailman (output) from mailman id 297154.506098; Fri, 01 Apr 2022 00:38:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1na5JV-00087o-Ey; Fri, 01 Apr 2022 00:38:53 +0000 Received: by outflank-mailman (input) for mailman id 297154; Fri, 01 Apr 2022 00:38:52 +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 1na5JU-0007ot-Jc for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:38:52 +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 19dab748-b154-11ec-8fbc-03012f2f19d4; Fri, 01 Apr 2022 02:38:51 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 95DB1617E0; Fri, 1 Apr 2022 00:38:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2444C340EE; Fri, 1 Apr 2022 00:38:49 +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: 19dab748-b154-11ec-8fbc-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773530; bh=oYEfEy8l6U2mW9uUtnlJVJBSNPmHg0BOI3Jqw79zWpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LosAIRx8EKkGN5sN23o9zUGgfNfLlCKnRLhMacfccGCKaVcYxbYN3GzBUtPqO06HB M47J9rOmaxAZVnwTFRwZt5ndc3rvuyZkljYDm3U1FP8VSg3hX3h5rBw9QGQhRgv59y qQx6CSu13szrd64JCj83L/cMIh9tAvcFDMDAElns3ZFUoVg07vCssUeisidAInWzGw 1DfyTtKXHlOOqE03tvcjcnwYBeJXkH9nfvIll3vFK7hhhGLj3UphepbwUwd+RXxcxh 5hcmYMBAMo3czQM4ujHKzCpftNLgh3tBUXdOv4opoppiSZc6yaFmMKintJDGTarcE4 lc1JwRlNvj+DA== 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, Stefano Stabellini Subject: [PATCH v4 1/9] xen/dt: dt_property_read_string should return -ENODATA on !length Date: Thu, 31 Mar 2022 17:38:39 -0700 Message-Id: <20220401003847.38393-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: 1648773556668100001 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini When the length is zero (pp->length =3D=3D 0), dt_property_read_string should return -ENODATA, but actually currently returns -EILSEQ because there is no specific check for lenght =3D=3D 0. Add a check now. Signed-off-by: Stefano Stabellini Reviewed-by: Henry Wang --- xen/common/device_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 4aae281e89..db67fb5fb4 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -198,7 +198,7 @@ int dt_property_read_string(const struct dt_device_node= *np, =20 if ( !pp ) return -EINVAL; - if ( !pp->value ) + if ( !pp->value || !pp->length ) return -ENODATA; if ( strnlen(pp->value, pp->length) >=3D pp->length ) return -EILSEQ; --=20 2.25.1 From nobody Fri Nov 29 04:31:46 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=1648773560; cv=none; d=zohomail.com; s=zohoarc; b=fE0wTrOr2teqhhSbbV3LqsJiLscltf9luhbAbicEvVOYyDKHk0iiO1tHsxQEzReHJoquZJ3tf+wWIi9yRTEEVLsrzxLtxkGVi1Mv52H6lKG0mF6pS2jOwPsVfKmDIEjFL8fvuhaG7o7RMzX2O6V/Bukvaa3iZhK3ZfgKWEo1na4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648773560; 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=SsaNDHTUO+X+6yxgofmyxI2UaH8oIpZoAylZK7RE3EM=; b=chg+LZ5ueliApdHeY1YuJD5Ufd/ixjQKn+zGaKibOkT5PQ4KWmojduH88oEPnSD5d3x+bjCSj7Xhyqtusa1cL1BI2+ApTQ4phQ4CTFGM50wyN2dK5QYV4Fy7uD6tN6gH+rAyU9KN33NK8dbK5IFn+NhxTY3/5BrIWyORy6rG4mA= 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 1648773560835399.6321807865223; Thu, 31 Mar 2022 17:39:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297155.506109 (Exim 4.92) (envelope-from ) id 1na5JX-0008Q2-TI; Fri, 01 Apr 2022 00:38:55 +0000 Received: by outflank-mailman (output) from mailman id 297155.506109; Fri, 01 Apr 2022 00:38:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1na5JX-0008Pp-Oc; Fri, 01 Apr 2022 00:38:55 +0000 Received: by outflank-mailman (input) for mailman id 297155; Fri, 01 Apr 2022 00:38:53 +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 1na5JV-0007ot-Jh for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:38:53 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1a09a9bd-b154-11ec-8fbc-03012f2f19d4; Fri, 01 Apr 2022 02:38:52 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 16DED618A9; Fri, 1 Apr 2022 00:38:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CD37C340F3; Fri, 1 Apr 2022 00:38:50 +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: 1a09a9bd-b154-11ec-8fbc-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773530; bh=0OtIcFrEIw2wTkzpgYCWd4LgGMpb5c1u12rgi3DHK38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KWikBJvm4a+e3wfh3njIghbLerNy6nw4RSt8iHiG8bOGESxipbVQy3Zpy9KdbY3/a rhMGulC4chjFfoIhRAR5so1fAht0Cn6T2xlIM5uOY32dvRLDi4kfhFohiaNhksAU4t iahVtefSe6bm44nSEOIAexzHIP97W8d7+AXsYqk273CFRdz/a2IcwmYRCqGuMEm89o RhF7jnNGMMQ4WHjcyRUbPjdT3qCjqoeyyUpyAy4YyNf1+JxO+RKsj9JR9bEU175/wi rl+63tkacU+wm9Fz5Tm3/7MGwZvSct2Vk1jIcl/SMGwdT7b/Irp0MryIfEIEy8EUQr /nZZM+lC2OmhQ== 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, Stefano Stabellini Subject: [PATCH v4 2/9] xen/arm: implement domU extended regions Date: Thu, 31 Mar 2022 17:38:40 -0700 Message-Id: <20220401003847.38393-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: 1648773562730100007 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini Implement extended regions for dom0less domUs. The implementation is based on the libxl implementation. Signed-off-by: Stefano Stabellini Reviewed-by: Luca Fancellu --- xen/arch/arm/domain_build.c | 42 ++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 8be01678de..b6189b935d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1324,6 +1324,35 @@ out: return res; } =20 +#define ALIGN_UP_TO_2MB(x) (((x) + MB(2) - 1) & (~(MB(2) - 1))) + +static int __init find_domU_holes(const struct kernel_info *kinfo, + struct meminfo *ext_regions) +{ + unsigned int i; + uint64_t bankend[GUEST_RAM_BANKS]; + const uint64_t bankbase[] =3D GUEST_RAM_BANK_BASES; + const uint64_t banksize[] =3D GUEST_RAM_BANK_SIZES; + + for ( i =3D 0; i < GUEST_RAM_BANKS; i++ ) + { + ext_regions->bank[ext_regions->nr_banks].start =3D + ALIGN_UP_TO_2MB(bankbase[i] + kinfo->mem.bank[i].size); + + bankend[i] =3D ~0ULL >> (64 - p2m_ipa_bits); + bankend[i] =3D min(bankend[i], bankbase[i] + banksize[i] - 1); + if (bankend[i] > ext_regions->bank[ext_regions->nr_banks].start) + ext_regions->bank[ext_regions->nr_banks].size =3D + bankend[i] - ext_regions->bank[ext_regions->nr_banks].star= t + 1; + + /* 64MB is the minimum size of an extended region */ + if ( ext_regions->bank[ext_regions->nr_banks].size < MB(64) ) + continue; + ext_regions->nr_banks++; + } + return 0; +} + static int __init make_hypervisor_node(struct domain *d, const struct kernel_info *kinfo, int addrcells, int sizecells) @@ -1374,10 +1403,17 @@ static int __init make_hypervisor_node(struct domai= n *d, if ( !ext_regions ) return -ENOMEM; =20 - if ( !is_iommu_enabled(d) ) - res =3D find_unallocated_memory(kinfo, ext_regions); + if ( is_domain_direct_mapped(d) ) + { + if ( !is_iommu_enabled(d) ) + res =3D find_unallocated_memory(kinfo, ext_regions); + else + res =3D find_memory_holes(kinfo, ext_regions); + } else - res =3D find_memory_holes(kinfo, ext_regions); + { + res =3D find_domU_holes(kinfo, ext_regions); + } =20 if ( res ) printk(XENLOG_WARNING "Failed to allocate extended regions\n"); --=20 2.25.1 From nobody Fri Nov 29 04:31:46 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=1648773557; cv=none; d=zohomail.com; s=zohoarc; b=H0GSeQc5oHAAG1b5AEmqQS1KwnJG7YMMyFA0XF5Xv+ryqvKC7hLzMV17L+smZsd0ZBbq4At++7DpPlSFX405sXs2ax0U8WTO7KvAZdabbKQSvqHdBnR9ZCyXZsFDgLc1976LpUPiNQHlP2VKJibTlrXVpvJcpN5TRA+QYgBVl28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648773557; 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=09Ngp3psbs6aU2xTyORpZb3gdYUMICNufZba5gS5Oi8=; b=CmcvIeMznzFjqzGZmbaGH3LZN98ozQNbepV+gMNaxK/twg7LT2qun7RCxerTEYjo0IMUVoQMke7tyqmatooT70yQcz3vKrNbbJhJsPuI36BKlac08Stgcb7gTlwO67MgdYg78/uKpAWPfDY9E2iQnqoaMDv4eanIZl9Ey0oYElw= 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 1648773557852522.7600142588573; Thu, 31 Mar 2022 17:39:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297156.506113 (Exim 4.92) (envelope-from ) id 1na5JY-0008U2-7P; Fri, 01 Apr 2022 00:38:56 +0000 Received: by outflank-mailman (output) from mailman id 297156.506113; Fri, 01 Apr 2022 00:38: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 1na5JY-0008St-1u; Fri, 01 Apr 2022 00:38:56 +0000 Received: by outflank-mailman (input) for mailman id 297156; Fri, 01 Apr 2022 00:38:53 +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 1na5JV-00087e-OR for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:38:53 +0000 Received: from ams.source.kernel.org (ams.source.kernel.org [2604:1380:4601:e00::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1aaad07d-b154-11ec-a405-831a346695d4; Fri, 01 Apr 2022 02:38:52 +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 3AEF8B82277; Fri, 1 Apr 2022 00:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5D83C34113; Fri, 1 Apr 2022 00:38:50 +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: 1aaad07d-b154-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773531; bh=9T3+bPtIQN0ln8b/3Ruflzv/jD4YwkoEfs6vAbEsKuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bZubmMK4hA+QRJdgCDdVehxIiX1RH8Ke1lwWCqwQgR806kzHp6rt0hv8Vk8+2ZEDa Zn7hQqnBTjrvR/r8511EpVtOo5WkNEibo1SFIV0unGDaZsSKlC4+S7LKkSxX2ZDBx4 8Y3lbNRNrGJwFXrJRvOn1PzTnA9oJo+mL0IZpQAud+ncZWgL4HVNvmkPXsKN7XGTKS aBb4wlk95Lz3rhhBgwXYChylN3e7Csy+vwikE7Z23FpKZYKMr4jo2WRapq9gdaDW8J xfymAwEmm868NeGswBzyIo0Tfyg3PC9M2OTIwN5tCKbSzf8lCfbAu4hDY0Sp4Txl05 VxYTIjX+udKMw== 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, Stefano Stabellini Subject: [PATCH v4 3/9] xen/arm: temporarily elevate idle_domain privileged during create_domUs Date: Thu, 31 Mar 2022 17:38:41 -0700 Message-Id: <20220401003847.38393-3-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: 1648773559182100001 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini create_domUs might call functions that perform XSM checks on the current domain, which is idle_domain at this time. Temporarily elevate idle_domain privileges in create_domUs. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index b6189b935d..100a4959a8 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 @@ -3210,6 +3211,8 @@ void __init create_domUs(void) struct dt_device_node *node; const struct dt_device_node *chosen =3D dt_find_node_by_path("/chosen"= ); =20 + xsm_elevate_priv(current->domain); + BUG_ON(chosen =3D=3D NULL); dt_for_each_child_node(chosen, node) { @@ -3291,6 +3294,8 @@ void __init create_domUs(void) if ( construct_domU(d, node) !=3D 0 ) panic("Could not set up domain %s\n", dt_node_name(node)); } + + xsm_demote_priv(current->domain); } =20 static int __init construct_dom0(struct domain *d) --=20 2.25.1 From nobody Fri Nov 29 04:31:46 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=1648773559; cv=none; d=zohomail.com; s=zohoarc; b=NRKn/u1KwS0sVhKb2v5INmFh6dIRNUrnYEUhcVOfsV/Ascji4Qsq7lNLOy5no15AJva9402Rub+p1jr2recaIXmkAo714oR/d4P7OD0rxbacjBzoFb9iAMDNlu+shjMFqAZp+2PELxOac7zHqvYcdCL0F2WYVRiAvbO+SWrOAz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648773559; 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=AwfnlWM5634q5vEoe6eq4dkfNfmreY0PAjEQqhGIRSA=; b=EYyCrqwX309I1DUMUvrXZYpCpoZcukFdr6OMHguBPXxeoy8Mcrs971mFpkgIstVwrpZwS63uCPJCKGxRfKwsMPH8CHiz3x72KhGaRcbm3IRE8glFUEfBxD2Xwm3OS+jK5K6D84dObxzPnqQLny3NWqTp76iHmk6Q6/k6Uj4YMaw= 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 1648773559290988.0557375374837; Thu, 31 Mar 2022 17:39:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297157.506121 (Exim 4.92) (envelope-from ) id 1na5JY-0000CP-Or; Fri, 01 Apr 2022 00:38:56 +0000 Received: by outflank-mailman (output) from mailman id 297157.506121; Fri, 01 Apr 2022 00:38: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 1na5JY-0000Aw-HX; Fri, 01 Apr 2022 00:38:56 +0000 Received: by outflank-mailman (input) for mailman id 297157; Fri, 01 Apr 2022 00:38: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 1na5JW-0007ot-Jz for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:38:54 +0000 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1b095c28-b154-11ec-8fbc-03012f2f19d4; Fri, 01 Apr 2022 02:38:53 +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 CEC9DB822B6; Fri, 1 Apr 2022 00:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27851C34111; Fri, 1 Apr 2022 00:38:51 +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: 1b095c28-b154-11ec-8fbc-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773531; bh=I6q904V+oM8H31/r5qy2ckfV9oZRtQr/EXcn4FzU6PE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ONe7h6hEItE8BISUA855nbRyVlJGnEeOXzJPNEFJTGb6iRgBzjRzDd45bUkgXdk0U ARH7PGJRRBM82+ziePeNFPhBanYNmyHDK6xwcPL6/DEEykRi9w/re8qLY0zb6M6Gw9 ZhhUeA802QTFvmYMpD0fjTOtYQD2KynMj+fnCezJN/1YlTAnODsp+rUlZQs7BHPZXn duwBvStInn9OoP/pboY5bWf5sUtcKnQQrtTRP3yjxcYIcfPiFEVFrfk96nxb814hQ6 st3z7c/mZ1I4w/Q9r2nxMWX/kT07Ld1olEunc5zbGY2/wgwDU5voVMdN1C7oVGJvI5 9lSEszHas/9/Q== 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, Stefano Stabellini Subject: [PATCH v4 4/9] xen: export evtchn_alloc_unbound Date: Thu, 31 Mar 2022 17:38:42 -0700 Message-Id: <20220401003847.38393-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: 1648773560702100003 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini It will be used during dom0less domains construction. Signed-off-by: Stefano Stabellini --- xen/common/event_channel.c | 2 +- xen/include/xen/event.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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..987e88623a 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 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 From nobody Fri Nov 29 04:31:46 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=1648773559; cv=none; d=zohomail.com; s=zohoarc; b=jnTibBd6/ec9NFnhyrtPSAANEczOI7a3OqkTHVCfP9BQsDb55K3zxv5OGXUinrbXEOq1QDALCV+s3E112z7mod2DjDiucLW9nlvsag/WMmdgk7CC2KsiXVGYCwjoQpKdmkw6NJJHlhZkh3nybccPvk8Onu5DQQWJTfUDIlFrMDA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648773559; 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=+w6ZXA4Iv1dtbT/AFkch1k9NpUF0dryIutwJrRT7Avw=; b=na2UrIY3Rgbhuwdk4ifYmnPatgHTqrfMo4v5wdN6XTvIltDMVaKLXmwxZ02GQjByn/QNtLtDQUVJOJChDhJAyCgy1vGG1mEVljBiN443EVofe4y0MK9ekVf7FoRZiIWf5QY7+0c+n40mmHS/vzQVPPvsNBG+cx3L+X88uTvwN0M= 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 1648773559061566.980176256894; Thu, 31 Mar 2022 17:39:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297158.506130 (Exim 4.92) (envelope-from ) id 1na5JZ-0000M7-Hv; Fri, 01 Apr 2022 00:38:57 +0000 Received: by outflank-mailman (output) from mailman id 297158.506130; Fri, 01 Apr 2022 00:38:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1na5JZ-0000Ix-4o; Fri, 01 Apr 2022 00:38:57 +0000 Received: by outflank-mailman (input) for mailman id 297158; Fri, 01 Apr 2022 00:38:54 +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 1na5JW-00087e-HM for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:38:54 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1aa9e15e-b154-11ec-a405-831a346695d4; Fri, 01 Apr 2022 02:38:53 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 1EB84618B4; Fri, 1 Apr 2022 00:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94378C340F3; Fri, 1 Apr 2022 00:38:51 +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: 1aa9e15e-b154-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773531; bh=4iBLNVmcXHYfyGJi5ahq2ucMYYpPYTlArhpqmmGmD68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nugHhDmuLVPBKwkBQFWcN8GC9tJA2q4fcSaHcK1pdagbiVrSuwuVgnIop0kIBoH/A aJHeqD8LdELqK4dxoaghbBO3GwG+TR2bHcIfjeCbEjBWkO1UvO5DGiUzH5YWGcqA1Q rv7xy4fNT/pXsPDiRrlot0E+ZO5M4Mm7K5A4IgklNkUyjMtyQ+oP0cYm3A1hb/6s66 jo7xAfSO6mmPiLY4uK0xbsN/nkpW/cCpBMbXKKiFyZg4+6Z8xNpgsyOcCwSUhcQekv Rfkv/xxDn79yK18/6YuXoX6M+ScGfnifrhJYX0vHMmQYmaVpcjq99PyjhVcqZj8E5N M05PTB8JymzxQ== 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, Stefano Stabellini , Bertrand Marquis Subject: [PATCH v4 5/9] xen: introduce xen,enhanced dom0less property Date: Thu, 31 Mar 2022 17:38:43 -0700 Message-Id: <20220401003847.38393-5-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: 1648773560821100004 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini Introduce a new "xen,enhanced" dom0less property to enable/disable PV driver interfaces for dom0less guests. Currently only "enabled" and "disabled" are supported property values (and empty). Leave the option open to implement further possible values in the future (e.g. "xenstore" to enable only xenstore.) The configurable option is for domUs only. For dom0 we always set the corresponding property in the Xen code to true (PV interfaces enabled.) This patch only parses the property. Next patches will make use of it. Signed-off-by: Stefano Stabellini Reviewed-by: Bertrand Marquis CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis --- Changes in v4: - move xen,enhanced to the bottom of the list - do not set kinfo.dom0less_enhanced for dom0 Changes in v3: - improve commit message Changes in v2: - rename kinfo.enhanced to kinfo.dom0less_enhanced - set kinfo.dom0less_enhanced to true for dom0 - handle -ENODATA in addition to -EILSEQ --- docs/misc/arm/device-tree/booting.txt | 18 ++++++++++++++++++ xen/arch/arm/domain_build.c | 7 +++++++ xen/arch/arm/include/asm/kernel.h | 3 +++ 3 files changed, 28 insertions(+) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index a94125394e..92097c4969 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -188,6 +188,24 @@ with the following properties: An empty property to request the memory of the domain to be direct-map (guest physical address =3D=3D physical address). =20 +- xen,enhanced + + A string property. Possible property values are: + + - "enabled" (or missing property value) + Xen PV interfaces, including grant-table and xenstore, will be + enabled for the VM. + + - "disabled" + Xen PV interfaces are disabled. + + 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. + + In the future other possible property values might be added to + enable only selected interfaces. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk. =20 diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 100a4959a8..b22fe95d92 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3150,6 +3150,7 @@ static int __init construct_domU(struct domain *d, const struct dt_device_node *node) { struct kernel_info kinfo =3D {}; + const char *dom0less_enhanced; int rc; u64 mem; =20 @@ -3165,6 +3166,12 @@ static int __init construct_domU(struct domain *d, =20 kinfo.vpl011 =3D dt_property_read_bool(node, "vpl011"); =20 + rc =3D dt_property_read_string(node, "xen,enhanced", &dom0less_enhance= d); + if ( rc =3D=3D -EILSEQ || + rc =3D=3D -ENODATA || + (rc =3D=3D 0 && !strcmp(dom0less_enhanced, "enabled")) ) + kinfo.dom0less_enhanced =3D true; + if ( vcpu_create(d, 0) =3D=3D NULL ) return -ENOMEM; =20 diff --git a/xen/arch/arm/include/asm/kernel.h b/xen/arch/arm/include/asm/k= ernel.h index 874aa108a7..c4dc039b54 100644 --- a/xen/arch/arm/include/asm/kernel.h +++ b/xen/arch/arm/include/asm/kernel.h @@ -36,6 +36,9 @@ struct kernel_info { /* Enable pl011 emulation */ bool vpl011; =20 + /* Enable PV drivers */ + bool dom0less_enhanced; + /* GIC phandle */ uint32_t phandle_gic; =20 --=20 2.25.1 From nobody Fri Nov 29 04:31:46 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=1648773560; cv=none; d=zohomail.com; s=zohoarc; b=PjFalxTS2alfqTBJenWYpGpQlT3QfLTc9AoG5F37V6FXipZ/9G5PKjj41Ss+taHujrZnVvMj6lxosvDSiPddJ02frpiqxutBKWQqIkB6flrhDTC6jb6OXJUbMXTpmREeA7z90MbxFgdFzn6FuzjcpKP+MGYyNrGFEhd01fIPIko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648773560; 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=GsBx1Z/zG+YJOU8SneCNoUPcbTR3N82PnjAZ5MulxU4=; b=V2ZWP+oFDQfDlYcSw3VBd3d3MCAsBNPMGz8QTpPg2CU4Y6W/tgAWK6jDeJcbBAkMaCstWI12FuP8pg+d+mL2Lt7ynSXdfTvRBuhDB+e6aissiP35UMccXsBxvQeZdT9KjmMA/3tdjhaYx1Mzf8QfvS3c00OAQTFVTs0oIsp224w= 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 1648773560576977.5908860645678; Thu, 31 Mar 2022 17:39:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297160.506145 (Exim 4.92) (envelope-from ) id 1na5Jb-0000iw-40; Fri, 01 Apr 2022 00:38:59 +0000 Received: by outflank-mailman (output) from mailman id 297160.506145; Fri, 01 Apr 2022 00:38:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1na5Ja-0000dR-Dh; Fri, 01 Apr 2022 00:38:58 +0000 Received: by outflank-mailman (input) for mailman id 297160; Fri, 01 Apr 2022 00:38:55 +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 1na5JX-00087e-HS for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:38:55 +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 1b312796-b154-11ec-a405-831a346695d4; Fri, 01 Apr 2022 02:38:53 +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 C13F9B822B4; Fri, 1 Apr 2022 00:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19EB2C34115; Fri, 1 Apr 2022 00:38:52 +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: 1b312796-b154-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773532; bh=bKlaACyobMzZqVlommlo53UDbjiZ7/QiZBJFdbFnFaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sr8JLH+zcSmfPwQCUPAKzjR2SLXM3cPGkNvqmUK/Qt0Axlv8YNEXep1m+DUwNFTsK 1X3skIp36V/NB7Aua1xcSZzqmfNiwO5Ad+s28fZVAk45823hv2qUXnbDSOYvF1f6ML OTT0DgbwrM+fPBvQ3JfQ2e7nmgKkgaT0XDzX/s3eMqB1Ebm81/geyedF5lV28KFLa0 xMCcGdueg5ugJMJ8PH7ZH9X1J1x9EAoBMFWCLoD87IUaLVf9VBCWGP9dr1xHgTGAe2 KGQPt1DRwFv/4rPmUgkLGXBYCFnOAHTWf5bcKmXQ08jvaa1+OY9n9aS1ws2t0W4SAL kxpma20BU3j4w== 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 Subject: [PATCH v4 6/9] xen/arm: configure dom0less domain for enabling xenstore after boot Date: Thu, 31 Mar 2022 17:38:44 -0700 Message-Id: <20220401003847.38393-6-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: 1648773562732100008 Content-Type: text/plain; charset="utf-8" From: Luca Miccio 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 Reviewed-by: Bertrand Marquis CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis --- 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/arch/arm/domain_build.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index b22fe95d92..a8ad95ce40 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -28,6 +28,7 @@ #include #include #include +#include =20 #include #include @@ -2806,6 +2807,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; @@ -2880,6 +2883,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; @@ -3146,6 +3156,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) { @@ -3210,6 +3239,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 --=20 2.25.1 From nobody Fri Nov 29 04:31:46 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=1648773564; cv=none; d=zohomail.com; s=zohoarc; b=F9aiiwsPSre0wYnl66RppoPPDo4wpvQ3imH8+Fbf/Z/7jtiFGgYr7AwD8GnnYKSd32gtCMxueIYY14lB0Cek99kELEUJYpC0Fmu+TavQ+Fw1exFiE3/jEBvmPoj7emImHWpjTH5a+0qxZM7pOBvxkqyC/LEjZbTkqoaVK3J+Dj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648773564; 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=c3EufV0dHs+gSkZblh15gbaVKS1GByV5POvlIlZ6aZs=; b=mLc06k6VU2i9YAsT9eI+AifDBPlCd67aMH+g8UvzpAYC2aA1f8hbrQt/NzUTqFvtM+kvef5WGg2Mce5N07AIiafr9BzSVMb3Fvn176KsewLlchMafHi5K5RrETqkKocCXfaw3vt+J7ITtP/Vdze+ZNkjS63wASfXRC6UlXQBlIE= 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 1648773564152532.9276757061548; Thu, 31 Mar 2022 17:39:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297159.506136 (Exim 4.92) (envelope-from ) id 1na5Ja-0000Yr-AM; Fri, 01 Apr 2022 00:38:58 +0000 Received: by outflank-mailman (output) from mailman id 297159.506136; Fri, 01 Apr 2022 00:38:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1na5JZ-0000Vm-QI; Fri, 01 Apr 2022 00:38:57 +0000 Received: by outflank-mailman (input) for mailman id 297159; Fri, 01 Apr 2022 00:38:55 +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 1na5JX-0007ot-K3 for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:38:55 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1b451931-b154-11ec-8fbc-03012f2f19d4; Fri, 01 Apr 2022 02:38:54 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 2BBB8618AB; Fri, 1 Apr 2022 00:38:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A5B1C34112; Fri, 1 Apr 2022 00:38:52 +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: 1b451931-b154-11ec-8fbc-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773533; bh=1MIKxVGlrxQHtL44VHiQsIws8+/TOeEKbJHjXPBZ7lI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LuuxqOnSU2PMw/gWnGe3y0YcxCQe8Kz2xM2QdKzoO0nPrGoikibDmr/yuYLoweInC hE1VvltYj+rH1mbTxz4lJnKIplr4rdytWH96OmGSLRZ++JQBJskqx4MgG/0UTa35lD 8yF2MCptNaNvuFZXxR7rkXjN3UoXvnfP9AH6YGaphinRVIRWsMnBe8xnEwVWwAY13q Xy6MfcfqnVYM/seGEQwesKU/Hrw/LzwiNQBkzjegOefRRtvUkZKI4ARTorkPRsIfqC BuN0WSbGd/3DDD2d3s3BaiV7khHLYh5/uzx6Msa4jvXhnLvmg75JADIW/9acsWaDuf gTaeJ82lDBNqw== 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 Subject: [PATCH v4 7/9] xenstored: send an evtchn notification on introduce_domain Date: Thu, 31 Mar 2022 17:38:45 -0700 Message-Id: <20220401003847.38393-7-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: 1648773564796100001 Content-Type: text/plain; charset="utf-8" From: Luca Miccio When xs_introduce_domain is called, send out a notification on the xenstore event channel so that any (dom0less) domain waiting for the xenstore interface to be ready can continue with the initialization. The extra notification is harmless for domains that don't require it. Signed-off-by: Luca Miccio Signed-off-by: Stefano Stabellini Reviewed-by: Bertrand Marquis Reviewed-by: Juergen Gross --- Changes in v2: - drop the new late_init parameter --- tools/xenstore/xenstored_domain.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index ae065fcbee..0543f49670 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -493,6 +493,9 @@ static struct domain *introduce_domain(const void *ctx, /* Now domain belongs to its connection. */ talloc_steal(domain->conn, domain); =20 + /* Notify the domain that xenstore is available */ + xenevtchn_notify(xce_handle, domain->port); + if (!is_master_domain && !restore) fire_watches(NULL, ctx, "@introduceDomain", NULL, false, NULL); --=20 2.25.1 From nobody Fri Nov 29 04:31:46 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=1648773564; cv=none; d=zohomail.com; s=zohoarc; b=Rl7g53g6jzTj4SiSDEY5sgYfYBIZevhbAHXyNGo7gDh6q5wedkzxTilP8SP/K/Gxe23pXX3qV7GPO/ZdePrfLLze1XKHSJK4yJel9mZ2oiD4RWFGMYLoUrdQqON8jDbY10lKBbpPP4nm8soUV/UNQx0rlASi/qP++QcJqT9KFMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648773564; 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=mXNGm6f5vOin33jFR0o0aLAnK6G3ZTzgz17+d/M7wF4=; b=YM03Ou5bHXeWZotjqzvIy37q1dG7ScqVfpmStdls6ACeBVoL2Ko6529G6pQUVuMZzjBRqNHLyA9OYD66vhq0oa3kjnV3Svp2qmffdPaaDPOMhjbhFBKCjqN9bpCgQcLHge/bSpJkpRLoZJ/YRTEXw2CHDtK6mN5ACD5thhpIHZ4= 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 1648773564831242.55209769248552; Thu, 31 Mar 2022 17:39:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297162.506163 (Exim 4.92) (envelope-from ) id 1na5Jd-0001A7-1H; Fri, 01 Apr 2022 00:39:01 +0000 Received: by outflank-mailman (output) from mailman id 297162.506163; Fri, 01 Apr 2022 00:39: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 1na5Jc-00014u-60; Fri, 01 Apr 2022 00:39:00 +0000 Received: by outflank-mailman (input) for mailman id 297162; Fri, 01 Apr 2022 00:38:58 +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 1na5JZ-0007ot-KP for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:38:57 +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 1ba970c0-b154-11ec-8fbc-03012f2f19d4; Fri, 01 Apr 2022 02:38:54 +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 dfw.source.kernel.org (Postfix) with ESMTPS id C1EB7618CB; Fri, 1 Apr 2022 00:38:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2859CC340F0; Fri, 1 Apr 2022 00:38:53 +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: 1ba970c0-b154-11ec-8fbc-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773533; bh=aVUhLT0k6h5mW+XusXYNb4z2CYJuj6jR5xtLUX9su5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ir72MTrGrRy2EOi7JInOLn7cruQ7kEHSvKpOcWVdTEUdKqUw9I4eCbEEOtpW3S0oI WyP+GzNyLMK9UPouiHfw979AOim5RF3ZM8d9JPTI6wKojzSXb2aBAiHjUiAuRxOz9S rb8/iS450aZVqwBoOgJORj2CMT6d27g5E8Hf71Dgsk3vXTRvCExW3XFz5okDb393uu r6UtcBA+7GPC/dhMmqzGsNWoiKF99IvmWpKt0cYCv/BxnWCXt+ZcTstfWhhGAim26P fWX6Dy2+hVUcpyNHkBgOTaDgz0eOONIy1NbgQwI09buAwZJzPcVbGe42rbcjKd8wyU GTomF3CPizitw== 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 , Wei Liu , Anthony PERARD Subject: [PATCH v4 8/9] tools: add example application to initialize dom0less PV drivers Date: Thu, 31 Mar 2022 17:38:46 -0700 Message-Id: <20220401003847.38393-8-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: 1648773566795100003 Content-Type: text/plain; charset="utf-8" From: Luca Miccio Add an example application that can be run in dom0 to complete the dom0less domains initialization so that they can get access to xenstore and use PV drivers. Signed-off-by: Luca Miccio Signed-off-by: Stefano Stabellini CC: Wei Liu CC: Anthony PERARD CC: Juergen Gross --- Changes in v4: - only alloc xs page (no other magic pages) - add xenstore permissions - check all return values - rename restore_xenstore to create_xenstore - set target_memkb - set start_time properly - close xs transaction on error - call xc_dom_gnttab_seed instead of xc_dom_gnttab_init - xs_open instead of xs_daemon_open Changes in v3: - handle xenstore errors - add an in-code comment about xenstore entries - less verbose output - clean-up error path in main Changes in v2: - do not set HVM_PARAM_STORE_EVTCHN twice - rename restore_xenstore to create_xenstore - increase maxmem --- tools/helpers/Makefile | 13 ++ tools/helpers/init-dom0less.c | 323 ++++++++++++++++++++++++++++++++++ 2 files changed, 336 insertions(+) create mode 100644 tools/helpers/init-dom0less.c diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile index 7f6c422440..8e42997052 100644 --- a/tools/helpers/Makefile +++ b/tools/helpers/Makefile @@ -10,6 +10,9 @@ ifeq ($(CONFIG_Linux),y) ifeq ($(CONFIG_X86),y) PROGS +=3D init-xenstore-domain endif +ifeq ($(CONFIG_ARM),y) +PROGS +=3D init-dom0less +endif endif =20 XEN_INIT_DOM0_OBJS =3D xen-init-dom0.o init-dom-json.o @@ -26,6 +29,13 @@ $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS +=3D $(CFLAGS_libxe= nstore) $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS +=3D $(CFLAGS_libxenlight) $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS +=3D -include $(XEN_ROOT)/tools/confi= g.h =20 +INIT_DOM0LESS_OBJS =3D init-dom0less.o init-dom-json.o +$(INIT_DOM0LESS_OBJS): CFLAGS +=3D $(CFLAGS_libxentoollog) +$(INIT_DOM0LESS_OBJS): CFLAGS +=3D $(CFLAGS_libxenstore) +$(INIT_DOM0LESS_OBJS): CFLAGS +=3D $(CFLAGS_libxenlight) +$(INIT_DOM0LESS_OBJS): CFLAGS +=3D $(CFLAGS_libxenctrl) +$(INIT_DOM0LESS_OBJS): CFLAGS +=3D $(CFLAGS_libxenevtchn) + .PHONY: all all: $(PROGS) =20 @@ -35,6 +45,9 @@ xen-init-dom0: $(XEN_INIT_DOM0_OBJS) init-xenstore-domain: $(INIT_XENSTORE_DOMAIN_OBJS) $(CC) $(LDFLAGS) -o $@ $(INIT_XENSTORE_DOMAIN_OBJS) $(LDLIBS_libxentoollo= g) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIB= S_libxenlight) $(APPEND_LDFLAGS) =20 +init-dom0less: $(INIT_DOM0LESS_OBJS) + $(CC) $(LDFLAGS) -o $@ $(INIT_DOM0LESS_OBJS) $(LDLIBS_libxenctrl) $(LDLIB= S_libxenevtchn) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libx= enlight) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS) + .PHONY: install install: all $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN) diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c new file mode 100644 index 0000000000..dc9ccee868 --- /dev/null +++ b/tools/helpers/init-dom0less.c @@ -0,0 +1,323 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "init-dom-json.h" + +#define XENSTORE_PFN_OFFSET 1 +#define STR_MAX_LENGTH 64 + +static int alloc_xs_page(struct xc_interface_core *xch, + libxl_dominfo *info, + uint64_t *xenstore_pfn) +{ + int rc; + const xen_pfn_t base =3D GUEST_MAGIC_BASE >> XC_PAGE_SHIFT; + xen_pfn_t p2m =3D (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_O= FFSET; + + rc =3D xc_domain_setmaxmem(xch, info->domid, + info->max_memkb + (XC_PAGE_SIZE/1024)); + if (rc < 0) + return rc; + + rc =3D xc_domain_populate_physmap_exact(xch, info->domid, 1, 0, 0, &p2= m); + if (rc < 0) + return rc; + + *xenstore_pfn =3D base + XENSTORE_PFN_OFFSET; + rc =3D xc_clear_domain_page(xch, info->domid, *xenstore_pfn); + if (rc < 0) + return rc; + + return 0; +} + +static bool do_xs_write_dom(struct xs_handle *xsh, xs_transaction_t t, + domid_t domid, char *path, char *val) +{ + char full_path[STR_MAX_LENGTH]; + struct xs_permissions perms[2]; + + perms[0].id =3D domid; + perms[0].perms =3D XS_PERM_NONE; + perms[1].id =3D 0; + perms[1].perms =3D XS_PERM_READ; + + if (snprintf(full_path, STR_MAX_LENGTH, + "/local/domain/%u/%s", domid, path) < 0) + return false; + if (!xs_write(xsh, t, full_path, val, strlen(val))) + return false; + return xs_set_permissions(xsh, t, full_path, perms, 2); +} + +static bool do_xs_write_libxl(struct xs_handle *xsh, xs_transaction_t t, + domid_t domid, char *path, char *val) +{ + char full_path[STR_MAX_LENGTH]; + + if (snprintf(full_path, STR_MAX_LENGTH, + "/libxl/%u/%s", domid, path) < 0) + return false; + return xs_write(xsh, t, full_path, val, strlen(val)); +} + +static bool do_xs_write_vm(struct xs_handle *xsh, xs_transaction_t t, + libxl_uuid uuid, char *path, char *val) +{ + char full_path[STR_MAX_LENGTH]; + + if (snprintf(full_path, STR_MAX_LENGTH, + "/vm/" LIBXL_UUID_FMT "/%s", LIBXL_UUID_BYTES(uuid), path= ) < 0) + return false; + return xs_write(xsh, t, full_path, val, strlen(val)); +} + +/* + * The xenstore nodes are the xenstore nodes libxl writes at domain + * creation. + * + * The list was retrieved by running xenstore-ls on a corresponding + * domain started by xl/libxl. + */ +static int create_xenstore(struct xs_handle *xsh, + libxl_dominfo *info, libxl_uuid uuid, + evtchn_port_t xenstore_port) +{ + domid_t domid; + unsigned int i; + char uuid_str[STR_MAX_LENGTH]; + char dom_name_str[STR_MAX_LENGTH]; + char vm_val_str[STR_MAX_LENGTH]; + char id_str[STR_MAX_LENGTH]; + char max_memkb_str[STR_MAX_LENGTH]; + char target_memkb_str[STR_MAX_LENGTH]; + char cpu_str[STR_MAX_LENGTH]; + char xenstore_port_str[STR_MAX_LENGTH]; + char ring_ref_str[STR_MAX_LENGTH]; + xs_transaction_t t; + struct timeval start_time; + char start_time_str[STR_MAX_LENGTH]; + int rc; + + if (gettimeofday(&start_time, NULL) < 0) + return -errno; + rc =3D snprintf(start_time_str, STR_MAX_LENGTH, "%jd.%02d", + (intmax_t)start_time.tv_sec, (int)start_time.tv_usec / 10000); + if (rc < 0) + return rc; + + domid =3D info->domid; + rc =3D snprintf(id_str, STR_MAX_LENGTH, "%u", domid); + if (rc < 0) + return rc; + rc =3D snprintf(dom_name_str, STR_MAX_LENGTH, "dom0less-%u", domid); + if (rc < 0) + return rc; + rc =3D snprintf(uuid_str, STR_MAX_LENGTH, LIBXL_UUID_FMT, LIBXL_UUID_B= YTES(uuid)); + if (rc < 0) + return rc; + rc =3D snprintf(vm_val_str, STR_MAX_LENGTH, + "vm/" LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid)); + if (rc < 0) + return rc; + rc =3D snprintf(max_memkb_str, STR_MAX_LENGTH, "%lu", info->max_memkb); + if (rc < 0) + return rc; + rc =3D snprintf(target_memkb_str, STR_MAX_LENGTH, "%lu", info->current= _memkb); + if (rc < 0) + return rc; + rc =3D snprintf(ring_ref_str, STR_MAX_LENGTH, "%lld", + (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSE= T); + if (rc < 0) + return rc; + rc =3D snprintf(xenstore_port_str, STR_MAX_LENGTH, "%u", xenstore_port= ); + if (rc < 0) + return rc; + +retry_transaction: + t =3D xs_transaction_start(xsh); + if (t =3D=3D XBT_NULL) + return -errno; + + rc =3D -EIO; + /* /vm */ + if (!do_xs_write_vm(xsh, t, uuid, "name", dom_name_str)) goto err; + if (!do_xs_write_vm(xsh, t, uuid, "uuid", uuid_str)) goto err; + if (!do_xs_write_vm(xsh, t, uuid, "start_time", start_time_str)) goto = err; + + /* /domain */ + if (!do_xs_write_dom(xsh, t, domid, "vm", vm_val_str)) goto err; + if (!do_xs_write_dom(xsh, t, domid, "name", dom_name_str)) goto err; + if (!do_xs_write_dom(xsh, t, domid, "cpu", "")) goto err; + for (i =3D 0; i < info->vcpu_max_id; i++) { + rc =3D snprintf(cpu_str, STR_MAX_LENGTH, "cpu/%u/availability/", i= ); + if (rc < 0) + goto err; + rc =3D -EIO; + if (!do_xs_write_dom(xsh, t, domid, cpu_str, + (info->cpupool & (1 << i)) ? "online" : "offl= ine")) + goto err; + } + + if (!do_xs_write_dom(xsh, t, domid, "memory", "")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "memory/static-max", max_memkb_str= )) goto err; + if (!do_xs_write_dom(xsh, t, domid, "memory/target", target_memkb_str)= ) goto err; + if (!do_xs_write_dom(xsh, t, domid, "memory/videoram", "-1")) goto err; + + if (!do_xs_write_dom(xsh, t, domid, "device", "")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "device/suspend", "")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "device/suspend/event-channel", ""= )) goto err; + + if (!do_xs_write_dom(xsh, t, domid, "control", "")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "control/shutdown", "")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "control/feature-poweroff", "1")) = goto err; + if (!do_xs_write_dom(xsh, t, domid, "control/feature-reboot", "1")) go= to err; + if (!do_xs_write_dom(xsh, t, domid, "control/feature-suspend", "")) go= to err; + if (!do_xs_write_dom(xsh, t, domid, "control/sysrq", "")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "control/platform-feature-multipro= cessor-suspend", "1")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "control/platform-feature-xs_reset= _watches", "1")) goto err; + + if (!do_xs_write_dom(xsh, t, domid, "domid", id_str)) goto err; + if (!do_xs_write_dom(xsh, t, domid, "data", "")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "drivers", "")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "feature", "")) goto err; + if (!do_xs_write_dom(xsh, t, domid, "attr", "")) goto err; + + if (!do_xs_write_dom(xsh, t, domid, "store/port", xenstore_port_str)) = goto err; + if (!do_xs_write_dom(xsh, t, domid, "store/ring-ref", ring_ref_str)) g= oto err; + + if (!do_xs_write_libxl(xsh, t, domid, "type", "pvh")) goto err; + if (!do_xs_write_libxl(xsh, t, domid, "dm-version", "qemu_xen")) goto = err; + + if (!xs_transaction_end(xsh, t, false)) { + if (errno =3D=3D EAGAIN) + goto retry_transaction; + else + return -errno; + } + + return 0; + +err: + xs_transaction_end(xsh, t, true); + return rc; +} + +static int init_domain(struct xs_handle *xsh, libxl_dominfo *info) +{ + struct xc_interface_core *xch; + libxl_uuid uuid; + uint64_t xenstore_evtchn, xenstore_pfn; + int rc; + + printf("Init dom0less domain: %u\n", info->domid); + xch =3D xc_interface_open(0, 0, 0); + + rc =3D xc_hvm_param_get(xch, info->domid, HVM_PARAM_STORE_EVTCHN, + &xenstore_evtchn); + if (rc !=3D 0) { + printf("Failed to get HVM_PARAM_STORE_EVTCHN\n"); + return 1; + } + + /* Alloc xenstore page */ + if (alloc_xs_page(xch, info, &xenstore_pfn) !=3D 0) { + printf("Error on alloc magic pages\n"); + return 1; + } + + rc =3D xc_dom_gnttab_seed(xch, info->domid, true, + (xen_pfn_t)-1, xenstore_pfn, 0, 0); + if (rc) + err(1, "xc_dom_gnttab_seed"); + + libxl_uuid_generate(&uuid); + xc_domain_sethandle(xch, info->domid, libxl_uuid_bytearray(&uuid)); + + rc =3D gen_stub_json_config(info->domid, &uuid); + if (rc) + err(1, "gen_stub_json_config"); + + /* Now everything is ready: set HVM_PARAM_STORE_PFN */ + rc =3D xc_hvm_param_set(xch, info->domid, HVM_PARAM_STORE_PFN, + xenstore_pfn); + if (rc < 0) + return rc; + + rc =3D create_xenstore(xsh, info, uuid, xenstore_evtchn); + if (rc) + err(1, "writing to xenstore"); + + rc =3D xs_introduce_domain(xsh, info->domid, + (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET, + xenstore_evtchn); + if (!rc) + err(1, "xs_introduce_domain"); + return 0; +} + +/* Check if domain has been configured in XS */ +static bool domain_exists(struct xs_handle *xsh, int domid) +{ + return xs_is_domain_introduced(xsh, domid); +} + +int main(int argc, char **argv) +{ + libxl_dominfo *info =3D NULL; + libxl_ctx *ctx; + int nb_vm =3D 0, rc =3D 0, i; + struct xs_handle *xsh =3D NULL; + + /* TODO reuse libxl xsh connection */ + xsh =3D xs_open(0); + if (xsh =3D=3D NULL) { + fprintf(stderr, "Could not contact XenStore"); + rc =3D -errno; + goto out; + } + + rc =3D libxl_ctx_alloc(&ctx, LIBXL_VERSION, 0, NULL); + if (rc) { + fprintf(stderr, "cannot init xl context\n"); + goto out; + } + + info =3D libxl_list_domain(ctx, &nb_vm); + if (!info) { + fprintf(stderr, "libxl_list_vm failed.\n"); + rc =3D -1; + goto out; + } + + for (i =3D 0; i < nb_vm; i++) { + domid_t domid =3D info[i].domid; + + /* Don't need to check for Dom0 */ + if (!domid) + continue; + + printf("Checking domid: %u\n", domid); + if (!domain_exists(xsh, domid)) { + rc =3D init_domain(xsh, &info[i]); + if (rc < 0) { + fprintf(stderr, "init_domain failed.\n"); + goto out; + } + } else { + printf("Domain %u has already been initialized\n", domid); + } + } +out: + libxl_dominfo_list_free(info, nb_vm); + return rc; +} --=20 2.25.1 From nobody Fri Nov 29 04:31:46 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=1648773562; cv=none; d=zohomail.com; s=zohoarc; b=JQ88PahRdy1IvmnGgIDOOizxlRH7zYEH88MljOX0gTkq9V91ZPyt9dVy4KAeq1wkqF0qivyz+oMOCMG7OBQpqe7ZoV5ZvEJ59Au+ZWM1x0oFLqlHbDSW2C5osIUYlDeThNqoYMo1JIxZQvZjjuTztO3xGgDW6oCIMRZ2LKwv1z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648773562; 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=0mPjjHuVBYZ/5v1HKlPj1ius3DiEs6gkynnmcaa3mbw=; b=HiKWEajkdteUJd/e4s6+twwYkR1ItxpihZjeB58B3nIrCspXaBrmaY1oOlQoQioYqNlPiLxXiZv9EPDl/tB81NAKe8P9wy1PurYAoLT1A1vcwZAZg3d97bPuLhUCYJxxKW2cZV/3e8Ch+m1s7s7mjlbCEol9o6MNhZOZgqBV0tY= 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 1648773562501761.9507573147206; Thu, 31 Mar 2022 17:39:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297161.506152 (Exim 4.92) (envelope-from ) id 1na5Jb-0000zD-Rx; Fri, 01 Apr 2022 00:38:59 +0000 Received: by outflank-mailman (output) from mailman id 297161.506152; Fri, 01 Apr 2022 00:38:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1na5Jb-0000wH-Ej; Fri, 01 Apr 2022 00:38:59 +0000 Received: by outflank-mailman (input) for mailman id 297161; Fri, 01 Apr 2022 00:38:56 +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 1na5JY-0007ot-KL for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:38:56 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1c1ac557-b154-11ec-8fbc-03012f2f19d4; Fri, 01 Apr 2022 02:38:55 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 9E1E3618B8; Fri, 1 Apr 2022 00:38:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF26EC340F2; Fri, 1 Apr 2022 00:38:53 +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: 1c1ac557-b154-11ec-8fbc-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773534; bh=SyJ8d/AZr5XFzu3v/AGdBw4+YWs6wkcRBAD8+aGiIR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZNcF/aqp8YX0OngKR48lncjoj4oL3Gi2+JJHtCOdyA2QN/Kq7MCfGqZuJBFFR6EF7 7TxsX4uFnSgfelEtrkvyZVBSNITXikzOppt7A75SrAO1impSlpVT1bsDHAZpjKXHTd lJYpdwrWCrPdesQCZcou81J0K4uRZ7rIxcDO3IOF2BH6Ain5V79Ymfv6m40D+hKaIs DUrRdWD1HtmOjxOPfjqIgTIuxQ0I/9ZmjNum0jbdWitO8B4OMJ/BqgCkTE3jRdz5Gg 2tN0UieyjWC3vXnW3dLjYmekJaqBoVnwKKT/YbNjPLq4Rhfq9ioUX9sWd/8LWmunPw qSDQ4wMfiPlTg== 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, Stefano Stabellini Subject: [PATCH v4 9/9] docs: document dom0less + PV drivers Date: Thu, 31 Mar 2022 17:38:47 -0700 Message-Id: <20220401003847.38393-9-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: 1648773562735100009 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini Document how to use the feature and how the implementation works. Signed-off-by: Stefano Stabellini Reviewed-by: Luca Fancellu --- docs/features/dom0less.pandoc | 43 ++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/features/dom0less.pandoc b/docs/features/dom0less.pandoc index c9edb529e1..725afa0558 100644 --- a/docs/features/dom0less.pandoc +++ b/docs/features/dom0less.pandoc @@ -90,6 +90,46 @@ Otherwise, they may be unusable in Xen (for instance if = they are compressed). =20 See docs/misc/arm/device-tree/booting.txt for more information. =20 +PV Drivers +---------- + +It is possible to use PV drivers with dom0less guests with some +restrictions: + +- dom0less domUs that want to use PV drivers support should have the + "xen,enhanced" property set under their device tree nodes (see + docs/misc/arm/device-tree/booting.txt) +- a dom0 must be present (or another domain with enough privileges to + run the toolstack) +- after dom0 is booted, the utility "init-dom0less" must be run +- do not run "init-dom0less" while creating other guests with xl + +After the execution of init-dom0less, it is possible to use "xl" to +hotplug PV drivers to dom0less guests. E.g. xl network-attach domU. + +The implementation works as follows: +- Xen allocates the xenstore event channel for each dom0less domU that + has the "xen,enhanced" property, and sets HVM_PARAM_STORE_EVTCHN +- Xen does *not* allocate the xenstore page and sets HVM_PARAM_STORE_PFN + to ~0ULL (invalid) +- Dom0less domU kernels check that HVM_PARAM_STORE_PFN is set to invalid + - Old kernels will continue without xenstore support (Note: some old + buggy kernels might crash because they don't check the validity of + HVM_PARAM_STORE_PFN before using it! Disable "xen,enhanced" in + those cases) + - New kernels will wait for a notification on the xenstore event + channel (HVM_PARAM_STORE_EVTCHN) before continuing with the + initialization +- Once dom0 is booted, init-dom0less is executed: + - it allocates the xenstore shared page and sets HVM_PARAM_STORE_PFN + - it calls xs_introduce_domain +- Xenstored notices the new domain, initializes interfaces as usual, and + sends an event channel notification to the domain using the xenstore + event channel (HVM_PARAM_STORE_EVTCHN) +- The Linux domU kernel receives the event channel notification, checks + HVM_PARAM_STORE_PFN again and continue with the initialization + + Limitations ----------- =20 @@ -107,9 +147,6 @@ limitations: information, the GIC version exposed to the domains started by Xen at boot is the same as the native GIC version. =20 -- No PV drivers. There is no support for PV devices at the moment. All - devices need to be statically assigned to guests. - - Pinning vCPUs of domains started by Xen at boot can be done from the control domain, using `xl vcpu-pin` as usual. It is not currently possible to configure vCPU pinning without a control domain. --=20 2.25.1