From patchwork Mon Feb 18 11:35:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158589 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384244jaa; Mon, 18 Feb 2019 03:37:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IbA2iQKyQstYp3x4qYGVUfwB16f3Cb+suNG/jcY5I694GWb7qrcigb6QG729CRkdo6BXAGK X-Received: by 2002:a25:d60e:: with SMTP id n14mr9597392ybg.71.1550489871770; Mon, 18 Feb 2019 03:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489871; cv=none; d=google.com; s=arc-20160816; b=vtH7NE71mr2DiPFDwnrPX0EmauPL306mh3MjCZgziM4uJxcQDcJ3SGXoMfKgWB3m/0 R4SjEGAnUwCtXvWdZ6L/NBOp4kf8BO0S7Lx7i0zDkO9y01K8VNOWveK3bGlDZSzmpTUp 7qV1+5PLdsKfylJPkd4/uuIuXJlrRAT9QoRSHHw2obkA3reXRBMxcDq1VPY7RLRVWA5k k5IYwwCbiqVGTsfNCYljH9BJb7cZojkzZGtI4cOqzcOaZgnWKA095msfUZdHyBpZ2K4a DIovvaZiDKRFPeanLl9Gml+Dlf1KnEOyTiOy8EmyOXJFifCu1Tt36UEubv+/u0iDCqLh wcWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=UKe+DanCXXqdkrAV1RP8zH7NUqTw+jZPiUXYLo0wWD8=; b=JeVXEtRV4Vkrw1psxQs+8f6vEIsf3qoMzYHkAVQC4sczhyNrwdlbUhiMGtWN4OMHbw XYj8zNreEDL24hEV26W/fSiJ7DcnyZYGY1qmSFbw5zKdebX71TXRrCXqpAp2iTx3uDr+ EfmQOzZ5osTzcGtvpihnEh0dTkJUAd56SZg7rId8WmUkEn81d+uBePc/m1/zAvDRHCyq 5oyf+dA2XwNTQqWN2lJRGzt6d/m/6kllaz83IhL1/G0sPnvElD2R20MfT9tBvzgacq4G rzmmVzZpdp0CIIAfG0vuAs5NAIyuDIHSN44Cozg2yYSu2miYrp4dFBTdDNuA1wodTlBP jwrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id d185si8117919ywe.27.2019.02.18.03.37.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:37:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gvhDW-0001wD-KJ; Mon, 18 Feb 2019 11:36:10 +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 1gvhDV-0001vX-OD for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:09 +0000 X-Inumbo-ID: 62a5acb6-3371-11e9-974e-0f99d71fa2e4 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 62a5acb6-3371-11e9-974e-0f99d71fa2e4; Mon, 18 Feb 2019 11:36:09 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D26A815AB; Mon, 18 Feb 2019 03:36:08 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 160E03F73F; Mon, 18 Feb 2019 03:36:07 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:52 +0000 Message-Id: <20190218113600.9540-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190218113600.9540-1-julien.grall@arm.com> References: <20190218113600.9540-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-next 1/9] xen/arm: Use mfn_to_pdx instead of pfn_to_pdx when possible 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: Julien Grall , sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" mfn_to_pdx adds more safety than pfn_to_pdx. Replace all but on place in the Arm code to use the former. No functional changes. Signed-off-by: Julien Grall --- xen/arch/arm/mm.c | 2 +- xen/include/asm-arm/mm.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 01ae2cccc0..be5338bb4c 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -886,7 +886,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) int i; #endif - frametable_base_pdx = pfn_to_pdx(ps >> PAGE_SHIFT); + frametable_base_pdx = mfn_to_pdx(maddr_to_mfn(ps)); /* Round up to 2M or 32M boundary, as appropriate. */ frametable_size = ROUNDUP(frametable_size, mapping_size); base_mfn = alloc_boot_pages(frametable_size >> PAGE_SHIFT, 32<<(20-12)); diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index eafa26f56e..7b6aaf5e3f 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -225,7 +225,7 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len) /* Convert between frame number and address formats. */ #define pfn_to_paddr(pfn) ((paddr_t)(pfn) << PAGE_SHIFT) #define paddr_to_pfn(pa) ((unsigned long)((pa) >> PAGE_SHIFT)) -#define paddr_to_pdx(pa) pfn_to_pdx(paddr_to_pfn(pa)) +#define paddr_to_pdx(pa) mfn_to_pdx(maddr_to_mfn(pa)) #define gfn_to_gaddr(gfn) pfn_to_paddr(gfn_x(gfn)) #define gaddr_to_gfn(ga) _gfn(paddr_to_pfn(ga)) #define mfn_to_maddr(mfn) pfn_to_paddr(mfn_x(mfn)) @@ -253,7 +253,7 @@ static inline void *maddr_to_virt(paddr_t ma) #else static inline void *maddr_to_virt(paddr_t ma) { - ASSERT(pfn_to_pdx(ma >> PAGE_SHIFT) < (DIRECTMAP_SIZE >> PAGE_SHIFT)); + ASSERT(mfn_to_pdx(maddr_to_mfn(ma)) < (DIRECTMAP_SIZE >> PAGE_SHIFT)); return (void *)(XENHEAP_VIRT_START - mfn_to_maddr(xenheap_mfn_start) + ((ma & ma_va_bottom_mask) | @@ -301,7 +301,7 @@ static inline struct page_info *virt_to_page(const void *v) ASSERT(va < xenheap_virt_end); pdx = (va - XENHEAP_VIRT_START) >> PAGE_SHIFT; - pdx += pfn_to_pdx(mfn_x(xenheap_mfn_start)); + pdx += mfn_to_pdx(xenheap_mfn_start); return frame_table + pdx - frametable_base_pdx; }