blob: 61bdf928f41f1d27fef86960d98626f0201602fb [file] [log] [blame]
Andrew Geisslerfc7e7972023-09-11 08:24:07 -04001From 665ab8253a0e3e17db54a1682bbee0f5659939a2 Mon Sep 17 00:00:00 2001
Brad Bishopbec4ebc2022-08-03 09:55:16 -04002From: Peter Hoyes <Peter.Hoyes@arm.com>
3Date: Wed, 18 May 2022 15:24:19 +0100
Andrew Geisslerfc7e7972023-09-11 08:24:07 -04004Subject: [PATCH] armv8: Allow PRBAR MPU attributes to be configured
Brad Bishopbec4ebc2022-08-03 09:55:16 -04005
6In a previous patch, support was added to initialize an S-EL2 MPU on
7armv8r64 machines. This implementation allowed the PRLAR attribute
8index to be configured, but not the shareability and access permission
9attributes in PRBAR. These attributes were hard-coded as "outer
10shareable" and "read/write at EL1 and EL0".
11
12Add separate prlar_attrs and prbar_attrs to the MPU region struct so
13that these attributes can be configured on a per-region basis.
14
15For the BASER_FVP, ensure the MPU memory attributes match those in the
16existing vexpress64 board MMU configuration ("non shareable" for device
17memory and "inner shareable" for normal memory).
18
19Issue-Id: SCM-4641
20Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
21Upstream-Status: Inappropriate [other]
22 Implementation pending further discussion
23Change-Id: I6b72aead91ad12412262aa32c61a53e12eab3984
Andrew Geisslerfc7e7972023-09-11 08:24:07 -040024
Brad Bishopbec4ebc2022-08-03 09:55:16 -040025---
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
31diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
Andrew Geisslerfc7e7972023-09-11 08:24:07 -040032index 8611a35eb3..f7de952187 100644
Brad Bishopbec4ebc2022-08-03 09:55:16 -040033--- 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
64diff --git a/arch/arm/include/asm/armv8/mpu.h b/arch/arm/include/asm/armv8/mpu.h
65index 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;
78diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
Andrew Geisslerea144b032023-01-27 16:03:57 -060079index 2310d18eb7..531fa4d618 100644
Brad Bishopbec4ebc2022-08-03 09:55:16 -040080--- 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,