[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 5/7] arm/mpu: Introduce MPU memory mapping flags
- To: Julien Grall <julien@xxxxxxx>
- From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
- Date: Wed, 16 Apr 2025 16:52:13 +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=xen.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=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=L2S3IO+vua4ihT4o2hq7kOos91bMviBIwTOa6K+qhSA=; b=HRYZYp762jVf2IhhACsMp3zOL5UWrF32l4iTGFIzfFpyPbKdEP3qRufH1TApcMYpmbGdmGtlZXtSqDKClPqUgUP9CGnQoyj00sRs7JuccfHoEhQEw93U/wfLLPMFxr8J5M1nzc0Bbtk+SO/gFd4+he0mbNIt4eiDVp6y4sANgRqArwCSISYg+qZjswRFfQnVBprXyE3h3YsECtW/i73knYU338f1IYOf962/1TTyc3qekITEvk5o25z+aG8tCAQAjD+m4BpcVj8Q8/Z0iFlFrvK/rREhZOyyqNwmoniFCsg3PAeQYtJRS5gc23zot1GkOhkJFTSWQ9RlGzcTh2lhpg==
- 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=L2S3IO+vua4ihT4o2hq7kOos91bMviBIwTOa6K+qhSA=; b=lfzsrPjIubh7Z1lQrlmn09TzNhSjNqhGeZdbAYY7SFx4YYg9uSMZ7VYr8FxDBTFTVA7fI+tYW5R+FtTwbRS/a2hjIq19xKtBwiwWvgZx9erTYqkQQK/hGv1cwRxPshrDZZCIYwn14aOZIDxDiAKZYyXA46ikruhSaa/ROgoQDjCDqFc/IZSIzDblBPaaPvsFNtd4eqdjVdPoGOjnN2foQK/DzA8djA+13KWHT9L37braQWFZ7CROj0+FFeTq1GvhVL8QfP/7IPYy1sylg1l/6h+QIldhYsMVFuTsL86i9uoppp3MjWuB9O5DXS8R498NRd21xF/Iu45HBUu0Cri/bw==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=rtSriI0bcc5fGzyYHQny4pN5ayNb06j9xV3fsIPe/S18oUkyMUsJqXXYnoU+xh8ErLC59WqGlxZ4DXhbS3kJhaMmrZT0qk2QdvSO8Qh0FTzt5fOEUEP3lB+y7VGo5C6C2mhyvEK3bUneu33CmIooDfZE4dUrXCmq8pAcT8VpB5nMINfAdypdfeMb70b8dhM+HDBD/i4FhxIjagUY8uHktWwtqJIRhh8ZGhVTM849GUS2grg29vcKxEu1fUciM78wkTz8yovKR56OAj+5jSScuSS/SMFcGRYtlrL6Ht275NHsrK/DbJfKjYh+qPTfJ6N+8xlaikcjSzi05Ml2HeBtZg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NqWpO21Pm4dhDLwDDvGODx/3SobM2eaPOm/fKTtH0v0823nCwV3W0NROdxjU2SOQ5sXwF3kYKa7pXrk9jbY+ADgPV6R0VzIWvqZFpQxnOsVjh1NpVEuafEiamJp/yfIRThL9bcmDPb2dtJZjWxhbBHf5yRufm+srBa6+Ahc+Edo++NknZjBwa2hUW+9pZmKMdQrdyAJs5MXriobSx69wp3zmFjSQz8/uToTsHcRQsffHKD6rcY+WIFtpZoKz9COy+sRZmPjX0i3M2KOl7WVMhcnYRFxK7pXmZtWJMdZJ+3T/9qxfO0PTUmwdVY34zxxpSzZgX+jJ+fbtYxNkwTRoFA==
- 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>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Wed, 16 Apr 2025 16:52:57 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Thread-index: AQHbqvIRPrwVw96fI0iTW2LEmRilT7OjEIMAgAN5QoA=
- Thread-topic: [PATCH v3 5/7] arm/mpu: Introduce MPU memory mapping flags
Hi Julien,
> On 14 Apr 2025, at 12:48, Julien Grall <julien@xxxxxxx> wrote:
>
> Hi Luca,
>
> On 11/04/2025 23:56, Luca Fancellu wrote:
>> Introduce the MPU memory mapping flags in asm/page.h.
>> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
>> ---
>> xen/arch/arm/include/asm/page.h | 25 +++++++++++++++++++++++++
>> 1 file changed, 25 insertions(+)
>> diff --git a/xen/arch/arm/include/asm/page.h
>> b/xen/arch/arm/include/asm/page.h
>> index 69f817d1e68a..22f7d2c6cb30 100644
>> --- a/xen/arch/arm/include/asm/page.h
>> +++ b/xen/arch/arm/include/asm/page.h
>> @@ -62,6 +62,7 @@
>> #define MAIRVAL (MAIR1VAL << 32 | MAIR0VAL)
>> +#ifdef CONFIG_MMU
>> /*
>> * Layout of the flags used for updating the hypervisor page tables
>> *
>> @@ -90,6 +91,30 @@
>> #define _PAGE_CONTIG_BIT 8
>> #define _PAGE_CONTIG (1U << _PAGE_CONTIG_BIT)
>> +#else /* !CONFIG_MMU */
>> +
>> +/*
>> + * Layout of the flags used for updating MPU memory region attributes
>> + * [0:2] Memory attribute Index
>> + * [3:4] Execute Never
>> + * [5:6] Access Permission
>
> I am rather confused why we are splitting Execute Never from the Access
> Permission. I guess you tried to match the HW, but it also means we need to
> duplicate a lot of define between the MMU and MPU code.
>
> Instead, I would rather try to re-use the existing ones and ignore the ones
> we don't need (e.g. BLOCK_BIT and CONTIG).
I’m having a bit of trouble understanding the MMU part:
/*
* Layout of the flags used for updating the hypervisor page tables
*
* [0:2] Memory Attribute Index
* [3:4] Permission flags
* [5] Page present
* [6] Only populate page tables
* [7] Superpage mappings is allowed
* [8] Set contiguous bit (internal flag)
*/
#define PAGE_AI_MASK(x) ((x) & 0x7U)
#define _PAGE_XN_BIT 3
#define _PAGE_RO_BIT 4
#define _PAGE_XN (1U << _PAGE_XN_BIT)
#define _PAGE_RO (1U << _PAGE_RO_BIT)
#define PAGE_XN_MASK(x) (((x) >> _PAGE_XN_BIT) & 0x1U)
#define PAGE_RO_MASK(x) (((x) >> _PAGE_RO_BIT) & 0x1U)
I can see on the MMU basically AP[1] means RO or not, AP[0] means XN or not,
from the arm spec
(verison L.a, D8.4.2.1.1 Stage 2 data accesses using Direct permissions) I can
see stage 2 AP[1:0] is:
- 00: no access
- 01: RO
- 10: WO
- 11: RW
So:
- 00: read-only is zero and execution is allowed
- 01: read-only is zero and execution is not allowed
- 10: read-only is one (??), execution is allowed
- 11: read-only is one (??), execution is not allowed
I’m clearly missing something because everything works, so could you help me to
understand this part?
|