[PATCH master] ARM: fix OP-TEE DT reservation clashing with barebox area at endmem
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Jul 1 03:08:59 PDT 2024
The barebox area reservation is meant to fix the issue of having gaps
between early barebox-related reservations that might be clobbered by
later calls to request_sdram_region().
The OP-TEE memory region, if it exists, is not a barebox-related
reservation and treating it as such will clash if the reservation is
also listed in the device-tree:
WARNING: of-reserved-mem: couldn't request reserved sdram region 0xdd000000-0xdfffffff
This failed reservation can lead to a failure to boot, e.g. on
STM32MP13:
WARNING: of-reserved-mem: couldn't request reserved sdram region 0xdd000000-0xdfffffff
E/TC:0 tzc_it_handler:26 TZC permission failure
E/TC:0 dump_fail_filter:420 Permission violation on filter 0
E/TC:0 dump_fail_filter:425 Violation @0xde03c530, non-secure privileged read, AXI ID 5c0
E/TC:0 Panic at core/arch/arm/plat-stm32mp1/plat_tzc400.c:30 <tzc_it_handler>
E/TC:0 TEE load address @ 0xde000000
E/TC:0 Call stack:
Fix this by defining the end of the barebox area to not include any
OP-TEE memory regions.
Fixes: 3f7b6146669c ("ARM: cpu: start: register barebox memory area")
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
arch/arm/cpu/start.c | 3 ++-
arch/arm/include/asm/barebox-arm.h | 7 ++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 2d60d190fe7c..ece9512a79f1 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -170,7 +170,8 @@ __noreturn __prereloc void barebox_non_pbl_start(unsigned long membase,
pr_debug("initializing malloc pool at 0x%08lx (size 0x%08lx)\n",
malloc_start, malloc_end - malloc_start);
- register_barebox_area(barebox_base, endmem - barebox_base);
+ register_barebox_area(barebox_base,
+ arm_mem_barebox_image_end(endmem) - barebox_base);
kasan_init(membase, memsize, malloc_start - (memsize >> KASAN_SHADOW_SCALE_SHIFT));
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 566986e515a4..6071c6435535 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -59,7 +59,7 @@ void *barebox_arm_boot_dtb(void);
* ↑
* OPTEE_SIZE (depends on CONFIG_OPTEE_SIZE)
* ↓
- * ------------------------- arm_mem_optee() -------------------------
+ * ---------- arm_mem_optee() / arm_mem_barebox_image_end() ----------
* ↑
* SZ_32K
* ↓
@@ -97,6 +97,11 @@ static inline unsigned long arm_mem_optee(unsigned long endmem)
return endmem - OPTEE_SIZE;
}
+static inline unsigned long arm_mem_barebox_image_end(unsigned long endmem)
+{
+ return arm_mem_optee(endmem);
+}
+
static inline unsigned long arm_mem_scratch(unsigned long endmem)
{
return arm_mem_optee(endmem) - SZ_32K;
--
2.39.2
More information about the barebox
mailing list