mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] ARM: fix OP-TEE DT reservation clashing with barebox area at endmem
Date: Mon,  1 Jul 2024 12:08:59 +0200	[thread overview]
Message-ID: <20240701100859.3876429-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2024-07-01 10:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 10:08 Ahmad Fatoum [this message]
2024-07-01 13:27 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240701100859.3876429-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox