From patchwork Wed May 8 22:47:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 10936561 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 BDAFA912 for ; Wed, 8 May 2019 22:49:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAEA428A21 for ; Wed, 8 May 2019 22:49:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B9B628A2A; Wed, 8 May 2019 22:49:13 +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 4186028A21 for ; Wed, 8 May 2019 22:49:13 +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 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 X-Inumbo-ID: 42224dae-71e3-11e9-9af2-67137243bebd 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) 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 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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_mfn, /* 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 = (pe - ps) >> PAGE_SHIFT; - unsigned long nr_pdxs = pfn_to_pdx(nr_pages); + unsigned long nr_pdxs = mfn_to_pdx(mfn_add(maddr_to_mfn(pe), -1)) - + mfn_to_pdx(maddr_to_mfn(ps)) + 1; unsigned long frametable_size = nr_pdxs * sizeof(struct page_info); mfn_t base_mfn; const unsigned long mapping_size = frametable_size < MB(32) ? MB(2) : MB(32);