From nobody Sat May 4 03:53:34 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1560797482; cv=none; d=zoho.com; s=zohoarc; b=bTYZejOZg8OrWAEIJL80gRHF2XHWI9lsBpJ3vyHbjGJNgwHbzwnjgcDqq0Bj5sbVfge6yV2ziQO01X3ZoufAkxtgLZ0gQg/zPhsknpGylNALXfi2NZHHAfOmjaztVZCqjQTMVzQ3DaiwuxSAlNT/xbKNH1RsVh6l99pK1UvcKkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560797482; h=Content-Type: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:ARC-Authentication-Results; bh=aiOWh8lJEvDx1kOHqotIZFtSP7VvcTjfmw6c91ui3KQ=; b=G/s8Y7cwmcWDFIXDd87tU2Fci6cnCsdhlRwrvKiN6vowwt7KnXhMuNsDdgjrNEOVQjvk8KuXdfa0bpDgNCAEpkzSz2DbJh+dzWOP4vZyqT69vezcm97/5RdT/v2/+cS4UN/Ax8EAXu06bjrF3hE1DAYxjKDR+27t+ltXs7N121w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560797482500181.72831130771942; Mon, 17 Jun 2019 11:51:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hcwhx-0001W5-LB; Mon, 17 Jun 2019 18:50:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hcwhw-0001Vs-Mp for xen-devel@lists.xenproject.org; Mon, 17 Jun 2019 18:50:20 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c129c17e-9130-11e9-b3dd-17fa74152a31; Mon, 17 Jun 2019 18:50:20 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1EE1A2084D; Mon, 17 Jun 2019 18:50:19 +0000 (UTC) X-Inumbo-ID: c129c17e-9130-11e9-b3dd-17fa74152a31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560797419; bh=WRiAdeA2JMJLA6xN8nZ6e+DN3JPP5PKLU9QW5JdRbRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NeueYqMxuB0v9nHzhYmAMdFNw0PiU8NvRSyQqqlYDcQU9GAyWMmrNDXRcIw63uxfz au4dToQmjDxm7Z/m0G3j3PrZcg8BBxyGm9PotGJN9KEGdK+LxiWqNLjunVO4IgGzjr /LurG/9tG6T1C9af1ThdhXLK947bCLryRfbRpD6I= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 17 Jun 2019 11:50:16 -0700 Message-Id: <20190617185017.32661-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 1/2] xen: switch pdx_init_mask to return uint64_t X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org, JBeulich@suse.com, andrew.cooper3@citrix.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Also change srat_region_mask to uint64_t as it is used to store the return value of pdx_init_mask. uint64_t is always greater or equal to u64. Signed-off-by: Stefano Stabellini CC: JBeulich@suse.com CC: andrew.cooper3@citrix.com CC: julien.grall@arm.com Acked-by: Jan Beulich --- xen/arch/arm/setup.c | 2 +- xen/arch/x86/srat.c | 2 +- xen/common/pdx.c | 2 +- xen/include/xen/pdx.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 2112715579..b03e7ac330 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -483,7 +483,7 @@ static void __init init_pdx(void) { paddr_t bank_start, bank_size, bank_end; =20 - u64 mask =3D pdx_init_mask(bootinfo.mem.bank[0].start); + uint64_t mask =3D pdx_init_mask(bootinfo.mem.bank[0].start); int bank; =20 for ( bank =3D 0 ; bank < bootinfo.mem.nr_banks; bank++ ) diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c index 2d70b45909..47a4267220 100644 --- a/xen/arch/x86/srat.c +++ b/xen/arch/x86/srat.c @@ -401,7 +401,7 @@ static int __init nodes_cover_memory(void) =20 void __init acpi_numa_arch_fixup(void) {} =20 -static u64 __initdata srat_region_mask; +static uint64_t __initdata srat_region_mask; =20 static int __init srat_parse_region(struct acpi_subtable_header *header, const unsigned long end) diff --git a/xen/common/pdx.c b/xen/common/pdx.c index bb7e437049..8356f03ce8 100644 --- a/xen/common/pdx.c +++ b/xen/common/pdx.c @@ -50,7 +50,7 @@ static u64 __init fill_mask(u64 mask) return mask; } =20 -u64 __init pdx_init_mask(u64 base_addr) +uint64_t __init pdx_init_mask(uint64_t base_addr) { return fill_mask(base_addr - 1); } diff --git a/xen/include/xen/pdx.h b/xen/include/xen/pdx.h index a151aac1a2..770fadc06c 100644 --- a/xen/include/xen/pdx.h +++ b/xen/include/xen/pdx.h @@ -13,7 +13,7 @@ extern unsigned long pfn_top_mask, ma_top_mask; (sizeof(*frame_table) & -sizeof(*frame_table))) extern unsigned long pdx_group_valid[]; =20 -extern u64 pdx_init_mask(u64 base_addr); +extern uint64_t pdx_init_mask(u64 base_addr); extern u64 pdx_region_mask(u64 base, u64 len); =20 extern void set_pdx_range(unsigned long smfn, unsigned long emfn); --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 03:53:34 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1560797487; cv=none; d=zoho.com; s=zohoarc; b=m0Ra77ItHveOMSw8JK5jjfZa0ZCWnei8PLWgHwLgjXUTr60gR4eMenco4Bv1R/LhG45HokxCSFEjRpj4v8ExoJvxqEk1hFMXXK145jD7VbeMEv2tdS4EqReksxPghaNj/nXUDEmbuq42B8wqcRqTgBK9iEkG4LbsZLALucA0nT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560797487; h=Content-Type: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:ARC-Authentication-Results; bh=GtYb0dkWzuyXUucCBMQcoL4dDl08qpcPNs0kc+FFyX8=; b=mSBiK5RRHNzHxOovsImjRyWr4v+tk+HtTh9vIwGx6z0cvXSK67D8nKGAJKdfxQNHCaYjm/2v7v2DuvZ0cz3UPmJcB6D8zCfA5TOH+1I1vdLwH+zhYXO+/MaKQ3FIxKXferpLvutuCRaWOOn8hz5AEhh3yqEl1saKKWy6yLT1+4E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560797487717416.88210997506576; Mon, 17 Jun 2019 11:51:27 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hcwhz-0001Wk-0B; Mon, 17 Jun 2019 18:50:23 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hcwhx-0001WA-Tg for xen-devel@lists.xenproject.org; Mon, 17 Jun 2019 18:50:21 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c1868e22-9130-11e9-8f92-67a05bddbbd6; Mon, 17 Jun 2019 18:50:20 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BC0A208E4; Mon, 17 Jun 2019 18:50:19 +0000 (UTC) X-Inumbo-ID: c1868e22-9130-11e9-8f92-67a05bddbbd6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560797420; bh=rDqCwZDQIKHVD5i0stXBDmSWt4/8m3WMWQtU65UZwgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C5TjnbNpDous5qoD6IG6XR87dcWmbKkdEWCOpB4CQ56GOlIMj7MFMAyVLRq0ZTS47 n4ppeGHjGbY48Ipp3aJzDvEH8K+eZTe9lA1XOcuqBLeLZtZLdyKNMgk/KnuqXED/tx p4Y2T9VazwevNnF01MmtsnZonLeizxK+WwQYnsvU= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 17 Jun 2019 11:50:17 -0700 Message-Id: <20190617185017.32661-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 2/2] xen/arm: fix mask calculation in pdx_init_mask X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , sstabellini@kernel.org, wei.liu2@citrix.com, konrad.wilk@oracle.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, JBeulich@suse.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The mask calculation in pdx_init_mask is wrong when the first bank starts at address 0x0. The reason is that pdx_init_mask will do '0 - 1' causing an underflow. As a result, the mask becomes 0xffffffffffffffff which is the biggest possible mask and ends up causing a significant memory waste in the frametable size computation. For instance, on platforms that have a low memory bank starting at 0x0 and a high memory bank, the frametable will end up covering all the holes in between. The purpose of the mask is to be passed as a parameter to pfn_pdx_hole_setup, which based on the mask parameter calculates pfn_pdx_hole_shift, pfn_pdx_bottom_mask, etc. which are actually the important masks for frametable initialization later on. pfn_pdx_hole_setup never compresses addresses below MAX_ORDER bits (1GB on ARM). Thus, it is safe to initialize mask passing 1ULL << (MAX_ORDER + PAGE_SHIFT) as start address to pdx_init_mask. Signed-off-by: Stefano Stabellini CC: JBeulich@suse.com CC: andrew.cooper3@citrix.com CC: George.Dunlap@eu.citrix.com CC: ian.jackson@eu.citrix.com CC: konrad.wilk@oracle.com CC: tim@xen.org CC: wei.liu2@citrix.com Acked-by: Jan Beulich Reviewed-by: Julien Grall --- Changes in v4: - use uint64_t - single line comment code style Changes in v3: - improve in-code comments Unchanged in v3: - (u64)1 Changes in v2: - update commit message - add in-code comments regarding update sites - improve in-code comments - move the mask initialization changes to pdx_init_mask --- xen/arch/arm/setup.c | 9 ++++++++- xen/common/pdx.c | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index b03e7ac330..b0af90e5bf 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -483,7 +483,14 @@ static void __init init_pdx(void) { paddr_t bank_start, bank_size, bank_end; =20 - uint64_t mask =3D pdx_init_mask(bootinfo.mem.bank[0].start); + /* + * Arm does not have any restrictions on the bits to compress. Pass 0 = to + * let the common code further restrict the mask. + * + * If the logic changes in pfn_pdx_hole_setup we might have to + * update this function too. + */ + uint64_t mask =3D pdx_init_mask(0x0); int bank; =20 for ( bank =3D 0 ; bank < bootinfo.mem.nr_banks; bank++ ) diff --git a/xen/common/pdx.c b/xen/common/pdx.c index 8356f03ce8..9990b94f73 100644 --- a/xen/common/pdx.c +++ b/xen/common/pdx.c @@ -50,9 +50,11 @@ static u64 __init fill_mask(u64 mask) return mask; } =20 +/* We don't compress the first MAX_ORDER bit of the addresses. */ uint64_t __init pdx_init_mask(uint64_t base_addr) { - return fill_mask(base_addr - 1); + return fill_mask(max(base_addr, + (uint64_t)1 << (MAX_ORDER + PAGE_SHIFT)) - 1); } =20 u64 __init pdx_region_mask(u64 base, u64 len) @@ -80,6 +82,9 @@ void __init pfn_pdx_hole_setup(unsigned long mask) * This guarantees that page-pointer arithmetic remains valid within * contiguous aligned ranges of 2^MAX_ORDER pages. Among others, our * buddy allocator relies on this assumption. + * + * If the logic changes here, we might have to update the ARM specific + * init_pdx too. */ for ( j =3D MAX_ORDER-1; ; ) { --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel