From nobody Thu Oct 23 00:45:40 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 1687750874799134.5020494401872; Sun, 25 Jun 2023 20:41:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.555077.866802 (Exim 4.92) (envelope-from ) id 1qDd5Y-0008Q9-MF; Mon, 26 Jun 2023 03:40:28 +0000 Received: by outflank-mailman (output) from mailman id 555077.866802; Mon, 26 Jun 2023 03:40:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qDd5X-0008Kr-CF; Mon, 26 Jun 2023 03:40:27 +0000 Received: by outflank-mailman (input) for mailman id 555077; Mon, 26 Jun 2023 03:40:22 +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 1qDd1A-0007ej-3s for xen-devel@lists.xenproject.org; Mon, 26 Jun 2023 03:35:56 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 8e148bdf-13d2-11ee-b237-6b7b168915f2; Mon, 26 Jun 2023 05:35:54 +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 180BB1FB; Sun, 25 Jun 2023 20:36:38 -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 20FCE3F64C; Sun, 25 Jun 2023 20:35:49 -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: 8e148bdf-13d2-11ee-b237-6b7b168915f2 From: Penny Zheng To: xen-devel@lists.xenproject.org Cc: Penny Zheng , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Penny Zheng , Wei Chen Subject: [PATCH v3 15/52] xen: make VMAP only support in MMU system Date: Mon, 26 Jun 2023 11:34:06 +0800 Message-Id: <20230626033443.2943270-16-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: 1687750875828100003 Content-Type: text/plain; charset="utf-8" VMAP is widely used in ALTERNATIVE feature, CPUERRATA feature, Grant Table feature, LIVEPATCH feature etc, to remap a range of memory with new memory attributes. Since this is highly dependent on virtual address translation, we choose to fold VMAP in MMU system. In this patch, we introduce a new Kconfig CONFIG_HAS_VMAP, and make it only support in MMU system on ARM architecture. And we make features like ALTERNATIVE, CPUERRATA, LIVEPATCH, Grant Table, etc, now depend on VMAP. Signed-off-by: Penny Zheng Signed-off-by: Wei Chen --- v2: - new commit --- v3: - make LIVEPATCH/ALTERNATIVE/CPUERRATA/Grant Table/LIVEPATCH depend on HAS_= VMAP - function call should be wrapped in context, then we could remove inline s= tubs --- xen/arch/arm/Kconfig | 3 ++- xen/arch/arm/Makefile | 2 +- xen/arch/arm/setup.c | 7 +++++++ xen/arch/arm/smpboot.c | 2 ++ xen/arch/x86/Kconfig | 1 + xen/arch/x86/setup.c | 2 ++ xen/common/Kconfig | 5 +++++ xen/common/Makefile | 2 +- xen/common/vmap.c | 7 +++++++ xen/include/xen/vmap.h | 11 ++++------- 10 files changed, 32 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 22b28b8ba2..a88500fb50 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -11,7 +11,7 @@ config ARM_64 =20 config ARM def_bool y - select HAS_ALTERNATIVE + select HAS_ALTERNATIVE if HAS_VMAP select HAS_DEVICE_TREE select HAS_PASSTHROUGH select HAS_PDX @@ -63,6 +63,7 @@ config HAS_MMU bool "Memory Management Unit support in a VMSA system" default y select HAS_PMAP + select HAS_VMAP help In a VMSA system, a Memory Management Unit (MMU) provides fine-grained = control of a memory system through a set of virtual to physical address mappings a= nd associated memory diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index c1babdba6a..d01528cac6 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -10,7 +10,7 @@ obj-$(CONFIG_HAS_VPCI) +=3D vpci.o =20 obj-$(CONFIG_HAS_ALTERNATIVE) +=3D alternative.o obj-y +=3D bootfdt.init.o -obj-y +=3D cpuerrata.o +obj-$(CONFIG_HAS_VMAP) +=3D cpuerrata.o obj-y +=3D cpufeature.o obj-y +=3D decode.o obj-y +=3D device.o diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 50259552a0..34923d9984 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -812,7 +812,9 @@ void __init start_xen(unsigned long boot_phys_offset, */ system_state =3D SYS_STATE_boot; =20 +#ifdef CONFIG_HAS_VMAP vm_init(); +#endif =20 if ( acpi_disabled ) { @@ -844,11 +846,13 @@ void __init start_xen(unsigned long boot_phys_offset, nr_cpu_ids =3D smp_get_max_cpus(); printk(XENLOG_INFO "SMP: Allowing %u CPUs\n", nr_cpu_ids); =20 +#ifdef CONFIG_HAS_VMAP /* * Some errata relies on SMCCC version which is detected by psci_init() * (called from smp_init_cpus()). */ check_local_cpu_errata(); +#endif =20 check_local_cpu_features(); =20 @@ -915,12 +919,15 @@ void __init start_xen(unsigned long boot_phys_offset, =20 do_initcalls(); =20 + +#ifdef CONFIG_HAS_VMAP /* * It needs to be called after do_initcalls to be able to use * stop_machine (tasklets initialized via an initcall). */ apply_alternatives_all(); enable_errata_workarounds(); +#endif enable_cpu_features(); =20 /* Create initial domain 0. */ diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 8bcdbea66c..0796e534ec 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -388,7 +388,9 @@ void start_secondary(void) =20 local_abort_enable(); =20 +#ifdef CONFIG_HAS_VMAP check_local_cpu_errata(); +#endif check_local_cpu_features(); =20 printk(XENLOG_DEBUG "CPU %u booted.\n", smp_processor_id()); diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 406445a358..033cc2332e 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -27,6 +27,7 @@ config X86 select HAS_PDX select HAS_SCHED_GRANULARITY select HAS_UBSAN + select HAS_VMAP select HAS_VPCI if HVM select NEEDS_LIBELF =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 74e3915a4d..9f06879225 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1750,12 +1750,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) end_boot_allocator(); =20 system_state =3D SYS_STATE_boot; +#ifdef CONFIG_HAS_VMAP /* * No calls involving ACPI code should go between the setting of * SYS_STATE_boot and vm_init() (or else acpi_os_{,un}map_memory() * will break). */ vm_init(); +#endif =20 bsp_stack =3D cpu_alloc_stack(0); if ( !bsp_stack ) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 3d2123a783..2c29e89b75 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -15,6 +15,7 @@ config CORE_PARKING config GRANT_TABLE bool "Grant table support" if EXPERT default y + depends on HAS_VMAP ---help--- Grant table provides a generic mechanism to memory sharing between domains. This shared memory interface underpins the @@ -65,6 +66,9 @@ config HAS_SCHED_GRANULARITY config HAS_UBSAN bool =20 +config HAS_VMAP + bool + config MEM_ACCESS_ALWAYS_ON bool =20 @@ -367,6 +371,7 @@ config LIVEPATCH bool "Live patching support" default X86 depends on "$(XEN_HAS_BUILD_ID)" =3D "y" + depends on HAS_VMAP select CC_SPLIT_SECTIONS ---help--- Allows a running Xen hypervisor to be dynamically patched using diff --git a/xen/common/Makefile b/xen/common/Makefile index 46049eac35..4803282d62 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -51,7 +51,7 @@ obj-$(CONFIG_TRACEBUFFER) +=3D trace.o obj-y +=3D version.o obj-y +=3D virtual_region.o obj-y +=3D vm_event.o -obj-y +=3D vmap.o +obj-$(CONFIG_HAS_VMAP) +=3D vmap.o obj-y +=3D vsprintf.o obj-y +=3D wait.o obj-bin-y +=3D warning.init.o diff --git a/xen/common/vmap.c b/xen/common/vmap.c index 4fd6b3067e..51e13e17ed 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -331,4 +331,11 @@ void vfree(void *va) while ( (pg =3D page_list_remove_head(&pg_list)) !=3D NULL ) free_domheap_page(pg); } + +void iounmap(void __iomem *va) +{ + unsigned long addr =3D (unsigned long)(void __force *)va; + + vunmap((void *)(addr & PAGE_MASK)); +} #endif diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index b0f7632e89..d7ef4df452 100644 --- a/xen/include/xen/vmap.h +++ b/xen/include/xen/vmap.h @@ -1,4 +1,4 @@ -#if !defined(__XEN_VMAP_H__) && defined(VMAP_VIRT_START) +#if !defined(__XEN_VMAP_H__) && (defined(VMAP_VIRT_START) || !defined(CONF= IG_HAS_VMAP)) #define __XEN_VMAP_H__ =20 #include @@ -25,17 +25,14 @@ void vfree(void *va); =20 void __iomem *ioremap(paddr_t, size_t); =20 -static inline void iounmap(void __iomem *va) -{ - unsigned long addr =3D (unsigned long)(void __force *)va; - - vunmap((void *)(addr & PAGE_MASK)); -} +void iounmap(void __iomem *va); =20 void *arch_vmap_virt_end(void); static inline void vm_init(void) { +#if defined(VMAP_VIRT_START) vm_init_type(VMAP_DEFAULT, (void *)VMAP_VIRT_START, arch_vmap_virt_end= ()); +#endif } =20 #endif /* __XEN_VMAP_H__ */ --=20 2.25.1