mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: Fix barebox header generation on arm64
@ 2022-09-09  7:29 Sascha Hauer
  2022-09-09  7:43 ` Ahmad Fatoum
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2022-09-09  7:29 UTC (permalink / raw)
  To: Barebox List

When using multiple ENTRY_FUNCTION_WITH_STACK an entry_prologue
is emitted for each usage. The entry_proloues end up in the
same section and thus can't be discarded with the effect that the
barebox magic is at the wrong place. To fix this put the entry_prologues
in function specific sections so that the linker can discard the
unused ones.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/include/asm/barebox-arm.h | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 16f9882b5a..a34f77f2ab 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -21,6 +21,7 @@
 #include <asm/common.h>
 #include <asm/sections.h>
 #include <asm/reloc.h>
+#include <linux/stringify.h>
 
 /*
  * We have a 4GiB address space split into 1MiB sections, with each
@@ -137,23 +138,23 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
 
 #ifdef CONFIG_CPU_64
 
-#define ____emit_entry_prologue(instr, ...) do { \
-	static __attribute__ ((unused,section(".text_head_prologue"))) \
+#define ____emit_entry_prologue(name, instr, ...) do { \
+	static __attribute__ ((unused,section(".text_head_prologue_" __stringify(name)))) \
 		const u32 __entry_prologue[] = {(instr), ##__VA_ARGS__}; \
 	barrier_data(__entry_prologue); \
 } while(0)
 
-#define __emit_entry_prologue(instr1, instr2, instr3, instr4, instr5) \
-	____emit_entry_prologue(instr1, instr2, instr3, instr4, instr5)
+#define __emit_entry_prologue(name, instr1, instr2, instr3, instr4, instr5) \
+	____emit_entry_prologue(name, instr1, instr2, instr3, instr4, instr5)
 
-#define __ARM_SETUP_STACK(stack_top) \
-	__emit_entry_prologue(0x14000002	/* b pc+0x8 */,		\
+#define __ARM_SETUP_STACK(name, stack_top) \
+	__emit_entry_prologue(name, 0x14000002	/* b pc+0x8 */,		\
 			      stack_top		/* 32-bit literal */,	\
 			      0x18ffffe9	/* ldr w9, top */,	\
 			      0xb4000049	/* cbz x9, pc+0x8 */,	\
 			      0x9100013f	/* mov sp, x9 */)
 #else
-#define __ARM_SETUP_STACK(stack_top) if (stack_top) arm_setup_stack(stack_top)
+#define __ARM_SETUP_STACK(name, stack_top) if (stack_top) arm_setup_stack(stack_top)
 #endif
 
 /*
@@ -174,7 +175,7 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
 				(ulong r0, ulong r1, ulong r2)		\
 		{							\
 			__barebox_arm_head();				\
-			__ARM_SETUP_STACK(stack_top);			\
+			__ARM_SETUP_STACK(name, stack_top);		\
 			__##name(r0, r1, r2);				\
 		}							\
 		static void noinline __##name				\
@@ -184,7 +185,7 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
 	static void ____##name(ulong, ulong, ulong);			\
 	ENTRY_FUNCTION(name, arg0, arg1, arg2)				\
 	{								\
-		__ARM_SETUP_STACK(stack_top);				\
+		__ARM_SETUP_STACK(name, stack_top);			\
 		____##name(arg0, arg1, arg2);				\
 	}								\
 	static void noinline ____##name					\
@@ -201,7 +202,7 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
 				(ulong r0, ulong r1, ulong r2)		\
 		{							\
 			__barebox_arm_head();				\
-			__ARM_SETUP_STACK(0);				\
+			__ARM_SETUP_STACK(name, 0);			\
 			__##name(r0, r1, r2);				\
 		}							\
 		static void NAKED noinline __##name			\
-- 
2.30.2




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

* Re: [PATCH] ARM: Fix barebox header generation on arm64
  2022-09-09  7:29 [PATCH] ARM: Fix barebox header generation on arm64 Sascha Hauer
@ 2022-09-09  7:43 ` Ahmad Fatoum
  0 siblings, 0 replies; 2+ messages in thread
From: Ahmad Fatoum @ 2022-09-09  7:43 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List

