From nobody Fri Nov 29 08:25:02 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