From nobody Sat May 11 02:33:36 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=1561148769; cv=none; d=zoho.com; s=zohoarc; b=Nd4XY+NMHFhhqZpqZ2C3/b8E7fJb24MVgGz4D1ixFEHTIZIULsDoVHRVotlhyjbZXhuSJOX+a+pxV94TJjv2/BF2iuCpEz/FjHIgSwPqIjZPQoMhjpa7k5MW9Br1Wtq2NG5uKyCcylg3jvypLdyjYs/EIKfsYcs1tv9r10bIaHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561148769; 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=1rrYsl3ncSW0lo02Z6e6suj/3aw7RF0Q36okna77Q5c=; b=aFefhNXLml7Vi7TmnKHPOUlVplTm6ooUSWk7tmbmtHhM2pD1uYZOnKpoYfgm8DrnZW0Kk5tS7ysX+n0qEiyvn5g6McYOb5fzTCEttMbhClLt46hB9dG4pmCmQ6cFlO72PsQWOkWK09LFM/FqP6VeMouO4G9jxAoCFbZZOkyYurg= 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 1561148769440133.29994024947734; Fri, 21 Jun 2019 13:26:09 -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 1heQ4y-0005CV-MU; Fri, 21 Jun 2019 20:24:12 +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 1heQ4x-0005CD-7G for xen-devel@lists.xenproject.org; Fri, 21 Jun 2019 20:24:11 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 86b2d91a-9462-11e9-95b8-af25c1a2abbd; Fri, 21 Jun 2019 20:24:10 +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 460992084E; Fri, 21 Jun 2019 20:24:09 +0000 (UTC) X-Inumbo-ID: 86b2d91a-9462-11e9-95b8-af25c1a2abbd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561148649; bh=nmMBhSQIbEAo+yHLesSyhzfGXA5KVkjU5E+/GIc69wg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=if0S6FVwhji3Ngao0/GQrZ5Vbdc8ijV2X1dsSk5PqWAjlj62ra+8oQxowjs8Qb2WX qcEOU/Ln5Xvy2JEdOFN9gqzw9F4YRemYHXqEVR6t78HlqPwTEKXDXL/RE4y4qeuQBM QLUms/i+NcgqD2a19pigmMKSN1RVf8oobIDegetY= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Fri, 21 Jun 2019 13:24:06 -0700 Message-Id: <20190621202407.7781-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 1/2] xen: Replace u64 with uint64_t in pdx_init_mask() and callers 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: andrew.cooper3@citrix.com, julien.grall@arm.com, sstabellini@kernel.org, JBeulich@suse.com, Stefano Stabellini 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) Xen is phasing out the use of u64 in favor of uint64_t. Therefore, the instance of u64 in the pdx_init_mask() (and the callers) are now replaced with uint64_t. Take the opportunity to also modify srat_region_mask as this is used to store the result of pdx_init_mask(). Signed-off-by: Stefano Stabellini Acked-by: Jan Beulich CC: JBeulich@suse.com CC: andrew.cooper3@citrix.com CC: julien.grall@arm.com --- Changes in v5: - new commit message --- 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 4156c0ebb3..d5d188a105 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -484,7 +484,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 11 02:33:36 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=1561148755; cv=none; d=zoho.com; s=zohoarc; b=IglaT1zP2/OmRsxnnToilf4QzK8aSv8Rzb43UZJXh0j/JyDqt2cYGfI9lUBlnRUHYTLIxv0CeVv3K98RNV6++cxDLOJKc5cB4ptLWrwfKLVRwHNQKFPeKY3ep7itSTsjhHvpy8kAahAz6BHQSpLjzesc9BvCbymWZUO0NlSECTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561148755; 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=2MVfggD8DthLnfwolHd6LmP532OQeM9W6TPMsy40pv8=; b=ocqEZX9Kpl6XfRrkMJqrZrg939T4erzaRi/YII05yMNkQkvY6NXBzfCVHswGoqHwarodEXFMs4tQ1lG+fAMSenWzm792kpMFG90kfyc2k3htgrUVJQjlgT0jzadthKsWMjmmj4AbyzEy9Uy6vbshHAdYkncxTaGnTtHpeA9q5Wc= 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 1561148755815973.5818918698733; Fri, 21 Jun 2019 13:25:55 -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 1heQ4z-0005Ck-0j; Fri, 21 Jun 2019 20:24:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heQ4y-0005CO-G1 for xen-devel@lists.xenproject.org; Fri, 21 Jun 2019 20:24:12 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 8726aeb7-9462-11e9-8980-bc764e045a96; Fri, 21 Jun 2019 20:24:10 +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 D8DEC208CA; Fri, 21 Jun 2019 20:24:09 +0000 (UTC) X-Inumbo-ID: 8726aeb7-9462-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561148650; bh=vu53aFBwfZWjUu5AA3/4w4BBdE0g1FGlZgv1ggO61nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ErdTYSrF2yu1F67AgsxuVJ5a+DZnoa744ipxIRJPpx3QE9cUs0UfkDkv0F4kOxgkU dr9hLP0DuKHG99KMglIy9W2WSj2JBlkjCWSYByRFMK6gEoDYdQsupwKhw7YOtAyzuk evnzjTPOTnGRHPODBH52k3dNX6kS6uQFaBzOUPWQ= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Fri, 21 Jun 2019 13:24:07 -0700 Message-Id: <20190621202407.7781-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 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, julien.grall@arm.com, 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 Reviewed-by: Julien Grall Acked-by: Jan Beulich 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 --- Changes in v5: - minor comment update 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 d5d188a105..215746a5c3 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -484,7 +484,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..c91875fabe 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 want to compress the low MAX_ORDER bits 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