From nobody Thu Oct 23 00:47:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1687750843202261.0442613914835; Sun, 25 Jun 2023 20:40:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.555057.866733 (Exim 4.92) (envelope-from ) id 1qDd5L-00058x-0P; Mon, 26 Jun 2023 03:40:15 +0000 Received: by outflank-mailman (output) from mailman id 555057.866733; Mon, 26 Jun 2023 03:40:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qDd5K-00054m-3O; Mon, 26 Jun 2023 03:40:14 +0000 Received: by outflank-mailman (input) for mailman id 555057; Mon, 26 Jun 2023 03:40:11 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qDd1p-0007ej-4G for xen-devel@lists.xenproject.org; Mon, 26 Jun 2023 03:36:37 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id a719f79e-13d2-11ee-b237-6b7b168915f2; Mon, 26 Jun 2023 05:36:36 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 136B41FB; Sun, 25 Jun 2023 20:37:20 -0700 (PDT) Received: from a011292.shanghai.arm.com (a011292.shanghai.arm.com [10.169.190.94]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 604803F64C; Sun, 25 Jun 2023 20:36:33 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a719f79e-13d2-11ee-b237-6b7b168915f2 From: Penny Zheng To: xen-devel@lists.xenproject.org Cc: Penny Zheng , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Penny Zheng , Wei Chen Subject: [PATCH v3 28/52] xen/mpu: plump virt/maddr conversion in MPU system Date: Mon, 26 Jun 2023 11:34:19 +0800 Message-Id: <20230626033443.2943270-29-Penny.Zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230626033443.2943270-1-Penny.Zheng@arm.com> References: <20230626033443.2943270-1-Penny.Zheng@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1687750844073100005 Content-Type: text/plain; charset="utf-8" virt_to_maddr and maddr_to_virt are used widely in Xen code. So even there is no VMSA in MPU system, we keep the interface in MPU to stay the same code flow. The MPU version of virt/maddr conversion is simple, and we just return the input address as the output with type conversion. Signed-off-by: Penny Zheng Signed-off-by: Wei Chen --- v3: - Fix typos - Move the implementation from mm/mpu.h to mm.h, to share as much as possible with MMU system. --- xen/arch/arm/include/asm/mm.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h index eb520b49e3..ea4847c12b 100644 --- a/xen/arch/arm/include/asm/mm.h +++ b/xen/arch/arm/include/asm/mm.h @@ -267,13 +267,22 @@ static inline void __iomem *ioremap_wc(paddr_t start,= size_t len) /* Page-align address and convert to frame number format */ #define paddr_to_pfn_aligned(paddr) paddr_to_pfn(PAGE_ALIGN(paddr)) =20 +#ifndef CONFIG_HAS_MPU static inline paddr_t __virt_to_maddr(vaddr_t va) { uint64_t par =3D va_to_par(va); return (par & PADDR_MASK & PAGE_MASK) | (va & ~PAGE_MASK); } +#else +static inline paddr_t __virt_to_maddr(vaddr_t va) +{ + return (paddr_t)va; +} +#endif /* CONFIG_HAS_MPU */ + #define virt_to_maddr(va) __virt_to_maddr((vaddr_t)(va)) =20 +#ifndef CONFIG_HAS_MPU #ifdef CONFIG_ARM_32 static inline void *maddr_to_virt(paddr_t ma) { @@ -292,6 +301,12 @@ static inline void *maddr_to_virt(paddr_t ma) ((ma & ma_top_mask) >> pfn_pdx_hole_shift))); } #endif +#else /* CONFIG_HAS_MPU */ +static inline void *maddr_to_virt(paddr_t ma) +{ + return (void *)(unsigned long)ma; +} +#endif =20 /* * Translate a guest virtual address to a machine address. --=20 2.25.1