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

Re: [PATCH v3 1/7] arm/mpu: Introduce MPU memory region map structure


  • To: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Mon, 14 Apr 2025 14:50:54 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=amd.com 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=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=IZ9JwRmV2mBzMtx9v9RYjZunck0Kd8DU6/udbxMQ77s=; b=cqqPYO2qebtApw3M+kQSOP4OT1Ln+e/jpz4aRb/urKVwc/LxbcVDyAAGFdzVBD1TlnwBnreKz+DfiZc0uG4itRLfnjd5F37515M1PVQBpDz4MiOQ2dQxolYvvW9evEcT4/N+l0RGs1Hf6cWkd3+u0UbDgX/g4W0zRreVw8ioeBKuXb/WNRDL0sftFUgvXjV02EysgT7I4Rxga9pUpai138HdHEb00l+Dvde1wwJ9WIunrXiQ8YZtGixFtET2uy0ssJ88ISlApTybuXQUb+mubYhS2cK7d4ztPnwoQbMts8QuaXCXqQkAV76kmvZ2/w94mIj2s40N7tMwOe380M3x8Q==
  • 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=IZ9JwRmV2mBzMtx9v9RYjZunck0Kd8DU6/udbxMQ77s=; b=vApjAEu3uNtgqLAJsK7SA9pTJkzwXin0VkjcveToZlHHpHN6hr/xLVH6kw/DSKrjGQPyXZm5uBlNf9z0ZbQu6Y5pYmP4HFOA9tT4QgSeL5iuwDaVcLF/oqH7/y3z/vRmrMG9yoWfZRuNe4Ao2mURnlRfQ3564Du+Ulfr8hLx96uPdhNyvlISAC6EbtAhQmglui7OczgA/w3tpEKQ+5RpXPCXI/Zw/fOn2JDn8rj2dPnDmgFv/3RONdqOdpvbBm2sNQ9z7PWHclOjxgaXEBk+1bz6mQd7A3VLZGqAqTfF3ouWC0qj1U9PiMcsteTdd9hzyD2EfWOnymOIe/LsekXq7A==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=aIrgXBIqxKO4U1vPOPDhh01aw5EBgFX5/hZKutzV+rVhCsJbJtO2Vb5W7HiBzU1Py56HwoWwa+sUvqjbIfojkdjACzMSoVYSQzAbQEyS2ZPMiiJYNE86GjKcVVn8FgIa7hTWo0BSZCemtv42A6bU8brbbNXru7kXx+4n/Q0fl7i/oAuFiNCiBWgf49TSS98tnSuPfld788klIlqZswCuzJ8b+FTgL6UrUEYpNDcALMsqolghAAH+0ObFJ8XaQA9eYo2NfVOQtEDxaMeoKp4rtQvD09aWeHljvHkSAIpGia10zma0/g4jgnXfXpafyTZao4NxI4tN0WLiivZRc2RM/w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eA0J4ybIqdup5ZAv2R1c/6OxBsoZHxk3u2VytZoJyXi43G9R6smTHbN/0JeU6cg80FbxjPwJe+GwaUpvxlUeXTYWry2otroNCHNfCRj26VrhLkoL54EXT0Om+1l2CEM/jdtRxBqhh1ya7q/FD7E2TsxobaeMIx+xgwfDWKrUZ6WUck9mzykHGTTVvVaGQtxa762Zhr4t86BRGP0XCbPgCTJzLtvcbmv8SZJ7sX6GC5U9Kh7nUTxE4JCFv+9WqpSHKv/DrhjaFs/gel+fveXZ6fzGWbQUnGxiiTs3EeagHf9wq1TuIzvIldIXPi7avdOBR1ukNCEglmB8avynGiXcVQ==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>
  • Delivery-date: Mon, 14 Apr 2025 14:51:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHbqvIQP3h8YyZqYkSDv4tGWZWI7LOi9uCAgABMVgA=
  • Thread-topic: [PATCH v3 1/7] arm/mpu: Introduce MPU memory region map structure

Hi Michal,

> On 14 Apr 2025, at 11:17, Orzel, Michal <michal.orzel@xxxxxxx> wrote:
> 
> 
> 
> On 11/04/2025 16:56, Luca Fancellu wrote:
>> 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.
> What should be the size of this array? I thought NUM_MPU_REGIONS indicates how
> many regions there can be (i.e. 256) and this should be the size. Yet you use
> MASK for size which is odd.

So the maximum number of regions for aarch64 armv8-r are 255, MPUIR_EL2.REGION 
is an
8 bit field advertising the number of region supported.

Is it better if I use just the below?

#define MAX_MPU_REGIONS 255

> 
>> 
>> 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/include/asm/arm64/mpu.h | 44 ++++++++++++++++++++++++++++
>> xen/arch/arm/include/asm/mpu.h       |  5 ++++
>> xen/arch/arm/mpu/mm.c                |  4 +++
>> 3 files changed, 53 insertions(+)
>> create mode 100644 xen/arch/arm/include/asm/arm64/mpu.h
>> 
>> diff --git a/xen/arch/arm/include/asm/arm64/mpu.h 
>> b/xen/arch/arm/include/asm/arm64/mpu.h
>> new file mode 100644
>> index 000000000000..4d2bd7d7877f
>> --- /dev/null
>> +++ b/xen/arch/arm/include/asm/arm64/mpu.h
>> @@ -0,0 +1,44 @@
>> +/* SPDX-License-Identifier: GPL-2.0-only */
>> +/*
>> + * mpu.h: Arm Memory Protection Unit definitions for aarch64.
> NIT: Do we really see the benefit in having such generic comments? What if you
> add a prototype of some function here. Will it fit into a definition scope?

I can remove the comment, but I would say that if I put some function prototype 
here
it should be related to arm64, being this file under arm64.

> 
>> + */
>> +
>> +#ifndef __ARM_ARM64_MPU_H__
>> +#define __ARM_ARM64_MPU_H__
>> +
>> +#ifndef __ASSEMBLY__
>> +
>> +/* Protection Region Base Address Register */
>> +typedef union {
>> +    struct __packed {
>> +        unsigned long xn:2;       /* Execute-Never */
>> +        unsigned long ap:2;       /* Acess Permission */
> s/Acess/Access/
> 
>> +        unsigned long sh:2;       /* Sharebility */
> s/Sharebility/Shareability/
> 
>> +        unsigned long base:46;    /* Base Address */
>> +        unsigned long pad:12;
> If you describe the register 1:1, why "pad" and not "res" or "res0"?
> 
>> +    } 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 */
> res0 /* RES0 */
> 
>> +        unsigned long limit:46; /* Limit Address */
>> +        unsigned long pad:12;
> res1 /* RES0 */
> 
>> +    } reg;
>> +    uint64_t bits;
>> +} prlar_t;
>> +
>> +/* MPU Protection Region */
>> +typedef struct {
>> +    prbar_t prbar;
>> +    prlar_t prlar;
>> +} pr_t;
>> +
>> +#endif /* __ASSEMBLY__ */
>> +
>> +#endif /* __ARM_ARM64_MPU_H__ */
>> \ No newline at end of file
> Please add a new line at the end
> 
> Also, EMACS comment is missing.

Thanks I will fix all these findings

Cheers,
Luca




 


Rackspace

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