From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: ore@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master v3 1/3] ARM: asm: fix miscompilation of 32-bit ENTRY_FUNCTION_WITHSTACK
Date: Mon, 25 Apr 2022 11:48:55 +0200 [thread overview]
Message-ID: <20220425094857.674044-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220425094857.674044-1-a.fatoum@pengutronix.de>
gcc-11.1.1 shipped with OSELAS.Toolchain-2021.07.0 hoists a single
instruction from __ARM_SETUP_STACK in front of __barebox_arm_head
breaking the barebox header format for the Raspberry Pi 3. This can't
happen with ARM64 and the Raspberry Pi entry points are currently the
only 32-bit users.
While the resulting barebox image was still bootable, header detection
would fail. Add an intermediate naked function for arm32 to work around
this.
This is not required for plain ENTRY_FUNCTION, because the
board-supplied entry point is already NAKED. For
ENTRY_FUNCTION_WITH_FUNCTION, that naked entry point is moved
to arch code intentionally to reduce pitfalls for board code authors..
Fixes: 880c9803b95a ("ARM: implement ENTRY_FUNCTION_WITHSTACK")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/include/asm/barebox-arm.h | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index d915cde294a4..15b3b6c44479 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -190,12 +190,13 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
* Stack top of 0 means stack is already set up. In that case, the follow-up
* code block will not be inlined and may spill to stack right away.
*/
+#ifdef CONFIG_CPU_64
#define ENTRY_FUNCTION_WITHSTACK(name, stack_top, arg0, arg1, arg2) \
void name(ulong r0, ulong r1, ulong r2); \
\
static void __##name(ulong, ulong, ulong); \
\
- void NAKED __section(.text_head_entry_##name) name \
+ void __section(.text_head_entry_##name) name \
(ulong r0, ulong r1, ulong r2) \
{ \
__barebox_arm_head(); \
@@ -204,6 +205,17 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
} \
static void noinline __##name \
(ulong arg0, ulong arg1, ulong arg2)
+#else
+#define ENTRY_FUNCTION_WITHSTACK(name, stack_top, arg0, arg1, arg2) \
+ static void ____##name(ulong, ulong, ulong); \
+ ENTRY_FUNCTION(name, arg0, arg1, arg2) \
+ { \
+ __ARM_SETUP_STACK(stack_top); \
+ ____##name(arg0, arg1, arg2); \
+ } \
+ static void noinline ____##name \
+ (ulong arg0, ulong arg1, ulong arg2)
+#endif
#define ENTRY_FUNCTION(name, arg0, arg1, arg2) \
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2022-04-25 9:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-25 9:48 [PATCH master v3 0/3] ARM: rpi3: fix misc recent breakage Ahmad Fatoum
2022-04-25 9:48 ` Ahmad Fatoum [this message]
2022-04-25 9:48 ` [PATCH master v3 2/3] clk: add BCM2835 auxiliary peripheral clock driver Ahmad Fatoum
2022-04-25 9:48 ` [PATCH master v3 3/3] clocksource: assign non-zero priorities to all clocksources Ahmad Fatoum
2022-04-25 10:35 ` [PATCH master v3 0/3] ARM: rpi3: fix misc recent breakage 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=20220425094857.674044-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=ore@pengutronix.de \
/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