[v5,02/16] powerpc: Override __ALIGN and __ALIGN_STR macros

Message ID 20221028143346.183569-3-sv@linux.ibm.com
State New
Headers
Series objtool: Enable and implement --mcount option on powerpc |

Commit Message

Sathvika Vasireddy Oct. 28, 2022, 2:33 p.m. UTC
  In a subsequent patch, we would want to annotate powerpc assembly functions
with SYM_FUNC_START_LOCAL macro. This macro depends on __ALIGN macro.

The default expansion of __ALIGN macro is:
        #define __ALIGN      .align 4,0x90

So, override __ALIGN and __ALIGN_STR macros to use the same alignment as
that of the existing _GLOBAL macro. Also, do not pad with 0x90, because
repeated 0x90s are not a nop or trap on powerpc.

Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/include/asm/linkage.h | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Christophe Leroy Nov. 2, 2022, 12:35 p.m. UTC | #1
Le 28/10/2022 à 16:33, Sathvika Vasireddy a écrit :
> In a subsequent patch, we would want to annotate powerpc assembly functions
> with SYM_FUNC_START_LOCAL macro. This macro depends on __ALIGN macro.
> 
> The default expansion of __ALIGN macro is:
>          #define __ALIGN      .align 4,0x90
> 
> So, override __ALIGN and __ALIGN_STR macros to use the same alignment as
> that of the existing _GLOBAL macro. Also, do not pad with 0x90, because
> repeated 0x90s are not a nop or trap on powerpc.

By the way, do we know what the instruction 0x90909090 is on powerpc ? 
Is that something valid or not ?

> 
> Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   arch/powerpc/include/asm/linkage.h | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
> index b71b9582e754..b88d1d2cf304 100644
> --- a/arch/powerpc/include/asm/linkage.h
> +++ b/arch/powerpc/include/asm/linkage.h
> @@ -4,6 +4,9 @@
>   
>   #include <asm/types.h>
>   
> +#define __ALIGN		.align 2
> +#define __ALIGN_STR	".align 2"
> +
>   #ifdef CONFIG_PPC64_ELF_ABI_V1
>   #define cond_syscall(x) \
>   	asm ("\t.weak " #x "\n\t.set " #x ", sys_ni_syscall\n"		\
  
Michael Ellerman Nov. 3, 2022, 12:01 a.m. UTC | #2
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 28/10/2022 à 16:33, Sathvika Vasireddy a écrit :
>> In a subsequent patch, we would want to annotate powerpc assembly functions
>> with SYM_FUNC_START_LOCAL macro. This macro depends on __ALIGN macro.
>> 
>> The default expansion of __ALIGN macro is:
>>          #define __ALIGN      .align 4,0x90
>> 
>> So, override __ALIGN and __ALIGN_STR macros to use the same alignment as
>> that of the existing _GLOBAL macro. Also, do not pad with 0x90, because
>> repeated 0x90s are not a nop or trap on powerpc.
>
> By the way, do we know what the instruction 0x90909090 is on powerpc ? 
> Is that something valid or not ?

According to objdump it's:

stw     r4,-28528(r16)

cheers
  
Peter Zijlstra Nov. 3, 2022, 8:48 a.m. UTC | #3
On Wed, Nov 02, 2022 at 12:35:07PM +0000, Christophe Leroy wrote:
> 
> 
> Le 28/10/2022 à 16:33, Sathvika Vasireddy a écrit :
> > In a subsequent patch, we would want to annotate powerpc assembly functions
> > with SYM_FUNC_START_LOCAL macro. This macro depends on __ALIGN macro.
> > 
> > The default expansion of __ALIGN macro is:
> >          #define __ALIGN      .align 4,0x90
> > 
> > So, override __ALIGN and __ALIGN_STR macros to use the same alignment as
> > that of the existing _GLOBAL macro. Also, do not pad with 0x90, because
> > repeated 0x90s are not a nop or trap on powerpc.
> 
> By the way, do we know what the instruction 0x90909090 is on powerpc ? 
> Is that something valid or not ?

Please also look at the version that's in tip/x86/core (and next). This
stuff should be gone now.

include/linux/linkage.h now reads like:

#ifndef __ALIGN
#define __ALIGN                 .balign CONFIG_FUNCTION_ALIGNMENT
#define __ALIGN_STR             __stringify(__ALIGN)
#endif
  
Sathvika Vasireddy Nov. 14, 2022, 3:48 a.m. UTC | #4
Hi Peter,

On 03/11/22 14:18, Peter Zijlstra wrote:
> On Wed, Nov 02, 2022 at 12:35:07PM +0000, Christophe Leroy wrote:
>>
>> Le 28/10/2022 à 16:33, Sathvika Vasireddy a écrit :
>>> In a subsequent patch, we would want to annotate powerpc assembly functions
>>> with SYM_FUNC_START_LOCAL macro. This macro depends on __ALIGN macro.
>>>
>>> The default expansion of __ALIGN macro is:
>>>           #define __ALIGN      .align 4,0x90
>>>
>>> So, override __ALIGN and __ALIGN_STR macros to use the same alignment as
>>> that of the existing _GLOBAL macro. Also, do not pad with 0x90, because
>>> repeated 0x90s are not a nop or trap on powerpc.
>> By the way, do we know what the instruction 0x90909090 is on powerpc ?
>> Is that something valid or not ?
> Please also look at the version that's in tip/x86/core (and next). This
> stuff should be gone now.
>
> include/linux/linkage.h now reads like:
>
> #ifndef __ALIGN
> #define __ALIGN                 .balign CONFIG_FUNCTION_ALIGNMENT
> #define __ALIGN_STR             __stringify(__ALIGN)
> #endif

Since the above mentioned changes are not a part of powerpc/merge branch 
yet, I am retaining this patch for this merge cycle and will post a 
cleanup patch (to move to using FUNCTION_ALIGNMENT_4B) after the next -rc1.

Thanks,
Sathvika
  

Patch

diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
index b71b9582e754..b88d1d2cf304 100644
--- a/arch/powerpc/include/asm/linkage.h
+++ b/arch/powerpc/include/asm/linkage.h
@@ -4,6 +4,9 @@ 
 
 #include <asm/types.h>
 
+#define __ALIGN		.align 2
+#define __ALIGN_STR	".align 2"
+
 #ifdef CONFIG_PPC64_ELF_ABI_V1
 #define cond_syscall(x) \
 	asm ("\t.weak " #x "\n\t.set " #x ", sys_ni_syscall\n"		\