Skip to contentSkip to conversation

arm-bsp/u-boot: fvp-baser-aemv8r64 cache_state_modelled fixes

PATCH Applied Peter Hoyes 2 participants 3 messages Jun 7, 2022 – Jun 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 arm-bsp/u-boot: fvp-baser-aemv8r64 cache_state_modelled fixes

From: Peter Hoyes <[email protected]>

Running the FVP_Base_AEMv8R model with the cache_state_modelled parameter enabled exposed some defects in the U-Boot BSP patches for the fvp-baser-aemv8r64:
* The MPU memory attributes are inconsistent with the existing MMU attributes, causing a model hang when sending packets using virtio-net in U-Boot.
* The instruction cache was left disabled after booting an EFI payload at S-EL1, violating the UEFI specification and causing Grub to hang when attempting to use dynamically loaded modules.

The cache_state_modelled FVP parameter is enabled by default in the model (for simulation accuracy) but is disabled by default in the machine conf (for simulation speed).

This patch adds two additional machine-specific U-Boot patches to fix the above issues.

Issue-Id: SCM-4641

Change-Id I5ab13c9fdadd82456ac3f3e3703df36590d52fb7
---
 ...RBAR-MPU-attributes-to-be-configured.patch | 105 ++++++++++++++++++
 ...che-when-switching-exception-levels-.patch |  63 +++++++++++
 .../recipes-bsp/u-boot/u-boot_%.bbappend      |   2 +
 3 files changed, 170 insertions(+)
 create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0014-armv8-Allow-PRBAR-MPU-attributes-to-be-configured.patch
 create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0015-armv8-Enable-icache-when-switching-exception-levels-.patch
meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0014-armv8-Allow-PRBAR-MPU-attributes-to-be-configured.patch new file +105 -0
new file mode 100644
index 0000000..94ac806
@@ -0,0 +1,105 @@
+From c4abb74e62817c5adf32c011db93f6bfc2deabaf Mon Sep 17 00:00:00 2001
+From: Peter Hoyes <[email protected]>
+Date: Wed, 18 May 2022 15:24:19 +0100
+Subject: [PATCH 1/2] armv8: Allow PRBAR MPU attributes to be configured
+
+In a previous patch, support was added to initialize an S-EL2 MPU on
+armv8r64 machines. This implementation allowed the PRLAR attribute
+index to be configured, but not the shareability and access permission
+attributes in PRBAR. These attributes were hard-coded as "outer
+shareable" and "read/write at EL1 and EL0".
+
+Add separate prlar_attrs and prbar_attrs to the MPU region struct so
+that these attributes can be configured on a per-region basis.
+
+For the BASER_FVP, ensure the MPU memory attributes match those in the
+existing vexpress64 board MMU configuration ("non shareable" for device
+memory and "inner shareable" for normal memory).
+
+Issue-Id: SCM-4641
+Signed-off-by: Peter Hoyes <[email protected]>
+Upstream-Status: Inappropriate [other]
+  Implementation pending further discussion
+Change-Id: I6b72aead91ad12412262aa32c61a53e12eab3984
+---
+ arch/arm/cpu/armv8/cache_v8.c        | 12 ++++++++----
+ arch/arm/include/asm/armv8/mpu.h     |  3 ++-
+ board/armltd/vexpress64/vexpress64.c |  9 ++++++---
+ 3 files changed, 16 insertions(+), 8 deletions(-)
+
+diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
+index f6e0ad0075..981aca4a0f 100644
+--- a/arch/arm/cpu/armv8/cache_v8.c
++++ b/arch/arm/cpu/armv8/cache_v8.c
+@@ -370,7 +370,9 @@ static void mpu_clear_regions(void)
+ {
+ 	int i;
+ 
+-	for (i = 0; mpu_mem_map[i].end || mpu_mem_map[i].attrs; i++) {
++	for (i = 0; mpu_mem_map[i].end ||
++	     mpu_mem_map[i].prbar_attrs ||
++	     mpu_mem_map[i].prlar_attrs; i++) {
+ 		setup_el2_mpu_region(i, 0, 0);
+ 	}
+ }
+@@ -390,12 +392,14 @@ static void mpu_setup(void)
+ 
+ 	asm volatile("msr MAIR_EL2, %0" : : "r" MEMORY_ATTRIBUTES);
+ 
+-	for (i = 0; mpu_mem_map[i].end || mpu_mem_map[i].attrs; i++) {
++	for (i = 0; mpu_mem_map[i].end ||
++	     mpu_mem_map[i].prbar_attrs ||
++	     mpu_mem_map[i].prlar_attrs; i++) {
+ 		setup_el2_mpu_region(i,
+ 			PRBAR_ADDRESS(mpu_mem_map[i].start)
+-				| PRBAR_OUTER_SH | PRBAR_AP_RW_ANY,
++				| mpu_mem_map[i].prbar_attrs,
+ 			PRLAR_ADDRESS(mpu_mem_map[i].end)
+-				| mpu_mem_map[i].attrs | PRLAR_EN_BIT
++				| mpu_mem_map[i].prlar_attrs | PRLAR_EN_BIT
+ 			);
+ 	}
+ 
+diff --git a/arch/arm/include/asm/armv8/mpu.h b/arch/arm/include/asm/armv8/mpu.h
+index 8de627cafd..dd4c689ea6 100644
+--- a/arch/arm/include/asm/armv8/mpu.h
++++ b/arch/arm/include/asm/armv8/mpu.h
+@@ -51,7 +51,8 @@ static inline void setup_el2_mpu_region(uint8_t region, uint64_t base, uint64_t
+ struct mpu_region {
+ 	u64 start;
+ 	u64 end;
+-	u64 attrs;
++	u64 prbar_attrs;
++	u64 prlar_attrs;
+ };
+ 
+ extern struct mpu_region *mpu_mem_map;
+diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
+index 3f1ac04bac..31ff2f7b2d 100644
+--- a/board/armltd/vexpress64/vexpress64.c
++++ b/board/armltd/vexpress64/vexpress64.c
+@@ -41,15 +41,18 @@ static struct mpu_region vexpress64_aemv8r_mem_map[] = {
+        {
+                .start = 0x0UL,
+                .end = 0x7fffffffUL,
+-               .attrs = PRLAR_ATTRIDX(MT_NORMAL)
++	       .prbar_attrs = PRBAR_INNER_SH | PRBAR_AP_RW_ANY,
++	       .prlar_attrs = PRLAR_ATTRIDX(MT_NORMAL)
+        }, {
+                .start = 0x80000000UL,
+                .end = 0xffffffffUL,
+-               .attrs = PRLAR_ATTRIDX(MT_DEVICE_NGNRNE)
++	       .prbar_attrs = PRBAR_OUTER_SH | PRBAR_AP_RW_ANY,
++	       .prlar_attrs = PRLAR_ATTRIDX(MT_DEVICE_NGNRNE)
+        }, {
+                .start = 0x100000000UL,
+                .end = 0xffffffffffUL,
+-               .attrs = PRLAR_ATTRIDX(MT_NORMAL)
++	       .prbar_attrs = PRBAR_INNER_SH | PRBAR_AP_RW_ANY,
++	       .prlar_attrs = PRLAR_ATTRIDX(MT_NORMAL)
+        }, {
+                /* List terminator */
+                0,
+-- 
+2.25.1
+
meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0015-armv8-Enable-icache-when-switching-exception-levels-.patch new file +63 -0

63 lines not on this page · raw message

meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend +2 -0
index f7336ad..75d086b 100644
@@ -73,6 +73,8 @@ SRC_URI:append:fvp-baser-aemv8r64 = " \
     file://0011-vexpress64-Add-BASER_FVP-vexpress-board-variant.patch \
     file://0012-vexpress64-Configure-memory-using-device-tree.patch \
     file://0013-vexpress64-Enable-LIBFDT_OVERLAY-in-the-vexpress_aem.patch \
+    file://0014-armv8-Allow-PRBAR-MPU-attributes-to-be-configured.patch \
+    file://0015-armv8-Enable-icache-when-switching-exception-levels-.patch \
     "
 
 #
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/2 arm-bsp/conf: fvp-baser-aemv8r64 model parameter update

From: Peter Hoyes <[email protected]>

Add parameters required to boot with cache_state_modelled enabled:
* bp.virtio_net.secure_accesses=1
* bp.virtio_rng.secure_accesses=1
* bp.virtioblockdevice.secure_accesses=1
* cci400.force_on_from_start=1

Add bp.ve_sysregs.exit_on_shutdown=1 to match fvp-base.

Remove parameters that are not required to boot or are setting the default value.

Alphabetize the list.

Issue-Id: SCM-4304

Change-Id I0a696eff5bb83206e5501f651c487f16f695aa4c
---
 .../conf/machine/fvp-baser-aemv8r64.conf      | 36 ++++++++-----------
 1 file changed, 14 insertions(+), 22 deletions(-)
meta-arm-bsp/conf/machine/fvp-baser-aemv8r64.conf +14 -22
index 7e45ff8..1ffafb6 100644
@@ -43,32 +43,24 @@ FVP_EXE ?= "FVP_BaseR_AEMv8R"
 FVP_CONSOLE ?= "terminal_0"
 
 # FVP parameters
-FVP_CONFIG[bp.virtioblockdevice.image_path] ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.wic"
-FVP_CONFIG[bp.dram_metadata.init_value] ?= "0"
-FVP_CONFIG[bp.dram_metadata.is_enabled] ?= "true"
-FVP_CONFIG[bp.exclusive_monitor.monitor_access_level] ?= "1"
-FVP_CONFIG[bp.pl011_uart0.unbuffered_output] ?= "1"
-FVP_CONFIG[bp.pl011_uart0.untimed_fifos] ?= "true"
+FVP_CONFIG[bp.exclusive_monitor.monitor_access_level] ?= "2"
 FVP_CONFIG[bp.refcounter.non_arch_start_at_default] ?= "1"
-FVP_CONFIG[bp.smsc_91c111.enabled] ?= "0"
-FVP_CONFIG[bp.ve_sysregs.mmbSiteDefault] ?= "0"
+FVP_CONFIG[bp.refcounter.use_real_time] ?= "1"
+FVP_CONFIG[bp.ve_sysregs.exit_on_shutdown] ?= "1"
+FVP_CONFIG[bp.virtio_net.enabled] ?= "1"
+FVP_CONFIG[bp.virtio_net.hostbridge.userNetPorts] ?= "8022=22"
+FVP_CONFIG[bp.virtio_net.hostbridge.userNetworking] ?= "1"
+FVP_CONFIG[bp.virtio_net.secure_accesses] = "1"
+FVP_CONFIG[bp.virtio_rng.enabled] ?= "1"
+FVP_CONFIG[bp.virtio_rng.secure_accesses] = "1"
+FVP_CONFIG[bp.virtioblockdevice.image_path] ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.wic"
+FVP_CONFIG[bp.virtioblockdevice.secure_accesses] = "1"
 FVP_CONFIG[cache_state_modelled] ?= "0"
+FVP_CONFIG[cci400.force_on_from_start] = "1"
 FVP_CONFIG[cluster0.gicv3.cpuintf-mmap-access-level] ?= "2"
-FVP_CONFIG[cluster0.gicv3.SRE-enable-action-on-mmap] ?= "2"
-FVP_CONFIG[cluster0.gicv3.SRE-EL2-enable-RAO] ?= "1"
 FVP_CONFIG[cluster0.gicv3.extended-interrupt-range-support] ?= "1"
+FVP_CONFIG[cluster0.gicv3.SRE-EL2-enable-RAO] ?= "1"
+FVP_CONFIG[cluster0.gicv3.SRE-enable-action-on-mmap] ?= "2"
 FVP_CONFIG[cluster0.has_aarch64] ?= "1"
-FVP_CONFIG[cluster0.NUM_CORES] ?= "4"
-FVP_CONFIG[cluster0.stage12_tlb_size] ?= "512"
 FVP_CONFIG[gic_distributor.GICD_CTLR-DS-1-means-secure-only] ?= "1"
-FVP_CONFIG[gic_distributor.GITS_BASER0-type] ?= "1"
-FVP_CONFIG[gic_distributor.ITS-count] ?= "1"
-FVP_CONFIG[gic_distributor.ITS-hardware-collection-count] ?= "1"
 FVP_CONFIG[gic_distributor.has-two-security-states] ?= "0"
-FVP_CONFIG[pctl.startup] ?= "0.0.0.*"
-FVP_CONFIG[bp.virtio_net.enabled] ?= "1"
-FVP_CONFIG[bp.virtio_net.hostbridge.userNetworking] ?= "1"
-FVP_CONFIG[bp.virtio_net.hostbridge.userNetPorts] ?= "8022=22"
-FVP_CONFIG[bp.virtio_rng.enabled] ?= "1"
-FVP_CONFIG[bp.vis.rate_limit-enable] ?= "0"
-FVP_CONFIG[bp.refcounter.use_real_time] ?= "1"
Signature · 1 line
2.25.1
Applied
#2 lore raw
In reply to Peter Hoyes
Quoted 11 lines · Peter Hoyes

Running the FVP_Base_AEMv8R model with the cache_state_modelled parameter enabled exposed some defects in the U-Boot BSP patches for the fvp-baser-aemv8r64:
* The MPU memory attributes are inconsistent with the existing MMU attributes, causing a model hang when sending packets using virtio-net in U-Boot.
* The instruction cache was left disabled after booting an EFI payload at S-EL1, violating the UEFI specification and causing Grub to hang when attempting to use dynamically loaded modules.

[...]

Applied, thanks!

[1/2] arm-bsp/u-boot: fvp-baser-aemv8r64 cache_state_modelled fixes

      commit: dd8b6c1dbe02666a2d4e372dabf832dbfc2977c8
[2/2] arm-bsp/conf: fvp-baser-aemv8r64 model parameter update
      commit: a8cb33d5139e30b4a643da9a277487299c0e658f

Best regards,

Signature · 1 line
Jon Mason <[email protected]>