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] fixup! ARM: add exception handling support for PBL
Date: Wed,  9 Jul 2025 12:12:49 +0200	[thread overview]
Message-ID: <20250709101249.4025552-1-a.fatoum@pengutronix.de> (raw)

ARM: interrupts: fix guard page linker error in PBL

We set up the stack guard page only in barebox proper. Attempting to
compile in support in barebox PBL leads to a compile error, because
arm_mem_guard_page_get() references arm_mem_endmem_get(), which is not
available.

Fix this by defining and using a new helper that always returns skips
referencing arm_mem_endmem_get when not IN_PROPER.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/cpu/interrupts_32.c       | 10 ++--------
 arch/arm/cpu/interrupts_64.c       | 10 ++--------
 arch/arm/include/asm/barebox-arm.h | 12 ++++++++++++
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/arm/cpu/interrupts_32.c b/arch/arm/cpu/interrupts_32.c
index cd503b38eeea..b8b9210197ea 100644
--- a/arch/arm/cpu/interrupts_32.c
+++ b/arch/arm/cpu/interrupts_32.c
@@ -111,16 +111,10 @@ void do_prefetch_abort (struct pt_regs *pt_regs)
 
 static const char *data_abort_reason(ulong far)
 {
-	ulong guard_page;
-
 	if (far < PAGE_SIZE)
 		return "NULL pointer dereference";
-
-	if (IS_ENABLED(CONFIG_STACK_GUARD_PAGE)) {
-		guard_page = arm_mem_guard_page_get();
-		if (guard_page <= far && far < guard_page + PAGE_SIZE)
-			return "stack overflow";
-	}
+	if (inside_stack_guard_page(far))
+		return "stack overflow";
 
 	return "paging request";
 }
diff --git a/arch/arm/cpu/interrupts_64.c b/arch/arm/cpu/interrupts_64.c
index 574ab6a7ec22..b4787783978e 100644
--- a/arch/arm/cpu/interrupts_64.c
+++ b/arch/arm/cpu/interrupts_64.c
@@ -147,16 +147,10 @@ extern volatile int arm_data_abort_occurred;
 
 static const char *data_abort_reason(ulong far)
 {
-	ulong guard_page;
-
 	if (far < PAGE_SIZE)
 		return "NULL pointer dereference: ";
-
-	if (IS_ENABLED(CONFIG_STACK_GUARD_PAGE)) {
-		guard_page = arm_mem_guard_page_get();
-		if (guard_page <= far && far < guard_page + PAGE_SIZE)
-			return "Stack overflow: ";
-	}
+	if (inside_stack_guard_page(far))
+		return "Stack overflow: ";
 
 	return NULL;
 }
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 0abdd297a2ce..da6f5d528338 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -167,6 +167,18 @@ static inline unsigned long arm_mem_guard_page_get(void)
 	return arm_mem_guard_page(arm_mem_endmem_get());
 }
 
+static inline bool inside_stack_guard_page(ulong addr)
+{
+	if (IS_ENABLED(CONFIG_STACK_GUARD_PAGE) && IN_PROPER) {
+		ulong guard_page = arm_mem_guard_page_get();
+
+		if (guard_page <= addr && addr < guard_page + PAGE_SIZE)
+			return true;
+	}
+
+	return false;
+}
+
 /*
  * When using compressed images in conjunction with relocatable images
  * the PBL code must pick a suitable place where to uncompress the barebox
-- 
2.39.5




                 reply	other threads:[~2025-07-09 12:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250709101249.4025552-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