From nobody Wed Nov 27 13:51:40 2024 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 1698027296122541.7122306316969; Sun, 22 Oct 2023 19:14:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.620930.966828 (Exim 4.92) (envelope-from ) id 1qukSW-00039l-Km; Mon, 23 Oct 2023 02:14:24 +0000 Received: by outflank-mailman (output) from mailman id 620930.966828; Mon, 23 Oct 2023 02:14:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qukSW-00038U-Fh; Mon, 23 Oct 2023 02:14:24 +0000 Received: by outflank-mailman (input) for mailman id 620930; Mon, 23 Oct 2023 02:14:23 +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 1qukSU-0001F1-Vu for xen-devel@lists.xenproject.org; Mon, 23 Oct 2023 02:14:22 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id e1289e33-7149-11ee-98d5-6d05b1d4d9a1; Mon, 23 Oct 2023 04:14:22 +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 4188C2F4; Sun, 22 Oct 2023 19:15:02 -0700 (PDT) Received: from a015966.shanghai.arm.com (a015966.shanghai.arm.com [10.169.190.5]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 64C103F738; Sun, 22 Oct 2023 19:14:18 -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: e1289e33-7149-11ee-98d5-6d05b1d4d9a1 From: Henry Wang To: xen-devel@lists.xenproject.org Cc: Henry Wang , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Penny Zheng , Wei Chen , Julien Grall Subject: [PATCH v8 6/8] xen/arm: Fold pmap and fixmap into MMU system Date: Mon, 23 Oct 2023 10:13:43 +0800 Message-Id: <20231023021345.1731436-7-Henry.Wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231023021345.1731436-1-Henry.Wang@arm.com> References: <20231023021345.1731436-1-Henry.Wang@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1698027296469100001 Content-Type: text/plain; charset="utf-8" fixmap and pmap are MMU-specific features, so fold them to the MMU system. Do the folding for pmap by moving the HAS_PMAP Kconfig selection under MMU. Since none of the definitions in asm/fixmap.h actually makes sense for the MPU, so do the folding for fixmap by limiting the inclusion of asm/fixmap.h for MPU code when necessary. To guarantee that, moving the implementation of copy_from_paddr() from kernel.c to mmu/setup.c, so that inclusion of asm/fixmap.h in the kernel.c can be dropped. Take the opportunity to add a missing space before and after '-' in "s =3D paddr & (PAGE_SIZE-1);" of copy_from_paddr(). Signed-off-by: Henry Wang Signed-off-by: Penny Zheng Signed-off-by: Wei Chen Reviewed-by: Julien Grall --- v8: - Add a missing space before/after '-' in "s =3D paddr & (PAGE_SIZE-1);" of copy_from_paddr(), mention this change in commit message. - Add Julien's Reviewed-by tag. v7: - No change. v6: - Rework original patch: [v5,08/13] xen/arm: Fold pmap and fixmap into MMU system and fold in the original patch: [v5,12/13] xen/arm: mmu: relocate copy_from_paddr() to setup.c --- xen/arch/arm/Kconfig | 2 +- xen/arch/arm/kernel.c | 28 ---------------------------- xen/arch/arm/mmu/setup.c | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 2939db429b..7b5b0c0c05 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -14,7 +14,6 @@ config ARM select HAS_ALTERNATIVE select HAS_DEVICE_TREE select HAS_PASSTHROUGH - select HAS_PMAP select HAS_UBSAN select IOMMU_FORCE_PT_SHARE =20 @@ -60,6 +59,7 @@ config PADDR_BITS =20 config MMU def_bool y + select HAS_PMAP =20 source "arch/Kconfig" =20 diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 508c54824d..bc3e5bd6f9 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -16,7 +16,6 @@ #include =20 #include -#include #include #include =20 @@ -41,33 +40,6 @@ struct minimal_dtb_header { =20 #define DTB_MAGIC 0xd00dfeedU =20 -/** - * copy_from_paddr - copy data from a physical address - * @dst: destination virtual address - * @paddr: source physical address - * @len: length to copy - */ -void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) -{ - void *src =3D (void *)FIXMAP_ADDR(FIXMAP_MISC); - - while (len) { - unsigned long l, s; - - s =3D paddr & (PAGE_SIZE-1); - l =3D min(PAGE_SIZE - s, len); - - set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_WC); - memcpy(dst, src + s, l); - clean_dcache_va_range(dst, l); - clear_fixmap(FIXMAP_MISC); - - paddr +=3D l; - dst +=3D l; - len -=3D l; - } -} - static void __init place_modules(struct kernel_info *info, paddr_t kernbase, paddr_t kernend) { diff --git a/xen/arch/arm/mmu/setup.c b/xen/arch/arm/mmu/setup.c index c2df976ab2..a5a9b538ff 100644 --- a/xen/arch/arm/mmu/setup.c +++ b/xen/arch/arm/mmu/setup.c @@ -339,6 +339,33 @@ void free_init_memory(void) printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>= 10); } =20 +/** + * copy_from_paddr - copy data from a physical address + * @dst: destination virtual address + * @paddr: source physical address + * @len: length to copy + */ +void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) +{ + void *src =3D (void *)FIXMAP_ADDR(FIXMAP_MISC); + + while (len) { + unsigned long l, s; + + s =3D paddr & (PAGE_SIZE - 1); + l =3D min(PAGE_SIZE - s, len); + + set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_WC); + memcpy(dst, src + s, l); + clean_dcache_va_range(dst, l); + clear_fixmap(FIXMAP_MISC); + + paddr +=3D l; + dst +=3D l; + len -=3D l; + } +} + /* * Local variables: * mode: C --=20 2.25.1