On 09.09.22 09:29, Sascha Hauer wrote:
> When using multiple ENTRY_FUNCTION_WITH_STACK an entry_prologue
> is emitted for each usage. The entry_proloues end up in the

                                     ^ prologues

> same section and thus can't be discarded with the effect that the
> barebox magic is at the wrong place. To fix this put the entry_prologues
> in function specific sections so that the linker can discard the
> unused ones.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>


Thanks for fixing,
Ahmad

> ---
>  arch/arm/include/asm/barebox-arm.h | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
> index 16f9882b5a..a34f77f2ab 100644
> --- a/arch/arm/include/asm/barebox-arm.h
> +++ b/arch/arm/include/asm/barebox-arm.h
> @@ -21,6 +21,7 @@
>  #include <asm/common.h>
>  #include <asm/sections.h>
>  #include <asm/reloc.h>
> +#include <linux/stringify.h>
>  
>  /*
>   * We have a 4GiB address space split into 1MiB sections, with each
> @@ -137,23 +138,23 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
>  
>  #ifdef CONFIG_CPU_64
>  
> -#define ____emit_entry_prologue(instr, ...) do { \
> -	static __attribute__ ((unused,section(".text_head_prologue"))) \
> +#define ____emit_entry_prologue(name, instr, ...) do { \
> +	static __attribute__ ((unused,section(".text_head_prologue_" __stringify(name)))) \
>  		const u32 __entry_prologue[] = {(instr), ##__VA_ARGS__}; \
>  	barrier_data(__entry_prologue); \
>  } while(0)
>  
> -#define __emit_entry_prologue(instr1, instr2, instr3, instr4, instr5) \
> -	____emit_entry_prologue(instr1, instr2, instr3, instr4, instr5)
> +#define __emit_entry_prologue(name, instr1, instr2, instr3, instr4, instr5) \
> +	____emit_entry_prologue(name, instr1, instr2, instr3, instr4, instr5)
>  
> -#define __ARM_SETUP_STACK(stack_top) \
> -	__emit_entry_prologue(0x14000002	/* b pc+0x8 */,		\
> +#define __ARM_SETUP_STACK(name, stack_top) \
> +	__emit_entry_prologue(name, 0x14000002	/* b pc+0x8 */,		\
>  			      stack_top		/* 32-bit literal */,	\
>  			      0x18ffffe9	/* ldr w9, top */,	\
>  			      0xb4000049	/* cbz x9, pc+0x8 */,	\
>  			      0x9100013f	/* mov sp, x9 */)
>  #else
> -#define __ARM_SETUP_STACK(stack_top) if (stack_top) arm_setup_stack(stack_top)
> +#define __ARM_SETUP_STACK(name, stack_top) if (stack_top) arm_setup_stack(stack_top)
>  #endif
>  
>  /*
> @@ -174,7 +175,7 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
>  				(ulong r0, ulong r1, ulong r2)		\
>  		{							\
>  			__barebox_arm_head();				\
> -			__ARM_SETUP_STACK(stack_top);			\
> +			__ARM_SETUP_STACK(name, stack_top);		\
>  			__##name(r0, r1, r2);				\
>  		}							\
>  		static void noinline __##name				\
> @@ -184,7 +185,7 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
>  	static void ____##name(ulong, ulong, ulong);			\
>  	ENTRY_FUNCTION(name, arg0, arg1, arg2)				\
>  	{								\
> -		__ARM_SETUP_STACK(stack_top);				\
> +		__ARM_SETUP_STACK(name, stack_top);			\
>  		____##name(arg0, arg1, arg2);				\
>  	}								\
>  	static void noinline ____##name					\
> @@ -201,7 +202,7 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
>  				(ulong r0, ulong r1, ulong r2)		\
>  		{							\
>  			__barebox_arm_head();				\
> -			__ARM_SETUP_STACK(0);				\
> +			__ARM_SETUP_STACK(name, 0);			\
>  			__##name(r0, r1, r2);				\
>  		}							\
>  		static void NAKED noinline __##name			\


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2022-09-09  7:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09  7:29 [PATCH] ARM: Fix barebox header generation on arm64 Sascha Hauer
2022-09-09  7:43 ` Ahmad Fatoum

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