diff mbox series

objtool: replace _ASM_PTR with quad in macros

Message ID 20220823133124.55914-1-chenzhongjin@huawei.com (mailing list archive)
State Handled Elsewhere
Headers show
Series objtool: replace _ASM_PTR with quad in macros | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_perf success Successfully ran 10 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 23 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.

Commit Message

Chen Zhongjin Aug. 23, 2022, 1:31 p.m. UTC
Macros STACK_FRAME_NON_STANDARD and ANNOTATE_NOENDBR uses
_ASM_PTR. It switch between .long and .quad based on 32bit
or 64bit. However objtool doesn't work for 32bit, so _ASM_PTR
makes no sense.

Considering that _ASM_PTR comes from asm.h, which is x86
specific head file, while objtool.h is generic. Replace
_ASM_PTR with quad and remove asm.h reference.

Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
---
 include/linux/objtool.h       | 6 ++----
 tools/include/linux/objtool.h | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

Comments

Christophe Leroy Aug. 23, 2022, 4:47 p.m. UTC | #1
Le 23/08/2022 à 15:31, Chen Zhongjin a écrit :
> Macros STACK_FRAME_NON_STANDARD and ANNOTATE_NOENDBR uses
> _ASM_PTR. It switch between .long and .quad based on 32bit
> or 64bit. However objtool doesn't work for 32bit, so _ASM_PTR
> makes no sense.
> 
> Considering that _ASM_PTR comes from asm.h, which is x86
> specific head file, while objtool.h is generic. Replace
> _ASM_PTR with quad and remove asm.h reference.

objtool is about to be used on powerpc on both PPC32 and PPC64, see 
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=312955&state=*

So if this part is meant to be used by all architectures, we need 
nothing that also works on 32 bits, don't we ?

Christophe


