mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] ARM: fix OP-TEE DT reservation clashing with barebox area at endmem
@ 2024-07-01 10:08 Ahmad Fatoum
  2024-07-01 13:27 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-07-01 10:08 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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@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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH master] ARM: fix OP-TEE DT reservation clashing with barebox area at endmem
  2024-07-01 10:08 [PATCH master] ARM: fix OP-TEE DT reservation clashing with barebox area at endmem Ahmad Fatoum
@ 2024-07-01 13:27 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-07-01 13:27 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 01 Jul 2024 12:08:59 +0200, Ahmad Fatoum wrote:
> 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:
> 
> [...]

Applied, thanks!

[1/1] ARM: fix OP-TEE DT reservation clashing with barebox area at endmem
      https://git.pengutronix.de/cgit/barebox/commit/?id=dc7419a068d6 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-01 13:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-01 10:08 [PATCH master] ARM: fix OP-TEE DT reservation clashing with barebox area at endmem Ahmad Fatoum
2024-07-01 13:27 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox