Andrew Geissler | fc7e797 | 2023-09-11 08:24:07 -0400 | [diff] [blame^] | 1 | From 665ab8253a0e3e17db54a1682bbee0f5659939a2 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 | fc7e797 | 2023-09-11 08:24:07 -0400 | [diff] [blame^] | 4 | Subject: [PATCH] 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 |
Andrew Geissler | fc7e797 | 2023-09-11 08:24:07 -0400 | [diff] [blame^] | 24 | |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 25 | --- |
| 26 | arch/arm/cpu/armv8/cache_v8.c | 12 ++++++++---- |
| 27 | arch/arm/include/asm/armv8/mpu.h | 3 ++- |
| 28 | board/armltd/vexpress64/vexpress64.c | 9 ++++++--- |
| 29 | 3 files changed, 16 insertions(+), 8 deletions(-) |
| 30 | |
| 31 | diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c |
Andrew Geissler | fc7e797 | 2023-09-11 08:24:07 -0400 | [diff] [blame^] | 32 | index 8611a35eb3..f7de952187 100644 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 33 | --- a/arch/arm/cpu/armv8/cache_v8.c |
| 34 | +++ b/arch/arm/cpu/armv8/cache_v8.c |
| 35 | @@ -390,7 +390,9 @@ static void mpu_clear_regions(void) |
| 36 | { |
| 37 | int i; |
| 38 | |
| 39 | - for (i = 0; mpu_mem_map[i].end || mpu_mem_map[i].attrs; i++) { |
| 40 | + for (i = 0; mpu_mem_map[i].end || |
| 41 | + mpu_mem_map[i].prbar_attrs || |
| 42 | + mpu_mem_map[i].prlar_attrs; i++) { |
| 43 | setup_el2_mpu_region(i, 0, 0); |
| 44 | } |
| 45 | } |
| 46 | @@ -410,12 +412,14 @@ static void mpu_setup(void) |
| 47 | |
| 48 | asm volatile("msr MAIR_EL2, %0" : : "r" MEMORY_ATTRIBUTES); |
| 49 | |
| 50 | - for (i = 0; mpu_mem_map[i].end || mpu_mem_map[i].attrs; i++) { |
| 51 | + for (i = 0; mpu_mem_map[i].end || |
| 52 | + mpu_mem_map[i].prbar_attrs || |
| 53 | + mpu_mem_map[i].prlar_attrs; i++) { |
| 54 | setup_el2_mpu_region(i, |
| 55 | PRBAR_ADDRESS(mpu_mem_map[i].start) |
| 56 | - | PRBAR_OUTER_SH | PRBAR_AP_RW_ANY, |
| 57 | + | mpu_mem_map[i].prbar_attrs, |
| 58 | PRLAR_ADDRESS(mpu_mem_map[i].end) |
| 59 | - | mpu_mem_map[i].attrs | PRLAR_EN_BIT |
| 60 | + | mpu_mem_map[i].prlar_attrs | PRLAR_EN_BIT |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | diff --git a/arch/arm/include/asm/armv8/mpu.h b/arch/arm/include/asm/armv8/mpu.h |
| 65 | index 8de627cafd..dd4c689ea6 100644 |
| 66 | --- a/arch/arm/include/asm/armv8/mpu.h |
| 67 | +++ b/arch/arm/include/asm/armv8/mpu.h |
| 68 | @@ -51,7 +51,8 @@ static inline void setup_el2_mpu_region(uint8_t region, uint64_t base, uint64_t |
| 69 | struct mpu_region { |
| 70 | u64 start; |
| 71 | u64 end; |
| 72 | - u64 attrs; |
| 73 | + u64 prbar_attrs; |
| 74 | + u64 prlar_attrs; |
| 75 | }; |
| 76 | |
| 77 | extern struct mpu_region *mpu_mem_map; |
| 78 | 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] | 79 | index 2310d18eb7..531fa4d618 100644 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 80 | --- a/board/armltd/vexpress64/vexpress64.c |
| 81 | +++ b/board/armltd/vexpress64/vexpress64.c |
| 82 | @@ -42,15 +42,18 @@ static struct mpu_region vexpress64_aemv8r_mem_map[] = { |
| 83 | { |
| 84 | .start = 0x0UL, |
| 85 | .end = 0x7fffffffUL, |
| 86 | - .attrs = PRLAR_ATTRIDX(MT_NORMAL) |
| 87 | + .prbar_attrs = PRBAR_INNER_SH | PRBAR_AP_RW_ANY, |
| 88 | + .prlar_attrs = PRLAR_ATTRIDX(MT_NORMAL) |
| 89 | }, { |
| 90 | .start = 0x80000000UL, |
| 91 | .end = 0xffffffffUL, |
| 92 | - .attrs = PRLAR_ATTRIDX(MT_DEVICE_NGNRNE) |
| 93 | + .prbar_attrs = PRBAR_OUTER_SH | PRBAR_AP_RW_ANY, |
| 94 | + .prlar_attrs = PRLAR_ATTRIDX(MT_DEVICE_NGNRNE) |
| 95 | }, { |
| 96 | .start = 0x100000000UL, |
| 97 | .end = 0xffffffffffUL, |
| 98 | - .attrs = PRLAR_ATTRIDX(MT_NORMAL) |
| 99 | + .prbar_attrs = PRBAR_INNER_SH | PRBAR_AP_RW_ANY, |
| 100 | + .prlar_attrs = PRLAR_ATTRIDX(MT_NORMAL) |
| 101 | }, { |
| 102 | /* List terminator */ |
| 103 | 0, |