> 
> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
> ---
>   include/linux/objtool.h       | 6 ++----
>   tools/include/linux/objtool.h | 6 ++----
>   2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/objtool.h b/include/linux/objtool.h
> index 62c54ffbeeaa..d2413cb78037 100644
> --- a/include/linux/objtool.h
> +++ b/include/linux/objtool.h
> @@ -45,8 +45,6 @@ struct unwind_hint {
>   
>   #ifdef CONFIG_OBJTOOL
>   
> -#include <asm/asm.h>
> -
>   #ifndef __ASSEMBLY__
>   
>   #define UNWIND_HINT(sp_reg, sp_offset, type, end)		\
> @@ -87,7 +85,7 @@ struct unwind_hint {
>   #define ANNOTATE_NOENDBR					\
>   	"986: \n\t"						\
>   	".pushsection .discard.noendbr\n\t"			\
> -	_ASM_PTR " 986b\n\t"					\
> +	".quad 986b\n\t"					\
>   	".popsection\n\t"
>   
>   #define ASM_REACHABLE							\
> @@ -144,7 +142,7 @@ struct unwind_hint {
>   
>   .macro STACK_FRAME_NON_STANDARD func:req
>   	.pushsection .discard.func_stack_frame_non_standard, "aw"
> -	_ASM_PTR \func
> +	.quad \func
>   	.popsection
>   .endm
>   
> diff --git a/tools/include/linux/objtool.h b/tools/include/linux/objtool.h
> index 62c54ffbeeaa..d2413cb78037 100644
> --- a/tools/include/linux/objtool.h
> +++ b/tools/include/linux/objtool.h
> @@ -45,8 +45,6 @@ struct unwind_hint {
>   
>   #ifdef CONFIG_OBJTOOL
>   
> -#include <asm/asm.h>
> -
>   #ifndef __ASSEMBLY__
>   
>   #define UNWIND_HINT(sp_reg, sp_offset, type, end)		\
> @@ -87,7 +85,7 @@ struct unwind_hint {
>   #define ANNOTATE_NOENDBR					\
>   	"986: \n\t"						\
>   	".pushsection .discard.noendbr\n\t"			\
> -	_ASM_PTR " 986b\n\t"					\
> +	".quad 986b\n\t"					\
>   	".popsection\n\t"
>   
>   #define ASM_REACHABLE							\
> @@ -144,7 +142,7 @@ struct unwind_hint {
>   
>   .macro STACK_FRAME_NON_STANDARD func:req
>   	.pushsection .discard.func_stack_frame_non_standard, "aw"
> -	_ASM_PTR \func
> +	.quad \func
>   	.popsection
>   .endm
>
Chen Zhongjin Aug. 24, 2022, 2:06 a.m. UTC | #2
On 2022/8/24 0:47, Christophe Leroy wrote:
>
> Le 23/08/2022 à 15:31, Chen Zhongjin a écrit :
>> Macros STACK_FRAME_NON_STANDARD and ANNOTATE_NOENDBR uses
>> _ASM_PTR. It switch between .long and .quad based on 32bit
>> or 64bit. However objtool doesn't work for 32bit, so _ASM_PTR
>> makes no sense.
>>
>> Considering that _ASM_PTR comes from asm.h, which is x86
>> specific head file, while objtool.h is generic. Replace
>> _ASM_PTR with quad and remove asm.h reference.
> objtool is about to be used on powerpc on both PPC32 and PPC64, see
> https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=312955&state=*
>
> So if this part is meant to be used by all architectures, we need
> nothing that also works on 32 bits, don't we ?
>
> Christophe
>
ANNOTATE_NOENDBR affects nothing because it's for x86 IBT. Leaving this 
macro here is harmless now, but I think maybe it's better to move this 
to arch-specific.

The problem is STACK_FRAME_NON_STANDARD. The C version macro uses 
function pointer so the reloc symbol type can change between 32 and 64 bit.

Although I think quad is workable for both 32 and 64 bit, and this macro 
is .discard so it won't affect something else, but it may not keep reloc 
symbol type consistency.


Anyway, NO _ASM_PTR and asm.h, they are arch-specific and will break 
compiling on other arches.


Maybe we should create a macro similar to _ASM_PTR for other arches. 
Till now I didn't find one.

I'll send v2 patch to make this and Peter can judge.


Best,

Chen

>> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
>> ---
>>    include/linux/objtool.h       | 6 ++----
>>    tools/include/linux/objtool.h | 6 ++----
>>    2 files changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/include/linux/objtool.h b/include/linux/objtool.h
>> index 62c54ffbeeaa..d2413cb78037 100644
>> --- a/include/linux/objtool.h
>> +++ b/include/linux/objtool.h
>> @@ -45,8 +45,6 @@ struct unwind_hint {
>>    
>>    #ifdef CONFIG_OBJTOOL
>>    
>> -#include <asm/asm.h>
>> -
>>    #ifndef __ASSEMBLY__
>>    
>>    #define UNWIND_HINT(sp_reg, sp_offset, type, end)		\
>> @@ -87,7 +85,7 @@ struct unwind_hint {
>>    #define ANNOTATE_NOENDBR					\
>>    	"986: \n\t"						\
>>    	".pushsection .discard.noendbr\n\t"			\
>> -	_ASM_PTR " 986b\n\t"					\
>> +	".quad 986b\n\t"					\
>>    	".popsection\n\t"
>>    
>>    #define ASM_REACHABLE							\
>> @@ -144,7 +142,7 @@ struct unwind_hint {
>>    
>>    .macro STACK_FRAME_NON_STANDARD func:req
>>    	.pushsection .discard.func_stack_frame_non_standard, "aw"
>> -	_ASM_PTR \func
>> +	.quad \func
>>    	.popsection
>>    .endm
>>    
>> diff --git a/tools/include/linux/objtool.h b/tools/include/linux/objtool.h
>> index 62c54ffbeeaa..d2413cb78037 100644
>> --- a/tools/include/linux/objtool.h
>> +++ b/tools/include/linux/objtool.h
>> @@ -45,8 +45,6 @@ struct unwind_hint {
>>    
>>    #ifdef CONFIG_OBJTOOL
>>    
>> -#include <asm/asm.h>
>> -
>>    #ifndef __ASSEMBLY__
>>    
>>    #define UNWIND_HINT(sp_reg, sp_offset, type, end)		\
>> @@ -87,7 +85,7 @@ struct unwind_hint {
>>    #define ANNOTATE_NOENDBR					\
>>    	"986: \n\t"						\
>>    	".pushsection .discard.noendbr\n\t"			\
>> -	_ASM_PTR " 986b\n\t"					\
>> +	".quad 986b\n\t"					\
>>    	".popsection\n\t"
>>    
>>    #define ASM_REACHABLE							\
>> @@ -144,7 +142,7 @@ struct unwind_hint {
>>    
>>    .macro STACK_FRAME_NON_STANDARD func:req
>>    	.pushsection .discard.func_stack_frame_non_standard, "aw"
>> -	_ASM_PTR \func
>> +	.quad \func
>>    	.popsection
>>    .endm
>>
Chen Zhongjin Aug. 24, 2022, 2:48 a.m. UTC | #3
On 2022/8/23 21:31, Chen Zhongjin wrote:
> Macros STACK_FRAME_NON_STANDARD and ANNOTATE_NOENDBR uses
> _ASM_PTR. It switch between .long and .quad based on 32bit
> or 64bit. However objtool doesn't work for 32bit, so _ASM_PTR
> makes no sense.
>
> Considering that _ASM_PTR comes from asm.h, which is x86
> specific head file, while objtool.h is generic. Replace
> _ASM_PTR with quad and remove asm.h reference.
>
> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
> ---
>   include/linux/objtool.h       | 6 ++----
>   tools/include/linux/objtool.h | 6 ++----
>   2 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/objtool.h b/include/linux/objtool.h
> index 62c54ffbeeaa..d2413cb78037 100644
> --- a/include/linux/objtool.h
> +++ b/include/linux/objtool.h
> @@ -45,8 +45,6 @@ struct unwind_hint {
>   
>   #ifdef CONFIG_OBJTOOL
>   
> -#include <asm/asm.h>
> -
>   #ifndef __ASSEMBLY__
>   
>   #define UNWIND_HINT(sp_reg, sp_offset, type, end)		\
> @@ -87,7 +85,7 @@ struct unwind_hint {
>   #define ANNOTATE_NOENDBR					\
>   	"986: \n\t"						\
>   	".pushsection .discard.noendbr\n\t"			\
> -	_ASM_PTR " 986b\n\t"					\
> +	".quad 986b\n\t"					\
>   	".popsection\n\t"
>   
>   #define ASM_REACHABLE							\
> @@ -144,7 +142,7 @@ struct unwind_hint {
>   
>   .macro STACK_FRAME_NON_STANDARD func:req
>   	.pushsection .discard.func_stack_frame_non_standard, "aw"
> -	_ASM_PTR \func
> +	.quad \func
>   	.popsection
>   .endm
>   
> diff --git a/tools/include/linux/objtool.h b/tools/include/linux/objtool.h
> index 62c54ffbeeaa..d2413cb78037 100644
> --- a/tools/include/linux/objtool.h
> +++ b/tools/include/linux/objtool.h
> @@ -45,8 +45,6 @@ struct unwind_hint {
>   
>   #ifdef CONFIG_OBJTOOL
>   
> -#include <asm/asm.h>
> -
>   #ifndef __ASSEMBLY__
>   
>   #define UNWIND_HINT(sp_reg, sp_offset, type, end)		\
> @@ -87,7 +85,7 @@ struct unwind_hint {
>   #define ANNOTATE_NOENDBR					\
>   	"986: \n\t"						\
>   	".pushsection .discard.noendbr\n\t"			\
> -	_ASM_PTR " 986b\n\t"					\
> +	".quad 986b\n\t"					\
>   	".popsection\n\t"
>   
>   #define ASM_REACHABLE							\
> @@ -144,7 +142,7 @@ struct unwind_hint {
>   
>   .macro STACK_FRAME_NON_STANDARD func:req
>   	.pushsection .discard.func_stack_frame_non_standard, "aw"
> -	_ASM_PTR \func
> +	.quad \func
>   	.popsection
>   .endm
>   

As ppc said they will use objtool for both 32 and 64bit, maybe we still 
need a switchable symbol type for this.

How about this one?


diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index 62c54ffbeeaa..14af2bcc460b 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -45,10 +45,14 @@ struct unwind_hint {

  #ifdef CONFIG_OBJTOOL

-#include <asm/asm.h>
-
  #ifndef __ASSEMBLY__

+#ifdef CONFIG_64BIT
+#define _RELOC_PTR __stringify(.quad)
+#else
+#define _RELOC_PTR __stringify(.long)
+#endif
+
  #define UNWIND_HINT(sp_reg, sp_offset, type, end)              \
         "987: \n\t"                                             \
         ".pushsection .discard.unwind_hints\n\t"                \
@@ -87,7 +91,7 @@ struct unwind_hint {
  #define ANNOTATE_NOENDBR                                       \
         "986: \n\t"                                             \
         ".pushsection .discard.noendbr\n\t"                     \
-       _ASM_PTR " 986b\n\t"                                    \
+       _RELOC_PTR " 986b\n\t"                                  \
         ".popsection\n\t"

  #define ASM_REACHABLE                                                  \
@@ -98,6 +102,12 @@ struct unwind_hint {

  #else /* __ASSEMBLY__ */

+#ifdef CONFIG_64BIT
+#define _RELOC_PTR .quad
+#else
+#define _RELOC_PTR .long
+#endif
+
  /*
   * This macro indicates that the following intra-function call is valid.
   * Any non-annotated intra-function call will cause objtool to issue a 
warning.
@@ -144,7 +154,7 @@ struct unwind_hint {

  .macro STACK_FRAME_NON_STANDARD func:req
         .pushsection .discard.func_stack_frame_non_standard, "aw"
-       _ASM_PTR \func
+       _RELOC_PTR \func
         .popsection
  .endm
diff mbox series

Patch

diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index 62c54ffbeeaa..d2413cb78037 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -45,8 +45,6 @@  struct unwind_hint {
 
 #ifdef CONFIG_OBJTOOL
 
-#include <asm/asm.h>
-
 #ifndef __ASSEMBLY__
 
 #define UNWIND_HINT(sp_reg, sp_offset, type, end)		\
@@ -87,7 +85,7 @@  struct unwind_hint {
 #define ANNOTATE_NOENDBR					\
 	"986: \n\t"						\
 	".pushsection .discard.noendbr\n\t"			\
-	_ASM_PTR " 986b\n\t"					\
+	".quad 986b\n\t"					\
 	".popsection\n\t"
 
 #define ASM_REACHABLE							\
@@ -144,7 +142,7 @@  struct unwind_hint {
 
 .macro STACK_FRAME_NON_STANDARD func:req
 	.pushsection .discard.func_stack_frame_non_standard, "aw"
-	_ASM_PTR \func
+	.quad \func
 	.popsection
 .endm
 
diff --git a/tools/include/linux/objtool.h b/tools/include/linux/objtool.h
index 62c54ffbeeaa..d2413cb78037 100644
--- a/tools/include/linux/objtool.h
+++ b/tools/include/linux/objtool.h
@@ -45,8 +45,6 @@  struct unwind_hint {
 
 #ifdef CONFIG_OBJTOOL
 
-#include <asm/asm.h>
-
 #ifndef __ASSEMBLY__
 
 #define UNWIND_HINT(sp_reg, sp_offset, type, end)		\
@@ -87,7 +85,7 @@  struct unwind_hint {
 #define ANNOTATE_NOENDBR					\
 	"986: \n\t"						\
 	".pushsection .discard.noendbr\n\t"			\
-	_ASM_PTR " 986b\n\t"					\
+	".quad 986b\n\t"					\
 	".popsection\n\t"
 
 #define ASM_REACHABLE							\
@@ -144,7 +142,7 @@  struct unwind_hint {
 
 .macro STACK_FRAME_NON_STANDARD func:req
 	.pushsection .discard.func_stack_frame_non_standard, "aw"
-	_ASM_PTR \func
+	.quad \func
 	.popsection
 .endm