blob: 8be14ee85a97c08fb4b62cd160713cc9be13d692 [file] [log] [blame]
Andrew Geisslerea144b032023-01-27 16:03:57 -06001From 01490ab8deb0f0b61eeb55a02ee5ea430cfe7eee 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
4Subject: [PATCH 8/9] armv8: Allow PRBAR MPU attributes to be configured
5
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
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
30diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
31index 798aed8058..e336339281 100644
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
63diff --git a/arch/arm/include/asm/armv8/mpu.h b/arch/arm/include/asm/armv8/mpu.h
64index 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;
77diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
Andrew Geisslerea144b032023-01-27 16:03:57 -060078index 2310d18eb7..531fa4d618 100644
Brad Bishopbec4ebc2022-08-03 09:55:16 -040079--- 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,
103--
1042.25.1
105