From: Wei Chen <wei.chen@arm.com>
To: <xen-devel@lists.xenproject.org>
Cc: <nd@arm.com>, Wei Chen <wei.chen@arm.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: [PATCH v6 07/11] xen/arm: implement FIXMAP_ADDR for MPU systems
Date: Fri, 4 Nov 2022 18:07:37 +0800 [thread overview]
Message-ID: <20221104100741.2176307-8-wei.chen@arm.com> (raw)
In-Reply-To: <20221104100741.2176307-1-wei.chen@arm.com>
FIXMAP is a special virtual address section for Xen to map some
physical ram or device memory temporarily in initialization for
MMU systems. FIXMAP_ADDR will return a virtual address by index
for special purpose phys-to-virt mapping usage. For example,
FIXMAP_ADDR(FIXMAP_CONSOLE) for early console mapping and
FIXMAP_ADDR(FIXMAP_MISC) for copy_from_paddr.
But in MPU systems, we can't map physical address to any virtual
address. So we want the code that is using FIXMAP_ADDR to return
the input physical address in MPU systems. So in MPU version,
FIXMAP_ADDR will trim physical address to PAGE alignment. This
will return an offset which is similar to MMU version FIXMAP_ADDR.
But it's a physical offset got from input physical address, plus
to an offset inside page (which is also got from physical address
mask with PAGE_MASK). The caller can return the input physical
address directly.
As pmap depends on FIXAMP, so we disable pmap for Arm with MPU
enabled systems.
Signed-off-by: Wei Chen <wei.chen@arm.com>
---
xen/arch/arm/Kconfig | 2 +-
xen/arch/arm/include/asm/config_mpu.h | 2 ++
xen/arch/arm/include/asm/fixmap.h | 25 +++++++++++++++++++++++++
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index ac276307d6..1458ffa777 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -16,7 +16,7 @@ config ARM
select HAS_DEVICE_TREE
select HAS_PASSTHROUGH
select HAS_PDX
- select HAS_PMAP
+ select HAS_PMAP if !HAS_MPU
select IOMMU_FORCE_PT_SHARE
config ARCH_DEFCONFIG
diff --git a/xen/arch/arm/include/asm/config_mpu.h b/xen/arch/arm/include/asm/config_mpu.h
index 530abb8302..eee60dcffc 100644
--- a/xen/arch/arm/include/asm/config_mpu.h
+++ b/xen/arch/arm/include/asm/config_mpu.h
@@ -24,4 +24,6 @@
#define HYPERVISOR_VIRT_START XEN_VIRT_START
+#define FIXMAP_ADDR(n) (_AT(paddr_t, n) & (PAGE_MASK))
+
#endif /* __ARM_CONFIG_MPU_H__ */
diff --git a/xen/arch/arm/include/asm/fixmap.h b/xen/arch/arm/include/asm/fixmap.h
index d0c9a52c8c..1e338759e9 100644
--- a/xen/arch/arm/include/asm/fixmap.h
+++ b/xen/arch/arm/include/asm/fixmap.h
@@ -7,6 +7,8 @@
#include <xen/acpi.h>
#include <xen/pmap.h>
+#ifndef CONFIG_HAS_MPU
+
/* Fixmap slots */
#define FIXMAP_CONSOLE 0 /* The primary UART */
#define FIXMAP_MISC 1 /* Ephemeral mappings of hardware */
@@ -45,4 +47,27 @@ static inline unsigned int virt_to_fix(vaddr_t vaddr)
#endif /* __ASSEMBLY__ */
+#else
+
+/*
+ * FIXMAP_ADDR will trim physical address to PAGE alignment.
+ * This will return an offset which is similar to MMU version
+ * FIXMAP_ADDR.
+ * For example:
+ * EARLY_UART_VIRTUAL_ADDRESS is defined by:
+ * (FIXMAP_ADDR(FIXMAP_CONSOLE) + \
+ * (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
+ * With MPU version FIXMAP_CONSOLE and FIXMAP_ADDR definitions,
+ * EARLY_UART_VIRTUAL_ADDRESS can be restore to
+ * CONFIG_EARLY_UART_BASE_ADDRESS.
+ * In this case, we don't need to use #ifdef MPU in the code
+ * where are using FIXMAP_ADDR to make them to use physical
+ * address explicitily.
+ */
+#ifdef CONFIG_EARLY_UART_BASE_ADDRESS
+#define FIXMAP_CONSOLE CONFIG_EARLY_UART_BASE_ADDRESS
+#endif
+
+#endif /* CONFIG_HAS_MPU */
+
#endif /* __ASM_FIXMAP_H */
--
2.25.1
next prev parent reply other threads:[~2022-11-04 10:08 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 10:07 [PATCH v6 00/11] xen/arm: Add Armv8-R64 MPU support to Xen - Part#1 Wei Chen
2022-11-04 10:07 ` [PATCH v6 01/11] xen/arm: remove xen_phys_start and xenheap_phys_end from config.h Wei Chen
2022-11-06 18:42 ` Julien Grall
2022-11-04 10:07 ` [PATCH v6 02/11] xen/arm: add iounmap after initrd has been loaded in domain_build Wei Chen
2022-11-06 18:55 ` Julien Grall
2022-11-07 1:33 ` Henry Wang
2022-11-07 9:09 ` Julien Grall
2022-11-07 9:11 ` Henry Wang
2022-11-07 19:00 ` Julien Grall
2022-11-08 2:14 ` Wei Chen
2022-11-08 2:24 ` Wei Chen
2022-11-04 10:07 ` [PATCH v6 03/11] xen/arm: disable EFI boot services for MPU systems Wei Chen
2022-11-06 19:12 ` Julien Grall
2022-11-06 19:13 ` Julien Grall
2022-11-08 3:02 ` Wei Chen
2022-11-15 8:21 ` Wei Chen
2022-11-04 10:07 ` [PATCH v6 04/11] xen/arm: adjust Xen TLB helpers for Armv8-R64 PMSA Wei Chen
2022-11-04 10:07 ` [PATCH v6 05/11] xen/arm: define Xen start address for FVP BaseR platform Wei Chen
2022-11-06 19:19 ` Julien Grall
2022-11-09 4:55 ` Wei Chen
2022-11-09 18:24 ` Julien Grall
2022-11-10 22:12 ` Stefano Stabellini
2022-11-11 10:13 ` Wei Chen
2022-11-11 20:15 ` Stefano Stabellini
2022-12-05 10:17 ` Wei Chen
2022-12-05 11:02 ` Julien Grall
2022-11-14 18:52 ` Ayan Kumar Halder
2022-11-15 5:42 ` Wei Chen
2022-11-04 10:07 ` [PATCH v6 06/11] xen/arm: split MMU and MPU config files from config.h Wei Chen
2022-11-04 10:07 ` Wei Chen [this message]
2022-11-06 19:44 ` [PATCH v6 07/11] xen/arm: implement FIXMAP_ADDR for MPU systems Julien Grall
2022-11-09 6:46 ` Wei Chen
2022-11-09 18:30 ` Julien Grall
2022-11-11 7:56 ` Wei Chen
2022-11-11 9:40 ` Julien Grall
2022-11-04 10:07 ` [PATCH v6 08/11] xen/arm64: move MMU related code from head.S to head_mmu.S Wei Chen
2022-11-06 20:06 ` Julien Grall
2022-11-07 9:34 ` Julien Grall
2022-11-09 7:36 ` Wei Chen
2022-11-09 18:33 ` Julien Grall
2022-11-13 21:42 ` Julien Grall
2022-11-14 5:36 ` Wei Chen
2022-11-04 10:07 ` [PATCH v6 09/11] xen/arm64: create boot-time MPU protection regions Wei Chen
2022-11-06 20:46 ` Julien Grall
2022-11-07 6:59 ` Penny Zheng
2022-11-07 9:29 ` Julien Grall
2022-11-07 10:17 ` Penny Zheng
2022-11-04 10:07 ` [PATCH v6 10/11] xen/arm64: introduce helpers for MPU enable/disable Wei Chen
2022-11-06 20:56 ` Julien Grall
2022-11-07 9:57 ` Penny Zheng
2022-11-07 10:38 ` Julien Grall
2022-11-08 3:01 ` Penny Zheng
2022-11-04 10:07 ` [PATCH v6 11/11] xen/arm64: add setup_fixmap and remove_identity_mapping for MPU Wei Chen
2022-11-06 21:02 ` Julien Grall
2022-11-07 8:13 ` Penny Zheng
2022-11-07 9:32 ` Julien Grall
2022-11-04 10:29 ` [PATCH v6 00/11] xen/arm: Add Armv8-R64 MPU support to Xen - Part#1 Wei Chen
2022-11-06 19:02 ` Julien Grall
2022-11-07 9:52 ` Wei Chen
2022-11-07 10:16 ` Julien Grall
2022-11-07 10:30 ` Wei Chen
2022-11-10 22:25 ` Stefano Stabellini
2022-11-11 10:41 ` Wei Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221104100741.2176307-8-wei.chen@arm.com \
--to=wei.chen@arm.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=julien@xen.org \
--cc=nd@arm.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.