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

[PATCH v2 2/4] xen/arm: mpu: Define Xen start address for MPU systems


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Date: Wed, 18 Sep 2024 18:51:00 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=t7jesCVWTowdWJmKWelF+BiqkcVbdQs3eyU2eIe6EMM=; b=FUDhBL5m55eWeATYH7ix9RaSeyWrkoJ6AEnyIly9nc9balB4W5lJx1ezneEbyejD3mgsiMvK+O9B8PFGzuiObIOI0AlI2Ki0CurgjtQ+K1/xnSIkZNsN5ir04/gc5vzUv/iHm4EyF1q0HGGvTgXCJTYymdExwOBTlwYfohXp3Xh7cBcCR8P3hmWfNLLLgwtZeEQYH+T4YKDhB+USI0Xhoj2SLh4tZENpP09noJO2jinKOJhsu41JI1CLJZ0PtnIBw0xc6+gSvKima/6L6Jvh5xiMZ+GsY79pvS2vHp2Fj197EiLihBZE7pJSuaoGNsslVxN47+VVElxH25GOV4Av2Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EVhhYlamgv0qETA7Y3oUBVKynMArtexxrDfcBazhcD1QMM9AdiWh3mjtklE6Ry9LGCiyILpwKqyzZsLfzZDzdXezzbsEAIyL3+pwDhcycF57sbZhiuh9YmVbVovZNW7k0lWOOvSHtPLU8J6lFSkj3Tl7n75ViZKKEfqwYLaNoXNKODLn1M168Hq/l2cNTgp6QyS6Gwte9czM2i6tUfJk+nM1+RTZUoc3JetnVCvDudulmbr3xYtiBoGmtEYxld3qUgrYRnPu7QOVMlB3OBODr8DkOf3R2XlR+udH/d4fbk1OfJEfmDZQsqpkWbvsLrci42quc5Jo7v5xSpmlWp5s0w==
  • Cc: Wei Chen <wei.chen@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "Jiamei . Xie" <jiamei.xie@xxxxxxx>, "Ayan Kumar Halder" <ayan.kumar.halder@xxxxxxx>
  • Delivery-date: Wed, 18 Sep 2024 17:52:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Wei Chen <wei.chen@xxxxxxx>

On Armv8-A, Xen has a fixed virtual start address (link address too) for all
Armv8-A platforms. In an MMU based system, Xen can map its loaded address to
this virtual start address. So, on Armv8-A platforms, the Xen start address does
not need to be configurable. But on Armv8-R platforms, there is no MMU to map
loaded address to a fixed virtual address and different platforms will have very
different address space layout. So Xen cannot use a fixed physical address on
MPU based system and need to have it configurable.

So, we introduce a Kconfig option for users to set the start address. The start
address needs to be aligned to 4KB. We have a check for this alignment.

In case if the user forgets to set the start address, then 0xffffffff is used
as default. This is to trigger the error (on alignment check) and thereby prompt
user to set the start address.

Also updated config.h so that it includes mpu/layout.h when CONFIG_MPU is
defined.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
Signed-off-by: Jiamei.Xie <jiamei.xie@xxxxxxx>
Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
Changes from :-

v1 - 1. Fixed some of the coding style issues.
2. Reworded the help message.
3. Updated the commit message.

 xen/arch/arm/Kconfig                  | 10 ++++++++++
 xen/arch/arm/include/asm/config.h     |  4 +++-
 xen/arch/arm/include/asm/mpu/layout.h | 27 +++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 xen/arch/arm/include/asm/mpu/layout.h

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index e881f5ba57..ab3ef005a6 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -23,6 +23,16 @@ config ARCH_DEFCONFIG
        default "arch/arm/configs/arm32_defconfig" if ARM_32
        default "arch/arm/configs/arm64_defconfig" if ARM_64
 
+config XEN_START_ADDRESS
+       hex "Xen start address: keep default to use platform defined address"
+       default 0xFFFFFFFF
+       depends on MPU
+       help
+         Used to set customized address at which which Xen will be linked on 
MPU
+         systems. Must be aligned to 4KB.
+         0xFFFFFFFF is used as default value to indicate that user has not
+         customized this address.
+
 menu "Architecture Features"
 
 choice
diff --git a/xen/arch/arm/include/asm/config.h 
b/xen/arch/arm/include/asm/config.h
index a2e22b659d..0a51142efd 100644
--- a/xen/arch/arm/include/asm/config.h
+++ b/xen/arch/arm/include/asm/config.h
@@ -69,8 +69,10 @@
 #include <xen/const.h>
 #include <xen/page-size.h>
 
-#ifdef CONFIG_MMU
+#if defined(CONFIG_MMU)
 #include <asm/mmu/layout.h>
+#elif defined(CONFIG_MPU)
+#include <asm/mpu/layout.h>
 #else
 # error "Unknown memory management layout"
 #endif
diff --git a/xen/arch/arm/include/asm/mpu/layout.h 
b/xen/arch/arm/include/asm/mpu/layout.h
new file mode 100644
index 0000000000..f9a5be2d6b
--- /dev/null
+++ b/xen/arch/arm/include/asm/mpu/layout.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ARM_MPU_LAYOUT_H__
+#define __ARM_MPU_LAYOUT_H__
+
+#define XEN_START_ADDRESS CONFIG_XEN_START_ADDRESS
+
+/*
+ * All MPU platforms need to provide a XEN_START_ADDRESS for linker. This
+ * address indicates where Xen image will be loaded and run from. This
+ * address must be aligned to a PAGE_SIZE.
+ */
+#if (XEN_START_ADDRESS % PAGE_SIZE) != 0
+#error "XEN_START_ADDRESS must be aligned to PAGE_SIZE"
+#endif
+
+#define XEN_VIRT_START         _AT(paddr_t, XEN_START_ADDRESS)
+
+#endif /* __ARM_MPU_LAYOUT_H__ */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.25.1




 


Rackspace

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