From patchwork Tue May 7 15:14:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 163537 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp3883104oca; Tue, 7 May 2019 08:16:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6EZ0nx5dlUVvr9tKmxPlBN9y7oFjOsvMoWTLWWnRx+K8OkJ1wBadqfvSCsogCQPmK7VFA X-Received: by 2002:a6b:4a09:: with SMTP id w9mr21656709iob.79.1557242207370; Tue, 07 May 2019 08:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557242207; cv=none; d=google.com; s=arc-20160816; b=xdBxmoHrZt/ot6tGKNOUWJ+SG2kqilGncErmbBstdB9MeLsEvGCXlFnmWhzKNfygdK m0hM55R+UcSlC+OY2tPJfhkRc9bXS03eXuHtOO3SWwb4RRgbEi1nBmwsnX0gOTlyrQXM XtjN1jiXKul+bjtu1IapViLAOsN16cNM5NNZezzW19J6kLFMWqSl3ue4Ep4He+pNh6Om 6gtyg8nxUNwTQeOzodOxEAosHqCjrAhg/hlov+5zCBKBpAdKG4/rsF8G2p6+Trto9Qvv +8GnOwUr0ER5IqFXp0NSuoD36NmfLVGMSeOFjT4zYedzr9wVrQgY7BhgnhuhKinsDekT 2YZQ== 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=EG7+alMgwO82LH4ioWQnErdjJ5wRfNuINQZ6efmf2LE=; b=wY6VLxT6MH/FgVuhSGVG9xwZPBy5WSx8dQM1CViKAN+nQmKY717vk1jyD8kO7XOpJo ANIDIxy1QK4+3tgpPLRVqE7hMes7s7aPJQSnpldtmXVsvPhBSkkQ8T3ZhDoEGDnoItrc JYKVboNWkOQpSEE1p2KTHc7yDde7bhGqJ4CepckfruLi2og53Q8yNWwDc23lkxFJwhQ8 dbTA+5CPfBAdHqmFt5VBmfu9aSQKCfrH/xROLzWn1DR+4rgn+OLq8Cumqq54ltI8jbqV J3Bii9n9NfPl2KSYfB5bdH/HrV4s/pZmpdQbOS+KIviQ9x/CQxIkoLi+g77vlcre4TpD 65vg== 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 n38si9700669jac.105.2019.05.07.08.16.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 May 2019 08:16:47 -0700 (PDT) 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 1hO1oI-0007JJ-VD; Tue, 07 May 2019 15:15:14 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hO1oH-0007J1-FB for xen-devel@lists.xenproject.org; Tue, 07 May 2019 15:15:13 +0000 X-Inumbo-ID: e891d2aa-70da-11e9-843c-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id e891d2aa-70da-11e9-843c-bc764e045a96; Tue, 07 May 2019 15:15:11 +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 A9B59EBD; Tue, 7 May 2019 08:15:11 -0700 (PDT) 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 E0F483F5AF; Tue, 7 May 2019 08:15:10 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 7 May 2019 16:14:45 +0100 Message-Id: <20190507151458.29350-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190507151458.29350-1-julien.grall@arm.com> References: <20190507151458.29350-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 01/14] 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 , Stefano Stabellini 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 Reviewed-by: Stefano Stabellini --- There are still one use of pfn_to_pdx in the Arm code (see mfn_valid). Ideally we would want to switch __mfn_valid(...) to be typesafe but it looks like it does not compile on x86. For the details see: <02478ff8-d1e2-abe1-74a5-ca72ab87f154@arm.com> This is unlikely going to be handled in this series. --- 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; }