From nobody Thu Apr 18 18:10:01 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=1557355722; cv=none; d=zoho.com; s=zohoarc; b=dbRrZ54e7xKfSN68krAb9PLArbehLowwe32HdV5r2uZDJslOfyG3T+9so6Aj/fc3u6ab5vOo1SPUyIk08Gv/xaCINE8rofEP2UGImmkaXoYAe3CoGD2L2OvT5kDH/e0WkvrvASY5V9ZLAdMYtuV57GX3jASTDWZtkOnLy5ePEts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557355722; 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=t1TIUy6zJVL61H4j3Xi9b37Z1aAhW4z7iRIAAKK8HvA=; b=Xl/oPbToSLG8FCi8tUAnRsHx1yEqb41YTAzl5K8hdR7cEx0mgVvOD2Hflo18w4az0rzNEzgUyApNa1ownwi2v8AZuYa1SSI7SuMz2bx2iMyJloAW6X2xcHPDM2bRzUHfTTdwTKEEXJ9JqMdgnBpyvlahqDUjmw+0ecRC134BrYc= 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 1557355722565501.1280967679928; Wed, 8 May 2019 15:48:42 -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 1hOVLY-0005dG-92; Wed, 08 May 2019 22:47:32 +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 1hOVLW-0005cv-L2 for xen-devel@lists.xenproject.org; Wed, 08 May 2019 22:47:30 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 42224dae-71e3-11e9-9af2-67137243bebd; Wed, 08 May 2019 22:47:29 +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 C68F4214AF; Wed, 8 May 2019 22:47:28 +0000 (UTC) X-Inumbo-ID: 42224dae-71e3-11e9-9af2-67137243bebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557355649; bh=C4xeet4PT74Qrv0I49NufomaIN2mdjU81vF4e8+VXAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OzxzPUMgR+IRg/+h+13RcBneHmros+OZ5EVfSaIc7OQ8rHkDYjtDvFAZ7eFRvJRoV XimyKuIVH8d7qJUDgsl2aOmfFLFkhpxD/DJz9Eq9cHuOCegciAERyjwi+cJtwp4ucx GpnxhFRvc40NJlgmdRo0cQ4JHfHtucTupqh5iHsE= From: Stefano Stabellini To: julien.grall@arm.com Date: Wed, 8 May 2019 15:47:25 -0700 Message-Id: <20190508224727.11549-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 1/3] xen/arm: fix nr_pdxs calculation 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: xen-devel@lists.xenproject.org, 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) pfn_to_pdx expects an address, not a size, as a parameter. It expects the end address, and the masks calculations compensate for any holes between start and end. Pass the end address to pfn_to_pdx. Also remove from the result pfn_to_pdx(start_address) because we know that we don't need to cover any memory in the range 0-start in the frametable. Remove the variable `nr_pages' because it is unused. Signed-off-by: Stefano Stabellini CC: JBeulich@suse.com --- Changes in v2: - use mfn_to_pdx and maddr_to_mfn along with mfn_add() --- xen/arch/arm/mm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 01ae2cccc0..58d71d3c23 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -874,8 +874,8 @@ void __init setup_xenheap_mappings(unsigned long base_m= fn, /* Map a frame table to cover physical addresses ps through pe */ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) { - unsigned long nr_pages =3D (pe - ps) >> PAGE_SHIFT; - unsigned long nr_pdxs =3D pfn_to_pdx(nr_pages); + unsigned long nr_pdxs =3D mfn_to_pdx(mfn_add(maddr_to_mfn(pe), -1)) - + mfn_to_pdx(maddr_to_mfn(ps)) + 1; unsigned long frametable_size =3D nr_pdxs * sizeof(struct page_info); mfn_t base_mfn; const unsigned long mapping_size =3D frametable_size < MB(32) ? MB(2) = : MB(32); --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 18 18:10:01 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=1557355726; cv=none; d=zoho.com; s=zohoarc; b=Vf8Xgjt0UQrQ4sqxUfkBIXl/4fBygKEdVJb9lSVcLvEfFndCu4ORIMa7WzSYhUcUH8s5PxGA6u3ZuXglpHI1FmQ6oTAaROsAzC/LUQS2FYzpVvyYmOQpC4lct3gHdfdoiApsEVcoH3nRHlc4lGsGLVknNpH3kaWRiO+EyORHCJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557355726; 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=q6F0rDrhKj2kRH5DV09GFES4C6HOKKX6syAYzKGLlf0=; b=ao1jgWiVmK/u7xQYeRVIPae9wy82Llcp+BVUwvsdpjhuAbxZPgooCHj8E18GK0N2iFKaSSQkNoWO/zh/lvQbKtym678l3pGrhtesczu8U8dcaMSXZl0Lg3kwXHx5yqhzUOmMJpYcxUl7YwnEDmM3BIXIVOhWDn5LILCbJpY4Tqc= 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 1557355726194590.1738583910563; Wed, 8 May 2019 15:48:46 -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 1hOVLZ-0005eG-Sz; Wed, 08 May 2019 22:47:33 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hOVLY-0005dK-Hf for xen-devel@lists.xenproject.org; Wed, 08 May 2019 22:47:32 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 4285b830-71e3-11e9-8980-bc764e045a96; Wed, 08 May 2019 22:47:30 +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 38EE82173C; Wed, 8 May 2019 22:47:29 +0000 (UTC) X-Inumbo-ID: 4285b830-71e3-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557355649; bh=3CCUvl0LQ/WFZ3gY9nIlwyemZpPkp3hn2VdsDAJkuhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgOmU5OWNqpO+Yh/Raebl+0ynML8QSi7nUguVxxmAlCglE6nP7+m2v3zocTkVbE7h CmdpPZnBpC+a7u3wXSJV0DpzM6ABoAa64EUFVkRf9iNwfrH66M+SH/Ylbx/zGOVLtm avBGqMtMJbk8jmN2dcBfpqH32srXFkNWIgrDLQRQ= From: Stefano Stabellini To: julien.grall@arm.com Date: Wed, 8 May 2019 15:47:26 -0700 Message-Id: <20190508224727.11549-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 2/3] xen: actually skip the first MAX_ORDER bits in pfn_pdx_hole_setup 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, xen-devel@lists.xenproject.org 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) pfn_pdx_hole_setup is meant to skip the first MAX_ORDER bits, but actually it only skips the first MAX_ORDER-1 bits. The issue was probably introduced by bdb5439c3f ("x86_64: Ensure frame-table compression leaves MAX_ORDER aligned"), when changing to loop to start from MAX_ORDER-1 an adjustment by 1 was needed in the call to find_next_bit() but not done. Fix the issue by passing j+1 and i+1 to find_next_zero_bit and find_next_bit. Also add a check for i >=3D BITS_PER_LONG because find_{,next_}zero_bit() are free to assume that their last argument is less than their middle one. Signed-off-by: Stefano Stabellini Signed-off-by: Jan Beulich CC: andrew.cooper3@citrix.com CC: JBeulich@suse.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 v2: - add commit title of bdb5439c3f - more CC - update commit message --- xen/common/pdx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/common/pdx.c b/xen/common/pdx.c index 50c21b6bf8..bb7e437049 100644 --- a/xen/common/pdx.c +++ b/xen/common/pdx.c @@ -83,8 +83,10 @@ void __init pfn_pdx_hole_setup(unsigned long mask) */ for ( j =3D MAX_ORDER-1; ; ) { - i =3D find_next_zero_bit(&mask, BITS_PER_LONG, j); - j =3D find_next_bit(&mask, BITS_PER_LONG, i); + i =3D find_next_zero_bit(&mask, BITS_PER_LONG, j + 1); + if ( i >=3D BITS_PER_LONG ) + break; + j =3D find_next_bit(&mask, BITS_PER_LONG, i + 1); if ( j >=3D BITS_PER_LONG ) break; if ( j - i > hole_shift ) --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 18 18:10:01 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=1557355727; cv=none; d=zoho.com; s=zohoarc; b=SrcDCOxY5L6a17vdA93lfYv3uhjl0oO55C4/xz0VH7yhF9NQNIci9fWn/I4+5NIy8nKRDvG8XOniM3qhSUXOo5tjGU3r9ZMQvQGTnJqnrOxWSJ24DDGmuTSqZJ1OPUWzBbMZY3N9yun9p5TAg2UZXhbRBE10zmhbVCxr+HGj2U8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557355727; 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=ppLxqXTXoZKHY/TtUD1FL2UwOotZjIBB4sabCxQCjyo=; b=M3NDUkB0Xt8zzvJz6Y5ZkNgthPNpFOC0E1+C3uAWgKNDER3J3WbMTwCSYSO0DPv7IMtkZZOJatkG35/Dqj4cC1qhG6m8vMqVj8JAuIuN3UjCg3UIB7kvmROz+2DG/AYPF75DnUNMjqoccoiDUYpqmzobhm/EoDjREYcAr+X+bvg= 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 1557355727083464.8615820819689; Wed, 8 May 2019 15:48:47 -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 1hOVLZ-0005dw-IB; Wed, 08 May 2019 22:47:33 +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 1hOVLX-0005d8-Sz for xen-devel@lists.xenproject.org; Wed, 08 May 2019 22:47:31 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 42f5e222-71e3-11e9-ac19-5beb5252e5b0; Wed, 08 May 2019 22:47:31 +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 DDBB32173E; Wed, 8 May 2019 22:47:29 +0000 (UTC) X-Inumbo-ID: 42f5e222-71e3-11e9-ac19-5beb5252e5b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557355650; bh=iBQFuyk2ANlWeX08tzlXt00YPbSG8rP6JeadB7axNJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jXk1DqaeXwHaclmvOmy8x0gpf3bMPRz4XKWpEkym59gjbOeKkQg6Xo+ZhZCF2ne+E l8sMveGXkUvqVEG2xY94o8/JQhZ13a9JBdqHf93zhJsK3XGt/JcMOhtK0hB2UicXwK 2+UAkJZPBJ4k2rYhKvk8Mv7hNdJ6wMgr01afQe7M= From: Stefano Stabellini To: julien.grall@arm.com Date: Wed, 8 May 2019 15:47:27 -0700 Message-Id: <20190508224727.11549-3-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 3/3] 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, xen-devel@lists.xenproject.org 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 --- 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 | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index ccb0f181ea..afaafe7b84 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -482,7 +482,14 @@ 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); + /* + * Pass 0x0 to pdx_init_mask to get a mask initialized with the + * first to 1<