Andrew Geissler | 80d4184 | 2023-09-11 08:36:15 -0400 | [diff] [blame] | 1 | From 01490ab8deb0f0b61eeb55a02ee5ea430cfe7eee Mon Sep 17 00:00:00 2001 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 2 | From: Peter Hoyes <Peter.Hoyes@arm.com> |
| 3 | Date: Wed, 18 May 2022 15:24:19 +0100 |
Andrew Geissler | 80d4184 | 2023-09-11 08:36:15 -0400 | [diff] [blame] | 4 | Subject: [PATCH 8/9] armv8: Allow PRBAR MPU attributes to be configured |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 5 | |
| 6 | In a previous patch, support was added to initialize an S-EL2 MPU on |
| 7 | armv8r64 machines. This implementation allowed the PRLAR attribute |
| 8 | index to be configured, but not the shareability and access permission |
| 9 | attributes in PRBAR. These attributes were hard-coded as "outer |
| 10 | shareable" and "read/write at EL1 and EL0". |
| 11 | |
| 12 | Add separate prlar_attrs and prbar_attrs to the MPU region struct so |
| 13 | that these attributes can be configured on a per-region basis. |
| 14 | |
| 15 | For the BASER_FVP, ensure the MPU memory attributes match those in the |
| 16 | existing vexpress64 board MMU configuration ("non shareable" for device |
| 17 | memory and "inner shareable" for normal memory). |
| 18 | |
| 19 | Issue-Id: SCM-4641 |
| 20 | Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com> |
| 21 | Upstream-Status: Inappropriate [other] |
| 22 | Implementation pending further discussion |
| 23 | Change-Id: I6b72aead91ad12412262aa32c61a53e12eab3984 |
| 24 | --- |
| 25 | arch/arm/cpu/armv8/cache_v8.c | 12 ++++++++---- |
| 26 | arch/arm/include/asm/armv8/mpu.h | 3 ++- |
| 27 | board/armltd/vexpress64/vexpress64.c | 9 ++++++--- |
| 28 | 3 files changed, 16 insertions(+), 8 deletions(-) |
| 29 | |
| 30 | diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c |
Andrew Geissler | 80d4184 | 2023-09-11 08:36:15 -0400 | [diff] [blame] | 31 | index 798aed8058..e336339281 100644 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 32 | --- a/arch/arm/cpu/armv8/cache_v8.c |
| 33 | +++ b/arch/arm/cpu/armv8/cache_v8.c |
| 34 | @@ -390,7 +390,9 @@ static void mpu_clear_regions(void) |
| 35 | { |
| 36 | int i; |
| 37 | |
| 38 | - for (i = 0; mpu_mem_map[i].end || mpu_mem_map[i].attrs; i++) { |
| 39 | + for (i = 0; mpu_mem_map[i].end || |
| 40 | + mpu_mem_map[i].prbar_attrs || |
| 41 | + mpu_mem_map[i].prlar_attrs; i++) { |
| 42 | setup_el2_mpu_region(i, 0, 0); |
| 43 | } |
| 44 | } |
| 45 | @@ -410,12 +412,14 @@ static void mpu_setup(void) |
| 46 | |
| 47 | asm volatile("msr MAIR_EL2, %0" : : "r" MEMORY_ATTRIBUTES); |
| 48 | |
| 49 | - for (i = 0; mpu_mem_map[i].end || mpu_mem_map[i].attrs; i++) { |
| 50 | + for (i = 0; mpu_mem_map[i].end || |
| 51 | + mpu_mem_map[i].prbar_attrs || |
| 52 | + mpu_mem_map[i].prlar_attrs; i++) { |
| 53 | setup_el2_mpu_region(i, |
| 54 | PRBAR_ADDRESS(mpu_mem_map[i].start) |
| 55 | - | PRBAR_OUTER_SH | PRBAR_AP_RW_ANY, |
| 56 | + | mpu_mem_map[i].prbar_attrs, |
| 57 | PRLAR_ADDRESS(mpu_mem_map[i].end) |
| 58 | - | mpu_mem_map[i].attrs | PRLAR_EN_BIT |
| 59 | + | mpu_mem_map[i].prlar_attrs | PRLAR_EN_BIT |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | diff --git a/arch/arm/include/asm/armv8/mpu.h b/arch/arm/include/asm/armv8/mpu.h |
| 64 | index 8de627cafd..dd4c689ea6 100644 |
| 65 | --- a/arch/arm/include/asm/armv8/mpu.h |
| 66 | +++ b/arch/arm/include/asm/armv8/mpu.h |
| 67 | @@ -51,7 +51,8 @@ static inline void setup_el2_mpu_region(uint8_t region, uint64_t base, uint64_t |
| 68 | struct mpu_region { |
| 69 | u64 start; |
| 70 | u64 end; |
| 71 | - u64 attrs; |
| 72 | + u64 prbar_attrs; |
| 73 | + u64 prlar_attrs; |
| 74 | }; |
| 75 | |
| 76 | extern struct mpu_region *mpu_mem_map; |
| 77 | diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c |
Andrew Geissler | ea144b03 | 2023-01-27 16:03:57 -0600 | [diff] [blame] | 78 | index 2310d18eb7..531fa4d618 100644 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 79 | --- a/board/armltd/vexpress64/vexpress64.c |
| 80 | +++ b/board/armltd/vexpress64/vexpress64.c |
| 81 | @@ -42,15 +42,18 @@ static struct mpu_region vexpress64_aemv8r_mem_map[] = { |
| 82 | { |
| 83 | .start = 0x0UL, |
| 84 | .end = 0x7fffffffUL, |
| 85 | - .attrs = PRLAR_ATTRIDX(MT_NORMAL) |
| 86 | + .prbar_attrs = PRBAR_INNER_SH | PRBAR_AP_RW_ANY, |
| 87 | + .prlar_attrs = PRLAR_ATTRIDX(MT_NORMAL) |
| 88 | }, { |
| 89 | .start = 0x80000000UL, |
| 90 | .end = 0xffffffffUL, |
| 91 | - .attrs = PRLAR_ATTRIDX(MT_DEVICE_NGNRNE) |
| 92 | + .prbar_attrs = PRBAR_OUTER_SH | PRBAR_AP_RW_ANY, |
| 93 | + .prlar_attrs = PRLAR_ATTRIDX(MT_DEVICE_NGNRNE) |
| 94 | }, { |
| 95 | .start = 0x100000000UL, |
| 96 | .end = 0xffffffffffUL, |
| 97 | - .attrs = PRLAR_ATTRIDX(MT_NORMAL) |
| 98 | + .prbar_attrs = PRBAR_INNER_SH | PRBAR_AP_RW_ANY, |
| 99 | + .prlar_attrs = PRLAR_ATTRIDX(MT_NORMAL) |
| 100 | }, { |
| 101 | /* List terminator */ |
| 102 | 0, |
Andrew Geissler | 80d4184 | 2023-09-11 08:36:15 -0400 | [diff] [blame] | 103 | -- |
| 104 | 2.25.1 |
| 105 | |