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

Re: [PATCH 3/9] arm/mpu: Introduce MPU memory region map structure


  • To: Luca Fancellu <luca.fancellu@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Tue, 4 Mar 2025 10:53:35 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • 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=q98jDG/zXttp23XJ0K5yMWmsuBIeS7jZbolHAqnegHM=; b=DEqGPaSg59DS5TLTtObDBtoY04ySVPeXvnr+qNGHrKlXSk8bs1pzwdFU+NO/9zg55ZbhpU9kUCkq5CQMWDF3Iq/kHXC5uyyO4po2gB4hyHigW9G7RdvgP7ZQUzWHiJ3alY2djxk+JTfnZUqmVuAp6u80EgzHf8c+yYGJfbirH2+OlC2YyHCoWL33V2kBEDVy4hw36c3D1TVXXclm18N0XNCm+H1PENwtmB7QKV+OHXQB24xdg2IWwMsqutad9uTZsOB9yOiYuJFU4LM56w4l7cxKHhkShNoDBYKI3m04HWGiEXF2GmEzsMvB/oR1NBB++IgjsZoplA/roj7nnB0nXw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qyyiUU+FgaVWfrTcG1qvYlHbhxuDzpy4WpqtVfpZcqGIFXqjiVcSUDRzBmfBNzHpDc4mJlCy8QWsVqGnhh0pLhWcUULRkrQAbXk8v+Cw7V+J40X47b6nQM+rzKJp7MfxJVTGM5n2BgO4AwbXJQWVZDmt8ChpOiZwp4g0AP9uIqvRqBTHT1v0Q9wytlKZjaG7h0SBgP/QsgulTlE3FQieZLuTSYYsX8WzlcEoIdnvFJHJG0LiyW4WrMXPrFnKzySBjiBND2aItx+7wS4th313kt9ML5oLkzO6rPNsg0DmTjPY8Npihr+4n860Xzy3/fHCTtjvaM90f/PMV1p7/qTWRw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Penny Zheng <Penny.Zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Wei Chen <wei.chen@xxxxxxx>
  • Delivery-date: Tue, 04 Mar 2025 10:54:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Luca,

On 28/02/2025 16:18, Luca Fancellu wrote:
CAUTION: This message has originated from an External Source. Please use proper 
judgment and caution when opening attachments, clicking links, or responding to 
this email.


From: Penny Zheng <Penny.Zheng@xxxxxxx>

Introduce pr_t typedef which is a structure having the prbar
and prlar members, each being structured as the registers of
the aarch64 armv8-r architecture.

Introduce the array 'xen_mpumap' that will store a view of
the content of the MPU regions.

Introduce MAX_MPU_REGIONS macro that uses the value of
NUM_MPU_REGIONS_MASK just for clarity, because using the
latter as number of elements of the xen_mpumap array might
be misleading.

Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
  xen/arch/arm/Makefile                |  1 +
  xen/arch/arm/include/asm/arm64/mpu.h | 38 ++++++++++++++++++++++++++++
  xen/arch/arm/mpu/Makefile            |  1 +
  xen/arch/arm/mpu/mm.c                | 23 +++++++++++++++++
  4 files changed, 63 insertions(+)
  create mode 100644 xen/arch/arm/mpu/Makefile
  create mode 100644 xen/arch/arm/mpu/mm.c

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 43ab5e8f2550..fb0948f067bd 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -1,6 +1,7 @@
  obj-$(CONFIG_ARM_32) += arm32/
  obj-$(CONFIG_ARM_64) += arm64/
  obj-$(CONFIG_MMU) += mmu/
+obj-$(CONFIG_MPU) += mpu/
  obj-$(CONFIG_ACPI) += acpi/
  obj-$(CONFIG_HAS_PCI) += pci/
  ifneq ($(CONFIG_NO_PLAT),y)
diff --git a/xen/arch/arm/include/asm/arm64/mpu.h 
b/xen/arch/arm/include/asm/arm64/mpu.h
index f8a029f1a135..38dbf5b2255a 100644
--- a/xen/arch/arm/include/asm/arm64/mpu.h
+++ b/xen/arch/arm/include/asm/arm64/mpu.h
@@ -13,6 +13,44 @@
  #define NUM_MPU_REGIONS_SHIFT   8
  #define NUM_MPU_REGIONS         (_AC(1, UL) << NUM_MPU_REGIONS_SHIFT)
  #define NUM_MPU_REGIONS_MASK    (NUM_MPU_REGIONS - 1)
+
+#define MAX_MPU_REGIONS         NUM_MPU_REGIONS_MASK

Not really a comment, but a note. The above needs to be common between arm64 and arm32.

I had moved this in


   "[PATCH 3/5] xen/arm: mpu: Move some of the definitions to common
   file" .

Depending on whose patch goes in first, this code needs to be moved in the initial patch so that there is less code movement in the latter patch.

+
+#ifndef __ASSEMBLY__
+
+/* Protection Region Base Address Register */
+typedef union {
+    struct __packed {
+        unsigned long xn:2;       /* Execute-Never */
+        unsigned long ap:2;       /* Acess Permission */
+        unsigned long sh:2;       /* Sharebility */
+        unsigned long base:46;    /* Base Address */
+        unsigned long pad:12;
+    } reg;
+    uint64_t bits;
+} prbar_t;
+
+/* Protection Region Limit Address Register */
+typedef union {
+    struct __packed {
+        unsigned long en:1;     /* Region enable */
+        unsigned long ai:3;     /* Memory Attribute Index */
+        unsigned long ns:1;     /* Not-Secure */
+        unsigned long res:1;    /* Reserved 0 by hardware */
+        unsigned long limit:46; /* Limit Address */
+        unsigned long pad:12;
+    } reg;
+    uint64_t bits;
+} prlar_t;
+
+/* MPU Protection Region */
+typedef struct {
+    prbar_t prbar;
+    prlar_t prlar;
+} pr_t;
+
+#endif /* __ASSEMBLY__ */
+
  #endif /* __ARM64_MPU_H__ */

  /*
diff --git a/xen/arch/arm/mpu/Makefile b/xen/arch/arm/mpu/Makefile
new file mode 100644
index 000000000000..b18cec483671
--- /dev/null
+++ b/xen/arch/arm/mpu/Makefile
@@ -0,0 +1 @@
+obj-y += mm.o
diff --git a/xen/arch/arm/mpu/mm.c b/xen/arch/arm/mpu/mm.c
new file mode 100644
index 000000000000..3ca609ff80cc
--- /dev/null
+++ b/xen/arch/arm/mpu/mm.c
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * xen/arch/arm/mpu/mm.c
+ *
+ * MPU-based memory managment code for Armv8-R AArch64.
+ *
+ * Copyright (C) 2023 Arm Ltd.
+ *
+ */
+
+#include <asm/arm64/mpu.h>

Can we just include <asm/mpu.h> ?

The arm64/arm32 specific includes will occur in the header file.

+
+/* EL2 Xen MPU memory region mapping table. */
+pr_t xen_mpumap[MAX_MPU_REGIONS];
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
2.34.1
- Ayan





 


Rackspace

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