* [PATCH 0/2] arm: socfpga: agilex5: fix stack in entry function
@ 2026-05-13 12:22 Michael Tretter
2026-05-13 12:22 ` [PATCH 1/2] arm: socfpga: axe5-eagle: fix stack location Michael Tretter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael Tretter @ 2026-05-13 12:22 UTC (permalink / raw)
To: Sascha Hauer, BAREBOX; +Cc: Steffen Trumtrar, Michael Tretter
The entry function for the Arrow AXE5 Eagle board places the stack at
the end of the OCRAM. However, the board firmware uses the same page for
handoff data for barebox, which is read after barebox is already
running. This may cause data corruption if the stack grows into the
handoff data.
Patch 1 fixes the stack location for the Arrow AXE5 Eagle board to avoid
corrupting the handoff data.
Patch 2 adds a ENTRY_FUNCTION_AGILEX5 macro, which uses the fixed
address for the stack and may be used by Agilex 5 based board. The
address for the stack in OCRAM is SoC specific and specifying it per
board is unnecessary and error prone.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
Michael Tretter (2):
arm: socfpga: axe5-eagle: fix stack location
arm: socfpga: agilex5: add helper for entry function
arch/arm/boards/arrow-axe5-eagle/lowlevel.c | 5 ++---
include/mach/socfpga/barebox-arm.h | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
---
base-commit: 2cb5e0014a37160731ad6eb6d7f7d846394db362
change-id: 20260513-socfpga-agilex5-entry-890604ad08c9
Best regards,
--
Michael Tretter <m.tretter@pengutronix.de>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] arm: socfpga: axe5-eagle: fix stack location
2026-05-13 12:22 [PATCH 0/2] arm: socfpga: agilex5: fix stack in entry function Michael Tretter
@ 2026-05-13 12:22 ` Michael Tretter
2026-05-13 12:22 ` [PATCH 2/2] arm: socfpga: agilex5: add helper for entry function Michael Tretter
2026-05-13 14:07 ` [PATCH 0/2] arm: socfpga: agilex5: fix stack in " Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Michael Tretter @ 2026-05-13 12:22 UTC (permalink / raw)
To: Sascha Hauer, BAREBOX; +Cc: Steffen Trumtrar, Michael Tretter
512K is the end of the OCRAM. THE SDM firmware uses the last page of the
OCRAM for handoff data, which is later read by barebox to retrieve board
configuration. Putting the stack on the same page may be dangerous and
lead to data corruption.
Move the stack below the handoff data.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
arch/arm/boards/arrow-axe5-eagle/lowlevel.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boards/arrow-axe5-eagle/lowlevel.c b/arch/arm/boards/arrow-axe5-eagle/lowlevel.c
index ffa5620413f6..b5a56a1a8c5f 100644
--- a/arch/arm/boards/arrow-axe5-eagle/lowlevel.c
+++ b/arch/arm/boards/arrow-axe5-eagle/lowlevel.c
@@ -8,11 +8,19 @@
#include <mach/socfpga/debug_ll.h>
#include <mach/socfpga/init.h>
#include <mach/socfpga/generic.h>
+#include <mach/socfpga/soc64-handoff.h>
#include <mach/socfpga/soc64-regs.h>
extern char __dtb_z_socfpga_agilex5_axe5_eagle_start[];
-#define AXE5_STACKTOP (SZ_512K)
+/*
+ * The SDM firmware uses the last page in the OCRAM for handoff data. Put the
+ * stack below the handoff data.
+ *
+ * Note: U-Boot puts the stack at 0x71000 (0x80000 - 0xf000) and reserves even
+ * more space.
+ */
+#define AXE5_STACKTOP SOC64_HANDOFF_BASE
static noinline void axe5_eagle_continue(void)
{
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] arm: socfpga: agilex5: add helper for entry function
2026-05-13 12:22 [PATCH 0/2] arm: socfpga: agilex5: fix stack in entry function Michael Tretter
2026-05-13 12:22 ` [PATCH 1/2] arm: socfpga: axe5-eagle: fix stack location Michael Tretter
@ 2026-05-13 12:22 ` Michael Tretter
2026-05-13 14:07 ` [PATCH 0/2] arm: socfpga: agilex5: fix stack in " Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Michael Tretter @ 2026-05-13 12:22 UTC (permalink / raw)
To: Sascha Hauer, BAREBOX; +Cc: Steffen Trumtrar, Michael Tretter
The entry function is useful for all Agilex 5 based boards and its easy
to get the stack location wrong.
Add a helper function that does the right thing for Agilex 5 and avoid
defining the stack location for every board.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
arch/arm/boards/arrow-axe5-eagle/lowlevel.c | 13 ++-----------
include/mach/socfpga/barebox-arm.h | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/arch/arm/boards/arrow-axe5-eagle/lowlevel.c b/arch/arm/boards/arrow-axe5-eagle/lowlevel.c
index b5a56a1a8c5f..de5a14b2d503 100644
--- a/arch/arm/boards/arrow-axe5-eagle/lowlevel.c
+++ b/arch/arm/boards/arrow-axe5-eagle/lowlevel.c
@@ -5,23 +5,14 @@
#include <asm/barebox-arm.h>
#include <asm/system.h>
#include <pbl.h>
+#include <mach/socfpga/barebox-arm.h>
#include <mach/socfpga/debug_ll.h>
#include <mach/socfpga/init.h>
#include <mach/socfpga/generic.h>
-#include <mach/socfpga/soc64-handoff.h>
#include <mach/socfpga/soc64-regs.h>
extern char __dtb_z_socfpga_agilex5_axe5_eagle_start[];
-/*
- * The SDM firmware uses the last page in the OCRAM for handoff data. Put the
- * stack below the handoff data.
- *
- * Note: U-Boot puts the stack at 0x71000 (0x80000 - 0xf000) and reserves even
- * more space.
- */
-#define AXE5_STACKTOP SOC64_HANDOFF_BASE
-
static noinline void axe5_eagle_continue(void)
{
agilex5_clk_init();
@@ -52,7 +43,7 @@ static noinline void axe5_eagle_continue(void)
agilex5_barebox_entry(__dtb_z_socfpga_agilex5_axe5_eagle_start);
}
-ENTRY_FUNCTION_WITHSTACK(start_socfpga_agilex5_axe5_eagle, AXE5_STACKTOP, r0, r1, r2)
+ENTRY_FUNCTION_AGILEX5(start_socfpga_agilex5_axe5_eagle)
{
if (current_el() == 3)
socfpga_agilex5_cpu_lowlevel_init();
diff --git a/include/mach/socfpga/barebox-arm.h b/include/mach/socfpga/barebox-arm.h
new file mode 100644
index 000000000000..60c9ddabea23
--- /dev/null
+++ b/include/mach/socfpga/barebox-arm.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef SOCFPGA_BAREBOX_ARM_H_
+#define SOCFPGA_BAREBOX_ARM_H_
+
+#include <asm/barebox-arm.h>
+#include <mach/socfpga/soc64-handoff.h>
+
+/*
+ * The SDM firmware uses the last page in the OCRAM for handoff data. Put the
+ * stack below the handoff data.
+ *
+ * Note: U-Boot puts the stack at 0x71000 (0x80000 - 0xf000) and reserves even
+ * more space.
+ */
+#define AGILEX5_STACKTOP SOC64_HANDOFF_BASE
+
+#define ENTRY_FUNCTION_AGILEX5(name) \
+ ENTRY_FUNCTION_WITHSTACK(name, AGILEX5_STACKTOP, r0, r1, r2)
+
+#endif
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] arm: socfpga: agilex5: fix stack in entry function
2026-05-13 12:22 [PATCH 0/2] arm: socfpga: agilex5: fix stack in entry function Michael Tretter
2026-05-13 12:22 ` [PATCH 1/2] arm: socfpga: axe5-eagle: fix stack location Michael Tretter
2026-05-13 12:22 ` [PATCH 2/2] arm: socfpga: agilex5: add helper for entry function Michael Tretter
@ 2026-05-13 14:07 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2026-05-13 14:07 UTC (permalink / raw)
To: BAREBOX, Michael Tretter; +Cc: Steffen Trumtrar
On Wed, 13 May 2026 14:22:21 +0200, Michael Tretter wrote:
> The entry function for the Arrow AXE5 Eagle board places the stack at
> the end of the OCRAM. However, the board firmware uses the same page for
> handoff data for barebox, which is read after barebox is already
> running. This may cause data corruption if the stack grows into the
> handoff data.
>
> Patch 1 fixes the stack location for the Arrow AXE5 Eagle board to avoid
> corrupting the handoff data.
>
> [...]
Applied, thanks!
[1/2] arm: socfpga: axe5-eagle: fix stack location
https://git.pengutronix.de/cgit/barebox/commit/?id=f566c8ecc9af (link may not be stable)
[2/2] arm: socfpga: agilex5: add helper for entry function
https://git.pengutronix.de/cgit/barebox/commit/?id=d5840df6ff29 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-13 15:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-13 12:22 [PATCH 0/2] arm: socfpga: agilex5: fix stack in entry function Michael Tretter
2026-05-13 12:22 ` [PATCH 1/2] arm: socfpga: axe5-eagle: fix stack location Michael Tretter
2026-05-13 12:22 ` [PATCH 2/2] arm: socfpga: agilex5: add helper for entry function Michael Tretter
2026-05-13 14:07 ` [PATCH 0/2] arm: socfpga: agilex5: fix stack in " Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox