From nobody Thu Apr 25 01:17:32 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=1556916700; cv=none; d=zoho.com; s=zohoarc; b=D6B+McpPNdPiGN2jscKBrt+vyX/tLeBbTRcirLDsiEZq1qzYLfNSnJk/BiOZA0H+anNgTh+iFV0MAV09cZWbQqJFW+OGvJJocuASsBBDpF//nLhAjcg444RaxgXGk8BJEzt0QK9qMU8cP/oo1isF7vwTbnSlBeC3bi3vjzTy4Xg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556916700; 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=7zUvblazcSdgJZPeI1pNF1006ZG2Kwd3GMfuFM9/m6o=; b=PHuCVzVSAeeDbXVmLaKh5RtZdOpLRPTd5+RMawSDih6HAWh8YTmZ4QFBk4eR798DO8x+G56UETsiL7ic7/B0P0xRQv5A3kelKdSt3NOqimTYjMUA+iL5PoJ6pgsdmv0ztQ0xQs+nqaCUTffjIe1fzhgzKRMxq6FryG/1zQ9bFaI= 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 1556916700182181.57427903619293; Fri, 3 May 2019 13:51:40 -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 1hMf8P-0006X1-CQ; Fri, 03 May 2019 20: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 1hMf8O-0006WM-4b for xen-devel@lists.xenproject.org; Fri, 03 May 2019 20:50:20 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0dcc37ec-6de5-11e9-bf08-eb69d0cd0c28; Fri, 03 May 2019 20:50:16 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 59463206E0; Fri, 3 May 2019 20:50:15 +0000 (UTC) X-Inumbo-ID: 0dcc37ec-6de5-11e9-bf08-eb69d0cd0c28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556916615; bh=6XsE+gt78baCd6KmBGaA+0d0kaxvop1C8Z3z2A0tfyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q7m25u9CQSIFxW1cXkw3IkWo0kKaKw7c28qtmpctuAiwsZVxV34ZEvnnSyC6n269o 4CCHJLohuYF/IqBfUO9ZMxplkXl8UZo3Jg0Hjqk6GZH8lyz61RovsowCxK6p7TQR5x +gOuK5YM6fm/vxrPYNWG9A3uo9qDDrhU2czqEIIo= From: Stefano Stabellini To: julien.grall@arm.com Date: Fri, 3 May 2019 13:50:12 -0700 Message-Id: <1556916614-21512-1-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH 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 --- 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 01ae2cc..5cb7932 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 pfn_to_pdx((pe >> PAGE_SHIFT) - 1) - + pfn_to_pdx(ps >> PAGE_SHIFT) + 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 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 01:17:32 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=1556916699; cv=none; d=zoho.com; s=zohoarc; b=NUcGPuQJsLbBiAFLRANAuLYITH/trueDMLqWS+pe014RtHbiT6Fl9lxYLhrw5WZidVNJeukIipRg8h8fDs8NznYYOu+GSt1C5ayqhARwrENNB3OqXvDyzzSSk2Jvgn2NoQw7jgyU+slwhXs1j8myAAwEKXsA5Fr4x3IBmUyb/uY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556916699; 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=Fu46ZbpSFV6HJcbUI9VcoFtjXZbW9YKKQkhj2JefIVU=; b=QK1QrM/jC7xqdfyxoNuiwYV6sol7EjtFARg2EsjVwkKv/djXwPhPQpHJ2MMrhu4VAoN4QjEV2p5cgb9xctGUdyd+nyEwz7MulzaOCNQLZqelIZiWADiaTbEgd3GO1eiVU6AebwhKRbr56rms1FkG56OwRiXi+Yy+/ifqvxhIguY= 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 1556916699619678.2204986721739; Fri, 3 May 2019 13:51:39 -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 1hMf8M-0006Vw-RJ; Fri, 03 May 2019 20:50:18 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMf8M-0006Vn-1F for xen-devel@lists.xenproject.org; Fri, 03 May 2019 20:50:18 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0e26373e-6de5-11e9-843c-bc764e045a96; Fri, 03 May 2019 20:50:16 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B87E92087F; Fri, 3 May 2019 20:50:15 +0000 (UTC) X-Inumbo-ID: 0e26373e-6de5-11e9-843c-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556916616; bh=+84OtcGsSXxXUmW9bHPCL6uFaWyF6QgG3w3gqS5A+BA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ocluEOABpEoxn05t0+T6pzVqNyWTmMwmZZRWlNhLAGZsOEPb/wNI5sz4/R6gCdDkR j1fQcqF/Tx9mVhFxhRQ08YCus1qdwmqukIF3hiBr1JqIbmIH1VAIWUC506+z0jFC4G 1Kv4ZkkybgJmtYFZqhsdn2v+t2MNKa06sblnQD18= From: Stefano Stabellini To: julien.grall@arm.com Date: Fri, 3 May 2019 13:50:13 -0700 Message-Id: <1556916614-21512-2-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH 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, 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() on x86 assume their last argument to be 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 --- 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 50c21b6..bb7e437 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 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 01:17:32 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=1556916698; cv=none; d=zoho.com; s=zohoarc; b=UkKv1G7a6z0b07RdWKaOWQ08cDDnik8zaatWVoabMfILfnBRkBqni00O+jCq2BF3HgYxTU+9q7VichLz08iqeIASWId/2p8AIimPvErB8LZSz2Yg3hUV0DtIuyT75MXvZlgKH3voDVxU1qo5OtMTbNz1zHgKMeJ2aN6rZpsaW9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556916698; 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=SwMbnbGavmIEQsvvM6gxRQVHdZCepMDSUk4q6ed+3VE=; b=E5bc9lKe1yb8pPJOoMj0JaaFLGl4x7msYLgqhRjSd5MBw22PQJ/vanvjoApaV4jWNq6p5NjrloFp9fogBTdvEJEEdqfI1f5W79JVBotaKlvpXcNnIWt/HE1yzYmytn7WjD4U4mbKG7oWlWFOuQGA5uJt1nXRgCqUBPDIS7DdBXI= 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 1556916698990770.1309305600205; Fri, 3 May 2019 13:51:38 -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 1hMf8P-0006Wi-3m; Fri, 03 May 2019 20: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 1hMf8O-0006WL-4b for xen-devel@lists.xenproject.org; Fri, 03 May 2019 20:50:20 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0e697570-6de5-11e9-828d-2b50afc410d5; Fri, 03 May 2019 20:50:17 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5DC9F20B7C; Fri, 3 May 2019 20:50:16 +0000 (UTC) X-Inumbo-ID: 0e697570-6de5-11e9-828d-2b50afc410d5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556916616; bh=3IWWvsDOnuB69RLJ4DGWqOAGTi/kmS2DUY2cbb7ugjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bs2xjMaCmhrW+IPJYUQ/o2oSd5r9ntKu7RqgAdvXBS2VF0Az87/ZLRvyJIEOR9ztd wjgvWeVnsof8TGFBPdOR0OQgBkB19CFy5Vwd8iwSWVwqUTXyCBWrq6rtJMYXHjwcL6 Zu0h4AbGvDcFmcVmvVsJyFKvoGf4gSCVWITfHr2s= From: Stefano Stabellini To: julien.grall@arm.com Date: Fri, 3 May 2019 13:50:14 -0700 Message-Id: <1556916614-21512-3-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH 3/3] xen/arm: fix mask calculation in init_pdx 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) The mask calculation in init_pdx 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 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 caculates 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 --- xen/arch/arm/setup.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index ccb0f18..22f20bb 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -481,10 +481,15 @@ static paddr_t __init next_module(paddr_t s, paddr_t = *end) static void __init init_pdx(void) { paddr_t bank_start, bank_size, bank_end; - - u64 mask =3D pdx_init_mask(bootinfo.mem.bank[0].start); + u64 mask; int bank; =20 + /* + * We always map the first 1<