From nobody Sun May 12 14:05:38 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=1651265878; cv=none; d=zohomail.com; s=zohoarc; b=TlnSQHPOhcDLir4BebMK7vHWY5uQZi+IBgq054lZ8OiB4sa7PdxKCIQLN0RW3YuKosaR7jxkJW5IW8mUgd9AYEv2nQJdvfW0dG9/0NQnFkbFtthKvNbnCwN8RJehaQBx13tElbTBZDTEvQfMhJHSTMyP2u8GnMSMeJSzJjDywHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651265878; 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=gMjsb3Le6w8xKOBoMw0OOvwi8DNZoeCrMToyuxIzrI8=; b=YR+fVQPWv5OPJJHCNJh1fxeL9XfLKI8L9CgXdhRcBmhISy6a7fzpjYtGqJO6+ZBp76Uu8EBGp0IlU7o+Pep9Afv4eY4AkOz7EyChLD1VKkhZlkSARxVE594+VrgSlxAPkSqJiwwBa8WS5vf8S2qsXUdTyClvWQJo54v8Kam8MA4= 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 1651265878535282.56906400326864; Fri, 29 Apr 2022 13:57:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.317702.537162 (Exim 4.92) (envelope-from ) id 1nkXgI-0007Em-4z; Fri, 29 Apr 2022 20:57:38 +0000 Received: by outflank-mailman (output) from mailman id 317702.537162; Fri, 29 Apr 2022 20:57:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nkXgI-0007Ed-1n; Fri, 29 Apr 2022 20:57:38 +0000 Received: by outflank-mailman (input) for mailman id 317702; Fri, 29 Apr 2022 20:57:37 +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 1nkXgH-0006w0-EI for xen-devel@lists.xenproject.org; Fri, 29 Apr 2022 20:57:37 +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 ff03d556-c7fe-11ec-8fc4-03012f2f19d4; Fri, 29 Apr 2022 22:57:36 +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 11385621A2; Fri, 29 Apr 2022 20:57:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 176B1C385A4; Fri, 29 Apr 2022 20:57:34 +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: ff03d556-c7fe-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651265854; bh=qNbBe6vmVEA5q4kiVCAEwgFL1a6sen9A+xt7fWqSkOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t2mf+d5+Yl/YFI//MIfxpyddVMpFHSoViMkxkhbAmDwvfKyySCDMqzGohssrt7ivY dGauxPXjx5u3tlE9B18X3/JlC3bHpAIipY+jo8jkg+OzH2nW4vDL7XlYSvHLOtkYPi l5KP0rEb7gpOO+5lwJt2pYF9+3UrXtM3Oi4lR6f5c1OY3f0YDAp2tGDqt+yO8GPqgV bG1s0MkVYB8DLMlfidkTNYlU1/XXdZ9FKZxQ7HLd7hd4cWuvoAwrnDvfp72Uzoem4Z 63+bzRRT5+/IZ3n5SrYay0iNl3kq9iNeuLz97MSjZPUgVFnHdSVmJkXCRNOCJ07O2C wRlbOjpoQCUuA== 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 v5 1/7] xen/dt: of_property_read_string return -ENODATA when !length Date: Fri, 29 Apr 2022 13:57:26 -0700 Message-Id: <20220429205732.2030094-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: 1651266779860100001 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini When the length of the string is zero of_property_read_string should return -ENODATA according to the description of the function. However, of_property_read_string doesn't check prop->length. If prop->length is zero, return -ENODATA. Without this patch the following command in u-boot: fdt set /chosen/node property-name results in of_property_read_string returning -EILSEQ when attempting to read property-name. With this patch, it returns -ENODATA as expected. This commit is a backport of: https://lore.kernel.org/xen-devel/20220416003028.1315268-1-sstabellini@kern= el.org/ Signed-off-by: Stefano Stabellini Reviewed-by: Bertrand Marquis Reviewed-by: Luca Fancellu --- Changes in v5: - backport from Linux, I don't have the commit id yet so I used an LKML link instead for now --- xen/common/device_tree.c | 2 +- xen/include/xen/device_tree.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 4aae281e89..0e8798bd24 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->length ) return -ENODATA; if ( strnlen(pp->value, pp->length) >=3D pp->length ) return -EILSEQ; diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index fd6cd00b43..430a1ef445 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -451,6 +451,9 @@ static inline bool_t dt_property_read_bool(const struct= dt_device_node *np, * doest not have value, and -EILSEQ if the string is not * null-terminated with the length of the property data. * + * Note that the empty string "" has length of 1, thus -ENODATA cannot + * be interpreted as an empty string. + * * The out_string pointer is modified only if a valid string can be decode= d. */ int dt_property_read_string(const struct dt_device_node *np, --=20 2.25.1 From nobody Sun May 12 14:05:38 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=1651265877; cv=none; d=zohomail.com; s=zohoarc; b=NaBlaY92x646plopNy27szMuZqhyyBQ9wAPtfRo6C4URS6ru4SmntosKfmhPczU1puVdu61ePNLlM1lBJYrNKnq8Y7VOBCE14Tvt4e5FtVZeKnxAHQflO5n3DGa4TrsnyA5ZQHNYhiTBb039JBI3KYIng4AjqSvN+GSLztguci4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651265877; 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=76qTT8STHe8vkcCBncONAw/APQfjUhhwp28DBHThtS0=; b=WGdK9D5/fRfw3poMUIynlam+d+WvI+J8e4Fbijl4ZSEs8p3JUEFEjC9kOJC9noUSwgoiq6MVa8vUNay529qqdqkW9BNkJigYgukktAwQUhhKaImfhHD0lRQXkZntTwj4jxft454/Mh0LutoeWYd17iwKHy6v8E0ZTzLrPB0kdOc= 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 1651265877712711.5371289239024; Fri, 29 Apr 2022 13:57:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.317703.537173 (Exim 4.92) (envelope-from ) id 1nkXgJ-0007Vh-EQ; Fri, 29 Apr 2022 20:57:39 +0000 Received: by outflank-mailman (output) from mailman id 317703.537173; Fri, 29 Apr 2022 20:57:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nkXgJ-0007VW-Ar; Fri, 29 Apr 2022 20:57:39 +0000 Received: by outflank-mailman (input) for mailman id 317703; Fri, 29 Apr 2022 20:57:38 +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 1nkXgI-0006w0-EP for xen-devel@lists.xenproject.org; Fri, 29 Apr 2022 20:57:38 +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 ff3d3a40-c7fe-11ec-8fc4-03012f2f19d4; Fri, 29 Apr 2022 22:57:36 +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 8F3BE621D7; Fri, 29 Apr 2022 20:57:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1047C385AE; Fri, 29 Apr 2022 20:57:34 +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: ff3d3a40-c7fe-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651265855; bh=xYtT+6HeBjKFPCtYs7kjkhcpxb7ruFyZ0/KuV9mvqgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VzCyC431VGEgRMAeJTo4H/YQpKqJQitqJvGPFJzWM0Nwpr2wqrcb1fuzxTRoaJk3g glXXrff9lyuceNjIjfNeVYuXP4AM8+Kee00ocMsYXTV9tsX9PZPMV7yWS0Ao47TAKH J/76RDLM4o8EZf8y4C8j2H0/C9yV+Nu9zokeMUhuwbsiaAkxKwQWA9neM56UeobIGS 30C5eRmTmrRzaN2nTj1uqg0AE8ZsAk/jj2J0S9snnSTCjtV6CNF2banTjHKEYkJIkQ AHkuVrUDwus7KQ+9SDsfmEb07U8jCAUrmbPBGJ8drCi7R4Ed0vlEZm0q4oASruA1nY vN9Yu1bP44d4Q== 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 v5 2/7] xen/arm: implement domU extended regions Date: Fri, 29 Apr 2022 13:57:27 -0700 Message-Id: <20220429205732.2030094-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: 1651265879127100002 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 --- Changes in v5: - print the domain - coding style - simplify the code in find_domU_holes - return error if no regions allocated in find_domU_holes - use ROUNDUP - uint64_t/paddr_t --- xen/arch/arm/domain_build.c | 56 +++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 8be01678de..34d3e5ce30 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1324,6 +1324,37 @@ out: return res; } =20 +static int __init find_domU_holes(const struct kernel_info *kinfo, + struct meminfo *ext_regions) +{ + unsigned int i; + paddr_t bankend; + const paddr_t bankbase[] =3D GUEST_RAM_BANK_BASES; + const paddr_t banksize[] =3D GUEST_RAM_BANK_SIZES; + int res =3D -ENOENT; + + for ( i =3D 0; i < GUEST_RAM_BANKS; i++ ) + { + struct membank *ext_bank =3D &(ext_regions->bank[ext_regions->nr_b= anks]); + + ext_bank->start =3D ROUNDUP(bankbase[i] + kinfo->mem.bank[i].size, + SZ_2M); + + bankend =3D ~0ULL >> (64 - p2m_ipa_bits); + bankend =3D min(bankend, bankbase[i] + banksize[i] - 1); + if ( bankend > ext_bank->start ) + ext_bank->size =3D bankend - ext_bank->start + 1; + + /* 64MB is the minimum size of an extended region */ + if ( ext_bank->size < MB(64) ) + continue; + ext_regions->nr_banks++; + res =3D 0; + } + + return res; +} + static int __init make_hypervisor_node(struct domain *d, const struct kernel_info *kinfo, int addrcells, int sizecells) @@ -1360,12 +1391,13 @@ static int __init make_hypervisor_node(struct domai= n *d, =20 if ( !opt_ext_regions ) { - printk(XENLOG_INFO "The extended regions support is disabled\n"); + printk(XENLOG_INFO "%pd: extended regions support is disabled\n", = d); nr_ext_regions =3D 0; } else if ( is_32bit_domain(d) ) { - printk(XENLOG_WARNING "The extended regions are only supported for= 64-bit guest currently\n"); + printk(XENLOG_WARNING "%pd: extended regions are only supported fo= r 64-bit guest currently\n", + d); nr_ext_regions =3D 0; } else @@ -1374,13 +1406,21 @@ 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"); + printk(XENLOG_WARNING "%pd: failed to allocate extended region= s\n", + d); nr_ext_regions =3D ext_regions->nr_banks; } =20 @@ -1401,8 +1441,8 @@ static int __init make_hypervisor_node(struct domain = *d, u64 start =3D ext_regions->bank[i].start; u64 size =3D ext_regions->bank[i].size; =20 - printk("Extended region %d: %#"PRIx64"->%#"PRIx64"\n", - i, start, start + size); + printk("%pd: extended region %d: %#"PRIx64"->%#"PRIx64"\n", + d, i, start, start + size); =20 dt_child_set_range(&cells, addrcells, sizecells, start, size); } --=20 2.25.1 From nobody Sun May 12 14:05:38 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=1651265877; cv=none; d=zohomail.com; s=zohoarc; b=fvT3ISPpgJMuhDCVUxGtTeRN+DPmsov91cuF9akHlWoq8RGRGbbcl63/2tRfU0E132W3cAOF5pIHWCSA81FDEFUbYEMMs+I+b1isJK7nBGFiTqCzd1UNsqAWHOGuAsm48pME4AegvhTjflzvjwfblF+NJQNevBwWqbGYINaB2jk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651265877; 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=Lr3oQ2s61zzO6XQhdCFMj+fuGcIiLFxBeLrZ64ksdfg=; b=L2zdn3RDdU9np1FIMC/t5VRaQ8mEP2hV1QVvKVDnP7jTTHiOW32TsOMbh/gfrvtddC1d/5VU9FK9AGl+LxpbFJK96/HU5zJ8GK5udUN2wbUPih7VUkQgUKUZiNaXNSqw48NOySdXLQJaN/XpsJ0/O5joLDJSqiXDyANS78Vg3NY= 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 1651265877436916.2087587878852; Fri, 29 Apr 2022 13:57:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.317705.537189 (Exim 4.92) (envelope-from ) id 1nkXgL-0007qZ-6z; Fri, 29 Apr 2022 20:57:41 +0000 Received: by outflank-mailman (output) from mailman id 317705.537189; Fri, 29 Apr 2022 20:57:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nkXgL-0007pf-14; Fri, 29 Apr 2022 20:57:41 +0000 Received: by outflank-mailman (input) for mailman id 317705; Fri, 29 Apr 2022 20:57:39 +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 1nkXgJ-0006w0-EY for xen-devel@lists.xenproject.org; Fri, 29 Apr 2022 20:57:39 +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 ff7c0e05-c7fe-11ec-8fc4-03012f2f19d4; Fri, 29 Apr 2022 22:57:37 +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 1178362197; Fri, 29 Apr 2022 20:57:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 267C3C385A7; 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: ff7c0e05-c7fe-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651265855; bh=6m3CZlBC4jLi1cx+SFKdE9IMqKeQVNwLUZ2DmiQZgwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lbrADBwSTXHRicxGA7BKm/+C4Zz3/c38hf5hyKfbPuwxwDCPaybhjNf6IIVYAaBsH s9pqrMoykdwN/mMvk+wrA5loKcoThdulaLA+Bbm+OP2a7dH/AUKgUv32/8Gw1gvsKi tMxfhbNIy1hyiyI0fap/CFjW+bzeQ8Eeip6hTwTZm2WB54PBJBDc4BwJOyc6tyrdpR Nqt7bm7lz9vTJ8z0U0cXnLNh5kpqC5NQJ6xAdA/+Cv13VOsMeW2H0BlgyTKfCV2fJu sr55G82ZjIvaKS+2xuW7sFGCvKgm5frL1Fom1W8GI2lYxepU4tAfFkPWVOuxxMNciH 59r6YceC3V2Jw== 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 v5 3/7] xen: introduce xen,enhanced dom0less property Date: Fri, 29 Apr 2022 13:57:28 -0700 Message-Id: <20220429205732.2030094-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: 1651266779867100002 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 34d3e5ce30..a877ccf585 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3153,6 +3153,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 @@ -3168,6 +3169,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 Sun May 12 14:05:38 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 From nobody Sun May 12 14:05:38 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=1651265879; cv=none; d=zohomail.com; s=zohoarc; b=mXPUt1BO9HifpdR8yn33aPoPPkuxXzuAu6b4mbBFr3+5iPIgzT3YrNwwPxyLCIwHPorW3qieNmKvhrNu9SpnZIxWAD7MCBQMvgylGIYpG3SNRK455kFGhW7Vb6kxT19pKFO1JCQSZphR5Hw77E+v/Lm1qG9GzU81hUiqOd7IlKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651265879; 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=4F5eQ7wsC1l9OngQ3773yWFIEuChw2l0r19/ZANmJb8=; b=O63QNb/6I+uRr+wxh72u6xY+uqrl3gSrKQ4IxztbueBp3OwqSsFY0ZUC9d9+QPqxEt9OvEAWWCkCcRr9cdgIUUVQuWDFN6CNoSGA2Y6LovBlo5YJCp+CLZkSZWvMVVSEgoiTR+dt/jAUx9MnQgEozTLAgLi/PLHIN1Rhn61JlQg= 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 1651265879648143.6578040518341; Fri, 29 Apr 2022 13:57:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.317707.537203 (Exim 4.92) (envelope-from ) id 1nkXgM-0008AM-EY; Fri, 29 Apr 2022 20:57:42 +0000 Received: by outflank-mailman (output) from mailman id 317707.537203; Fri, 29 Apr 2022 20:57:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nkXgM-00087X-5x; Fri, 29 Apr 2022 20:57:42 +0000 Received: by outflank-mailman (input) for mailman id 317707; Fri, 29 Apr 2022 20:57:40 +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 1nkXgK-0006w0-Ey for xen-devel@lists.xenproject.org; Fri, 29 Apr 2022 20:57:40 +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 0046ac0c-c7ff-11ec-8fc4-03012f2f19d4; 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 dfw.source.kernel.org (Postfix) with ESMTPS id 30ABC621E0; Fri, 29 Apr 2022 20:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46767C385AC; Fri, 29 Apr 2022 20:57:36 +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: 0046ac0c-c7ff-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651265856; bh=6seieTR73PH0f82Y34HYb9MpClaXG8oJYvBYPMoiaDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k5GRPcr8GP3K8y0qny7p1zb6YiGMIlCW9P+OME3kKPshu/LxqKY8B59ApDF+m5mee pNo+Bu5sC2SVSLwgUDi0wnTVvua5iZkt9eHCR416wok+K592gYw0wv2ZWUabyKJIp6 AdjPt2r7iLnNwCHpZnTq/aq+dmryD07R4jgweqsCm/iryHUxxWDV67dp2XIJhEX8P3 t844yfb6M+fyZ7E1zDYZUM2m4mIZNdeJElapXrCxxWY8ivabovwVipl5ewltATtG5E BuXgm+2gstcKjkwEI1SzTluY3VMD018j96/LrrUNXCdkG1D3sPcgaBPPWlsFqbOtAI 6edhDcAgFtn0Q== 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 Subject: [PATCH v5 5/7] xenstored: send an evtchn notification on introduce_domain Date: Fri, 29 Apr 2022 13:57:30 -0700 Message-Id: <20220429205732.2030094-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: 1651265880885100007 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. Before sending the notification, clear XS_CONNECTION_STATE_RECONNECTING. The extra notification is harmless for domains that don't require it. Signed-off-by: Luca Miccio Signed-off-by: Stefano Stabellini CC: Juergen Gross CC: Julien Grall --- I dropped the Reviewed-by tags due to the connect =3D 0 change. Julien also suggested it would be a good idea to add a clarification statement about the usage of XS_CONNECTION_STATE_RECONNECTING in the header files but I wasn't sure what to write. Please advise and I am happy to include a statement in the next version. Changes in v5: - reset XS_CONNECTION_STATE_RECONNECTING before notifying the domU Changes in v2: - drop the new late_init parameter --- tools/xenstore/xenstored_domain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index ae065fcbee..7bb8c64d33 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -493,6 +493,10 @@ 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 */ + interface->connection =3D 0x0; + 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 Sun May 12 14:05:38 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=1651265882; cv=none; d=zohomail.com; s=zohoarc; b=CtJrR5IniXy5Kila3T/iqXloSRlq2DAGOJfam1DhkLXqwqDCizG2+h5imEWyPcjTfiI6jF5aNkFp32MPYlyrug/6p3qNiC/VAo7/GLyDzPkrRYUMXVpWNfxSBpd1ZRJSy9IAPymKoPFjEoCVxOikef5J42wg3IkIfaURJpJZFS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651265882; 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=98PDFm6KEURgXb54njqhJtsWc4fyPGKaon0VDRNX81k=; b=B3MbRisioPIThtScAcENTZKdCedtT9hLk/2DurdSSm0nLImcwKVzPcuRrR4x+Hno/QwqewJKAk+otV4+kxvzqrRA+rrIGbavpJAVZkN6PN1MqJbbjJLTvkxq/dxejYYi9svVfUENB0AIjO2hzJ4SKUh0rQPmeWDVtC4wimwPqco= 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 1651265882230888.3518561891609; Fri, 29 Apr 2022 13:58:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.317706.537196 (Exim 4.92) (envelope-from ) id 1nkXgL-00081L-SS; Fri, 29 Apr 2022 20:57:41 +0000 Received: by outflank-mailman (output) from mailman id 317706.537196; Fri, 29 Apr 2022 20:57:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nkXgL-0007yB-LE; Fri, 29 Apr 2022 20:57:41 +0000 Received: by outflank-mailman (input) for mailman id 317706; Fri, 29 Apr 2022 20:57:40 +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 1nkXgK-0007P4-6K for xen-devel@lists.xenproject.org; Fri, 29 Apr 2022 20:57:40 +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 00591aee-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 dfw.source.kernel.org (Postfix) with ESMTPS id 6BEB4621E4; Fri, 29 Apr 2022 20:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEB37C385A7; Fri, 29 Apr 2022 20:57:36 +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: 00591aee-c7ff-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651265857; bh=btLZXtaxl9qWeM6CyJYOjZEoxyC1CnI0BUVRGmnQUKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pt7N1gLJEnAAM8jQvYRp1WVXDZ9gHpl+i4uvjOVZlc+K62tGeONq9uLmFmBoBgRQ/ YhPL+Gc+Q5QGdlDujmEmsqtTe1LcLnL4/JaaH25iDoJ0+JMu/TQEzVpvM6blIkKB1Z dXiaiDuzQ7QQElLt8bBsSxo1hNEUixejrumOuIzktD7u3WQIOKgQ4n/WNyAHcHIGyt uqJSba1XJdBUFLdzUHUDKgxchK+YWP4X7AE9WyW4K021mZRiI7xQA/MWO5e2luZC5D mGNXcBuvDdpzsLAU6KN7f9QkGyS/KXmI//juUwfnndfw0AXxJIi0vex4u/AcgzvjkM kMGz/MXX8febw== 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 v5 6/7] tools: add example application to initialize dom0less PV drivers Date: Fri, 29 Apr 2022 13:57:31 -0700 Message-Id: <20220429205732.2030094-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: 1651265882948100011 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. The application sets XS_CONNECTION_STATE_RECONNECTING on the xenstore page before calling xs_introduce_domain to signal that the connection is not ready yet to be used. XS_CONNECTION_STATE_RECONNECTING is reset soon after by xenstored. Signed-off-by: Luca Miccio Signed-off-by: Stefano Stabellini CC: Wei Liu CC: Anthony PERARD CC: Juergen Gross --- Changes in v5: - set XS_CONNECTION_STATE_RECONNECTING before xs_introduce_domain 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 connection reconnecting --- tools/helpers/Makefile | 13 ++ tools/helpers/init-dom0less.c | 341 ++++++++++++++++++++++++++++++++++ 2 files changed, 354 insertions(+) create mode 100644 tools/helpers/init-dom0less.c diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile index 7f6c422440..8d78ab1e90 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) $(LDLIBS_libxenforeignmemory) $(APPEND_LDFLA= GS) + .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..a99398e928 --- /dev/null +++ b/tools/helpers/init-dom0less.c @@ -0,0 +1,341 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "init-dom-json.h" + +#define XS_CONNECTION_STATE_OFFSET (2068/4) +#define XS_CONNECTION_STATE_RECONNECTING 0x1 +#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, + struct xc_interface_core *xch, + xenforeignmemory_handle *xfh, + libxl_dominfo *info) +{ + libxl_uuid uuid; + uint64_t xenstore_evtchn, xenstore_pfn; + int rc; + uint32_t *page; + + printf("Init dom0less domain: %u\n", info->domid); + + 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; + } + + page =3D xenforeignmemory_map(xfh, info->domid, XS_READ | XS_WRITE, 1, + &xenstore_pfn, NULL); + if (!page) { + printf("Error mapping xenstore page\n"); + return 1; + } + page[XS_CONNECTION_STATE_OFFSET] =3D XS_CONNECTION_STATE_RECONNECTING; + xenforeignmemory_unmap(xfh, page, 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; + struct xc_interface_core *xch =3D NULL; + xenforeignmemory_handle *xfh =3D NULL; + + /* TODO reuse libxl xsh connection */ + xsh =3D xs_open(0); + xch =3D xc_interface_open(0, 0, 0); + xfh =3D xenforeignmemory_open(0, 0); + if (xsh =3D=3D NULL || xch =3D=3D NULL || xfh =3D=3D NULL) { + fprintf(stderr, "Cannot open xc/xs/xenforeignmemory interfaces"); + 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, xch, xfh, &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 Sun May 12 14:05:38 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=1651265883; cv=none; d=zohomail.com; s=zohoarc; b=UbDObP/+a8RE7pOhlFYSP2LrCnmAQKy+b/HD14WGPFzi2t5dlTLnZA/jmnm8PC5b+pNNfxdOo1XYnGb204Zdt4oA7pRXxDDhf8p3rVD/DCp4OPUQ2gKdURwRQrH4tNbyEesKmSla9UXoQ/LSF3fb+y8O6R9n4jD/oMoCSM9iQN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651265883; 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=ixbZgoiy+NCYQ/ZeMKOpriJf1azKBC5EWlMV0oRXhR3JzR7YeWi3zXXTLqhL2uBzV6NPyl+JToQM4y02PHQOst69eYL3lpAkA8b/aC1Lqy4ETwo2vv0KBMChg+QNvUPJjTR7Gf5d0MAf+mabC7PWZV/dY305PO1qRjGXE2SKDA4= 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 1651265883093808.9822044521759; Fri, 29 Apr 2022 13:58:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.317708.537209 (Exim 4.92) (envelope-from ) id 1nkXgN-0008HO-03; Fri, 29 Apr 2022 20:57:43 +0000 Received: by outflank-mailman (output) from mailman id 317708.537209; Fri, 29 Apr 2022 20:57:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nkXgM-0008FH-Lc; Fri, 29 Apr 2022 20:57:42 +0000 Received: by outflank-mailman (input) for mailman id 317708; Fri, 29 Apr 2022 20:57:40 +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 1nkXgK-0007P4-Sv for xen-devel@lists.xenproject.org; Fri, 29 Apr 2022 20:57:40 +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 00b7edbe-c7ff-11ec-a405-831a346695d4; Fri, 29 Apr 2022 22:57:39 +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 DCFE2621EF; Fri, 29 Apr 2022 20:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66E02C385A4; Fri, 29 Apr 2022 20:57:37 +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: 00b7edbe-c7ff-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651265857; bh=SyJ8d/AZr5XFzu3v/AGdBw4+YWs6wkcRBAD8+aGiIR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cFwoZ1jZoKmm0fIaLPrBdtVpQwmMmWQuOMdhpElQ86ZHxbI24kfpM2w8tfWDMsEDU 6RX0FiuvfZ2cG+CbZpXwL1gZ+9GVFj+OnZnDMSrfvJ2iKEyimlXmlwrCsdZXtFZhzk nL4ixopKip//3f+DvViNCdLEIumFn8pGVZskMeMyjhmTXmuZj626QBtug9B5xn+Zax GBkq/K6uaiAGXY1A/Inc9TwQB5GL1c5DxgGTRi7ZuoTgbQk05I5BXA8twZagiuQhmL 6++0+3rQyWkkTNSobTdT+jkokKUYCFrOiifVEyZQFZUUUMYQjY2IpusJUhe6Fw2BHT wxR5rj8UQul7g== 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 v5 7/7] docs: document dom0less + PV drivers Date: Fri, 29 Apr 2022 13:57:32 -0700 Message-Id: <20220429205732.2030094-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: 1651265884931100013 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 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