From patchwork Fri May 3 20:50:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 10929181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 431EF912 for ; Fri, 3 May 2019 20:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3548D2878E for ; Fri, 3 May 2019 20:51:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 293EC287A0; Fri, 3 May 2019 20:51:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C7AE32878E for ; Fri, 3 May 2019 20:51:43 +0000 (UTC) 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 X-Inumbo-ID: 0e697570-6de5-11e9-828d-2b50afc410d5 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) 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 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 = pdx_init_mask(bootinfo.mem.bank[0].start); + u64 mask; int bank; + /* + * We always map the first 1<