From nobody Sat Apr 20 10:27:53 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1557242196; cv=none; d=zoho.com; s=zohoarc; b=SyyIqkW8rvpAS8aPuMVzkje0Cv1ihSw4w9PC9YMxURABvomxhlog24/oebmJ8MbLirrXI0dnoKXqoYYRAn0vyFAfPwFZerPho5Sj7ACPyeVxG8ph8xjeTbqlPyCV3JAJAeF9ubAhr6UInUQajT4l4rPX9M4QWlEwQ7SEFr0PteY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242196; 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=EG7+alMgwO82LH4ioWQnErdjJ5wRfNuINQZ6efmf2LE=; b=e8qqIroVwV1tqNXCABV7kH3eLvOQbUZvHBiIc59/wb/Y2GOW7I9JwzG7YgMYU06561bZpTkVALKkNPRSlMNR0hH4plXMRKT+0J9Z5DcQ/E1WtrAaulqMuUapul6rmx8y5IZt6csy/Aqm+0Zs+hWw+i58jp0U0ldFIujF0xPZgnw= ARC-Authentication-Results: i=1; mx.zoho.com; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557242196391141.98358088880343; Tue, 7 May 2019 08:16:36 -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 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 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) X-Inumbo-ID: e891d2aa-70da-11e9-843c-bc764e045a96 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 =20 - frametable_base_pdx =3D pfn_to_pdx(ps >> PAGE_SHIFT); + frametable_base_pdx =3D mfn_to_pdx(maddr_to_mfn(ps)); /* Round up to 2M or 32M boundary, as appropriate. */ frametable_size =3D ROUNDUP(frametable_size, mapping_size); base_mfn =3D alloc_boot_pages(frametable_size >> PAGE_SHIFT, 32<<(20-1= 2)); 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, s= ize_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); =20 pdx =3D (va - XENHEAP_VIRT_START) >> PAGE_SHIFT; - pdx +=3D pfn_to_pdx(mfn_x(xenheap_mfn_start)); + pdx +=3D mfn_to_pdx(xenheap_mfn_start); return frame_table + pdx - frametable_base_pdx; } =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel