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

Re: [PATCH 5/9] arm/mpu: Introduce utility functions for the pr_t type


  • To: Luca Fancellu <luca.fancellu@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Tue, 4 Mar 2025 11:36:27 +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=jXEoohGIxcxD0z6lw6grT+nxAnpaG3x6Xy+lOgYd1cw=; b=VDn6y5XWtHGwnQl6hH/VcByixdwEkDdMftz/Nc07H/TyTM9T3sdlMqDabTc6+g9aN/cChovlLHHw99ZSMYq1tb3d7nFyPXY6FVYN0z1Y+wWQ3txHfi5eQgaVUmwJM6SerYPJUINcOqny0APe/Yqy5aEXPbWR2tA+KC0tW/TkNMHayoK5o3020I0Td/LybiLWi4JjBW0KN90GKq0xaSJ+MpYieNShUrjtPmzuyzivJkbf5tVl4mNrLR5VAana6ztSwSzlHag/8Ej+ZEsKpRxny6NQ64GemJELUxtMbjHOikKv6dcpcQ5PjAGijbK/segjtdskx34yoj3souySGAgmlg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l4HAm/QCZomX4ufpzSJ//dnXyHAztogZrutJj4njaIR+rqB53YCEJ6DONv+x/TM4RWlZHzQjlvZQCRY9NOSdiVjpMhnYFvbCeXuwIRcskZUZOMe23WM7bHGrOnrjTiiC2xaS09tmXd+HZXg3vrgLnfklDZov2P+8XPcbTxZeMchRFNelx+glUvklU56XqQvdZBZKVyJwgpg/fpDbj6xmCRZLxp8DZyRCVUTL3i/RXgFUnU4OM8DSuhgi/e274RyLxQVSoPfVi2sXbkEGrHEhgetkYwUgb8rwA4z2bRTPnWRJsq49zjaeRb+8QJC7kSOtpEuLYs/19dgQjIeRV9F6ow==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 04 Mar 2025 11:36:50 +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.


Introduce few utility function to manipulate and handle the
pr_t type.

Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
  xen/arch/arm/include/asm/arm64/mpu.h | 36 ++++++++++++++++++++++++++++
  1 file changed, 36 insertions(+)

diff --git a/xen/arch/arm/include/asm/arm64/mpu.h 
b/xen/arch/arm/include/asm/arm64/mpu.h
index c63a9e6e5455..3a09339818a0 100644
--- a/xen/arch/arm/include/asm/arm64/mpu.h
+++ b/xen/arch/arm/include/asm/arm64/mpu.h
@@ -50,6 +50,42 @@ typedef struct {
      prlar_t prlar;
  } pr_t;

+/* Set base address of MPU protection region(pr_t). */
+static inline void pr_set_base(pr_t *pr, paddr_t base)
+{
+    pr->prbar.reg.base = (base >> MPU_REGION_SHIFT);
+}
+
+/* Set limit address of MPU protection region(pr_t). */
+static inline void pr_set_limit(pr_t *pr, paddr_t limit)
+{
+    pr->prlar.reg.limit = ((limit - 1) >> MPU_REGION_SHIFT);
+}
+
+/*
+ * Access to get base address of MPU protection region(pr_t).
+ * The base address shall be zero extended.
+ */
+static inline paddr_t pr_get_base(pr_t *pr)
+{
+    return (paddr_t)(pr->prbar.reg.base << MPU_REGION_SHIFT);
+}
+
+/*
+ * Access to get limit address of MPU protection region(pr_t).
+ * The limit address shall be concatenated with 0x3f.
+ */
+static inline paddr_t pr_get_limit(pr_t *pr)
+{
+    return (paddr_t)((pr->prlar.reg.limit << MPU_REGION_SHIFT)
+                     | ~MPU_REGION_MASK);
+}
+
+static inline bool region_is_valid(pr_t *pr)
+{
+    return pr->prlar.reg.en;
+}
+

This is common between arm32 and arm64. This can be moved to a common file.

- Ayan

  #endif /* __ASSEMBLY__ */

  #endif /* __ARM64_MPU_H__ */
--
2.34.1





 


Rackspace

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