[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v6 07/11] xen/arm: implement FIXMAP_ADDR for MPU systems


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Fri, 4 Nov 2022 18:07:37 +0800
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZBjv5anLZDwEd2jLmxOkcveDVsYBDtYxSedDem5n/0U=; b=Vwi8cv6UKtUujdUwbkBDWI0SpqPG0fNX/HdutasVbWit25VhdKuwcF8rAcNfrRxxKJ1P7QUUidscegz/bJj98ORloy3bmMb+4WacN72G1B2pFQS3B1eIRrb+0Z3S1360s2MYUZs1G6ST5FXiRZnFktGbjLqxL1FtUUdsKhvAilxrLPTK9x/fNsGLBv46BeiT+aUqwe3WD251A2LRcEL2myNtiiPgs9kBplTsmRpIH8Mq5Askbm+k8YmjzhMI39QsgYJW3xW3MxzxcEUu/cwTxD+UcwhqdxubWuvpvf6HhnjTF6GDCD+DKARaaNd9Gpw9aSM9a2VZDOHSIT3QLvrBOA==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZBjv5anLZDwEd2jLmxOkcveDVsYBDtYxSedDem5n/0U=; b=XsBaiqa8FyEycZ7NNbjt4JVyuuk4nNDrsXPv/B6f9/718sN9/eYO+U79Wdra20A6Q65rbQz/Mgfgtpwux8jr45y5R7bV5oIYSrQdZKAuPmk+P4f65u88w5j6YCHpchqo3uYt57z5rRSI7aZw8/vbpabt5vrbPy12TW2ze1/X0uqvDZ8aQJQ6jZj3IRQV6O5Prn5Du7mUVYpTcjTkWfHtRA3VlmHbQmbSfJTgJOX7ePalohURb2ojGJv1SD0JDflZ5eTS3T3s+DZErY1+TdYrL2SJtOaL3uGMby1M0FaeFhKtv3SyPBk/YhUrck22s5VL66D4HkLWtFPPDXnB1yi3+A==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=E3y7J/HMCf1Ejhg7ofXqqSIpbXddQO5zmV4qsmgwTw1dcrkRwi1vm5XdOS5x4i7VY4YlunNEvu7q11boOgFXX8ChErHJSnZk2RY35I8cE/i2vnQPSFsZ8O7t69Fy0o3BNQ5gEI00Tbxq2DO3+ar42+S4pAImiyLcHcSEjCzhODL/yBuv4/WwAcGqTZqtzPEy+pdMA13sbvZ3bbO9UIsJJT+w3GfgJfgoyyfFty1eTzIpzSpgPR3QsbH5aZq7EB8aOfm/MzCCOmgwnmNKfLAbLvgCJxQAx91b7p6Hh6Y71YGC1/9KagJw225sdgNgdA05/a8tGMnUThEiZ/g7dzFFAw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KymGxHlErzk+6DPD5M07tYLbuLxHcP9BnZf8DAQb7wBDVGBI/crpSFHNz6FFHJdf2k+xDv7mQH85Ev37rIkyuy3eTkBsPaGT4lAdk4diLODhGnWedO4kWL6K05mh66exWzxSa0aesIBbxEhcHl1jVGPWkKICOlKF0UB1v43x40JD5e7VrHctDEerqZ5iKjV+9wDlXbtTqtVXSvY9VJfpOuZL/1K9hRmtWjXQSegqklWlpxuM7jWzBi0SgUUj+6YXLE5GhJLL5fngrUqQJlIXDCxVIxKiv8L9k4WAanw0hwNsM/OFcy7WRXq6PJLV521C+tE6cIp/av39hkTXTNZyEQ==
  • Cc: <nd@xxxxxxx>, Wei Chen <wei.chen@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 04 Nov 2022 10:08:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

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@xxxxxxx>
---
 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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.