All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/16] objtool: Enable and implement --mcount option on powerpc
@ 2022-08-29  5:52 ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

This patchset enables and implements objtool --mcount
option on powerpc. This applies atop powerpc/merge branch.

Changelog:

v2:

* Change subject of patch 01/16
* As suggested by Christophe Leroy, add barrier_before_unreachable()
before __builtin_unreachable() to work around a gcc problem.
* Fix issues reported by Kernel Test Robot.
* Include suggestions from Christophe Leroy, and change commit 
messages for patches 01/16, 02/16, 03/16, 05/16.

Christophe Leroy (4):
  objtool: Fix SEGFAULT
  objtool: Use target file endianness instead of a compiled constant
  objtool: Use target file class size instead of a compiled constant
  powerpc: Fix objtool unannotated intra-function call warnings on PPC32

Sathvika Vasireddy (12):
  powerpc: Replace unreachable() with it's builtin variant in __WARN_FLAGS()
  powerpc: override __ALIGN() and __ALIGN_STR() macros
  powerpc: Fix objtool unannotated intra-function call warnings
  powerpc: curb objtool unannotated intra-function call warnings
  powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
  powerpc: Skip objtool from running on VDSO files
  objtool: Add --mnop as an option to --mcount
  objtool: Read special sections with alts only when specific options are selected
  objtool: Use macros to define arch specific reloc types
  objtool: Add arch specific function arch_ftrace_match()
  objtool/powerpc: Enable objtool to be built on ppc
  objtool/powerpc: Add --mcount specific implementation

 Makefile                                      |  4 +-
 arch/powerpc/Kconfig                          |  2 +
 arch/powerpc/include/asm/asm.h                |  7 ++
 arch/powerpc/include/asm/bug.h                |  3 +-
 arch/powerpc/include/asm/linkage.h            |  4 +
 arch/powerpc/kernel/cpu_setup_6xx.S           | 26 +++--
 arch/powerpc/kernel/cpu_setup_fsl_booke.S     |  8 +-
 arch/powerpc/kernel/entry_32.S                |  9 +-
 arch/powerpc/kernel/entry_64.S                |  2 +
 arch/powerpc/kernel/exceptions-64s.S          |  7 +-
 arch/powerpc/kernel/head_40x.S                |  5 +-
 arch/powerpc/kernel/head_64.S                 |  7 +-
 arch/powerpc/kernel/head_8xx.S                |  5 +-
 arch/powerpc/kernel/head_book3s_32.S          | 29 ++++--
 arch/powerpc/kernel/head_fsl_booke.S          |  5 +-
 arch/powerpc/kernel/misc_64.S                 |  4 +-
 arch/powerpc/kernel/swsusp_32.S               |  5 +-
 arch/powerpc/kernel/vdso/Makefile             |  2 +
 arch/powerpc/kernel/vector.S                  |  4 +-
 arch/powerpc/kvm/book3s_hv_interrupts.S       |  4 +-
 arch/powerpc/kvm/book3s_hv_rmhandlers.S       | 25 +++--
 arch/powerpc/kvm/fpu.S                        | 17 +++-
 arch/powerpc/platforms/52xx/lite5200_sleep.S  | 15 ++-
 arch/x86/Kconfig                              |  1 +
 drivers/crypto/vmx/Makefile                   |  2 +
 scripts/Makefile.lib                          |  1 +
 tools/objtool/arch/powerpc/Build              |  2 +
 tools/objtool/arch/powerpc/decode.c           | 96 +++++++++++++++++++
 .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
 tools/objtool/arch/powerpc/include/arch/elf.h | 10 ++
 .../arch/powerpc/include/arch/special.h       | 21 ++++
 tools/objtool/arch/powerpc/special.c          | 19 ++++
 tools/objtool/arch/x86/decode.c               |  8 ++
 tools/objtool/arch/x86/include/arch/elf.h     |  2 +
 .../arch/x86/include/arch/endianness.h        |  9 --
 tools/objtool/builtin-check.c                 | 14 +++
 tools/objtool/check.c                         | 51 +++++-----
 tools/objtool/elf.c                           |  8 +-
 tools/objtool/include/objtool/arch.h          |  2 +
 tools/objtool/include/objtool/builtin.h       |  1 +
 tools/objtool/include/objtool/elf.h           |  8 ++
 tools/objtool/include/objtool/endianness.h    | 32 +++----
 tools/objtool/orc_dump.c                      | 11 ++-
 tools/objtool/orc_gen.c                       |  4 +-
 tools/objtool/special.c                       |  3 +-
 45 files changed, 409 insertions(+), 106 deletions(-)
 create mode 100644 arch/powerpc/include/asm/asm.h
 create mode 100644 tools/objtool/arch/powerpc/Build
 create mode 100644 tools/objtool/arch/powerpc/decode.c
 create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
 create mode 100644 tools/objtool/arch/powerpc/special.c
 delete mode 100644 tools/objtool/arch/x86/include/arch/endianness.h

-- 
2.31.1


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

* [PATCH v2 00/16] objtool: Enable and implement --mcount option on powerpc
@ 2022-08-29  5:52 ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

This patchset enables and implements objtool --mcount
option on powerpc. This applies atop powerpc/merge branch.

Changelog:

v2:

* Change subject of patch 01/16
* As suggested by Christophe Leroy, add barrier_before_unreachable()
before __builtin_unreachable() to work around a gcc problem.
* Fix issues reported by Kernel Test Robot.
* Include suggestions from Christophe Leroy, and change commit 
messages for patches 01/16, 02/16, 03/16, 05/16.

Christophe Leroy (4):
  objtool: Fix SEGFAULT
  objtool: Use target file endianness instead of a compiled constant
  objtool: Use target file class size instead of a compiled constant
  powerpc: Fix objtool unannotated intra-function call warnings on PPC32

Sathvika Vasireddy (12):
  powerpc: Replace unreachable() with it's builtin variant in __WARN_FLAGS()
  powerpc: override __ALIGN() and __ALIGN_STR() macros
  powerpc: Fix objtool unannotated intra-function call warnings
  powerpc: curb objtool unannotated intra-function call warnings
  powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
  powerpc: Skip objtool from running on VDSO files
  objtool: Add --mnop as an option to --mcount
  objtool: Read special sections with alts only when specific options are selected
  objtool: Use macros to define arch specific reloc types
  objtool: Add arch specific function arch_ftrace_match()
  objtool/powerpc: Enable objtool to be built on ppc
  objtool/powerpc: Add --mcount specific implementation

 Makefile                                      |  4 +-
 arch/powerpc/Kconfig                          |  2 +
 arch/powerpc/include/asm/asm.h                |  7 ++
 arch/powerpc/include/asm/bug.h                |  3 +-
 arch/powerpc/include/asm/linkage.h            |  4 +
 arch/powerpc/kernel/cpu_setup_6xx.S           | 26 +++--
 arch/powerpc/kernel/cpu_setup_fsl_booke.S     |  8 +-
 arch/powerpc/kernel/entry_32.S                |  9 +-
 arch/powerpc/kernel/entry_64.S                |  2 +
 arch/powerpc/kernel/exceptions-64s.S          |  7 +-
 arch/powerpc/kernel/head_40x.S                |  5 +-
 arch/powerpc/kernel/head_64.S                 |  7 +-
 arch/powerpc/kernel/head_8xx.S                |  5 +-
 arch/powerpc/kernel/head_book3s_32.S          | 29 ++++--
 arch/powerpc/kernel/head_fsl_booke.S          |  5 +-
 arch/powerpc/kernel/misc_64.S                 |  4 +-
 arch/powerpc/kernel/swsusp_32.S               |  5 +-
 arch/powerpc/kernel/vdso/Makefile             |  2 +
 arch/powerpc/kernel/vector.S                  |  4 +-
 arch/powerpc/kvm/book3s_hv_interrupts.S       |  4 +-
 arch/powerpc/kvm/book3s_hv_rmhandlers.S       | 25 +++--
 arch/powerpc/kvm/fpu.S                        | 17 +++-
 arch/powerpc/platforms/52xx/lite5200_sleep.S  | 15 ++-
 arch/x86/Kconfig                              |  1 +
 drivers/crypto/vmx/Makefile                   |  2 +
 scripts/Makefile.lib                          |  1 +
 tools/objtool/arch/powerpc/Build              |  2 +
 tools/objtool/arch/powerpc/decode.c           | 96 +++++++++++++++++++
 .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
 tools/objtool/arch/powerpc/include/arch/elf.h | 10 ++
 .../arch/powerpc/include/arch/special.h       | 21 ++++
 tools/objtool/arch/powerpc/special.c          | 19 ++++
 tools/objtool/arch/x86/decode.c               |  8 ++
 tools/objtool/arch/x86/include/arch/elf.h     |  2 +
 .../arch/x86/include/arch/endianness.h        |  9 --
 tools/objtool/builtin-check.c                 | 14 +++
 tools/objtool/check.c                         | 51 +++++-----
 tools/objtool/elf.c                           |  8 +-
 tools/objtool/include/objtool/arch.h          |  2 +
 tools/objtool/include/objtool/builtin.h       |  1 +
 tools/objtool/include/objtool/elf.h           |  8 ++
 tools/objtool/include/objtool/endianness.h    | 32 +++----
 tools/objtool/orc_dump.c                      | 11 ++-
 tools/objtool/orc_gen.c                       |  4 +-
 tools/objtool/special.c                       |  3 +-
 45 files changed, 409 insertions(+), 106 deletions(-)
 create mode 100644 arch/powerpc/include/asm/asm.h
 create mode 100644 tools/objtool/arch/powerpc/Build
 create mode 100644 tools/objtool/arch/powerpc/decode.c
 create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
 create mode 100644 tools/objtool/arch/powerpc/special.c
 delete mode 100644 tools/objtool/arch/x86/include/arch/endianness.h

-- 
2.31.1


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

* [PATCH v2 01/16] powerpc: Replace unreachable() with it's builtin variant in __WARN_FLAGS()
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

objtool is throwing *unannotated intra-function call* warnings in
.c files with a few instructions that are marked unreachable. The
problem comes from the annotate_unreachable() macro that is
called by unreachable(). This annotation is adding a call to a
function with size 0, and objtool does not add such symbols
to the rbtree. Due to this reason, find_call_destination() function
is not able to find the destination symbol for that call.

With the annotation (annotate_unreachable()), gcc seems to
generate a 'bl' to unreachable symbol with size 0. But with
the builtin variant of unreachable (__builtin_unreachable()),
gcc does not emit calls to such symbols and the warnings
go away. Given that the codegen remains same, and that
there are no 'bl' instructions to such symbols emitted, fix
these warnings by replacing unreachable() with it's builtin
variant in __WARN_FLAGS().

Also, add barrier_before_unreachable() before __builtin_unreachable()
to work around a gcc bug [1], for the problem reported at [2].

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106751
[2]: https://lkml.org/lkml/2022/8/25/418

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/include/asm/bug.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index 61a4736355c2..ef42adb44aa3 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -99,7 +99,8 @@
 	__label__ __label_warn_on;				\
 								\
 	WARN_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags), __label_warn_on); \
-	unreachable();						\
+	barrier_before_unreachable();				\
+	__builtin_unreachable();				\
 								\
 __label_warn_on:						\
 	break;							\
-- 
2.31.1


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

* [PATCH v2 01/16] powerpc: Replace unreachable() with it's builtin variant in __WARN_FLAGS()
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

objtool is throwing *unannotated intra-function call* warnings in
.c files with a few instructions that are marked unreachable. The
problem comes from the annotate_unreachable() macro that is
called by unreachable(). This annotation is adding a call to a
function with size 0, and objtool does not add such symbols
to the rbtree. Due to this reason, find_call_destination() function
is not able to find the destination symbol for that call.

With the annotation (annotate_unreachable()), gcc seems to
generate a 'bl' to unreachable symbol with size 0. But with
the builtin variant of unreachable (__builtin_unreachable()),
gcc does not emit calls to such symbols and the warnings
go away. Given that the codegen remains same, and that
there are no 'bl' instructions to such symbols emitted, fix
these warnings by replacing unreachable() with it's builtin
variant in __WARN_FLAGS().

Also, add barrier_before_unreachable() before __builtin_unreachable()
to work around a gcc bug [1], for the problem reported at [2].

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106751
[2]: https://lkml.org/lkml/2022/8/25/418

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/include/asm/bug.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index 61a4736355c2..ef42adb44aa3 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -99,7 +99,8 @@
 	__label__ __label_warn_on;				\
 								\
 	WARN_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags), __label_warn_on); \
-	unreachable();						\
+	barrier_before_unreachable();				\
+	__builtin_unreachable();				\
 								\
 __label_warn_on:						\
 	break;							\
-- 
2.31.1


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

* [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

Powerpc instructions must be word-aligned. Currently,
there is an alignment of 16 bytes (by default), and it is
much more than what is required for powerpc (4 bytes).

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

Since Powerpc Linux does not require a 16 byte alignment,
override __ALIGN() and __ALIGN_STR() macros to use required
4 byte alignment.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/include/asm/linkage.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
index b71b9582e754..8df88fe61438 100644
--- a/arch/powerpc/include/asm/linkage.h
+++ b/arch/powerpc/include/asm/linkage.h
@@ -2,8 +2,12 @@
 #ifndef _ASM_POWERPC_LINKAGE_H
 #define _ASM_POWERPC_LINKAGE_H
 
+#include <linux/stringify.h>
 #include <asm/types.h>
 
+#define __ALIGN			.align 2
+#define __ALIGN_STR		__stringify(__ALIGN)
+
 #ifdef CONFIG_PPC64_ELF_ABI_V1
 #define cond_syscall(x) \
 	asm ("\t.weak " #x "\n\t.set " #x ", sys_ni_syscall\n"		\
-- 
2.31.1


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

* [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

Powerpc instructions must be word-aligned. Currently,
there is an alignment of 16 bytes (by default), and it is
much more than what is required for powerpc (4 bytes).

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

Since Powerpc Linux does not require a 16 byte alignment,
override __ALIGN() and __ALIGN_STR() macros to use required
4 byte alignment.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/include/asm/linkage.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
index b71b9582e754..8df88fe61438 100644
--- a/arch/powerpc/include/asm/linkage.h
+++ b/arch/powerpc/include/asm/linkage.h
@@ -2,8 +2,12 @@
 #ifndef _ASM_POWERPC_LINKAGE_H
 #define _ASM_POWERPC_LINKAGE_H
 
+#include <linux/stringify.h>
 #include <asm/types.h>
 
+#define __ALIGN			.align 2
+#define __ALIGN_STR		__stringify(__ALIGN)
+
 #ifdef CONFIG_PPC64_ELF_ABI_V1
 #define cond_syscall(x) \
 	asm ("\t.weak " #x "\n\t.set " #x ", sys_ni_syscall\n"		\
-- 
2.31.1


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

* [PATCH v2 03/16] powerpc: Fix objtool unannotated intra-function call warnings
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

objtool throws unannotated intra-function call warnings
in the following assembly files:

arch/powerpc/kernel/vector.o: warning: objtool: .text+0x53c: unannotated intra-function call

arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x60: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x124: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5d4: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5dc: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xcb8: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xd0c: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x1030: unannotated intra-function call

arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x358: unannotated intra-function call
arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x728: unannotated intra-function call
arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4d94: unannotated intra-function call
arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4ec4: unannotated intra-function call

arch/powerpc/kvm/book3s_hv_interrupts.o: warning: objtool: .text+0x6c: unannotated intra-function call
arch/powerpc/kernel/misc_64.o: warning: objtool: .text+0x64: unannotated intra-function call

objtool does not add STT_NOTYPE symbols with size 0 to the
rbtree, which is why find_call_destination() function is not able
to find the destination symbol for 'bl' instruction. For such symbols,
objtool is throwing unannotated intra-function call warnings in
assembly files. Fix these warnings by adding SYM_FUNC_START_LOCAL()
and SYM_FUNC_END() annotations to those symbols to be able to set symbol
type to STT_FUNC and set size of these symbols accordingly.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/kernel/exceptions-64s.S    |  7 +++++--
 arch/powerpc/kernel/head_64.S           |  7 +++++--
 arch/powerpc/kernel/misc_64.S           |  4 +++-
 arch/powerpc/kernel/vector.S            |  4 +++-
 arch/powerpc/kvm/book3s_hv_interrupts.S |  4 +++-
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 22 +++++++++++++++-------
 6 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 3d0dc133a9ae..4242c1a20bcd 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -20,6 +20,7 @@
 #include <asm/head-64.h>
 #include <asm/feature-fixups.h>
 #include <asm/kup.h>
+#include <linux/linkage.h>
 
 /*
  * Following are fixed section helper macros.
@@ -3075,7 +3076,7 @@ CLOSE_FIXED_SECTION(virt_trampolines);
 USE_TEXT_SECTION()
 
 /* MSR[RI] should be clear because this uses SRR[01] */
-enable_machine_check:
+SYM_FUNC_START_LOCAL(enable_machine_check)
 	mflr	r0
 	bcl	20,31,$+4
 0:	mflr	r3
@@ -3087,9 +3088,10 @@ enable_machine_check:
 	RFI_TO_KERNEL
 1:	mtlr	r0
 	blr
+SYM_FUNC_END(enable_machine_check)
 
 /* MSR[RI] should be clear because this uses SRR[01] */
-disable_machine_check:
+SYM_FUNC_START_LOCAL(disable_machine_check)
 	mflr	r0
 	bcl	20,31,$+4
 0:	mflr	r3
@@ -3102,3 +3104,4 @@ disable_machine_check:
 	RFI_TO_KERNEL
 1:	mtlr	r0
 	blr
+SYM_FUNC_END(disable_machine_check)
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index cf2c08902c05..10e2d43420d0 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -18,6 +18,7 @@
  *  variants.
  */
 
+#include <linux/linkage.h>
 #include <linux/threads.h>
 #include <linux/init.h>
 #include <asm/reg.h>
@@ -465,7 +466,7 @@ generic_secondary_common_init:
  * Assumes we're mapped EA == RA if the MMU is on.
  */
 #ifdef CONFIG_PPC_BOOK3S
-__mmu_off:
+SYM_FUNC_START_LOCAL(__mmu_off)
 	mfmsr	r3
 	andi.	r0,r3,MSR_IR|MSR_DR
 	beqlr
@@ -476,6 +477,7 @@ __mmu_off:
 	sync
 	rfid
 	b	.	/* prevent speculative execution */
+SYM_FUNC_END(__mmu_off)
 #endif
 
 
@@ -869,7 +871,7 @@ _GLOBAL(start_secondary_resume)
 /*
  * This subroutine clobbers r11 and r12
  */
-enable_64b_mode:
+SYM_FUNC_START_LOCAL(enable_64b_mode)
 	mfmsr	r11			/* grab the current MSR */
 #ifdef CONFIG_PPC_BOOK3E
 	oris	r11,r11,0x8000		/* CM bit set, we'll set ICM later */
@@ -881,6 +883,7 @@ enable_64b_mode:
 	isync
 #endif
 	blr
+SYM_FUNC_END(enable_64b_mode)
 
 /*
  * This puts the TOC pointer into r2, offset by 0x8000 (as expected
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index fd6d8d3a548e..b36fb89ff718 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -9,6 +9,7 @@
  * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
  */
 
+#include <linux/linkage.h>
 #include <linux/sys.h>
 #include <asm/unistd.h>
 #include <asm/errno.h>
@@ -353,7 +354,7 @@ _GLOBAL(kexec_smp_wait)
  *
  * don't overwrite r3 here, it is live for kexec_wait above.
  */
-real_mode:	/* assume normal blr return */
+SYM_FUNC_START_LOCAL(real_mode)	/* assume normal blr return */
 #ifdef CONFIG_PPC_BOOK3E
 	/* Create an identity mapping. */
 	b	kexec_create_tlb
@@ -370,6 +371,7 @@ real_mode:	/* assume normal blr return */
 	mtspr	SPRN_SRR0,r11
 	rfid
 #endif
+SYM_FUNC_END(real_mode)
 
 /*
  * kexec_sequence(newstack, start, image, control, clear_all(),
diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
index 5cc24d8cce94..fb96aed2b5c3 100644
--- a/arch/powerpc/kernel/vector.S
+++ b/arch/powerpc/kernel/vector.S
@@ -9,6 +9,7 @@
 #include <asm/ptrace.h>
 #include <asm/export.h>
 #include <asm/asm-compat.h>
+#include <linux/linkage.h>
 
 /*
  * Load state from memory into VMX registers including VSCR.
@@ -186,7 +187,7 @@ fphalf:
  * Internal routine to enable floating point and set FPSCR to 0.
  * Don't call it from C; it doesn't use the normal calling convention.
  */
-fpenable:
+SYM_FUNC_START_LOCAL(fpenable)
 #ifdef CONFIG_PPC32
 	stwu	r1,-64(r1)
 #else
@@ -203,6 +204,7 @@ fpenable:
 	mffs	fr31
 	MTFSF_L(fr1)
 	blr
+SYM_FUNC_END(fpenable)
 
 fpdisable:
 	mtlr	r12
diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S
index 59d89e4b154a..c0deeea7eef3 100644
--- a/arch/powerpc/kvm/book3s_hv_interrupts.S
+++ b/arch/powerpc/kvm/book3s_hv_interrupts.S
@@ -9,6 +9,7 @@
  * Authors: Alexander Graf <agraf@suse.de>
  */
 
+#include <linux/linkage.h>
 #include <asm/ppc_asm.h>
 #include <asm/kvm_asm.h>
 #include <asm/reg.h>
@@ -107,7 +108,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
 /*
  * void kvmhv_save_host_pmu(void)
  */
-kvmhv_save_host_pmu:
+SYM_FUNC_START_LOCAL(kvmhv_save_host_pmu)
 BEGIN_FTR_SECTION
 	/* Work around P8 PMAE bug */
 	li	r3, -1
@@ -154,3 +155,4 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	stw	r8, HSTATE_PMC5(r13)
 	stw	r9, HSTATE_PMC6(r13)
 31:	blr
+SYM_FUNC_END(kvmhv_save_host_pmu)
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 7ded202bf995..de91118df0c5 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -29,6 +29,7 @@
 #include <asm/asm-compat.h>
 #include <asm/feature-fixups.h>
 #include <asm/cpuidle.h>
+#include <linux/linkage.h>
 
 /* Values in HSTATE_NAPPING(r13) */
 #define NAPPING_CEDE	1
@@ -2358,7 +2359,7 @@ hmi_realmode:
  * This routine calls kvmppc_read_intr, a C function, if an external
  * interrupt is pending.
  */
-kvmppc_check_wake_reason:
+SYM_FUNC_START_LOCAL(kvmppc_check_wake_reason)
 	mfspr	r6, SPRN_SRR1
 BEGIN_FTR_SECTION
 	rlwinm	r6, r6, 45-31, 0xf	/* extract wake reason field (P8) */
@@ -2427,6 +2428,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	addi	r1, r1, PPC_MIN_STKFRM
 	mtlr	r0
 	blr
+SYM_FUNC_END(kvmppc_check_wake_reason)
 
 /*
  * Save away FP, VMX and VSX registers.
@@ -2434,7 +2436,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
  * N.B. r30 and r31 are volatile across this function,
  * thus it is not callable from C.
  */
-kvmppc_save_fp:
+SYM_FUNC_START_LOCAL(kvmppc_save_fp)
 	mflr	r30
 	mr	r31,r3
 	mfmsr	r5
@@ -2462,6 +2464,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 	stw	r6,VCPU_VRSAVE(r31)
 	mtlr	r30
 	blr
+SYM_FUNC_END(kvmppc_save_fp)
 
 /*
  * Load up FP, VMX and VSX registers
@@ -2469,7 +2472,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  * N.B. r30 and r31 are volatile across this function,
  * thus it is not callable from C.
  */
-kvmppc_load_fp:
+SYM_FUNC_START_LOCAL(kvmppc_load_fp)
 	mflr	r30
 	mr	r31,r4
 	mfmsr	r9
@@ -2498,6 +2501,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 	mtlr	r30
 	mr	r4,r31
 	blr
+SYM_FUNC_END(kvmppc_load_fp)
 
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 /*
@@ -2746,7 +2750,7 @@ kvmppc_bad_host_intr:
  *   r9 has a vcpu pointer (in)
  *   r0 is used as a scratch register
  */
-kvmppc_msr_interrupt:
+SYM_FUNC_START_LOCAL(kvmppc_msr_interrupt)
 	rldicl	r0, r11, 64 - MSR_TS_S_LG, 62
 	cmpwi	r0, 2 /* Check if we are in transactional state..  */
 	ld	r11, VCPU_INTR_MSR(r9)
@@ -2755,13 +2759,14 @@ kvmppc_msr_interrupt:
 	li	r0, 1
 1:	rldimi	r11, r0, MSR_TS_S_LG, 63 - MSR_TS_T_LG
 	blr
+SYM_FUNC_END(kvmppc_msr_interrupt)
 
 /*
  * void kvmhv_load_guest_pmu(struct kvm_vcpu *vcpu)
  *
  * Load up guest PMU state.  R3 points to the vcpu struct.
  */
-kvmhv_load_guest_pmu:
+SYM_FUNC_START_LOCAL(kvmhv_load_guest_pmu)
 	mr	r4, r3
 	mflr	r0
 	li	r3, 1
@@ -2811,13 +2816,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	isync
 	mtlr	r0
 	blr
+SYM_FUNC_END(kvmhv_load_guest_pmu)
 
 /*
  * void kvmhv_load_host_pmu(void)
  *
  * Reload host PMU state saved in the PACA by kvmhv_save_host_pmu.
  */
-kvmhv_load_host_pmu:
+SYM_FUNC_START_LOCAL(kvmhv_load_host_pmu)
 	mflr	r0
 	lbz	r4, PACA_PMCINUSE(r13) /* is the host using the PMU? */
 	cmpwi	r4, 0
@@ -2859,6 +2865,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	isync
 	mtlr	r0
 23:	blr
+SYM_FUNC_END(kvmhv_load_host_pmu)
 
 /*
  * void kvmhv_save_guest_pmu(struct kvm_vcpu *vcpu, bool pmu_in_use)
@@ -2866,7 +2873,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
  * Save guest PMU state into the vcpu struct.
  * r3 = vcpu, r4 = full save flag (PMU in use flag set in VPA)
  */
-kvmhv_save_guest_pmu:
+SYM_FUNC_START_LOCAL(kvmhv_save_guest_pmu)
 	mr	r9, r3
 	mr	r8, r4
 BEGIN_FTR_SECTION
@@ -2942,6 +2949,7 @@ BEGIN_FTR_SECTION
 	mtspr	SPRN_MMCRS, r4
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 22:	blr
+SYM_FUNC_END(kvmhv_save_guest_pmu)
 
 /*
  * This works around a hardware bug on POWER8E processors, where
-- 
2.31.1


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

* [PATCH v2 03/16] powerpc: Fix objtool unannotated intra-function call warnings
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

objtool throws unannotated intra-function call warnings
in the following assembly files:

arch/powerpc/kernel/vector.o: warning: objtool: .text+0x53c: unannotated intra-function call

arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x60: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x124: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5d4: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5dc: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xcb8: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xd0c: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x1030: unannotated intra-function call

arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x358: unannotated intra-function call
arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x728: unannotated intra-function call
arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4d94: unannotated intra-function call
arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4ec4: unannotated intra-function call

arch/powerpc/kvm/book3s_hv_interrupts.o: warning: objtool: .text+0x6c: unannotated intra-function call
arch/powerpc/kernel/misc_64.o: warning: objtool: .text+0x64: unannotated intra-function call

objtool does not add STT_NOTYPE symbols with size 0 to the
rbtree, which is why find_call_destination() function is not able
to find the destination symbol for 'bl' instruction. For such symbols,
objtool is throwing unannotated intra-function call warnings in
assembly files. Fix these warnings by adding SYM_FUNC_START_LOCAL()
and SYM_FUNC_END() annotations to those symbols to be able to set symbol
type to STT_FUNC and set size of these symbols accordingly.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/kernel/exceptions-64s.S    |  7 +++++--
 arch/powerpc/kernel/head_64.S           |  7 +++++--
 arch/powerpc/kernel/misc_64.S           |  4 +++-
 arch/powerpc/kernel/vector.S            |  4 +++-
 arch/powerpc/kvm/book3s_hv_interrupts.S |  4 +++-
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 22 +++++++++++++++-------
 6 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 3d0dc133a9ae..4242c1a20bcd 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -20,6 +20,7 @@
 #include <asm/head-64.h>
 #include <asm/feature-fixups.h>
 #include <asm/kup.h>
+#include <linux/linkage.h>
 
 /*
  * Following are fixed section helper macros.
@@ -3075,7 +3076,7 @@ CLOSE_FIXED_SECTION(virt_trampolines);
 USE_TEXT_SECTION()
 
 /* MSR[RI] should be clear because this uses SRR[01] */
-enable_machine_check:
+SYM_FUNC_START_LOCAL(enable_machine_check)
 	mflr	r0
 	bcl	20,31,$+4
 0:	mflr	r3
@@ -3087,9 +3088,10 @@ enable_machine_check:
 	RFI_TO_KERNEL
 1:	mtlr	r0
 	blr
+SYM_FUNC_END(enable_machine_check)
 
 /* MSR[RI] should be clear because this uses SRR[01] */
-disable_machine_check:
+SYM_FUNC_START_LOCAL(disable_machine_check)
 	mflr	r0
 	bcl	20,31,$+4
 0:	mflr	r3
@@ -3102,3 +3104,4 @@ disable_machine_check:
 	RFI_TO_KERNEL
 1:	mtlr	r0
 	blr
+SYM_FUNC_END(disable_machine_check)
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index cf2c08902c05..10e2d43420d0 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -18,6 +18,7 @@
  *  variants.
  */
 
+#include <linux/linkage.h>
 #include <linux/threads.h>
 #include <linux/init.h>
 #include <asm/reg.h>
@@ -465,7 +466,7 @@ generic_secondary_common_init:
  * Assumes we're mapped EA == RA if the MMU is on.
  */
 #ifdef CONFIG_PPC_BOOK3S
-__mmu_off:
+SYM_FUNC_START_LOCAL(__mmu_off)
 	mfmsr	r3
 	andi.	r0,r3,MSR_IR|MSR_DR
 	beqlr
@@ -476,6 +477,7 @@ __mmu_off:
 	sync
 	rfid
 	b	.	/* prevent speculative execution */
+SYM_FUNC_END(__mmu_off)
 #endif
 
 
@@ -869,7 +871,7 @@ _GLOBAL(start_secondary_resume)
 /*
  * This subroutine clobbers r11 and r12
  */
-enable_64b_mode:
+SYM_FUNC_START_LOCAL(enable_64b_mode)
 	mfmsr	r11			/* grab the current MSR */
 #ifdef CONFIG_PPC_BOOK3E
 	oris	r11,r11,0x8000		/* CM bit set, we'll set ICM later */
@@ -881,6 +883,7 @@ enable_64b_mode:
 	isync
 #endif
 	blr
+SYM_FUNC_END(enable_64b_mode)
 
 /*
  * This puts the TOC pointer into r2, offset by 0x8000 (as expected
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index fd6d8d3a548e..b36fb89ff718 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -9,6 +9,7 @@
  * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
  */
 
+#include <linux/linkage.h>
 #include <linux/sys.h>
 #include <asm/unistd.h>
 #include <asm/errno.h>
@@ -353,7 +354,7 @@ _GLOBAL(kexec_smp_wait)
  *
  * don't overwrite r3 here, it is live for kexec_wait above.
  */
-real_mode:	/* assume normal blr return */
+SYM_FUNC_START_LOCAL(real_mode)	/* assume normal blr return */
 #ifdef CONFIG_PPC_BOOK3E
 	/* Create an identity mapping. */
 	b	kexec_create_tlb
@@ -370,6 +371,7 @@ real_mode:	/* assume normal blr return */
 	mtspr	SPRN_SRR0,r11
 	rfid
 #endif
+SYM_FUNC_END(real_mode)
 
 /*
  * kexec_sequence(newstack, start, image, control, clear_all(),
diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
index 5cc24d8cce94..fb96aed2b5c3 100644
--- a/arch/powerpc/kernel/vector.S
+++ b/arch/powerpc/kernel/vector.S
@@ -9,6 +9,7 @@
 #include <asm/ptrace.h>
 #include <asm/export.h>
 #include <asm/asm-compat.h>
+#include <linux/linkage.h>
 
 /*
  * Load state from memory into VMX registers including VSCR.
@@ -186,7 +187,7 @@ fphalf:
  * Internal routine to enable floating point and set FPSCR to 0.
  * Don't call it from C; it doesn't use the normal calling convention.
  */
-fpenable:
+SYM_FUNC_START_LOCAL(fpenable)
 #ifdef CONFIG_PPC32
 	stwu	r1,-64(r1)
 #else
@@ -203,6 +204,7 @@ fpenable:
 	mffs	fr31
 	MTFSF_L(fr1)
 	blr
+SYM_FUNC_END(fpenable)
 
 fpdisable:
 	mtlr	r12
diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S
index 59d89e4b154a..c0deeea7eef3 100644
--- a/arch/powerpc/kvm/book3s_hv_interrupts.S
+++ b/arch/powerpc/kvm/book3s_hv_interrupts.S
@@ -9,6 +9,7 @@
  * Authors: Alexander Graf <agraf@suse.de>
  */
 
+#include <linux/linkage.h>
 #include <asm/ppc_asm.h>
 #include <asm/kvm_asm.h>
 #include <asm/reg.h>
@@ -107,7 +108,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
 /*
  * void kvmhv_save_host_pmu(void)
  */
-kvmhv_save_host_pmu:
+SYM_FUNC_START_LOCAL(kvmhv_save_host_pmu)
 BEGIN_FTR_SECTION
 	/* Work around P8 PMAE bug */
 	li	r3, -1
@@ -154,3 +155,4 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	stw	r8, HSTATE_PMC5(r13)
 	stw	r9, HSTATE_PMC6(r13)
 31:	blr
+SYM_FUNC_END(kvmhv_save_host_pmu)
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 7ded202bf995..de91118df0c5 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -29,6 +29,7 @@
 #include <asm/asm-compat.h>
 #include <asm/feature-fixups.h>
 #include <asm/cpuidle.h>
+#include <linux/linkage.h>
 
 /* Values in HSTATE_NAPPING(r13) */
 #define NAPPING_CEDE	1
@@ -2358,7 +2359,7 @@ hmi_realmode:
  * This routine calls kvmppc_read_intr, a C function, if an external
  * interrupt is pending.
  */
-kvmppc_check_wake_reason:
+SYM_FUNC_START_LOCAL(kvmppc_check_wake_reason)
 	mfspr	r6, SPRN_SRR1
 BEGIN_FTR_SECTION
 	rlwinm	r6, r6, 45-31, 0xf	/* extract wake reason field (P8) */
@@ -2427,6 +2428,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	addi	r1, r1, PPC_MIN_STKFRM
 	mtlr	r0
 	blr
+SYM_FUNC_END(kvmppc_check_wake_reason)
 
 /*
  * Save away FP, VMX and VSX registers.
@@ -2434,7 +2436,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
  * N.B. r30 and r31 are volatile across this function,
  * thus it is not callable from C.
  */
-kvmppc_save_fp:
+SYM_FUNC_START_LOCAL(kvmppc_save_fp)
 	mflr	r30
 	mr	r31,r3
 	mfmsr	r5
@@ -2462,6 +2464,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 	stw	r6,VCPU_VRSAVE(r31)
 	mtlr	r30
 	blr
+SYM_FUNC_END(kvmppc_save_fp)
 
 /*
  * Load up FP, VMX and VSX registers
@@ -2469,7 +2472,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  * N.B. r30 and r31 are volatile across this function,
  * thus it is not callable from C.
  */
-kvmppc_load_fp:
+SYM_FUNC_START_LOCAL(kvmppc_load_fp)
 	mflr	r30
 	mr	r31,r4
 	mfmsr	r9
@@ -2498,6 +2501,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 	mtlr	r30
 	mr	r4,r31
 	blr
+SYM_FUNC_END(kvmppc_load_fp)
 
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 /*
@@ -2746,7 +2750,7 @@ kvmppc_bad_host_intr:
  *   r9 has a vcpu pointer (in)
  *   r0 is used as a scratch register
  */
-kvmppc_msr_interrupt:
+SYM_FUNC_START_LOCAL(kvmppc_msr_interrupt)
 	rldicl	r0, r11, 64 - MSR_TS_S_LG, 62
 	cmpwi	r0, 2 /* Check if we are in transactional state..  */
 	ld	r11, VCPU_INTR_MSR(r9)
@@ -2755,13 +2759,14 @@ kvmppc_msr_interrupt:
 	li	r0, 1
 1:	rldimi	r11, r0, MSR_TS_S_LG, 63 - MSR_TS_T_LG
 	blr
+SYM_FUNC_END(kvmppc_msr_interrupt)
 
 /*
  * void kvmhv_load_guest_pmu(struct kvm_vcpu *vcpu)
  *
  * Load up guest PMU state.  R3 points to the vcpu struct.
  */
-kvmhv_load_guest_pmu:
+SYM_FUNC_START_LOCAL(kvmhv_load_guest_pmu)
 	mr	r4, r3
 	mflr	r0
 	li	r3, 1
@@ -2811,13 +2816,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	isync
 	mtlr	r0
 	blr
+SYM_FUNC_END(kvmhv_load_guest_pmu)
 
 /*
  * void kvmhv_load_host_pmu(void)
  *
  * Reload host PMU state saved in the PACA by kvmhv_save_host_pmu.
  */
-kvmhv_load_host_pmu:
+SYM_FUNC_START_LOCAL(kvmhv_load_host_pmu)
 	mflr	r0
 	lbz	r4, PACA_PMCINUSE(r13) /* is the host using the PMU? */
 	cmpwi	r4, 0
@@ -2859,6 +2865,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	isync
 	mtlr	r0
 23:	blr
+SYM_FUNC_END(kvmhv_load_host_pmu)
 
 /*
  * void kvmhv_save_guest_pmu(struct kvm_vcpu *vcpu, bool pmu_in_use)
@@ -2866,7 +2873,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
  * Save guest PMU state into the vcpu struct.
  * r3 = vcpu, r4 = full save flag (PMU in use flag set in VPA)
  */
-kvmhv_save_guest_pmu:
+SYM_FUNC_START_LOCAL(kvmhv_save_guest_pmu)
 	mr	r9, r3
 	mr	r8, r4
 BEGIN_FTR_SECTION
@@ -2942,6 +2949,7 @@ BEGIN_FTR_SECTION
 	mtspr	SPRN_MMCRS, r4
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 22:	blr
+SYM_FUNC_END(kvmhv_save_guest_pmu)
 
 /*
  * This works around a hardware bug on POWER8E processors, where
-- 
2.31.1


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

* [PATCH v2 04/16] powerpc: Curb objtool unannotated intra-function warnings
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

objtool throws the following unannotated intra-function call
warnings:

arch/powerpc/kernel/entry_64.o: warning: objtool: .text+0x4: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xe64: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xee4: unannotated intra-function call

Fix these warnings by annotating intra-function
call, using ANNOTATE_INTRA_FUNCTION_CALL macro,
to indicate that the branch targets are valid.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/kernel/entry_64.S          | 2 ++
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 01ace4c56104..fb444bc64f3f 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -14,6 +14,7 @@
  *  code, and exception/interrupt return code for PowerPC.
  */
 
+#include <linux/objtool.h>
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <asm/cache.h>
@@ -73,6 +74,7 @@ flush_branch_caches:
 
 	// Flush the link stack
 	.rept 64
+	ANNOTATE_INTRA_FUNCTION_CALL
 	bl	.+4
 	.endr
 	b	1f
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index de91118df0c5..ea39a0cf591a 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -30,6 +30,7 @@
 #include <asm/feature-fixups.h>
 #include <asm/cpuidle.h>
 #include <linux/linkage.h>
+#include <linux/objtool.h>
 
 /* Values in HSTATE_NAPPING(r13) */
 #define NAPPING_CEDE	1
@@ -1523,12 +1524,14 @@ kvm_flush_link_stack:
 
 	/* Flush the link stack. On Power8 it's up to 32 entries in size. */
 	.rept 32
+	ANNOTATE_INTRA_FUNCTION_CALL
 	bl	.+4
 	.endr
 
 	/* And on Power9 it's up to 64. */
 BEGIN_FTR_SECTION
 	.rept 32
+	ANNOTATE_INTRA_FUNCTION_CALL
 	bl	.+4
 	.endr
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
-- 
2.31.1


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

* [PATCH v2 04/16] powerpc: Curb objtool unannotated intra-function warnings
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

objtool throws the following unannotated intra-function call
warnings:

arch/powerpc/kernel/entry_64.o: warning: objtool: .text+0x4: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xe64: unannotated intra-function call
arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xee4: unannotated intra-function call

Fix these warnings by annotating intra-function
call, using ANNOTATE_INTRA_FUNCTION_CALL macro,
to indicate that the branch targets are valid.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/kernel/entry_64.S          | 2 ++
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 01ace4c56104..fb444bc64f3f 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -14,6 +14,7 @@
  *  code, and exception/interrupt return code for PowerPC.
  */
 
+#include <linux/objtool.h>
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <asm/cache.h>
@@ -73,6 +74,7 @@ flush_branch_caches:
 
 	// Flush the link stack
 	.rept 64
+	ANNOTATE_INTRA_FUNCTION_CALL
 	bl	.+4
 	.endr
 	b	1f
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index de91118df0c5..ea39a0cf591a 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -30,6 +30,7 @@
 #include <asm/feature-fixups.h>
 #include <asm/cpuidle.h>
 #include <linux/linkage.h>
+#include <linux/objtool.h>
 
 /* Values in HSTATE_NAPPING(r13) */
 #define NAPPING_CEDE	1
@@ -1523,12 +1524,14 @@ kvm_flush_link_stack:
 
 	/* Flush the link stack. On Power8 it's up to 32 entries in size. */
 	.rept 32
+	ANNOTATE_INTRA_FUNCTION_CALL
 	bl	.+4
 	.endr
 
 	/* And on Power9 it's up to 64. */
 BEGIN_FTR_SECTION
 	.rept 32
+	ANNOTATE_INTRA_FUNCTION_CALL
 	bl	.+4
 	.endr
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
-- 
2.31.1


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

* [PATCH v2 05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

With objtool enabled, below warnings are seen when trying to build:

drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call

drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2448: unannotated intra-function call

drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2d68: unannotated intra-function call

Skip objtool from running on this file, for two main reasons:

Since this file comes from OpenSSL, and since it is a perl file
which generates a .S file, it may not be the best choice to
make too many code changes to such files, unless absolutely
necessary.

Second reason is that, at least as far as the objtool --mcount
functionality is concerned, we do not have to run objtool on
that file because that file does not have any calls to _mcount.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 drivers/crypto/vmx/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
index 2560cfea1dec..7b41f0da6807 100644
--- a/drivers/crypto/vmx/Makefile
+++ b/drivers/crypto/vmx/Makefile
@@ -9,3 +9,5 @@ targets += aesp8-ppc.S ghashp8-ppc.S
 
 $(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
 	$(call if_changed,perl)
+
+OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y
-- 
2.31.1


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

* [PATCH v2 05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

With objtool enabled, below warnings are seen when trying to build:

drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call

drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2448: unannotated intra-function call

drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2d68: unannotated intra-function call

Skip objtool from running on this file, for two main reasons:

Since this file comes from OpenSSL, and since it is a perl file
which generates a .S file, it may not be the best choice to
make too many code changes to such files, unless absolutely
necessary.

Second reason is that, at least as far as the objtool --mcount
functionality is concerned, we do not have to run objtool on
that file because that file does not have any calls to _mcount.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 drivers/crypto/vmx/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
index 2560cfea1dec..7b41f0da6807 100644
--- a/drivers/crypto/vmx/Makefile
+++ b/drivers/crypto/vmx/Makefile
@@ -9,3 +9,5 @@ targets += aesp8-ppc.S ghashp8-ppc.S
 
 $(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
 	$(call if_changed,perl)
+
+OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y
-- 
2.31.1


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

* [PATCH v2 06/16] powerpc: Fix objtool unannotated intra-function call warnings on PPC32
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

From: Christophe Leroy <christophe.leroy@csgroup.eu>

Fix several annotations in assembly files on PPC32.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
[Sathvika Vasireddy: Changed subject line from objtool/powerpc: Activate objtool on PPC32
to powerpc: Fix objtool unannotated intra-function call warnings on PPC32, and removed
Kconfig change to enable objtool, as it is part of objtool/powerpc: Enable objtool to be built on ppc patch in this series.]
Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/kernel/cpu_setup_6xx.S          | 26 ++++++++++++------
 arch/powerpc/kernel/cpu_setup_fsl_booke.S    |  8 ++++--
 arch/powerpc/kernel/entry_32.S               |  9 ++++--
 arch/powerpc/kernel/head_40x.S               |  5 +++-
 arch/powerpc/kernel/head_8xx.S               |  5 +++-
 arch/powerpc/kernel/head_book3s_32.S         | 29 ++++++++++++++------
 arch/powerpc/kernel/head_fsl_booke.S         |  5 +++-
 arch/powerpc/kernel/swsusp_32.S              |  5 +++-
 arch/powerpc/kvm/fpu.S                       | 17 ++++++++----
 arch/powerpc/platforms/52xx/lite5200_sleep.S | 15 +++++++---
 10 files changed, 89 insertions(+), 35 deletions(-)

diff --git a/arch/powerpc/kernel/cpu_setup_6xx.S b/arch/powerpc/kernel/cpu_setup_6xx.S
index f8b5ff64b604..f29ce3dd6140 100644
--- a/arch/powerpc/kernel/cpu_setup_6xx.S
+++ b/arch/powerpc/kernel/cpu_setup_6xx.S
@@ -4,6 +4,8 @@
  *    Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
  */
 
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/cputable.h>
@@ -81,7 +83,7 @@ _GLOBAL(__setup_cpu_745x)
 	blr
 
 /* Enable caches for 603's, 604, 750 & 7400 */
-setup_common_caches:
+SYM_FUNC_START_LOCAL(setup_common_caches)
 	mfspr	r11,SPRN_HID0
 	andi.	r0,r11,HID0_DCE
 	ori	r11,r11,HID0_ICE|HID0_DCE
@@ -95,11 +97,12 @@ setup_common_caches:
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_common_caches)
 
 /* 604, 604e, 604ev, ...
  * Enable superscalar execution & branch history table
  */
-setup_604_hid0:
+SYM_FUNC_START_LOCAL(setup_604_hid0)
 	mfspr	r11,SPRN_HID0
 	ori	r11,r11,HID0_SIED|HID0_BHTE
 	ori	r8,r11,HID0_BTCD
@@ -110,6 +113,7 @@ setup_604_hid0:
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_604_hid0)
 
 /* 7400 <= rev 2.7 and 7410 rev = 1.0 suffer from some
  * erratas we work around here.
@@ -125,13 +129,14 @@ setup_604_hid0:
  * needed once we have applied workaround #5 (though it's
  * not set by Apple's firmware at least).
  */
-setup_7400_workarounds:
+SYM_FUNC_START_LOCAL(setup_7400_workarounds)
 	mfpvr	r3
 	rlwinm	r3,r3,0,20,31
 	cmpwi	0,r3,0x0207
 	ble	1f
 	blr
-setup_7410_workarounds:
+SYM_FUNC_END(setup_7400_workarounds)
+SYM_FUNC_START_LOCAL(setup_7410_workarounds)
 	mfpvr	r3
 	rlwinm	r3,r3,0,20,31
 	cmpwi	0,r3,0x0100
@@ -151,6 +156,7 @@ setup_7410_workarounds:
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_7410_workarounds)
 
 /* 740/750/7400/7410
  * Enable Store Gathering (SGE), Address Broadcast (ABE),
@@ -158,7 +164,7 @@ setup_7410_workarounds:
  * Dynamic Power Management (DPM), Speculative (SPD)
  * Clear Instruction cache throttling (ICTC)
  */
-setup_750_7400_hid0:
+SYM_FUNC_START_LOCAL(setup_750_7400_hid0)
 	mfspr	r11,SPRN_HID0
 	ori	r11,r11,HID0_SGE | HID0_ABE | HID0_BHTE | HID0_BTIC
 	oris	r11,r11,HID0_DPM@h
@@ -177,12 +183,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_NO_DPM)
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_750_7400_hid0)
 
 /* 750cx specific
  * Looks like we have to disable NAP feature for some PLL settings...
  * (waiting for confirmation)
  */
-setup_750cx:
+SYM_FUNC_START_LOCAL(setup_750cx)
 	mfspr	r10, SPRN_HID1
 	rlwinm	r10,r10,4,28,31
 	cmpwi	cr0,r10,7
@@ -196,11 +203,13 @@ setup_750cx:
 	andc	r6,r6,r7
 	stw	r6,CPU_SPEC_FEATURES(r4)
 	blr
+SYM_FUNC_END(setup_750cx)
 
 /* 750fx specific
  */
-setup_750fx:
+SYM_FUNC_START_LOCAL(setup_750fx)
 	blr
+SYM_FUNC_END(setup_750fx)
 
 /* MPC 745x
  * Enable Store Gathering (SGE), Branch Folding (FOLD)
@@ -212,7 +221,7 @@ setup_750fx:
  * Clear Instruction cache throttling (ICTC)
  * Enable L2 HW prefetch
  */
-setup_745x_specifics:
+SYM_FUNC_START_LOCAL(setup_745x_specifics)
 	/* We check for the presence of an L3 cache setup by
 	 * the firmware. If any, we disable NAP capability as
 	 * it's known to be bogus on rev 2.1 and earlier
@@ -270,6 +279,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_NO_DPM)
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_745x_specifics)
 
 /*
  * Initialize the FPU registers. This is needed to work around an errata
diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 4bf33f1b4193..f573a4f3bbe6 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -8,6 +8,8 @@
  * Benjamin Herrenschmidt <benh@kernel.crashing.org>
  */
 
+#include <linux/linkage.h>
+
 #include <asm/page.h>
 #include <asm/processor.h>
 #include <asm/cputable.h>
@@ -274,7 +276,7 @@ _GLOBAL(flush_dcache_L1)
 
 	blr
 
-has_L2_cache:
+SYM_FUNC_START_LOCAL(has_L2_cache)
 	/* skip L2 cache on P2040/P2040E as they have no L2 cache */
 	mfspr	r3, SPRN_SVR
 	/* shift right by 8 bits and clear E bit of SVR */
@@ -290,9 +292,10 @@ has_L2_cache:
 1:
 	li	r3, 0
 	blr
+SYM_FUNC_END(has_L2_cache)
 
 /* flush backside L2 cache */
-flush_backside_L2_cache:
+SYM_FUNC_START_LOCAL(flush_backside_L2_cache)
 	mflr	r10
 	bl	has_L2_cache
 	mtlr	r10
@@ -313,6 +316,7 @@ flush_backside_L2_cache:
 	bne	1b
 2:
 	blr
+SYM_FUNC_END(flush_backside_L2_cache)
 
 _GLOBAL(cpu_down_flush_e500v2)
 	mflr r0
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 1d599df6f169..f8480d88509f 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -18,6 +18,8 @@
 #include <linux/err.h>
 #include <linux/sys.h>
 #include <linux/threads.h>
+#include <linux/linkage.h>
+
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -74,17 +76,18 @@ _ASM_NOKPROBE_SYMBOL(prepare_transfer_to_handler)
 #endif /* CONFIG_PPC_BOOK3S_32 || CONFIG_E500 */
 
 #if defined(CONFIG_PPC_KUEP) && defined(CONFIG_PPC_BOOK3S_32)
-	.globl	__kuep_lock
-__kuep_lock:
+SYM_FUNC_START(__kuep_lock)
 	lwz	r9, THREAD+THSR0(r2)
 	update_user_segments_by_4 r9, r10, r11, r12
 	blr
+SYM_FUNC_END(__kuep_lock)
 
-__kuep_unlock:
+SYM_FUNC_START_LOCAL(__kuep_unlock)
 	lwz	r9, THREAD+THSR0(r2)
 	rlwinm  r9,r9,0,~SR_NX
 	update_user_segments_by_4 r9, r10, r11, r12
 	blr
+SYM_FUNC_END(__kuep_unlock)
 
 .macro	kuep_lock
 	bl	__kuep_lock
diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S
index 088f500896c7..9110fe9d6747 100644
--- a/arch/powerpc/kernel/head_40x.S
+++ b/arch/powerpc/kernel/head_40x.S
@@ -28,6 +28,8 @@
 #include <linux/init.h>
 #include <linux/pgtable.h>
 #include <linux/sizes.h>
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -662,7 +664,7 @@ start_here:
  * kernel initialization.  This maps the first 32 MBytes of memory 1:1
  * virtual to physical and more importantly sets the cache mode.
  */
-initial_mmu:
+SYM_FUNC_START_LOCAL(initial_mmu)
 	tlbia			/* Invalidate all TLB entries */
 	isync
 
@@ -711,6 +713,7 @@ initial_mmu:
 	mtspr	SPRN_EVPR,r0
 
 	blr
+SYM_FUNC_END(initial_mmu)
 
 _GLOBAL(abort)
         mfspr   r13,SPRN_DBCR0
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 0b05f2be66b9..c94ed5a08c93 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -18,6 +18,8 @@
 #include <linux/magic.h>
 #include <linux/pgtable.h>
 #include <linux/sizes.h>
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -625,7 +627,7 @@ start_here:
  * 24 Mbytes of data, and the 512k IMMR space.  Anything not covered by
  * these mappings is mapped by page tables.
  */
-initial_mmu:
+SYM_FUNC_START_LOCAL(initial_mmu)
 	li	r8, 0
 	mtspr	SPRN_MI_CTR, r8		/* remove PINNED ITLB entries */
 	lis	r10, MD_TWAM@h
@@ -686,6 +688,7 @@ initial_mmu:
 #endif
 	mtspr	SPRN_DER, r8
 	blr
+SYM_FUNC_END(initial_mmu)
 
 _GLOBAL(mmu_pin_tlb)
 	lis	r9, (1f - PAGE_OFFSET)@h
diff --git a/arch/powerpc/kernel/head_book3s_32.S b/arch/powerpc/kernel/head_book3s_32.S
index 519b60695167..4af12447dc0b 100644
--- a/arch/powerpc/kernel/head_book3s_32.S
+++ b/arch/powerpc/kernel/head_book3s_32.S
@@ -18,6 +18,8 @@
 
 #include <linux/init.h>
 #include <linux/pgtable.h>
+#include <linux/linkage.h>
+
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -877,7 +879,7 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_HPTE_TABLE)
  * Load stuff into the MMU.  Intended to be called with
  * IR=0 and DR=0.
  */
-early_hash_table:
+SYM_FUNC_START_LOCAL(early_hash_table)
 	sync			/* Force all PTE updates to finish */
 	isync
 	tlbia			/* Clear all TLB entries */
@@ -888,8 +890,9 @@ early_hash_table:
 	ori	r6, r6, 3	/* 256kB table */
 	mtspr	SPRN_SDR1, r6
 	blr
+SYM_FUNC_END(early_hash_table)
 
-load_up_mmu:
+SYM_FUNC_START_LOCAL(load_up_mmu)
 	sync			/* Force all PTE updates to finish */
 	isync
 	tlbia			/* Clear all TLB entries */
@@ -918,6 +921,7 @@ BEGIN_MMU_FTR_SECTION
 	LOAD_BAT(7,r3,r4,r5)
 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
 	blr
+SYM_FUNC_END(load_up_mmu)
 
 _GLOBAL(load_segment_registers)
 	li	r0, NUM_USER_SEGMENTS /* load up user segment register values */
@@ -1028,7 +1032,7 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_HPTE_TABLE)
  * this makes sure it's done.
  *  -- Cort
  */
-clear_bats:
+SYM_FUNC_START_LOCAL(clear_bats)
 	li	r10,0
 
 	mtspr	SPRN_DBAT0U,r10
@@ -1072,6 +1076,7 @@ BEGIN_MMU_FTR_SECTION
 	mtspr	SPRN_IBAT7L,r10
 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
 	blr
+SYM_FUNC_END(clear_bats)
 
 _GLOBAL(update_bats)
 	lis	r4, 1f@h
@@ -1108,15 +1113,16 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
 	mtspr	SPRN_SRR1, r6
 	rfi
 
-flush_tlbs:
+SYM_FUNC_START_LOCAL(flush_tlbs)
 	lis	r10, 0x40
 1:	addic.	r10, r10, -0x1000
 	tlbie	r10
 	bgt	1b
 	sync
 	blr
+SYM_FUNC_END(flush_tlbs)
 
-mmu_off:
+SYM_FUNC_START_LOCAL(mmu_off)
  	addi	r4, r3, __after_mmu_off - _start
 	mfmsr	r3
 	andi.	r0,r3,MSR_DR|MSR_IR		/* MMU enabled? */
@@ -1128,9 +1134,10 @@ mmu_off:
 	mtspr	SPRN_SRR1,r3
 	sync
 	rfi
+SYM_FUNC_END(mmu_off)
 
 /* We use one BAT to map up to 256M of RAM at _PAGE_OFFSET */
-initial_bats:
+SYM_FUNC_START_LOCAL(initial_bats)
 	lis	r11,PAGE_OFFSET@h
 	tophys(r8,r11)
 #ifdef CONFIG_SMP
@@ -1146,9 +1153,10 @@ initial_bats:
 	mtspr	SPRN_IBAT0U,r11
 	isync
 	blr
+SYM_FUNC_END(initial_bats)
 
 #ifdef CONFIG_BOOTX_TEXT
-setup_disp_bat:
+SYM_FUNC_START_LOCAL(setup_disp_bat)
 	/*
 	 * setup the display bat prepared for us in prom.c
 	 */
@@ -1164,10 +1172,11 @@ setup_disp_bat:
 	mtspr	SPRN_DBAT3L,r8
 	mtspr	SPRN_DBAT3U,r11
 	blr
+SYM_FUNC_END(setup_disp_bat)
 #endif /* CONFIG_BOOTX_TEXT */
 
 #ifdef CONFIG_PPC_EARLY_DEBUG_CPM
-setup_cpm_bat:
+SYM_FUNC_START_LOCAL(setup_cpm_bat)
 	lis	r8, 0xf000
 	ori	r8, r8,	0x002a
 	mtspr	SPRN_DBAT1L, r8
@@ -1177,10 +1186,11 @@ setup_cpm_bat:
 	mtspr	SPRN_DBAT1U, r11
 
 	blr
+SYM_FUNC_END(setup_cpm_bat)
 #endif
 
 #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
-setup_usbgecko_bat:
+SYM_FUNC_START_LOCAL(setup_usbgecko_bat)
 	/* prepare a BAT for early io */
 #if defined(CONFIG_GAMECUBE)
 	lis	r8, 0x0c00
@@ -1199,6 +1209,7 @@ setup_usbgecko_bat:
 	mtspr	SPRN_DBAT1L, r8
 	mtspr	SPRN_DBAT1U, r11
 	blr
+SYM_FUNC_END(setup_usbgecko_bat)
 #endif
 
 	.data
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index f0db4f52bc00..744b096857a1 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -29,6 +29,8 @@
 #include <linux/init.h>
 #include <linux/threads.h>
 #include <linux/pgtable.h>
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -885,7 +887,7 @@ KernelSPE:
  * Translate the effec addr in r3 to phys addr. The phys addr will be put
  * into r3(higher 32bit) and r4(lower 32bit)
  */
-get_phys_addr:
+SYM_FUNC_START_LOCAL(get_phys_addr)
 	mfmsr	r8
 	mfspr	r9,SPRN_PID
 	rlwinm	r9,r9,16,0x3fff0000	/* turn PID into MAS6[SPID] */
@@ -907,6 +909,7 @@ get_phys_addr:
 	mfspr	r3,SPRN_MAS7
 #endif
 	blr
+SYM_FUNC_END(get_phys_addr)
 
 /*
  * Global functions
diff --git a/arch/powerpc/kernel/swsusp_32.S b/arch/powerpc/kernel/swsusp_32.S
index e0cbd63007f2..ffb79326483c 100644
--- a/arch/powerpc/kernel/swsusp_32.S
+++ b/arch/powerpc/kernel/swsusp_32.S
@@ -1,5 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/threads.h>
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/cputable.h>
@@ -400,7 +402,7 @@ _ASM_NOKPROBE_SYMBOL(swsusp_arch_resume)
 /* FIXME:This construct is actually not useful since we don't shut
  * down the instruction MMU, we could just flip back MSR-DR on.
  */
-turn_on_mmu:
+SYM_FUNC_START_LOCAL(turn_on_mmu)
 	mflr	r4
 	mtsrr0	r4
 	mtsrr1	r3
@@ -408,4 +410,5 @@ turn_on_mmu:
 	isync
 	rfi
 _ASM_NOKPROBE_SYMBOL(turn_on_mmu)
+SYM_FUNC_END(turn_on_mmu)
 
diff --git a/arch/powerpc/kvm/fpu.S b/arch/powerpc/kvm/fpu.S
index 315c94946bad..b68e7f26a81f 100644
--- a/arch/powerpc/kvm/fpu.S
+++ b/arch/powerpc/kvm/fpu.S
@@ -6,6 +6,8 @@
  */
 
 #include <linux/pgtable.h>
+#include <linux/linkage.h>
+
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -110,18 +112,22 @@ FPS_THREE_IN(fsel)
  * R8 = (double*)&param3 [load_three]
  * LR = instruction call function
  */
-fpd_load_three:
+SYM_FUNC_START_LOCAL(fpd_load_three)
 	lfd	2,0(r8)			/* load param3 */
-fpd_load_two:
+SYM_FUNC_START_LOCAL(fpd_load_two)
 	lfd	1,0(r7)			/* load param2 */
-fpd_load_one:
+SYM_FUNC_START_LOCAL(fpd_load_one)
 	lfd	0,0(r6)			/* load param1 */
-fpd_load_none:
+SYM_FUNC_START_LOCAL(fpd_load_none)
 	lfd	3,0(r3)			/* load up fpscr value */
 	MTFSF_L(3)
 	lwz	r6, 0(r4)		/* load cr */
 	mtcr	r6
 	blr
+SYM_FUNC_END(fpd_load_none)
+SYM_FUNC_END(fpd_load_one)
+SYM_FUNC_END(fpd_load_two)
+SYM_FUNC_END(fpd_load_three)
 
 /*
  * End of double instruction processing
@@ -131,13 +137,14 @@ fpd_load_none:
  * R5 = (double*)&result
  * LR = caller of instruction call function
  */
-fpd_return:
+SYM_FUNC_START_LOCAL(fpd_return)
 	mfcr	r6
 	stfd	0,0(r5)			/* save result */
 	mffs	0
 	stfd	0,0(r3)			/* save new fpscr value */
 	stw	r6,0(r4)		/* save new cr value */
 	blr
+SYM_FUNC_END(fpd_return)
 
 /*
  * Double operation with no input operand
diff --git a/arch/powerpc/platforms/52xx/lite5200_sleep.S b/arch/powerpc/platforms/52xx/lite5200_sleep.S
index afee8b1515a8..0b12647e7b42 100644
--- a/arch/powerpc/platforms/52xx/lite5200_sleep.S
+++ b/arch/powerpc/platforms/52xx/lite5200_sleep.S
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/linkage.h>
+
 #include <asm/reg.h>
 #include <asm/ppc_asm.h>
 #include <asm/processor.h>
@@ -178,7 +180,8 @@ sram_code:
 
 
 	/* local udelay in sram is needed */
-  udelay: /* r11 - tb_ticks_per_usec, r12 - usecs, overwrites r13 */
+SYM_FUNC_START_LOCAL(udelay)
+	/* r11 - tb_ticks_per_usec, r12 - usecs, overwrites r13 */
 	mullw	r12, r12, r11
 	mftb	r13	/* start */
 	add	r12, r13, r12 /* end */
@@ -187,6 +190,7 @@ sram_code:
 	cmp	cr0, r13, r12
 	blt	1b
 	blr
+SYM_FUNC_END(udelay)
 
 sram_code_end:
 
@@ -271,7 +275,7 @@ _ASM_NOKPROBE_SYMBOL(lite5200_wakeup)
 	SAVE_SR(n+2, addr+2);	\
 	SAVE_SR(n+3, addr+3);
 
-save_regs:
+SYM_FUNC_START_LOCAL(save_regs)
 	stw	r0, 0(r4)
 	stw	r1, 0x4(r4)
 	stw	r2, 0x8(r4)
@@ -317,6 +321,7 @@ save_regs:
 	SAVE_SPRN(TBRU,  0x5b)
 
 	blr
+SYM_FUNC_END(save_regs)
 
 
 /* restore registers */
@@ -336,7 +341,7 @@ save_regs:
 	LOAD_SR(n+2, addr+2);	\
 	LOAD_SR(n+3, addr+3);
 
-restore_regs:
+SYM_FUNC_START_LOCAL(restore_regs)
 	lis	r4, registers@h
 	ori	r4, r4, registers@l
 
@@ -393,6 +398,7 @@ restore_regs:
 
 	blr
 _ASM_NOKPROBE_SYMBOL(restore_regs)
+SYM_FUNC_END(restore_regs)
 
 
 
@@ -403,7 +409,7 @@ _ASM_NOKPROBE_SYMBOL(restore_regs)
  * Flush data cache
  * Do this by just reading lots of stuff into the cache.
  */
-flush_data_cache:
+SYM_FUNC_START_LOCAL(flush_data_cache)
 	lis	r3,CONFIG_KERNEL_START@h
 	ori	r3,r3,CONFIG_KERNEL_START@l
 	li	r4,NUM_CACHE_LINES
@@ -413,3 +419,4 @@ flush_data_cache:
 	addi	r3,r3,L1_CACHE_BYTES	/* Next line, please */
 	bdnz	1b
 	blr
+SYM_FUNC_END(flush_data_cache)
-- 
2.31.1


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

* [PATCH v2 06/16] powerpc: Fix objtool unannotated intra-function call warnings on PPC32
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

From: Christophe Leroy <christophe.leroy@csgroup.eu>

Fix several annotations in assembly files on PPC32.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
[Sathvika Vasireddy: Changed subject line from objtool/powerpc: Activate objtool on PPC32
to powerpc: Fix objtool unannotated intra-function call warnings on PPC32, and removed
Kconfig change to enable objtool, as it is part of objtool/powerpc: Enable objtool to be built on ppc patch in this series.]
Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/kernel/cpu_setup_6xx.S          | 26 ++++++++++++------
 arch/powerpc/kernel/cpu_setup_fsl_booke.S    |  8 ++++--
 arch/powerpc/kernel/entry_32.S               |  9 ++++--
 arch/powerpc/kernel/head_40x.S               |  5 +++-
 arch/powerpc/kernel/head_8xx.S               |  5 +++-
 arch/powerpc/kernel/head_book3s_32.S         | 29 ++++++++++++++------
 arch/powerpc/kernel/head_fsl_booke.S         |  5 +++-
 arch/powerpc/kernel/swsusp_32.S              |  5 +++-
 arch/powerpc/kvm/fpu.S                       | 17 ++++++++----
 arch/powerpc/platforms/52xx/lite5200_sleep.S | 15 +++++++---
 10 files changed, 89 insertions(+), 35 deletions(-)

diff --git a/arch/powerpc/kernel/cpu_setup_6xx.S b/arch/powerpc/kernel/cpu_setup_6xx.S
index f8b5ff64b604..f29ce3dd6140 100644
--- a/arch/powerpc/kernel/cpu_setup_6xx.S
+++ b/arch/powerpc/kernel/cpu_setup_6xx.S
@@ -4,6 +4,8 @@
  *    Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
  */
 
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/cputable.h>
@@ -81,7 +83,7 @@ _GLOBAL(__setup_cpu_745x)
 	blr
 
 /* Enable caches for 603's, 604, 750 & 7400 */
-setup_common_caches:
+SYM_FUNC_START_LOCAL(setup_common_caches)
 	mfspr	r11,SPRN_HID0
 	andi.	r0,r11,HID0_DCE
 	ori	r11,r11,HID0_ICE|HID0_DCE
@@ -95,11 +97,12 @@ setup_common_caches:
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_common_caches)
 
 /* 604, 604e, 604ev, ...
  * Enable superscalar execution & branch history table
  */
-setup_604_hid0:
+SYM_FUNC_START_LOCAL(setup_604_hid0)
 	mfspr	r11,SPRN_HID0
 	ori	r11,r11,HID0_SIED|HID0_BHTE
 	ori	r8,r11,HID0_BTCD
@@ -110,6 +113,7 @@ setup_604_hid0:
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_604_hid0)
 
 /* 7400 <= rev 2.7 and 7410 rev = 1.0 suffer from some
  * erratas we work around here.
@@ -125,13 +129,14 @@ setup_604_hid0:
  * needed once we have applied workaround #5 (though it's
  * not set by Apple's firmware at least).
  */
-setup_7400_workarounds:
+SYM_FUNC_START_LOCAL(setup_7400_workarounds)
 	mfpvr	r3
 	rlwinm	r3,r3,0,20,31
 	cmpwi	0,r3,0x0207
 	ble	1f
 	blr
-setup_7410_workarounds:
+SYM_FUNC_END(setup_7400_workarounds)
+SYM_FUNC_START_LOCAL(setup_7410_workarounds)
 	mfpvr	r3
 	rlwinm	r3,r3,0,20,31
 	cmpwi	0,r3,0x0100
@@ -151,6 +156,7 @@ setup_7410_workarounds:
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_7410_workarounds)
 
 /* 740/750/7400/7410
  * Enable Store Gathering (SGE), Address Broadcast (ABE),
@@ -158,7 +164,7 @@ setup_7410_workarounds:
  * Dynamic Power Management (DPM), Speculative (SPD)
  * Clear Instruction cache throttling (ICTC)
  */
-setup_750_7400_hid0:
+SYM_FUNC_START_LOCAL(setup_750_7400_hid0)
 	mfspr	r11,SPRN_HID0
 	ori	r11,r11,HID0_SGE | HID0_ABE | HID0_BHTE | HID0_BTIC
 	oris	r11,r11,HID0_DPM@h
@@ -177,12 +183,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_NO_DPM)
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_750_7400_hid0)
 
 /* 750cx specific
  * Looks like we have to disable NAP feature for some PLL settings...
  * (waiting for confirmation)
  */
-setup_750cx:
+SYM_FUNC_START_LOCAL(setup_750cx)
 	mfspr	r10, SPRN_HID1
 	rlwinm	r10,r10,4,28,31
 	cmpwi	cr0,r10,7
@@ -196,11 +203,13 @@ setup_750cx:
 	andc	r6,r6,r7
 	stw	r6,CPU_SPEC_FEATURES(r4)
 	blr
+SYM_FUNC_END(setup_750cx)
 
 /* 750fx specific
  */
-setup_750fx:
+SYM_FUNC_START_LOCAL(setup_750fx)
 	blr
+SYM_FUNC_END(setup_750fx)
 
 /* MPC 745x
  * Enable Store Gathering (SGE), Branch Folding (FOLD)
@@ -212,7 +221,7 @@ setup_750fx:
  * Clear Instruction cache throttling (ICTC)
  * Enable L2 HW prefetch
  */
-setup_745x_specifics:
+SYM_FUNC_START_LOCAL(setup_745x_specifics)
 	/* We check for the presence of an L3 cache setup by
 	 * the firmware. If any, we disable NAP capability as
 	 * it's known to be bogus on rev 2.1 and earlier
@@ -270,6 +279,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_NO_DPM)
 	sync
 	isync
 	blr
+SYM_FUNC_END(setup_745x_specifics)
 
 /*
  * Initialize the FPU registers. This is needed to work around an errata
diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 4bf33f1b4193..f573a4f3bbe6 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -8,6 +8,8 @@
  * Benjamin Herrenschmidt <benh@kernel.crashing.org>
  */
 
+#include <linux/linkage.h>
+
 #include <asm/page.h>
 #include <asm/processor.h>
 #include <asm/cputable.h>
@@ -274,7 +276,7 @@ _GLOBAL(flush_dcache_L1)
 
 	blr
 
-has_L2_cache:
+SYM_FUNC_START_LOCAL(has_L2_cache)
 	/* skip L2 cache on P2040/P2040E as they have no L2 cache */
 	mfspr	r3, SPRN_SVR
 	/* shift right by 8 bits and clear E bit of SVR */
@@ -290,9 +292,10 @@ has_L2_cache:
 1:
 	li	r3, 0
 	blr
+SYM_FUNC_END(has_L2_cache)
 
 /* flush backside L2 cache */
-flush_backside_L2_cache:
+SYM_FUNC_START_LOCAL(flush_backside_L2_cache)
 	mflr	r10
 	bl	has_L2_cache
 	mtlr	r10
@@ -313,6 +316,7 @@ flush_backside_L2_cache:
 	bne	1b
 2:
 	blr
+SYM_FUNC_END(flush_backside_L2_cache)
 
 _GLOBAL(cpu_down_flush_e500v2)
 	mflr r0
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 1d599df6f169..f8480d88509f 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -18,6 +18,8 @@
 #include <linux/err.h>
 #include <linux/sys.h>
 #include <linux/threads.h>
+#include <linux/linkage.h>
+
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -74,17 +76,18 @@ _ASM_NOKPROBE_SYMBOL(prepare_transfer_to_handler)
 #endif /* CONFIG_PPC_BOOK3S_32 || CONFIG_E500 */
 
 #if defined(CONFIG_PPC_KUEP) && defined(CONFIG_PPC_BOOK3S_32)
-	.globl	__kuep_lock
-__kuep_lock:
+SYM_FUNC_START(__kuep_lock)
 	lwz	r9, THREAD+THSR0(r2)
 	update_user_segments_by_4 r9, r10, r11, r12
 	blr
+SYM_FUNC_END(__kuep_lock)
 
-__kuep_unlock:
+SYM_FUNC_START_LOCAL(__kuep_unlock)
 	lwz	r9, THREAD+THSR0(r2)
 	rlwinm  r9,r9,0,~SR_NX
 	update_user_segments_by_4 r9, r10, r11, r12
 	blr
+SYM_FUNC_END(__kuep_unlock)
 
 .macro	kuep_lock
 	bl	__kuep_lock
diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S
index 088f500896c7..9110fe9d6747 100644
--- a/arch/powerpc/kernel/head_40x.S
+++ b/arch/powerpc/kernel/head_40x.S
@@ -28,6 +28,8 @@
 #include <linux/init.h>
 #include <linux/pgtable.h>
 #include <linux/sizes.h>
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -662,7 +664,7 @@ start_here:
  * kernel initialization.  This maps the first 32 MBytes of memory 1:1
  * virtual to physical and more importantly sets the cache mode.
  */
-initial_mmu:
+SYM_FUNC_START_LOCAL(initial_mmu)
 	tlbia			/* Invalidate all TLB entries */
 	isync
 
@@ -711,6 +713,7 @@ initial_mmu:
 	mtspr	SPRN_EVPR,r0
 
 	blr
+SYM_FUNC_END(initial_mmu)
 
 _GLOBAL(abort)
         mfspr   r13,SPRN_DBCR0
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 0b05f2be66b9..c94ed5a08c93 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -18,6 +18,8 @@
 #include <linux/magic.h>
 #include <linux/pgtable.h>
 #include <linux/sizes.h>
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -625,7 +627,7 @@ start_here:
  * 24 Mbytes of data, and the 512k IMMR space.  Anything not covered by
  * these mappings is mapped by page tables.
  */
-initial_mmu:
+SYM_FUNC_START_LOCAL(initial_mmu)
 	li	r8, 0
 	mtspr	SPRN_MI_CTR, r8		/* remove PINNED ITLB entries */
 	lis	r10, MD_TWAM@h
@@ -686,6 +688,7 @@ initial_mmu:
 #endif
 	mtspr	SPRN_DER, r8
 	blr
+SYM_FUNC_END(initial_mmu)
 
 _GLOBAL(mmu_pin_tlb)
 	lis	r9, (1f - PAGE_OFFSET)@h
diff --git a/arch/powerpc/kernel/head_book3s_32.S b/arch/powerpc/kernel/head_book3s_32.S
index 519b60695167..4af12447dc0b 100644
--- a/arch/powerpc/kernel/head_book3s_32.S
+++ b/arch/powerpc/kernel/head_book3s_32.S
@@ -18,6 +18,8 @@
 
 #include <linux/init.h>
 #include <linux/pgtable.h>
+#include <linux/linkage.h>
+
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -877,7 +879,7 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_HPTE_TABLE)
  * Load stuff into the MMU.  Intended to be called with
  * IR=0 and DR=0.
  */
-early_hash_table:
+SYM_FUNC_START_LOCAL(early_hash_table)
 	sync			/* Force all PTE updates to finish */
 	isync
 	tlbia			/* Clear all TLB entries */
@@ -888,8 +890,9 @@ early_hash_table:
 	ori	r6, r6, 3	/* 256kB table */
 	mtspr	SPRN_SDR1, r6
 	blr
+SYM_FUNC_END(early_hash_table)
 
-load_up_mmu:
+SYM_FUNC_START_LOCAL(load_up_mmu)
 	sync			/* Force all PTE updates to finish */
 	isync
 	tlbia			/* Clear all TLB entries */
@@ -918,6 +921,7 @@ BEGIN_MMU_FTR_SECTION
 	LOAD_BAT(7,r3,r4,r5)
 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
 	blr
+SYM_FUNC_END(load_up_mmu)
 
 _GLOBAL(load_segment_registers)
 	li	r0, NUM_USER_SEGMENTS /* load up user segment register values */
@@ -1028,7 +1032,7 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_HPTE_TABLE)
  * this makes sure it's done.
  *  -- Cort
  */
-clear_bats:
+SYM_FUNC_START_LOCAL(clear_bats)
 	li	r10,0
 
 	mtspr	SPRN_DBAT0U,r10
@@ -1072,6 +1076,7 @@ BEGIN_MMU_FTR_SECTION
 	mtspr	SPRN_IBAT7L,r10
 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
 	blr
+SYM_FUNC_END(clear_bats)
 
 _GLOBAL(update_bats)
 	lis	r4, 1f@h
@@ -1108,15 +1113,16 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
 	mtspr	SPRN_SRR1, r6
 	rfi
 
-flush_tlbs:
+SYM_FUNC_START_LOCAL(flush_tlbs)
 	lis	r10, 0x40
 1:	addic.	r10, r10, -0x1000
 	tlbie	r10
 	bgt	1b
 	sync
 	blr
+SYM_FUNC_END(flush_tlbs)
 
-mmu_off:
+SYM_FUNC_START_LOCAL(mmu_off)
  	addi	r4, r3, __after_mmu_off - _start
 	mfmsr	r3
 	andi.	r0,r3,MSR_DR|MSR_IR		/* MMU enabled? */
@@ -1128,9 +1134,10 @@ mmu_off:
 	mtspr	SPRN_SRR1,r3
 	sync
 	rfi
+SYM_FUNC_END(mmu_off)
 
 /* We use one BAT to map up to 256M of RAM at _PAGE_OFFSET */
-initial_bats:
+SYM_FUNC_START_LOCAL(initial_bats)
 	lis	r11,PAGE_OFFSET@h
 	tophys(r8,r11)
 #ifdef CONFIG_SMP
@@ -1146,9 +1153,10 @@ initial_bats:
 	mtspr	SPRN_IBAT0U,r11
 	isync
 	blr
+SYM_FUNC_END(initial_bats)
 
 #ifdef CONFIG_BOOTX_TEXT
-setup_disp_bat:
+SYM_FUNC_START_LOCAL(setup_disp_bat)
 	/*
 	 * setup the display bat prepared for us in prom.c
 	 */
@@ -1164,10 +1172,11 @@ setup_disp_bat:
 	mtspr	SPRN_DBAT3L,r8
 	mtspr	SPRN_DBAT3U,r11
 	blr
+SYM_FUNC_END(setup_disp_bat)
 #endif /* CONFIG_BOOTX_TEXT */
 
 #ifdef CONFIG_PPC_EARLY_DEBUG_CPM
-setup_cpm_bat:
+SYM_FUNC_START_LOCAL(setup_cpm_bat)
 	lis	r8, 0xf000
 	ori	r8, r8,	0x002a
 	mtspr	SPRN_DBAT1L, r8
@@ -1177,10 +1186,11 @@ setup_cpm_bat:
 	mtspr	SPRN_DBAT1U, r11
 
 	blr
+SYM_FUNC_END(setup_cpm_bat)
 #endif
 
 #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
-setup_usbgecko_bat:
+SYM_FUNC_START_LOCAL(setup_usbgecko_bat)
 	/* prepare a BAT for early io */
 #if defined(CONFIG_GAMECUBE)
 	lis	r8, 0x0c00
@@ -1199,6 +1209,7 @@ setup_usbgecko_bat:
 	mtspr	SPRN_DBAT1L, r8
 	mtspr	SPRN_DBAT1U, r11
 	blr
+SYM_FUNC_END(setup_usbgecko_bat)
 #endif
 
 	.data
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index f0db4f52bc00..744b096857a1 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -29,6 +29,8 @@
 #include <linux/init.h>
 #include <linux/threads.h>
 #include <linux/pgtable.h>
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -885,7 +887,7 @@ KernelSPE:
  * Translate the effec addr in r3 to phys addr. The phys addr will be put
  * into r3(higher 32bit) and r4(lower 32bit)
  */
-get_phys_addr:
+SYM_FUNC_START_LOCAL(get_phys_addr)
 	mfmsr	r8
 	mfspr	r9,SPRN_PID
 	rlwinm	r9,r9,16,0x3fff0000	/* turn PID into MAS6[SPID] */
@@ -907,6 +909,7 @@ get_phys_addr:
 	mfspr	r3,SPRN_MAS7
 #endif
 	blr
+SYM_FUNC_END(get_phys_addr)
 
 /*
  * Global functions
diff --git a/arch/powerpc/kernel/swsusp_32.S b/arch/powerpc/kernel/swsusp_32.S
index e0cbd63007f2..ffb79326483c 100644
--- a/arch/powerpc/kernel/swsusp_32.S
+++ b/arch/powerpc/kernel/swsusp_32.S
@@ -1,5 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/threads.h>
+#include <linux/linkage.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/cputable.h>
@@ -400,7 +402,7 @@ _ASM_NOKPROBE_SYMBOL(swsusp_arch_resume)
 /* FIXME:This construct is actually not useful since we don't shut
  * down the instruction MMU, we could just flip back MSR-DR on.
  */
-turn_on_mmu:
+SYM_FUNC_START_LOCAL(turn_on_mmu)
 	mflr	r4
 	mtsrr0	r4
 	mtsrr1	r3
@@ -408,4 +410,5 @@ turn_on_mmu:
 	isync
 	rfi
 _ASM_NOKPROBE_SYMBOL(turn_on_mmu)
+SYM_FUNC_END(turn_on_mmu)
 
diff --git a/arch/powerpc/kvm/fpu.S b/arch/powerpc/kvm/fpu.S
index 315c94946bad..b68e7f26a81f 100644
--- a/arch/powerpc/kvm/fpu.S
+++ b/arch/powerpc/kvm/fpu.S
@@ -6,6 +6,8 @@
  */
 
 #include <linux/pgtable.h>
+#include <linux/linkage.h>
+
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
@@ -110,18 +112,22 @@ FPS_THREE_IN(fsel)
  * R8 = (double*)&param3 [load_three]
  * LR = instruction call function
  */
-fpd_load_three:
+SYM_FUNC_START_LOCAL(fpd_load_three)
 	lfd	2,0(r8)			/* load param3 */
-fpd_load_two:
+SYM_FUNC_START_LOCAL(fpd_load_two)
 	lfd	1,0(r7)			/* load param2 */
-fpd_load_one:
+SYM_FUNC_START_LOCAL(fpd_load_one)
 	lfd	0,0(r6)			/* load param1 */
-fpd_load_none:
+SYM_FUNC_START_LOCAL(fpd_load_none)
 	lfd	3,0(r3)			/* load up fpscr value */
 	MTFSF_L(3)
 	lwz	r6, 0(r4)		/* load cr */
 	mtcr	r6
 	blr
+SYM_FUNC_END(fpd_load_none)
+SYM_FUNC_END(fpd_load_one)
+SYM_FUNC_END(fpd_load_two)
+SYM_FUNC_END(fpd_load_three)
 
 /*
  * End of double instruction processing
@@ -131,13 +137,14 @@ fpd_load_none:
  * R5 = (double*)&result
  * LR = caller of instruction call function
  */
-fpd_return:
+SYM_FUNC_START_LOCAL(fpd_return)
 	mfcr	r6
 	stfd	0,0(r5)			/* save result */
 	mffs	0
 	stfd	0,0(r3)			/* save new fpscr value */
 	stw	r6,0(r4)		/* save new cr value */
 	blr
+SYM_FUNC_END(fpd_return)
 
 /*
  * Double operation with no input operand
diff --git a/arch/powerpc/platforms/52xx/lite5200_sleep.S b/arch/powerpc/platforms/52xx/lite5200_sleep.S
index afee8b1515a8..0b12647e7b42 100644
--- a/arch/powerpc/platforms/52xx/lite5200_sleep.S
+++ b/arch/powerpc/platforms/52xx/lite5200_sleep.S
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/linkage.h>
+
 #include <asm/reg.h>
 #include <asm/ppc_asm.h>
 #include <asm/processor.h>
@@ -178,7 +180,8 @@ sram_code:
 
 
 	/* local udelay in sram is needed */
-  udelay: /* r11 - tb_ticks_per_usec, r12 - usecs, overwrites r13 */
+SYM_FUNC_START_LOCAL(udelay)
+	/* r11 - tb_ticks_per_usec, r12 - usecs, overwrites r13 */
 	mullw	r12, r12, r11
 	mftb	r13	/* start */
 	add	r12, r13, r12 /* end */
@@ -187,6 +190,7 @@ sram_code:
 	cmp	cr0, r13, r12
 	blt	1b
 	blr
+SYM_FUNC_END(udelay)
 
 sram_code_end:
 
@@ -271,7 +275,7 @@ _ASM_NOKPROBE_SYMBOL(lite5200_wakeup)
 	SAVE_SR(n+2, addr+2);	\
 	SAVE_SR(n+3, addr+3);
 
-save_regs:
+SYM_FUNC_START_LOCAL(save_regs)
 	stw	r0, 0(r4)
 	stw	r1, 0x4(r4)
 	stw	r2, 0x8(r4)
@@ -317,6 +321,7 @@ save_regs:
 	SAVE_SPRN(TBRU,  0x5b)
 
 	blr
+SYM_FUNC_END(save_regs)
 
 
 /* restore registers */
@@ -336,7 +341,7 @@ save_regs:
 	LOAD_SR(n+2, addr+2);	\
 	LOAD_SR(n+3, addr+3);
 
-restore_regs:
+SYM_FUNC_START_LOCAL(restore_regs)
 	lis	r4, registers@h
 	ori	r4, r4, registers@l
 
@@ -393,6 +398,7 @@ restore_regs:
 
 	blr
 _ASM_NOKPROBE_SYMBOL(restore_regs)
+SYM_FUNC_END(restore_regs)
 
 
 
@@ -403,7 +409,7 @@ _ASM_NOKPROBE_SYMBOL(restore_regs)
  * Flush data cache
  * Do this by just reading lots of stuff into the cache.
  */
-flush_data_cache:
+SYM_FUNC_START_LOCAL(flush_data_cache)
 	lis	r3,CONFIG_KERNEL_START@h
 	ori	r3,r3,CONFIG_KERNEL_START@l
 	li	r4,NUM_CACHE_LINES
@@ -413,3 +419,4 @@ flush_data_cache:
 	addi	r3,r3,L1_CACHE_BYTES	/* Next line, please */
 	bdnz	1b
 	blr
+SYM_FUNC_END(flush_data_cache)
-- 
2.31.1


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

* [PATCH v2 07/16] powerpc: Skip objtool from running on VDSO files
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

Do not run objtool on VDSO files, by using
OBJECT_FILES_NON_STANDARD

Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/kernel/vdso/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
index 096b0bf1335f..a49a0d6a1c53 100644
--- a/arch/powerpc/kernel/vdso/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -102,3 +102,5 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@
       cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
 quiet_cmd_vdso64as = VDSO64A $@
       cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
+
+OBJECT_FILES_NON_STANDARD := y
-- 
2.31.1


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

* [PATCH v2 07/16] powerpc: Skip objtool from running on VDSO files
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

Do not run objtool on VDSO files, by using
OBJECT_FILES_NON_STANDARD

Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/kernel/vdso/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
index 096b0bf1335f..a49a0d6a1c53 100644
--- a/arch/powerpc/kernel/vdso/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -102,3 +102,5 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@
       cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
 quiet_cmd_vdso64as = VDSO64A $@
       cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
+
+OBJECT_FILES_NON_STANDARD := y
-- 
2.31.1


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

* [PATCH v2 08/16] objtool: Fix SEGFAULT
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

From: Christophe Leroy <christophe.leroy@csgroup.eu>

find_insn() will return NULL in case of failure. Check insn in order
to avoid a kernel Oops for NULL pointer dereference.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 tools/objtool/check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 91678252a9b6..ed2fdfeb1d9c 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -205,7 +205,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
 		return false;
 
 	insn = find_insn(file, func->sec, func->offset);
-	if (!insn->func)
+	if (!insn || !insn->func)
 		return false;
 
 	func_for_each_insn(file, func, insn) {
-- 
2.31.1


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

* [PATCH v2 08/16] objtool: Fix SEGFAULT
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

From: Christophe Leroy <christophe.leroy@csgroup.eu>

find_insn() will return NULL in case of failure. Check insn in order
to avoid a kernel Oops for NULL pointer dereference.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 tools/objtool/check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 91678252a9b6..ed2fdfeb1d9c 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -205,7 +205,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
 		return false;
 
 	insn = find_insn(file, func->sec, func->offset);
-	if (!insn->func)
+	if (!insn || !insn->func)
 		return false;
 
 	func_for_each_insn(file, func, insn) {
-- 
2.31.1


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

* [PATCH v2 09/16] objtool: Use target file endianness instead of a compiled constant
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

From: Christophe Leroy <christophe.leroy@csgroup.eu>

Some architectures like powerpc support both endianness, it's
therefore not possible to fix the endianness via arch/endianness.h
because there is no easy way to get the target endianness at
build time.

Use the endianness recorded in the file objtool is working on.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 .../arch/x86/include/arch/endianness.h        |  9 ------
 tools/objtool/check.c                         |  2 +-
 tools/objtool/include/objtool/endianness.h    | 32 +++++++++----------
 tools/objtool/orc_dump.c                      | 11 +++++--
 tools/objtool/orc_gen.c                       |  4 +--
 tools/objtool/special.c                       |  3 +-
 6 files changed, 30 insertions(+), 31 deletions(-)
 delete mode 100644 tools/objtool/arch/x86/include/arch/endianness.h

diff --git a/tools/objtool/arch/x86/include/arch/endianness.h b/tools/objtool/arch/x86/include/arch/endianness.h
deleted file mode 100644
index 7c362527da20..000000000000
--- a/tools/objtool/arch/x86/include/arch/endianness.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _ARCH_ENDIANNESS_H
-#define _ARCH_ENDIANNESS_H
-
-#include <endian.h>
-
-#define __TARGET_BYTE_ORDER __LITTLE_ENDIAN
-
-#endif /* _ARCH_ENDIANNESS_H */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index ed2fdfeb1d9c..a948b2551520 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2075,7 +2075,7 @@ static int read_unwind_hints(struct objtool_file *file)
 			return -1;
 		}
 
-		cfi.cfa.offset = bswap_if_needed(hint->sp_offset);
+		cfi.cfa.offset = bswap_if_needed(file->elf, hint->sp_offset);
 		cfi.type = hint->type;
 		cfi.end = hint->end;
 
diff --git a/tools/objtool/include/objtool/endianness.h b/tools/objtool/include/objtool/endianness.h
index 10241341eff3..4d2aa9b0fe2f 100644
--- a/tools/objtool/include/objtool/endianness.h
+++ b/tools/objtool/include/objtool/endianness.h
@@ -2,33 +2,33 @@
 #ifndef _OBJTOOL_ENDIANNESS_H
 #define _OBJTOOL_ENDIANNESS_H
 
-#include <arch/endianness.h>
 #include <linux/kernel.h>
 #include <endian.h>
-
-#ifndef __TARGET_BYTE_ORDER
-#error undefined arch __TARGET_BYTE_ORDER
-#endif
-
-#if __BYTE_ORDER != __TARGET_BYTE_ORDER
-#define __NEED_BSWAP 1
-#else
-#define __NEED_BSWAP 0
-#endif
+#include <objtool/elf.h>
 
 /*
- * Does a byte swap if target endianness doesn't match the host, i.e. cross
+ * Does a byte swap if target file endianness doesn't match the host, i.e. cross
  * compilation for little endian on big endian and vice versa.
  * To be used for multi-byte values conversion, which are read from / about
  * to be written to a target native endianness ELF file.
  */
-#define bswap_if_needed(val)						\
+static inline bool need_bswap(struct elf *elf)
+{
+	return (__BYTE_ORDER == __LITTLE_ENDIAN) ^
+	       (elf->ehdr.e_ident[EI_DATA] == ELFDATA2LSB);
+}
+
+#define bswap_if_needed(elf, val)					\
 ({									\
 	__typeof__(val) __ret;						\
+	bool __need_bswap = need_bswap(elf);				\
 	switch (sizeof(val)) {						\
-	case 8: __ret = __NEED_BSWAP ? bswap_64(val) : (val); break;	\
-	case 4: __ret = __NEED_BSWAP ? bswap_32(val) : (val); break;	\
-	case 2: __ret = __NEED_BSWAP ? bswap_16(val) : (val); break;	\
+	case 8:								\
+		__ret = __need_bswap ? bswap_64(val) : (val); break;	\
+	case 4:								\
+		__ret = __need_bswap ? bswap_32(val) : (val); break;	\
+	case 2:								\
+		__ret = __need_bswap ? bswap_16(val) : (val); break;	\
 	default:							\
 		BUILD_BUG(); break;					\
 	}								\
diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c
index f5a8508c42d6..4f1211fec82c 100644
--- a/tools/objtool/orc_dump.c
+++ b/tools/objtool/orc_dump.c
@@ -76,6 +76,7 @@ int orc_dump(const char *_objname)
 	GElf_Rela rela;
 	GElf_Sym sym;
 	Elf_Data *data, *symtab = NULL, *rela_orc_ip = NULL;
+	struct elf dummy_elf = {};
 
 
 	objname = _objname;
@@ -94,6 +95,12 @@ int orc_dump(const char *_objname)
 		return -1;
 	}
 
+	if (!elf64_getehdr(elf)) {
+		WARN_ELF("elf64_getehdr");
+		return -1;
+	}
+	memcpy(&dummy_elf.ehdr, elf64_getehdr(elf), sizeof(dummy_elf.ehdr));
+
 	if (elf_getshdrnum(elf, &nr_sections)) {
 		WARN_ELF("elf_getshdrnum");
 		return -1;
@@ -198,11 +205,11 @@ int orc_dump(const char *_objname)
 
 		printf(" sp:");
 
-		print_reg(orc[i].sp_reg, bswap_if_needed(orc[i].sp_offset));
+		print_reg(orc[i].sp_reg, bswap_if_needed(&dummy_elf, orc[i].sp_offset));
 
 		printf(" bp:");
 
-		print_reg(orc[i].bp_reg, bswap_if_needed(orc[i].bp_offset));
+		print_reg(orc[i].bp_reg, bswap_if_needed(&dummy_elf, orc[i].bp_offset));
 
 		printf(" type:%s end:%d\n",
 		       orc_type_name(orc[i].type), orc[i].end);
diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
index dd3c64af9db2..1f22b7ebae58 100644
--- a/tools/objtool/orc_gen.c
+++ b/tools/objtool/orc_gen.c
@@ -97,8 +97,8 @@ static int write_orc_entry(struct elf *elf, struct section *orc_sec,
 	/* populate ORC data */
 	orc = (struct orc_entry *)orc_sec->data->d_buf + idx;
 	memcpy(orc, o, sizeof(*orc));
-	orc->sp_offset = bswap_if_needed(orc->sp_offset);
-	orc->bp_offset = bswap_if_needed(orc->bp_offset);
+	orc->sp_offset = bswap_if_needed(elf, orc->sp_offset);
+	orc->bp_offset = bswap_if_needed(elf, orc->bp_offset);
 
 	/* populate reloc for ip */
 	if (elf_add_reloc_to_insn(elf, ip_sec, idx * sizeof(int), R_X86_64_PC32,
diff --git a/tools/objtool/special.c b/tools/objtool/special.c
index e2223dd91c37..9c8d827f69af 100644
--- a/tools/objtool/special.c
+++ b/tools/objtool/special.c
@@ -87,7 +87,8 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry,
 	if (entry->feature) {
 		unsigned short feature;
 
-		feature = bswap_if_needed(*(unsigned short *)(sec->data->d_buf +
+		feature = bswap_if_needed(elf,
+					  *(unsigned short *)(sec->data->d_buf +
 							      offset +
 							      entry->feature));
 		arch_handle_alternative(feature, alt);
-- 
2.31.1


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

* [PATCH v2 09/16] objtool: Use target file endianness instead of a compiled constant
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

From: Christophe Leroy <christophe.leroy@csgroup.eu>

Some architectures like powerpc support both endianness, it's
therefore not possible to fix the endianness via arch/endianness.h
because there is no easy way to get the target endianness at
build time.

Use the endianness recorded in the file objtool is working on.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 .../arch/x86/include/arch/endianness.h        |  9 ------
 tools/objtool/check.c                         |  2 +-
 tools/objtool/include/objtool/endianness.h    | 32 +++++++++----------
 tools/objtool/orc_dump.c                      | 11 +++++--
 tools/objtool/orc_gen.c                       |  4 +--
 tools/objtool/special.c                       |  3 +-
 6 files changed, 30 insertions(+), 31 deletions(-)
 delete mode 100644 tools/objtool/arch/x86/include/arch/endianness.h

diff --git a/tools/objtool/arch/x86/include/arch/endianness.h b/tools/objtool/arch/x86/include/arch/endianness.h
deleted file mode 100644
index 7c362527da20..000000000000
--- a/tools/objtool/arch/x86/include/arch/endianness.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _ARCH_ENDIANNESS_H
-#define _ARCH_ENDIANNESS_H
-
-#include <endian.h>
-
-#define __TARGET_BYTE_ORDER __LITTLE_ENDIAN
-
-#endif /* _ARCH_ENDIANNESS_H */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index ed2fdfeb1d9c..a948b2551520 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2075,7 +2075,7 @@ static int read_unwind_hints(struct objtool_file *file)
 			return -1;
 		}
 
-		cfi.cfa.offset = bswap_if_needed(hint->sp_offset);
+		cfi.cfa.offset = bswap_if_needed(file->elf, hint->sp_offset);
 		cfi.type = hint->type;
 		cfi.end = hint->end;
 
diff --git a/tools/objtool/include/objtool/endianness.h b/tools/objtool/include/objtool/endianness.h
index 10241341eff3..4d2aa9b0fe2f 100644
--- a/tools/objtool/include/objtool/endianness.h
+++ b/tools/objtool/include/objtool/endianness.h
@@ -2,33 +2,33 @@
 #ifndef _OBJTOOL_ENDIANNESS_H
 #define _OBJTOOL_ENDIANNESS_H
 
-#include <arch/endianness.h>
 #include <linux/kernel.h>
 #include <endian.h>
-
-#ifndef __TARGET_BYTE_ORDER
-#error undefined arch __TARGET_BYTE_ORDER
-#endif
-
-#if __BYTE_ORDER != __TARGET_BYTE_ORDER
-#define __NEED_BSWAP 1
-#else
-#define __NEED_BSWAP 0
-#endif
+#include <objtool/elf.h>
 
 /*
- * Does a byte swap if target endianness doesn't match the host, i.e. cross
+ * Does a byte swap if target file endianness doesn't match the host, i.e. cross
  * compilation for little endian on big endian and vice versa.
  * To be used for multi-byte values conversion, which are read from / about
  * to be written to a target native endianness ELF file.
  */
-#define bswap_if_needed(val)						\
+static inline bool need_bswap(struct elf *elf)
+{
+	return (__BYTE_ORDER == __LITTLE_ENDIAN) ^
+	       (elf->ehdr.e_ident[EI_DATA] == ELFDATA2LSB);
+}
+
+#define bswap_if_needed(elf, val)					\
 ({									\
 	__typeof__(val) __ret;						\
+	bool __need_bswap = need_bswap(elf);				\
 	switch (sizeof(val)) {						\
-	case 8: __ret = __NEED_BSWAP ? bswap_64(val) : (val); break;	\
-	case 4: __ret = __NEED_BSWAP ? bswap_32(val) : (val); break;	\
-	case 2: __ret = __NEED_BSWAP ? bswap_16(val) : (val); break;	\
+	case 8:								\
+		__ret = __need_bswap ? bswap_64(val) : (val); break;	\
+	case 4:								\
+		__ret = __need_bswap ? bswap_32(val) : (val); break;	\
+	case 2:								\
+		__ret = __need_bswap ? bswap_16(val) : (val); break;	\
 	default:							\
 		BUILD_BUG(); break;					\
 	}								\
diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c
index f5a8508c42d6..4f1211fec82c 100644
--- a/tools/objtool/orc_dump.c
+++ b/tools/objtool/orc_dump.c
@@ -76,6 +76,7 @@ int orc_dump(const char *_objname)
 	GElf_Rela rela;
 	GElf_Sym sym;
 	Elf_Data *data, *symtab = NULL, *rela_orc_ip = NULL;
+	struct elf dummy_elf = {};
 
 
 	objname = _objname;
@@ -94,6 +95,12 @@ int orc_dump(const char *_objname)
 		return -1;
 	}
 
+	if (!elf64_getehdr(elf)) {
+		WARN_ELF("elf64_getehdr");
+		return -1;
+	}
+	memcpy(&dummy_elf.ehdr, elf64_getehdr(elf), sizeof(dummy_elf.ehdr));
+
 	if (elf_getshdrnum(elf, &nr_sections)) {
 		WARN_ELF("elf_getshdrnum");
 		return -1;
@@ -198,11 +205,11 @@ int orc_dump(const char *_objname)
 
 		printf(" sp:");
 
-		print_reg(orc[i].sp_reg, bswap_if_needed(orc[i].sp_offset));
+		print_reg(orc[i].sp_reg, bswap_if_needed(&dummy_elf, orc[i].sp_offset));
 
 		printf(" bp:");
 
-		print_reg(orc[i].bp_reg, bswap_if_needed(orc[i].bp_offset));
+		print_reg(orc[i].bp_reg, bswap_if_needed(&dummy_elf, orc[i].bp_offset));
 
 		printf(" type:%s end:%d\n",
 		       orc_type_name(orc[i].type), orc[i].end);
diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
index dd3c64af9db2..1f22b7ebae58 100644
--- a/tools/objtool/orc_gen.c
+++ b/tools/objtool/orc_gen.c
@@ -97,8 +97,8 @@ static int write_orc_entry(struct elf *elf, struct section *orc_sec,
 	/* populate ORC data */
 	orc = (struct orc_entry *)orc_sec->data->d_buf + idx;
 	memcpy(orc, o, sizeof(*orc));
-	orc->sp_offset = bswap_if_needed(orc->sp_offset);
-	orc->bp_offset = bswap_if_needed(orc->bp_offset);
+	orc->sp_offset = bswap_if_needed(elf, orc->sp_offset);
+	orc->bp_offset = bswap_if_needed(elf, orc->bp_offset);
 
 	/* populate reloc for ip */
 	if (elf_add_reloc_to_insn(elf, ip_sec, idx * sizeof(int), R_X86_64_PC32,
diff --git a/tools/objtool/special.c b/tools/objtool/special.c
index e2223dd91c37..9c8d827f69af 100644
--- a/tools/objtool/special.c
+++ b/tools/objtool/special.c
@@ -87,7 +87,8 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry,
 	if (entry->feature) {
 		unsigned short feature;
 
-		feature = bswap_if_needed(*(unsigned short *)(sec->data->d_buf +
+		feature = bswap_if_needed(elf,
+					  *(unsigned short *)(sec->data->d_buf +
 							      offset +
 							      entry->feature));
 		arch_handle_alternative(feature, alt);
-- 
2.31.1


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

* [PATCH v2 10/16] objtool: Use target file class size instead of a compiled constant
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

From: Christophe Leroy <christophe.leroy@csgroup.eu>

In order to allow using objtool on cross-built kernels,
determine size of long from elf data instead of using
sizeof(long) at build time.

For the time being this covers only mcount.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 tools/objtool/check.c               | 16 +++++++++-------
 tools/objtool/elf.c                 |  8 ++++++--
 tools/objtool/include/objtool/elf.h |  8 ++++++++
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a948b2551520..0ecf41ee73f0 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -851,9 +851,9 @@ static int create_ibt_endbr_seal_sections(struct objtool_file *file)
 static int create_mcount_loc_sections(struct objtool_file *file)
 {
 	struct section *sec;
-	unsigned long *loc;
 	struct instruction *insn;
 	int idx;
+	int addrsize = elf_class_addrsize(file->elf);
 
 	sec = find_section_by_name(file->elf, "__mcount_loc");
 	if (sec) {
@@ -869,23 +869,25 @@ static int create_mcount_loc_sections(struct objtool_file *file)
 	list_for_each_entry(insn, &file->mcount_loc_list, call_node)
 		idx++;
 
-	sec = elf_create_section(file->elf, "__mcount_loc", 0, sizeof(unsigned long), idx);
+	sec = elf_create_section(file->elf, "__mcount_loc", 0, addrsize, idx);
 	if (!sec)
 		return -1;
 
+	sec->sh.sh_addralign = addrsize;
+
 	idx = 0;
 	list_for_each_entry(insn, &file->mcount_loc_list, call_node) {
+		void *loc;
 
-		loc = (unsigned long *)sec->data->d_buf + idx;
-		memset(loc, 0, sizeof(unsigned long));
+		loc = sec->data->d_buf + idx;
+		memset(loc, 0, addrsize);
 
-		if (elf_add_reloc_to_insn(file->elf, sec,
-					  idx * sizeof(unsigned long),
+		if (elf_add_reloc_to_insn(file->elf, sec, idx,
 					  R_X86_64_64,
 					  insn->sec, insn->offset))
 			return -1;
 
-		idx++;
+		idx += addrsize;
 	}
 
 	return 0;
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index c25e957c1e52..40c6d53b081f 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1124,6 +1124,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
 {
 	char *relocname;
 	struct section *sec;
+	int addrsize = elf_class_addrsize(elf);
 
 	relocname = malloc(strlen(base->name) + strlen(".rela") + 1);
 	if (!relocname) {
@@ -1133,7 +1134,10 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
 	strcpy(relocname, ".rela");
 	strcat(relocname, base->name);
 
-	sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0);
+	if (addrsize == sizeof(u32))
+		sec = elf_create_section(elf, relocname, 0, sizeof(Elf32_Rela), 0);
+	else
+		sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0);
 	free(relocname);
 	if (!sec)
 		return NULL;
@@ -1142,7 +1146,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
 	sec->base = base;
 
 	sec->sh.sh_type = SHT_RELA;
-	sec->sh.sh_addralign = 8;
+	sec->sh.sh_addralign = addrsize;
 	sec->sh.sh_link = find_section_by_name(elf, ".symtab")->idx;
 	sec->sh.sh_info = base->idx;
 	sec->sh.sh_flags = SHF_INFO_LINK;
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index 16f4067b82ae..78b3aa2e546d 100644
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -142,6 +142,14 @@ static inline bool has_multiple_files(struct elf *elf)
 	return elf->num_files > 1;
 }
 
+static inline int elf_class_addrsize(struct elf *elf)
+{
+	if (elf->ehdr.e_ident[EI_CLASS] == ELFCLASS32)
+		return sizeof(u32);
+	else
+		return sizeof(u64);
+}
+
 struct elf *elf_open_read(const char *name, int flags);
 struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr);
 
-- 
2.31.1


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

* [PATCH v2 10/16] objtool: Use target file class size instead of a compiled constant
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

From: Christophe Leroy <christophe.leroy@csgroup.eu>

In order to allow using objtool on cross-built kernels,
determine size of long from elf data instead of using
sizeof(long) at build time.

For the time being this covers only mcount.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 tools/objtool/check.c               | 16 +++++++++-------
 tools/objtool/elf.c                 |  8 ++++++--
 tools/objtool/include/objtool/elf.h |  8 ++++++++
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a948b2551520..0ecf41ee73f0 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -851,9 +851,9 @@ static int create_ibt_endbr_seal_sections(struct objtool_file *file)
 static int create_mcount_loc_sections(struct objtool_file *file)
 {
 	struct section *sec;
-	unsigned long *loc;
 	struct instruction *insn;
 	int idx;
+	int addrsize = elf_class_addrsize(file->elf);
 
 	sec = find_section_by_name(file->elf, "__mcount_loc");
 	if (sec) {
@@ -869,23 +869,25 @@ static int create_mcount_loc_sections(struct objtool_file *file)
 	list_for_each_entry(insn, &file->mcount_loc_list, call_node)
 		idx++;
 
-	sec = elf_create_section(file->elf, "__mcount_loc", 0, sizeof(unsigned long), idx);
+	sec = elf_create_section(file->elf, "__mcount_loc", 0, addrsize, idx);
 	if (!sec)
 		return -1;
 
+	sec->sh.sh_addralign = addrsize;
+
 	idx = 0;
 	list_for_each_entry(insn, &file->mcount_loc_list, call_node) {
+		void *loc;
 
-		loc = (unsigned long *)sec->data->d_buf + idx;
-		memset(loc, 0, sizeof(unsigned long));
+		loc = sec->data->d_buf + idx;
+		memset(loc, 0, addrsize);
 
-		if (elf_add_reloc_to_insn(file->elf, sec,
-					  idx * sizeof(unsigned long),
+		if (elf_add_reloc_to_insn(file->elf, sec, idx,
 					  R_X86_64_64,
 					  insn->sec, insn->offset))
 			return -1;
 
-		idx++;
+		idx += addrsize;
 	}
 
 	return 0;
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index c25e957c1e52..40c6d53b081f 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1124,6 +1124,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
 {
 	char *relocname;
 	struct section *sec;
+	int addrsize = elf_class_addrsize(elf);
 
 	relocname = malloc(strlen(base->name) + strlen(".rela") + 1);
 	if (!relocname) {
@@ -1133,7 +1134,10 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
 	strcpy(relocname, ".rela");
 	strcat(relocname, base->name);
 
-	sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0);
+	if (addrsize == sizeof(u32))
+		sec = elf_create_section(elf, relocname, 0, sizeof(Elf32_Rela), 0);
+	else
+		sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0);
 	free(relocname);
 	if (!sec)
 		return NULL;
@@ -1142,7 +1146,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
 	sec->base = base;
 
 	sec->sh.sh_type = SHT_RELA;
-	sec->sh.sh_addralign = 8;
+	sec->sh.sh_addralign = addrsize;
 	sec->sh.sh_link = find_section_by_name(elf, ".symtab")->idx;
 	sec->sh.sh_info = base->idx;
 	sec->sh.sh_flags = SHF_INFO_LINK;
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index 16f4067b82ae..78b3aa2e546d 100644
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -142,6 +142,14 @@ static inline bool has_multiple_files(struct elf *elf)
 	return elf->num_files > 1;
 }
 
+static inline int elf_class_addrsize(struct elf *elf)
+{
+	if (elf->ehdr.e_ident[EI_CLASS] == ELFCLASS32)
+		return sizeof(u32);
+	else
+		return sizeof(u64);
+}
+
 struct elf *elf_open_read(const char *name, int flags);
 struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr);
 
-- 
2.31.1


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

* [PATCH v2 11/16] objtool: Add --mnop as an option to --mcount
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

Architectures can select HAVE_NOP_MCOUNT if they choose
to nop out mcount call sites. If that config option is
selected, then --mnop is passed as an option to objtool,
along with --mcount.

Also, make sure that --mnop can be passed as an option
to objtool only when --mcount is passed.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 Makefile                                |  4 +++-
 arch/x86/Kconfig                        |  1 +
 scripts/Makefile.lib                    |  1 +
 tools/objtool/builtin-check.c           | 14 ++++++++++++++
 tools/objtool/check.c                   | 19 ++++++++++---------
 tools/objtool/include/objtool/builtin.h |  1 +
 6 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index c7705f749601..99dd33d8bcfa 100644
--- a/Makefile
+++ b/Makefile
@@ -857,7 +857,9 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC
   endif
 endif
 ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
-  CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
+  ifdef CONFIG_HAVE_NOP_MCOUNT
+    CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
+  endif
 endif
 ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
   ifdef CONFIG_HAVE_C_RECORDMCOUNT
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f9920f1341c8..a8dd138df637 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -189,6 +189,7 @@ config X86
 	select HAVE_CONTEXT_TRACKING_USER_OFFSTACK	if HAVE_CONTEXT_TRACKING_USER
 	select HAVE_C_RECORDMCOUNT
 	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
+	select HAVE_NOP_MCOUNT			if HAVE_OBJTOOL_MCOUNT
 	select HAVE_BUILDTIME_MCOUNT_SORT
 	select HAVE_DEBUG_KMEMLEAK
 	select HAVE_DMA_CONTIGUOUS
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3fb6a99e78c4..0610078e057a 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -234,6 +234,7 @@ objtool_args =								\
 	$(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr)		\
 	$(if $(CONFIG_X86_KERNEL_IBT), --ibt)				\
 	$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount)		\
+	$(if $(CONFIG_HAVE_NOP_MCOUNT), --mnop)				\
 	$(if $(CONFIG_UNWINDER_ORC), --orc)				\
 	$(if $(CONFIG_RETPOLINE), --retpoline)				\
 	$(if $(CONFIG_RETHUNK), --rethunk)				\
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 24fbe803a0d3..9bd347d3c244 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -82,6 +82,7 @@ const struct option check_options[] = {
 	OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"),
 	OPT_BOOLEAN(0, "link", &opts.link, "object is a linked object"),
 	OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel module"),
+	OPT_BOOLEAN(0, "mnop", &opts.mnop, "nop out mcount call sites"),
 	OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable instruction' warnings"),
 	OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"),
 	OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),
@@ -150,6 +151,16 @@ static bool opts_valid(void)
 	return false;
 }
 
+static bool mnop_opts_valid(void)
+{
+	if (opts.mnop && !opts.mcount) {
+		ERROR("--mnop requires --mcount");
+		return false;
+	}
+
+	return true;
+}
+
 static bool link_opts_valid(struct objtool_file *file)
 {
 	if (opts.link)
@@ -198,6 +209,9 @@ int objtool_run(int argc, const char **argv)
 	if (!file)
 		return 1;
 
+	if (!mnop_opts_valid())
+		return 1;
+
 	if (!link_opts_valid(file))
 		return 1;
 
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 0ecf41ee73f0..3cea58f73878 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1231,17 +1231,18 @@ static void annotate_call_site(struct objtool_file *file,
 	if (opts.mcount && sym->fentry) {
 		if (sibling)
 			WARN_FUNC("Tail call to __fentry__ !?!?", insn->sec, insn->offset);
+		if (opts.mnop) {
+			if (reloc) {
+				reloc->type = R_NONE;
+				elf_write_reloc(file->elf, reloc);
+			}
 
-		if (reloc) {
-			reloc->type = R_NONE;
-			elf_write_reloc(file->elf, reloc);
-		}
-
-		elf_write_insn(file->elf, insn->sec,
-			       insn->offset, insn->len,
-			       arch_nop_insn(insn->len));
+			elf_write_insn(file->elf, insn->sec,
+				       insn->offset, insn->len,
+				       arch_nop_insn(insn->len));
 
-		insn->type = INSN_NOP;
+			insn->type = INSN_NOP;
+		}
 
 		list_add_tail(&insn->call_node, &file->mcount_loc_list);
 		return;
diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/include/objtool/builtin.h
index 42a52f1a0add..0785707c5a92 100644
--- a/tools/objtool/include/objtool/builtin.h
+++ b/tools/objtool/include/objtool/builtin.h
@@ -31,6 +31,7 @@ struct opts {
 	bool backup;
 	bool dryrun;
 	bool link;
+	bool mnop;
 	bool module;
 	bool no_unreachable;
 	bool sec_address;
-- 
2.31.1


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

* [PATCH v2 11/16] objtool: Add --mnop as an option to --mcount
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

Architectures can select HAVE_NOP_MCOUNT if they choose
to nop out mcount call sites. If that config option is
selected, then --mnop is passed as an option to objtool,
along with --mcount.

Also, make sure that --mnop can be passed as an option
to objtool only when --mcount is passed.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 Makefile                                |  4 +++-
 arch/x86/Kconfig                        |  1 +
 scripts/Makefile.lib                    |  1 +
 tools/objtool/builtin-check.c           | 14 ++++++++++++++
 tools/objtool/check.c                   | 19 ++++++++++---------
 tools/objtool/include/objtool/builtin.h |  1 +
 6 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index c7705f749601..99dd33d8bcfa 100644
--- a/Makefile
+++ b/Makefile
@@ -857,7 +857,9 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC
   endif
 endif
 ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
-  CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
+  ifdef CONFIG_HAVE_NOP_MCOUNT
+    CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
+  endif
 endif
 ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
   ifdef CONFIG_HAVE_C_RECORDMCOUNT
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f9920f1341c8..a8dd138df637 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -189,6 +189,7 @@ config X86
 	select HAVE_CONTEXT_TRACKING_USER_OFFSTACK	if HAVE_CONTEXT_TRACKING_USER
 	select HAVE_C_RECORDMCOUNT
 	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
+	select HAVE_NOP_MCOUNT			if HAVE_OBJTOOL_MCOUNT
 	select HAVE_BUILDTIME_MCOUNT_SORT
 	select HAVE_DEBUG_KMEMLEAK
 	select HAVE_DMA_CONTIGUOUS
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3fb6a99e78c4..0610078e057a 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -234,6 +234,7 @@ objtool_args =								\
 	$(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr)		\
 	$(if $(CONFIG_X86_KERNEL_IBT), --ibt)				\
 	$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount)		\
+	$(if $(CONFIG_HAVE_NOP_MCOUNT), --mnop)				\
 	$(if $(CONFIG_UNWINDER_ORC), --orc)				\
 	$(if $(CONFIG_RETPOLINE), --retpoline)				\
 	$(if $(CONFIG_RETHUNK), --rethunk)				\
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 24fbe803a0d3..9bd347d3c244 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -82,6 +82,7 @@ const struct option check_options[] = {
 	OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"),
 	OPT_BOOLEAN(0, "link", &opts.link, "object is a linked object"),
 	OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel module"),
+	OPT_BOOLEAN(0, "mnop", &opts.mnop, "nop out mcount call sites"),
 	OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable instruction' warnings"),
 	OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"),
 	OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),
@@ -150,6 +151,16 @@ static bool opts_valid(void)
 	return false;
 }
 
+static bool mnop_opts_valid(void)
+{
+	if (opts.mnop && !opts.mcount) {
+		ERROR("--mnop requires --mcount");
+		return false;
+	}
+
+	return true;
+}
+
 static bool link_opts_valid(struct objtool_file *file)
 {
 	if (opts.link)
@@ -198,6 +209,9 @@ int objtool_run(int argc, const char **argv)
 	if (!file)
 		return 1;
 
+	if (!mnop_opts_valid())
+		return 1;
+
 	if (!link_opts_valid(file))
 		return 1;
 
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 0ecf41ee73f0..3cea58f73878 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1231,17 +1231,18 @@ static void annotate_call_site(struct objtool_file *file,
 	if (opts.mcount && sym->fentry) {
 		if (sibling)
 			WARN_FUNC("Tail call to __fentry__ !?!?", insn->sec, insn->offset);
+		if (opts.mnop) {
+			if (reloc) {
+				reloc->type = R_NONE;
+				elf_write_reloc(file->elf, reloc);
+			}
 
-		if (reloc) {
-			reloc->type = R_NONE;
-			elf_write_reloc(file->elf, reloc);
-		}
-
-		elf_write_insn(file->elf, insn->sec,
-			       insn->offset, insn->len,
-			       arch_nop_insn(insn->len));
+			elf_write_insn(file->elf, insn->sec,
+				       insn->offset, insn->len,
+				       arch_nop_insn(insn->len));
 
-		insn->type = INSN_NOP;
+			insn->type = INSN_NOP;
+		}
 
 		list_add_tail(&insn->call_node, &file->mcount_loc_list);
 		return;
diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/include/objtool/builtin.h
index 42a52f1a0add..0785707c5a92 100644
--- a/tools/objtool/include/objtool/builtin.h
+++ b/tools/objtool/include/objtool/builtin.h
@@ -31,6 +31,7 @@ struct opts {
 	bool backup;
 	bool dryrun;
 	bool link;
+	bool mnop;
 	bool module;
 	bool no_unreachable;
 	bool sec_address;
-- 
2.31.1


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

* [PATCH v2 12/16] objtool: Read special sections with alts only when specific options are selected
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

This patch reads special sections which have alternate
instructions, only when stackval or orc or uaccess or
noinstr options are passed to objtool.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 tools/objtool/check.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 3cea58f73878..5298a143ceac 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2370,9 +2370,11 @@ static int decode_sections(struct objtool_file *file)
 	 * Must be before add_jump_destinations(), which depends on 'func'
 	 * being set for alternatives, to enable proper sibling call detection.
 	 */
-	ret = add_special_section_alts(file);
-	if (ret)
-		return ret;
+	if (opts.stackval || opts.orc || opts.uaccess || opts.noinstr) {
+		ret = add_special_section_alts(file);
+		if (ret)
+			return ret;
+	}
 
 	ret = add_jump_destinations(file);
 	if (ret)
-- 
2.31.1


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

* [PATCH v2 12/16] objtool: Read special sections with alts only when specific options are selected
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

This patch reads special sections which have alternate
instructions, only when stackval or orc or uaccess or
noinstr options are passed to objtool.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 tools/objtool/check.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 3cea58f73878..5298a143ceac 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2370,9 +2370,11 @@ static int decode_sections(struct objtool_file *file)
 	 * Must be before add_jump_destinations(), which depends on 'func'
 	 * being set for alternatives, to enable proper sibling call detection.
 	 */
-	ret = add_special_section_alts(file);
-	if (ret)
-		return ret;
+	if (opts.stackval || opts.orc || opts.uaccess || opts.noinstr) {
+		ret = add_special_section_alts(file);
+		if (ret)
+			return ret;
+	}
 
 	ret = add_jump_destinations(file);
 	if (ret)
-- 
2.31.1


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

* [PATCH v2 13/16] objtool: Use macros to define arch specific reloc types
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

Make relocation types architecture specific.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 tools/objtool/arch/x86/include/arch/elf.h | 2 ++
 tools/objtool/check.c                     | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/arch/x86/include/arch/elf.h b/tools/objtool/arch/x86/include/arch/elf.h
index 69cc4264b28a..ac14987cf687 100644
--- a/tools/objtool/arch/x86/include/arch/elf.h
+++ b/tools/objtool/arch/x86/include/arch/elf.h
@@ -2,5 +2,7 @@
 #define _OBJTOOL_ARCH_ELF
 
 #define R_NONE R_X86_64_NONE
+#define R_ABS64 R_X86_64_64
+#define R_ABS32 R_X86_64_32
 
 #endif /* _OBJTOOL_ARCH_ELF */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 5298a143ceac..f1d055467926 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -883,7 +883,7 @@ static int create_mcount_loc_sections(struct objtool_file *file)
 		memset(loc, 0, addrsize);
 
 		if (elf_add_reloc_to_insn(file->elf, sec, idx,
-					  R_X86_64_64,
+					  addrsize == sizeof(u64) ? R_ABS64 : R_ABS32,
 					  insn->sec, insn->offset))
 			return -1;
 
-- 
2.31.1


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

* [PATCH v2 13/16] objtool: Use macros to define arch specific reloc types
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

Make relocation types architecture specific.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 tools/objtool/arch/x86/include/arch/elf.h | 2 ++
 tools/objtool/check.c                     | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/arch/x86/include/arch/elf.h b/tools/objtool/arch/x86/include/arch/elf.h
index 69cc4264b28a..ac14987cf687 100644
--- a/tools/objtool/arch/x86/include/arch/elf.h
+++ b/tools/objtool/arch/x86/include/arch/elf.h
@@ -2,5 +2,7 @@
 #define _OBJTOOL_ARCH_ELF
 
 #define R_NONE R_X86_64_NONE
+#define R_ABS64 R_X86_64_64
+#define R_ABS32 R_X86_64_32
 
 #endif /* _OBJTOOL_ARCH_ELF */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 5298a143ceac..f1d055467926 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -883,7 +883,7 @@ static int create_mcount_loc_sections(struct objtool_file *file)
 		memset(loc, 0, addrsize);
 
 		if (elf_add_reloc_to_insn(file->elf, sec, idx,
-					  R_X86_64_64,
+					  addrsize == sizeof(u64) ? R_ABS64 : R_ABS32,
 					  insn->sec, insn->offset))
 			return -1;
 
-- 
2.31.1


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

* [PATCH v2 14/16] objtool: Add arch specific function arch_ftrace_match()
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

Add architecture specific function to look for
relocation records pointing to arch specific
symbols.

Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 tools/objtool/arch/x86/decode.c      | 8 ++++++++
 tools/objtool/check.c                | 2 +-
 tools/objtool/include/objtool/arch.h | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index c260006106be..025598b6b703 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -23,6 +23,14 @@
 #include <objtool/builtin.h>
 #include <arch/elf.h>
 
+bool arch_ftrace_match(char *name)
+{
+	if (!strcmp(name, "__fentry__"))
+		return true;
+
+	return false;
+}
+
 static int is_x86_64(const struct elf *elf)
 {
 	switch (elf->ehdr.e_machine) {
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index f1d055467926..01ff7504f18d 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2294,7 +2294,7 @@ static int classify_symbols(struct objtool_file *file)
 			if (arch_is_rethunk(func))
 				func->return_thunk = true;
 
-			if (!strcmp(func->name, "__fentry__"))
+			if (arch_ftrace_match(func->name))
 				func->fentry = true;
 
 			if (is_profiling_func(func->name))
diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h
index beb2f3aa94ff..2ba4b9897285 100644
--- a/tools/objtool/include/objtool/arch.h
+++ b/tools/objtool/include/objtool/arch.h
@@ -69,6 +69,8 @@ struct stack_op {
 
 struct instruction;
 
+bool arch_ftrace_match(char *name);
+
 void arch_initial_func_cfi_state(struct cfi_init_state *state);
 
 int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
-- 
2.31.1


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

* [PATCH v2 14/16] objtool: Add arch specific function arch_ftrace_match()
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

Add architecture specific function to look for
relocation records pointing to arch specific
symbols.

Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 tools/objtool/arch/x86/decode.c      | 8 ++++++++
 tools/objtool/check.c                | 2 +-
 tools/objtool/include/objtool/arch.h | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index c260006106be..025598b6b703 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -23,6 +23,14 @@
 #include <objtool/builtin.h>
 #include <arch/elf.h>
 
+bool arch_ftrace_match(char *name)
+{
+	if (!strcmp(name, "__fentry__"))
+		return true;
+
+	return false;
+}
+
 static int is_x86_64(const struct elf *elf)
 {
 	switch (elf->ehdr.e_machine) {
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index f1d055467926..01ff7504f18d 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2294,7 +2294,7 @@ static int classify_symbols(struct objtool_file *file)
 			if (arch_is_rethunk(func))
 				func->return_thunk = true;
 
-			if (!strcmp(func->name, "__fentry__"))
+			if (arch_ftrace_match(func->name))
 				func->fentry = true;
 
 			if (is_profiling_func(func->name))
diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h
index beb2f3aa94ff..2ba4b9897285 100644
--- a/tools/objtool/include/objtool/arch.h
+++ b/tools/objtool/include/objtool/arch.h
@@ -69,6 +69,8 @@ struct stack_op {
 
 struct instruction;
 
+bool arch_ftrace_match(char *name);
+
 void arch_initial_func_cfi_state(struct cfi_init_state *state);
 
 int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
-- 
2.31.1


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

* [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

This patch adds [stub] implementations for required
functions, inorder to enable objtool build on powerpc.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
[Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/Kconfig                          |  1 +
 arch/powerpc/include/asm/asm.h                |  7 ++
 tools/objtool/arch/powerpc/Build              |  2 +
 tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
 .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
 tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
 .../arch/powerpc/include/arch/special.h       | 21 ++++++
 tools/objtool/arch/powerpc/special.c          | 19 +++++
 8 files changed, 143 insertions(+)
 create mode 100644 arch/powerpc/include/asm/asm.h
 create mode 100644 tools/objtool/arch/powerpc/Build
 create mode 100644 tools/objtool/arch/powerpc/decode.c
 create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
 create mode 100644 tools/objtool/arch/powerpc/special.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 4c466acdc70d..dc05cd23c233 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -237,6 +237,7 @@ config PPC
 	select HAVE_MOD_ARCH_SPECIFIC
 	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
 	select HAVE_OPTPROBES
+	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_EVENTS_NMI		if PPC64
 	select HAVE_PERF_REGS
diff --git a/arch/powerpc/include/asm/asm.h b/arch/powerpc/include/asm/asm.h
new file mode 100644
index 000000000000..86f46b604e9a
--- /dev/null
+++ b/arch/powerpc/include/asm/asm.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_POWERPC_ASM_H
+#define _ASM_POWERPC_ASM_H
+
+#define _ASM_PTR	" .long "
+
+#endif /* _ASM_POWERPC_ASM_H */
diff --git a/tools/objtool/arch/powerpc/Build b/tools/objtool/arch/powerpc/Build
new file mode 100644
index 000000000000..d24d5636a5b8
--- /dev/null
+++ b/tools/objtool/arch/powerpc/Build
@@ -0,0 +1,2 @@
+objtool-y += decode.o
+objtool-y += special.o
diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
new file mode 100644
index 000000000000..8b6a14680da7
--- /dev/null
+++ b/tools/objtool/arch/powerpc/decode.c
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <objtool/check.h>
+#include <objtool/elf.h>
+#include <objtool/arch.h>
+#include <objtool/warn.h>
+#include <objtool/builtin.h>
+#include <objtool/endianness.h>
+
+unsigned long arch_dest_reloc_offset(int addend)
+{
+	return addend;
+}
+
+bool arch_callee_saved_reg(unsigned char reg)
+{
+	return false;
+}
+
+int arch_decode_hint_reg(u8 sp_reg, int *base)
+{
+	exit(-1);
+}
+
+const char *arch_nop_insn(int len)
+{
+	exit(-1);
+}
+
+const char *arch_ret_insn(int len)
+{
+	exit(-1);
+}
+
+int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
+			    unsigned long offset, unsigned int maxlen,
+			    unsigned int *len, enum insn_type *type,
+			    unsigned long *immediate,
+			    struct list_head *ops_list)
+{
+	u32 insn;
+
+	*immediate = 0;
+	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
+	*len = 4;
+	*type = INSN_OTHER;
+
+	return 0;
+}
+
+unsigned long arch_jump_destination(struct instruction *insn)
+{
+	return insn->offset +  insn->immediate;
+}
+
+void arch_initial_func_cfi_state(struct cfi_init_state *state)
+{
+	int i;
+
+	for (i = 0; i < CFI_NUM_REGS; i++) {
+		state->regs[i].base = CFI_UNDEFINED;
+		state->regs[i].offset = 0;
+	}
+
+	/* initial CFA (call frame address) */
+	state->cfa.base = CFI_SP;
+	state->cfa.offset = 0;
+
+	/* initial LR (return address) */
+	state->regs[CFI_RA].base = CFI_CFA;
+	state->regs[CFI_RA].offset = 0;
+}
diff --git a/tools/objtool/arch/powerpc/include/arch/cfi_regs.h b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
new file mode 100644
index 000000000000..59638ebeafc8
--- /dev/null
+++ b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _OBJTOOL_CFI_REGS_H
+#define _OBJTOOL_CFI_REGS_H
+
+#define CFI_BP 1
+#define CFI_SP CFI_BP
+#define CFI_RA 32
+#define CFI_NUM_REGS 33
+
+#endif
diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
new file mode 100644
index 000000000000..3c8ebb7d2a6b
--- /dev/null
+++ b/tools/objtool/arch/powerpc/include/arch/elf.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _OBJTOOL_ARCH_ELF
+#define _OBJTOOL_ARCH_ELF
+
+#define R_NONE R_PPC_NONE
+
+#endif /* _OBJTOOL_ARCH_ELF */
diff --git a/tools/objtool/arch/powerpc/include/arch/special.h b/tools/objtool/arch/powerpc/include/arch/special.h
new file mode 100644
index 000000000000..ffef9ada7133
--- /dev/null
+++ b/tools/objtool/arch/powerpc/include/arch/special.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _PPC_ARCH_SPECIAL_H
+#define _PPC_ARCH_SPECIAL_H
+
+#define EX_ENTRY_SIZE 8
+#define EX_ORIG_OFFSET 0
+#define EX_NEW_OFFSET 4
+
+#define JUMP_ENTRY_SIZE 16
+#define JUMP_ORIG_OFFSET 0
+#define JUMP_NEW_OFFSET 4
+#define JUMP_KEY_OFFSET 8
+
+#define ALT_ENTRY_SIZE 12
+#define ALT_ORIG_OFFSET 0
+#define ALT_NEW_OFFSET 4
+#define ALT_FEATURE_OFFSET 8
+#define ALT_ORIG_LEN_OFFSET 10
+#define ALT_NEW_LEN_OFFSET 11
+
+#endif /* _PPC_ARCH_SPECIAL_H */
diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
new file mode 100644
index 000000000000..d33868147196
--- /dev/null
+++ b/tools/objtool/arch/powerpc/special.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <string.h>
+#include <stdlib.h>
+#include <objtool/special.h>
+#include <objtool/builtin.h>
+
+
+bool arch_support_alt_relocation(struct special_alt *special_alt,
+				 struct instruction *insn,
+				 struct reloc *reloc)
+{
+	exit(-1);
+}
+
+struct reloc *arch_find_switch_table(struct objtool_file *file,
+				    struct instruction *insn)
+{
+	exit(-1);
+}
-- 
2.31.1


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

* [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

This patch adds [stub] implementations for required
functions, inorder to enable objtool build on powerpc.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
[Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/Kconfig                          |  1 +
 arch/powerpc/include/asm/asm.h                |  7 ++
 tools/objtool/arch/powerpc/Build              |  2 +
 tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
 .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
 tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
 .../arch/powerpc/include/arch/special.h       | 21 ++++++
 tools/objtool/arch/powerpc/special.c          | 19 +++++
 8 files changed, 143 insertions(+)
 create mode 100644 arch/powerpc/include/asm/asm.h
 create mode 100644 tools/objtool/arch/powerpc/Build
 create mode 100644 tools/objtool/arch/powerpc/decode.c
 create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
 create mode 100644 tools/objtool/arch/powerpc/special.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 4c466acdc70d..dc05cd23c233 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -237,6 +237,7 @@ config PPC
 	select HAVE_MOD_ARCH_SPECIFIC
 	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
 	select HAVE_OPTPROBES
+	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_EVENTS_NMI		if PPC64
 	select HAVE_PERF_REGS
diff --git a/arch/powerpc/include/asm/asm.h b/arch/powerpc/include/asm/asm.h
new file mode 100644
index 000000000000..86f46b604e9a
--- /dev/null
+++ b/arch/powerpc/include/asm/asm.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_POWERPC_ASM_H
+#define _ASM_POWERPC_ASM_H
+
+#define _ASM_PTR	" .long "
+
+#endif /* _ASM_POWERPC_ASM_H */
diff --git a/tools/objtool/arch/powerpc/Build b/tools/objtool/arch/powerpc/Build
new file mode 100644
index 000000000000..d24d5636a5b8
--- /dev/null
+++ b/tools/objtool/arch/powerpc/Build
@@ -0,0 +1,2 @@
+objtool-y += decode.o
+objtool-y += special.o
diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
new file mode 100644
index 000000000000..8b6a14680da7
--- /dev/null
+++ b/tools/objtool/arch/powerpc/decode.c
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <objtool/check.h>
+#include <objtool/elf.h>
+#include <objtool/arch.h>
+#include <objtool/warn.h>
+#include <objtool/builtin.h>
+#include <objtool/endianness.h>
+
+unsigned long arch_dest_reloc_offset(int addend)
+{
+	return addend;
+}
+
+bool arch_callee_saved_reg(unsigned char reg)
+{
+	return false;
+}
+
+int arch_decode_hint_reg(u8 sp_reg, int *base)
+{
+	exit(-1);
+}
+
+const char *arch_nop_insn(int len)
+{
+	exit(-1);
+}
+
+const char *arch_ret_insn(int len)
+{
+	exit(-1);
+}
+
+int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
+			    unsigned long offset, unsigned int maxlen,
+			    unsigned int *len, enum insn_type *type,
+			    unsigned long *immediate,
+			    struct list_head *ops_list)
+{
+	u32 insn;
+
+	*immediate = 0;
+	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
+	*len = 4;
+	*type = INSN_OTHER;
+
+	return 0;
+}
+
+unsigned long arch_jump_destination(struct instruction *insn)
+{
+	return insn->offset +  insn->immediate;
+}
+
+void arch_initial_func_cfi_state(struct cfi_init_state *state)
+{
+	int i;
+
+	for (i = 0; i < CFI_NUM_REGS; i++) {
+		state->regs[i].base = CFI_UNDEFINED;
+		state->regs[i].offset = 0;
+	}
+
+	/* initial CFA (call frame address) */
+	state->cfa.base = CFI_SP;
+	state->cfa.offset = 0;
+
+	/* initial LR (return address) */
+	state->regs[CFI_RA].base = CFI_CFA;
+	state->regs[CFI_RA].offset = 0;
+}
diff --git a/tools/objtool/arch/powerpc/include/arch/cfi_regs.h b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
new file mode 100644
index 000000000000..59638ebeafc8
--- /dev/null
+++ b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _OBJTOOL_CFI_REGS_H
+#define _OBJTOOL_CFI_REGS_H
+
+#define CFI_BP 1
+#define CFI_SP CFI_BP
+#define CFI_RA 32
+#define CFI_NUM_REGS 33
+
+#endif
diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
new file mode 100644
index 000000000000..3c8ebb7d2a6b
--- /dev/null
+++ b/tools/objtool/arch/powerpc/include/arch/elf.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _OBJTOOL_ARCH_ELF
+#define _OBJTOOL_ARCH_ELF
+
+#define R_NONE R_PPC_NONE
+
+#endif /* _OBJTOOL_ARCH_ELF */
diff --git a/tools/objtool/arch/powerpc/include/arch/special.h b/tools/objtool/arch/powerpc/include/arch/special.h
new file mode 100644
index 000000000000..ffef9ada7133
--- /dev/null
+++ b/tools/objtool/arch/powerpc/include/arch/special.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _PPC_ARCH_SPECIAL_H
+#define _PPC_ARCH_SPECIAL_H
+
+#define EX_ENTRY_SIZE 8
+#define EX_ORIG_OFFSET 0
+#define EX_NEW_OFFSET 4
+
+#define JUMP_ENTRY_SIZE 16
+#define JUMP_ORIG_OFFSET 0
+#define JUMP_NEW_OFFSET 4
+#define JUMP_KEY_OFFSET 8
+
+#define ALT_ENTRY_SIZE 12
+#define ALT_ORIG_OFFSET 0
+#define ALT_NEW_OFFSET 4
+#define ALT_FEATURE_OFFSET 8
+#define ALT_ORIG_LEN_OFFSET 10
+#define ALT_NEW_LEN_OFFSET 11
+
+#endif /* _PPC_ARCH_SPECIAL_H */
diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
new file mode 100644
index 000000000000..d33868147196
--- /dev/null
+++ b/tools/objtool/arch/powerpc/special.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <string.h>
+#include <stdlib.h>
+#include <objtool/special.h>
+#include <objtool/builtin.h>
+
+
+bool arch_support_alt_relocation(struct special_alt *special_alt,
+				 struct instruction *insn,
+				 struct reloc *reloc)
+{
+	exit(-1);
+}
+
+struct reloc *arch_find_switch_table(struct objtool_file *file,
+				    struct instruction *insn)
+{
+	exit(-1);
+}
-- 
2.31.1


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

* [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
  2022-08-29  5:52 ` Sathvika Vasireddy
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao, sv

This patch enables objtool --mcount on powerpc, and
adds implementation specific to powerpc.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/Kconfig                          |  1 +
 tools/objtool/arch/powerpc/decode.c           | 22 +++++++++++++++++++
 tools/objtool/arch/powerpc/include/arch/elf.h |  2 ++
 3 files changed, 25 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index dc05cd23c233..6be2e68fa9eb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -238,6 +238,7 @@ config PPC
 	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
 	select HAVE_OPTPROBES
 	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
+	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_EVENTS_NMI		if PPC64
 	select HAVE_PERF_REGS
diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
index 8b6a14680da7..b71c265ed503 100644
--- a/tools/objtool/arch/powerpc/decode.c
+++ b/tools/objtool/arch/powerpc/decode.c
@@ -9,6 +9,14 @@
 #include <objtool/builtin.h>
 #include <objtool/endianness.h>
 
+bool arch_ftrace_match(char *name)
+{
+	if (!strcmp(name, "_mcount"))
+		return true;
+
+	return false;
+}
+
 unsigned long arch_dest_reloc_offset(int addend)
 {
 	return addend;
@@ -41,12 +49,26 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
 			    struct list_head *ops_list)
 {
 	u32 insn;
+	unsigned int opcode;
 
 	*immediate = 0;
 	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
 	*len = 4;
 	*type = INSN_OTHER;
 
+	opcode = insn >> 26;
+
+	switch (opcode) {
+	case 18: /* bl */
+		if ((insn & 3) == 1) {
+			*type = INSN_CALL;
+			*immediate = insn & 0x3fffffc;
+			if (*immediate & 0x2000000)
+				*immediate -= 0x4000000;
+		}
+		break;
+	}
+
 	return 0;
 }
 
diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
index 3c8ebb7d2a6b..73f9ae172fe5 100644
--- a/tools/objtool/arch/powerpc/include/arch/elf.h
+++ b/tools/objtool/arch/powerpc/include/arch/elf.h
@@ -4,5 +4,7 @@
 #define _OBJTOOL_ARCH_ELF
 
 #define R_NONE R_PPC_NONE
+#define R_ABS64 R_PPC64_ADDR64
+#define R_ABS32 R_PPC_ADDR32
 
 #endif /* _OBJTOOL_ARCH_ELF */
-- 
2.31.1


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

* [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
@ 2022-08-29  5:52   ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29  5:52 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: peterz, npiggin, linux-kernel, aik, mingo, sv, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

This patch enables objtool --mcount on powerpc, and
adds implementation specific to powerpc.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 arch/powerpc/Kconfig                          |  1 +
 tools/objtool/arch/powerpc/decode.c           | 22 +++++++++++++++++++
 tools/objtool/arch/powerpc/include/arch/elf.h |  2 ++
 3 files changed, 25 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index dc05cd23c233..6be2e68fa9eb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -238,6 +238,7 @@ config PPC
 	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
 	select HAVE_OPTPROBES
 	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
+	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_EVENTS_NMI		if PPC64
 	select HAVE_PERF_REGS
diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
index 8b6a14680da7..b71c265ed503 100644
--- a/tools/objtool/arch/powerpc/decode.c
+++ b/tools/objtool/arch/powerpc/decode.c
@@ -9,6 +9,14 @@
 #include <objtool/builtin.h>
 #include <objtool/endianness.h>
 
+bool arch_ftrace_match(char *name)
+{
+	if (!strcmp(name, "_mcount"))
+		return true;
+
+	return false;
+}
+
 unsigned long arch_dest_reloc_offset(int addend)
 {
 	return addend;
@@ -41,12 +49,26 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
 			    struct list_head *ops_list)
 {
 	u32 insn;
+	unsigned int opcode;
 
 	*immediate = 0;
 	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
 	*len = 4;
 	*type = INSN_OTHER;
 
+	opcode = insn >> 26;
+
+	switch (opcode) {
+	case 18: /* bl */
+		if ((insn & 3) == 1) {
+			*type = INSN_CALL;
+			*immediate = insn & 0x3fffffc;
+			if (*immediate & 0x2000000)
+				*immediate -= 0x4000000;
+		}
+		break;
+	}
+
 	return 0;
 }
 
diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
index 3c8ebb7d2a6b..73f9ae172fe5 100644
--- a/tools/objtool/arch/powerpc/include/arch/elf.h
+++ b/tools/objtool/arch/powerpc/include/arch/elf.h
@@ -4,5 +4,7 @@
 #define _OBJTOOL_ARCH_ELF
 
 #define R_NONE R_PPC_NONE
+#define R_ABS64 R_PPC64_ADDR64
+#define R_ABS32 R_PPC_ADDR32
 
 #endif /* _OBJTOOL_ARCH_ELF */
-- 
2.31.1


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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-29 13:26     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-29 13:26 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Powerpc instructions must be word-aligned. Currently,
> there is an alignment of 16 bytes (by default), and it is
> much more than what is required for powerpc (4 bytes).
> 
> The default expansion of __ALIGN() macro is:
> #define __ALIGN       .align 4,0x90
> 
> Since Powerpc Linux does not require a 16 byte alignment,
> override __ALIGN() and __ALIGN_STR() macros to use required
> 4 byte alignment.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   arch/powerpc/include/asm/linkage.h | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
> index b71b9582e754..8df88fe61438 100644
> --- a/arch/powerpc/include/asm/linkage.h
> +++ b/arch/powerpc/include/asm/linkage.h
> @@ -2,8 +2,12 @@
>   #ifndef _ASM_POWERPC_LINKAGE_H
>   #define _ASM_POWERPC_LINKAGE_H
>   
> +#include <linux/stringify.h>
>   #include <asm/types.h>
>   
> +#define __ALIGN			.align 2
> +#define __ALIGN_STR		__stringify(__ALIGN)
> +

I still can't see the added value of using __stringify() macro here. In 
order to use that macro you have to include linux/stringify.h . Usually 
we try to minimise the amount of headers required by other headers.

>   #ifdef CONFIG_PPC64_ELF_ABI_V1
>   #define cond_syscall(x) \
>   	asm ("\t.weak " #x "\n\t.set " #x ", sys_ni_syscall\n"		\

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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
@ 2022-08-29 13:26     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-29 13:26 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Powerpc instructions must be word-aligned. Currently,
> there is an alignment of 16 bytes (by default), and it is
> much more than what is required for powerpc (4 bytes).
> 
> The default expansion of __ALIGN() macro is:
> #define __ALIGN       .align 4,0x90
> 
> Since Powerpc Linux does not require a 16 byte alignment,
> override __ALIGN() and __ALIGN_STR() macros to use required
> 4 byte alignment.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   arch/powerpc/include/asm/linkage.h | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
> index b71b9582e754..8df88fe61438 100644
> --- a/arch/powerpc/include/asm/linkage.h
> +++ b/arch/powerpc/include/asm/linkage.h
> @@ -2,8 +2,12 @@
>   #ifndef _ASM_POWERPC_LINKAGE_H
>   #define _ASM_POWERPC_LINKAGE_H
>   
> +#include <linux/stringify.h>
>   #include <asm/types.h>
>   
> +#define __ALIGN			.align 2
> +#define __ALIGN_STR		__stringify(__ALIGN)
> +

I still can't see the added value of using __stringify() macro here. In 
order to use that macro you have to include linux/stringify.h . Usually 
we try to minimise the amount of headers required by other headers.

>   #ifdef CONFIG_PPC64_ELF_ABI_V1
>   #define cond_syscall(x) \
>   	asm ("\t.weak " #x "\n\t.set " #x ", sys_ni_syscall\n"		\

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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
  2022-08-29 13:26     ` Christophe Leroy
@ 2022-08-29 14:39       ` Sathvika Vasireddy
  -1 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29 14:39 UTC (permalink / raw)
  To: Christophe Leroy, Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao

Hi Christophe,

On 29/08/22 18:56, Christophe Leroy wrote:
>
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> Powerpc instructions must be word-aligned. Currently,
>> there is an alignment of 16 bytes (by default), and it is
>> much more than what is required for powerpc (4 bytes).
>>
>> The default expansion of __ALIGN() macro is:
>> #define __ALIGN       .align 4,0x90
>>
>> Since Powerpc Linux does not require a 16 byte alignment,
>> override __ALIGN() and __ALIGN_STR() macros to use required
>> 4 byte alignment.
>>
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>> ---
>>    arch/powerpc/include/asm/linkage.h | 4 ++++
>>    1 file changed, 4 insertions(+)
>>
>> diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
>> index b71b9582e754..8df88fe61438 100644
>> --- a/arch/powerpc/include/asm/linkage.h
>> +++ b/arch/powerpc/include/asm/linkage.h
>> @@ -2,8 +2,12 @@
>>    #ifndef _ASM_POWERPC_LINKAGE_H
>>    #define _ASM_POWERPC_LINKAGE_H
>>    
>> +#include <linux/stringify.h>
>>    #include <asm/types.h>
>>    
>> +#define __ALIGN			.align 2
>> +#define __ALIGN_STR		__stringify(__ALIGN)
>> +
> I still can't see the added value of using __stringify() macro here. In
> order to use that macro you have to include linux/stringify.h . Usually
> we try to minimise the amount of headers required by other headers.
Oh ok, makes sense to me. I'll wait for a day to see if there are any
other comments, and make this change as part of v3.

Thanks for reviewing!

- Sathvika

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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
@ 2022-08-29 14:39       ` Sathvika Vasireddy
  0 siblings, 0 replies; 128+ messages in thread
From: Sathvika Vasireddy @ 2022-08-29 14:39 UTC (permalink / raw)
  To: Christophe Leroy, Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

Hi Christophe,

On 29/08/22 18:56, Christophe Leroy wrote:
>
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> Powerpc instructions must be word-aligned. Currently,
>> there is an alignment of 16 bytes (by default), and it is
>> much more than what is required for powerpc (4 bytes).
>>
>> The default expansion of __ALIGN() macro is:
>> #define __ALIGN       .align 4,0x90
>>
>> Since Powerpc Linux does not require a 16 byte alignment,
>> override __ALIGN() and __ALIGN_STR() macros to use required
>> 4 byte alignment.
>>
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>> ---
>>    arch/powerpc/include/asm/linkage.h | 4 ++++
>>    1 file changed, 4 insertions(+)
>>
>> diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
>> index b71b9582e754..8df88fe61438 100644
>> --- a/arch/powerpc/include/asm/linkage.h
>> +++ b/arch/powerpc/include/asm/linkage.h
>> @@ -2,8 +2,12 @@
>>    #ifndef _ASM_POWERPC_LINKAGE_H
>>    #define _ASM_POWERPC_LINKAGE_H
>>    
>> +#include <linux/stringify.h>
>>    #include <asm/types.h>
>>    
>> +#define __ALIGN			.align 2
>> +#define __ALIGN_STR		__stringify(__ALIGN)
>> +
> I still can't see the added value of using __stringify() macro here. In
> order to use that macro you have to include linux/stringify.h . Usually
> we try to minimise the amount of headers required by other headers.
Oh ok, makes sense to me. I'll wait for a day to see if there are any
other comments, and make this change as part of v3.

Thanks for reviewing!

- Sathvika

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

* Re: [PATCH v2 01/16] powerpc: Replace unreachable() with it's builtin variant in __WARN_FLAGS()
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:15     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:15 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> objtool is throwing *unannotated intra-function call* warnings in
> .c files with a few instructions that are marked unreachable. The
> problem comes from the annotate_unreachable() macro that is
> called by unreachable(). This annotation is adding a call to a
> function with size 0, and objtool does not add such symbols
> to the rbtree. Due to this reason, find_call_destination() function
> is not able to find the destination symbol for that call.
> 
> With the annotation (annotate_unreachable()), gcc seems to
> generate a 'bl' to unreachable symbol with size 0. But with
> the builtin variant of unreachable (__builtin_unreachable()),
> gcc does not emit calls to such symbols and the warnings
> go away. Given that the codegen remains same, and that
> there are no 'bl' instructions to such symbols emitted, fix
> these warnings by replacing unreachable() with it's builtin
> variant in __WARN_FLAGS().

How can you say that the codegen remains the same if with the original 
you get stale 'bl' instructions and with the alternative you don't ?

> 
> Also, add barrier_before_unreachable() before __builtin_unreachable()
> to work around a gcc bug [1], for the problem reported at [2].

Here my comment was not related to the gcc bug [1] but to gcc bug 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365 , which was worked 
around by commit 173a3efd3edb ("bug.h: work around GCC PR82365 in BUG()")

By chance it also solve the problem [1] as you mention.

> 
> [1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106751
> [2]: https://lkml.org/lkml/2022/8/25/418
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/include/asm/bug.h | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
> index 61a4736355c2..ef42adb44aa3 100644
> --- a/arch/powerpc/include/asm/bug.h
> +++ b/arch/powerpc/include/asm/bug.h
> @@ -99,7 +99,8 @@
>   	__label__ __label_warn_on;				\
>   								\
>   	WARN_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags), __label_warn_on); \
> -	unreachable();						\
> +	barrier_before_unreachable();				\
> +	__builtin_unreachable();				\
>   								\
>   __label_warn_on:						\
>   	break;							\

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

* Re: [PATCH v2 01/16] powerpc: Replace unreachable() with it's builtin variant in __WARN_FLAGS()
@ 2022-08-30  6:15     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:15 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> objtool is throwing *unannotated intra-function call* warnings in
> .c files with a few instructions that are marked unreachable. The
> problem comes from the annotate_unreachable() macro that is
> called by unreachable(). This annotation is adding a call to a
> function with size 0, and objtool does not add such symbols
> to the rbtree. Due to this reason, find_call_destination() function
> is not able to find the destination symbol for that call.
> 
> With the annotation (annotate_unreachable()), gcc seems to
> generate a 'bl' to unreachable symbol with size 0. But with
> the builtin variant of unreachable (__builtin_unreachable()),
> gcc does not emit calls to such symbols and the warnings
> go away. Given that the codegen remains same, and that
> there are no 'bl' instructions to such symbols emitted, fix
> these warnings by replacing unreachable() with it's builtin
> variant in __WARN_FLAGS().

How can you say that the codegen remains the same if with the original 
you get stale 'bl' instructions and with the alternative you don't ?

> 
> Also, add barrier_before_unreachable() before __builtin_unreachable()
> to work around a gcc bug [1], for the problem reported at [2].

Here my comment was not related to the gcc bug [1] but to gcc bug 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365 , which was worked 
around by commit 173a3efd3edb ("bug.h: work around GCC PR82365 in BUG()")

By chance it also solve the problem [1] as you mention.

> 
> [1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106751
> [2]: https://lkml.org/lkml/2022/8/25/418
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/include/asm/bug.h | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
> index 61a4736355c2..ef42adb44aa3 100644
> --- a/arch/powerpc/include/asm/bug.h
> +++ b/arch/powerpc/include/asm/bug.h
> @@ -99,7 +99,8 @@
>   	__label__ __label_warn_on;				\
>   								\
>   	WARN_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags), __label_warn_on); \
> -	unreachable();						\
> +	barrier_before_unreachable();				\
> +	__builtin_unreachable();				\
>   								\
>   __label_warn_on:						\
>   	break;							\

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

* Re: [PATCH v2 03/16] powerpc: Fix objtool unannotated intra-function call warnings
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:16     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:16 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> objtool throws unannotated intra-function call warnings
> in the following assembly files:
> 
> arch/powerpc/kernel/vector.o: warning: objtool: .text+0x53c: unannotated intra-function call
> 
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x60: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x124: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5d4: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5dc: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xcb8: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xd0c: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x1030: unannotated intra-function call
> 
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x358: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x728: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4d94: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4ec4: unannotated intra-function call
> 
> arch/powerpc/kvm/book3s_hv_interrupts.o: warning: objtool: .text+0x6c: unannotated intra-function call
> arch/powerpc/kernel/misc_64.o: warning: objtool: .text+0x64: unannotated intra-function call
> 
> objtool does not add STT_NOTYPE symbols with size 0 to the
> rbtree, which is why find_call_destination() function is not able
> to find the destination symbol for 'bl' instruction. For such symbols,
> objtool is throwing unannotated intra-function call warnings in
> assembly files. Fix these warnings by adding SYM_FUNC_START_LOCAL()
> and SYM_FUNC_END() annotations to those symbols to be able to set symbol
> type to STT_FUNC and set size of these symbols accordingly.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/kernel/exceptions-64s.S    |  7 +++++--
>   arch/powerpc/kernel/head_64.S           |  7 +++++--
>   arch/powerpc/kernel/misc_64.S           |  4 +++-
>   arch/powerpc/kernel/vector.S            |  4 +++-
>   arch/powerpc/kvm/book3s_hv_interrupts.S |  4 +++-
>   arch/powerpc/kvm/book3s_hv_rmhandlers.S | 22 +++++++++++++++-------
>   6 files changed, 34 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index 3d0dc133a9ae..4242c1a20bcd 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -20,6 +20,7 @@
>   #include <asm/head-64.h>
>   #include <asm/feature-fixups.h>
>   #include <asm/kup.h>
> +#include <linux/linkage.h>
>   
>   /*
>    * Following are fixed section helper macros.
> @@ -3075,7 +3076,7 @@ CLOSE_FIXED_SECTION(virt_trampolines);
>   USE_TEXT_SECTION()
>   
>   /* MSR[RI] should be clear because this uses SRR[01] */
> -enable_machine_check:
> +SYM_FUNC_START_LOCAL(enable_machine_check)
>   	mflr	r0
>   	bcl	20,31,$+4
>   0:	mflr	r3
> @@ -3087,9 +3088,10 @@ enable_machine_check:
>   	RFI_TO_KERNEL
>   1:	mtlr	r0
>   	blr
> +SYM_FUNC_END(enable_machine_check)
>   
>   /* MSR[RI] should be clear because this uses SRR[01] */
> -disable_machine_check:
> +SYM_FUNC_START_LOCAL(disable_machine_check)
>   	mflr	r0
>   	bcl	20,31,$+4
>   0:	mflr	r3
> @@ -3102,3 +3104,4 @@ disable_machine_check:
>   	RFI_TO_KERNEL
>   1:	mtlr	r0
>   	blr
> +SYM_FUNC_END(disable_machine_check)
> diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
> index cf2c08902c05..10e2d43420d0 100644
> --- a/arch/powerpc/kernel/head_64.S
> +++ b/arch/powerpc/kernel/head_64.S
> @@ -18,6 +18,7 @@
>    *  variants.
>    */
>   
> +#include <linux/linkage.h>
>   #include <linux/threads.h>
>   #include <linux/init.h>
>   #include <asm/reg.h>
> @@ -465,7 +466,7 @@ generic_secondary_common_init:
>    * Assumes we're mapped EA == RA if the MMU is on.
>    */
>   #ifdef CONFIG_PPC_BOOK3S
> -__mmu_off:
> +SYM_FUNC_START_LOCAL(__mmu_off)
>   	mfmsr	r3
>   	andi.	r0,r3,MSR_IR|MSR_DR
>   	beqlr
> @@ -476,6 +477,7 @@ __mmu_off:
>   	sync
>   	rfid
>   	b	.	/* prevent speculative execution */
> +SYM_FUNC_END(__mmu_off)
>   #endif
>   
>   
> @@ -869,7 +871,7 @@ _GLOBAL(start_secondary_resume)
>   /*
>    * This subroutine clobbers r11 and r12
>    */
> -enable_64b_mode:
> +SYM_FUNC_START_LOCAL(enable_64b_mode)
>   	mfmsr	r11			/* grab the current MSR */
>   #ifdef CONFIG_PPC_BOOK3E
>   	oris	r11,r11,0x8000		/* CM bit set, we'll set ICM later */
> @@ -881,6 +883,7 @@ enable_64b_mode:
>   	isync
>   #endif
>   	blr
> +SYM_FUNC_END(enable_64b_mode)
>   
>   /*
>    * This puts the TOC pointer into r2, offset by 0x8000 (as expected
> diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
> index fd6d8d3a548e..b36fb89ff718 100644
> --- a/arch/powerpc/kernel/misc_64.S
> +++ b/arch/powerpc/kernel/misc_64.S
> @@ -9,6 +9,7 @@
>    * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
>    */
>   
> +#include <linux/linkage.h>
>   #include <linux/sys.h>
>   #include <asm/unistd.h>
>   #include <asm/errno.h>
> @@ -353,7 +354,7 @@ _GLOBAL(kexec_smp_wait)
>    *
>    * don't overwrite r3 here, it is live for kexec_wait above.
>    */
> -real_mode:	/* assume normal blr return */
> +SYM_FUNC_START_LOCAL(real_mode)	/* assume normal blr return */
>   #ifdef CONFIG_PPC_BOOK3E
>   	/* Create an identity mapping. */
>   	b	kexec_create_tlb
> @@ -370,6 +371,7 @@ real_mode:	/* assume normal blr return */
>   	mtspr	SPRN_SRR0,r11
>   	rfid
>   #endif
> +SYM_FUNC_END(real_mode)
>   
>   /*
>    * kexec_sequence(newstack, start, image, control, clear_all(),
> diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
> index 5cc24d8cce94..fb96aed2b5c3 100644
> --- a/arch/powerpc/kernel/vector.S
> +++ b/arch/powerpc/kernel/vector.S
> @@ -9,6 +9,7 @@
>   #include <asm/ptrace.h>
>   #include <asm/export.h>
>   #include <asm/asm-compat.h>
> +#include <linux/linkage.h>
>   
>   /*
>    * Load state from memory into VMX registers including VSCR.
> @@ -186,7 +187,7 @@ fphalf:
>    * Internal routine to enable floating point and set FPSCR to 0.
>    * Don't call it from C; it doesn't use the normal calling convention.
>    */
> -fpenable:
> +SYM_FUNC_START_LOCAL(fpenable)
>   #ifdef CONFIG_PPC32
>   	stwu	r1,-64(r1)
>   #else
> @@ -203,6 +204,7 @@ fpenable:
>   	mffs	fr31
>   	MTFSF_L(fr1)
>   	blr
> +SYM_FUNC_END(fpenable)
>   
>   fpdisable:
>   	mtlr	r12
> diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S
> index 59d89e4b154a..c0deeea7eef3 100644
> --- a/arch/powerpc/kvm/book3s_hv_interrupts.S
> +++ b/arch/powerpc/kvm/book3s_hv_interrupts.S
> @@ -9,6 +9,7 @@
>    * Authors: Alexander Graf <agraf@suse.de>
>    */
>   
> +#include <linux/linkage.h>
>   #include <asm/ppc_asm.h>
>   #include <asm/kvm_asm.h>
>   #include <asm/reg.h>
> @@ -107,7 +108,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
>   /*
>    * void kvmhv_save_host_pmu(void)
>    */
> -kvmhv_save_host_pmu:
> +SYM_FUNC_START_LOCAL(kvmhv_save_host_pmu)
>   BEGIN_FTR_SECTION
>   	/* Work around P8 PMAE bug */
>   	li	r3, -1
> @@ -154,3 +155,4 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   	stw	r8, HSTATE_PMC5(r13)
>   	stw	r9, HSTATE_PMC6(r13)
>   31:	blr
> +SYM_FUNC_END(kvmhv_save_host_pmu)
> diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> index 7ded202bf995..de91118df0c5 100644
> --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> @@ -29,6 +29,7 @@
>   #include <asm/asm-compat.h>
>   #include <asm/feature-fixups.h>
>   #include <asm/cpuidle.h>
> +#include <linux/linkage.h>
>   
>   /* Values in HSTATE_NAPPING(r13) */
>   #define NAPPING_CEDE	1
> @@ -2358,7 +2359,7 @@ hmi_realmode:
>    * This routine calls kvmppc_read_intr, a C function, if an external
>    * interrupt is pending.
>    */
> -kvmppc_check_wake_reason:
> +SYM_FUNC_START_LOCAL(kvmppc_check_wake_reason)
>   	mfspr	r6, SPRN_SRR1
>   BEGIN_FTR_SECTION
>   	rlwinm	r6, r6, 45-31, 0xf	/* extract wake reason field (P8) */
> @@ -2427,6 +2428,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   	addi	r1, r1, PPC_MIN_STKFRM
>   	mtlr	r0
>   	blr
> +SYM_FUNC_END(kvmppc_check_wake_reason)
>   
>   /*
>    * Save away FP, VMX and VSX registers.
> @@ -2434,7 +2436,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>    * N.B. r30 and r31 are volatile across this function,
>    * thus it is not callable from C.
>    */
> -kvmppc_save_fp:
> +SYM_FUNC_START_LOCAL(kvmppc_save_fp)
>   	mflr	r30
>   	mr	r31,r3
>   	mfmsr	r5
> @@ -2462,6 +2464,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
>   	stw	r6,VCPU_VRSAVE(r31)
>   	mtlr	r30
>   	blr
> +SYM_FUNC_END(kvmppc_save_fp)
>   
>   /*
>    * Load up FP, VMX and VSX registers
> @@ -2469,7 +2472,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
>    * N.B. r30 and r31 are volatile across this function,
>    * thus it is not callable from C.
>    */
> -kvmppc_load_fp:
> +SYM_FUNC_START_LOCAL(kvmppc_load_fp)
>   	mflr	r30
>   	mr	r31,r4
>   	mfmsr	r9
> @@ -2498,6 +2501,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
>   	mtlr	r30
>   	mr	r4,r31
>   	blr
> +SYM_FUNC_END(kvmppc_load_fp)
>   
>   #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
>   /*
> @@ -2746,7 +2750,7 @@ kvmppc_bad_host_intr:
>    *   r9 has a vcpu pointer (in)
>    *   r0 is used as a scratch register
>    */
> -kvmppc_msr_interrupt:
> +SYM_FUNC_START_LOCAL(kvmppc_msr_interrupt)
>   	rldicl	r0, r11, 64 - MSR_TS_S_LG, 62
>   	cmpwi	r0, 2 /* Check if we are in transactional state..  */
>   	ld	r11, VCPU_INTR_MSR(r9)
> @@ -2755,13 +2759,14 @@ kvmppc_msr_interrupt:
>   	li	r0, 1
>   1:	rldimi	r11, r0, MSR_TS_S_LG, 63 - MSR_TS_T_LG
>   	blr
> +SYM_FUNC_END(kvmppc_msr_interrupt)
>   
>   /*
>    * void kvmhv_load_guest_pmu(struct kvm_vcpu *vcpu)
>    *
>    * Load up guest PMU state.  R3 points to the vcpu struct.
>    */
> -kvmhv_load_guest_pmu:
> +SYM_FUNC_START_LOCAL(kvmhv_load_guest_pmu)
>   	mr	r4, r3
>   	mflr	r0
>   	li	r3, 1
> @@ -2811,13 +2816,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   	isync
>   	mtlr	r0
>   	blr
> +SYM_FUNC_END(kvmhv_load_guest_pmu)
>   
>   /*
>    * void kvmhv_load_host_pmu(void)
>    *
>    * Reload host PMU state saved in the PACA by kvmhv_save_host_pmu.
>    */
> -kvmhv_load_host_pmu:
> +SYM_FUNC_START_LOCAL(kvmhv_load_host_pmu)
>   	mflr	r0
>   	lbz	r4, PACA_PMCINUSE(r13) /* is the host using the PMU? */
>   	cmpwi	r4, 0
> @@ -2859,6 +2865,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   	isync
>   	mtlr	r0
>   23:	blr
> +SYM_FUNC_END(kvmhv_load_host_pmu)
>   
>   /*
>    * void kvmhv_save_guest_pmu(struct kvm_vcpu *vcpu, bool pmu_in_use)
> @@ -2866,7 +2873,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>    * Save guest PMU state into the vcpu struct.
>    * r3 = vcpu, r4 = full save flag (PMU in use flag set in VPA)
>    */
> -kvmhv_save_guest_pmu:
> +SYM_FUNC_START_LOCAL(kvmhv_save_guest_pmu)
>   	mr	r9, r3
>   	mr	r8, r4
>   BEGIN_FTR_SECTION
> @@ -2942,6 +2949,7 @@ BEGIN_FTR_SECTION
>   	mtspr	SPRN_MMCRS, r4
>   END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   22:	blr
> +SYM_FUNC_END(kvmhv_save_guest_pmu)
>   
>   /*
>    * This works around a hardware bug on POWER8E processors, where

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

* Re: [PATCH v2 03/16] powerpc: Fix objtool unannotated intra-function call warnings
@ 2022-08-30  6:16     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:16 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> objtool throws unannotated intra-function call warnings
> in the following assembly files:
> 
> arch/powerpc/kernel/vector.o: warning: objtool: .text+0x53c: unannotated intra-function call
> 
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x60: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x124: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5d4: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5dc: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xcb8: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xd0c: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x1030: unannotated intra-function call
> 
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x358: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x728: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4d94: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4ec4: unannotated intra-function call
> 
> arch/powerpc/kvm/book3s_hv_interrupts.o: warning: objtool: .text+0x6c: unannotated intra-function call
> arch/powerpc/kernel/misc_64.o: warning: objtool: .text+0x64: unannotated intra-function call
> 
> objtool does not add STT_NOTYPE symbols with size 0 to the
> rbtree, which is why find_call_destination() function is not able
> to find the destination symbol for 'bl' instruction. For such symbols,
> objtool is throwing unannotated intra-function call warnings in
> assembly files. Fix these warnings by adding SYM_FUNC_START_LOCAL()
> and SYM_FUNC_END() annotations to those symbols to be able to set symbol
> type to STT_FUNC and set size of these symbols accordingly.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/kernel/exceptions-64s.S    |  7 +++++--
>   arch/powerpc/kernel/head_64.S           |  7 +++++--
>   arch/powerpc/kernel/misc_64.S           |  4 +++-
>   arch/powerpc/kernel/vector.S            |  4 +++-
>   arch/powerpc/kvm/book3s_hv_interrupts.S |  4 +++-
>   arch/powerpc/kvm/book3s_hv_rmhandlers.S | 22 +++++++++++++++-------
>   6 files changed, 34 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index 3d0dc133a9ae..4242c1a20bcd 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -20,6 +20,7 @@
>   #include <asm/head-64.h>
>   #include <asm/feature-fixups.h>
>   #include <asm/kup.h>
> +#include <linux/linkage.h>
>   
>   /*
>    * Following are fixed section helper macros.
> @@ -3075,7 +3076,7 @@ CLOSE_FIXED_SECTION(virt_trampolines);
>   USE_TEXT_SECTION()
>   
>   /* MSR[RI] should be clear because this uses SRR[01] */
> -enable_machine_check:
> +SYM_FUNC_START_LOCAL(enable_machine_check)
>   	mflr	r0
>   	bcl	20,31,$+4
>   0:	mflr	r3
> @@ -3087,9 +3088,10 @@ enable_machine_check:
>   	RFI_TO_KERNEL
>   1:	mtlr	r0
>   	blr
> +SYM_FUNC_END(enable_machine_check)
>   
>   /* MSR[RI] should be clear because this uses SRR[01] */
> -disable_machine_check:
> +SYM_FUNC_START_LOCAL(disable_machine_check)
>   	mflr	r0
>   	bcl	20,31,$+4
>   0:	mflr	r3
> @@ -3102,3 +3104,4 @@ disable_machine_check:
>   	RFI_TO_KERNEL
>   1:	mtlr	r0
>   	blr
> +SYM_FUNC_END(disable_machine_check)
> diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
> index cf2c08902c05..10e2d43420d0 100644
> --- a/arch/powerpc/kernel/head_64.S
> +++ b/arch/powerpc/kernel/head_64.S
> @@ -18,6 +18,7 @@
>    *  variants.
>    */
>   
> +#include <linux/linkage.h>
>   #include <linux/threads.h>
>   #include <linux/init.h>
>   #include <asm/reg.h>
> @@ -465,7 +466,7 @@ generic_secondary_common_init:
>    * Assumes we're mapped EA == RA if the MMU is on.
>    */
>   #ifdef CONFIG_PPC_BOOK3S
> -__mmu_off:
> +SYM_FUNC_START_LOCAL(__mmu_off)
>   	mfmsr	r3
>   	andi.	r0,r3,MSR_IR|MSR_DR
>   	beqlr
> @@ -476,6 +477,7 @@ __mmu_off:
>   	sync
>   	rfid
>   	b	.	/* prevent speculative execution */
> +SYM_FUNC_END(__mmu_off)
>   #endif
>   
>   
> @@ -869,7 +871,7 @@ _GLOBAL(start_secondary_resume)
>   /*
>    * This subroutine clobbers r11 and r12
>    */
> -enable_64b_mode:
> +SYM_FUNC_START_LOCAL(enable_64b_mode)
>   	mfmsr	r11			/* grab the current MSR */
>   #ifdef CONFIG_PPC_BOOK3E
>   	oris	r11,r11,0x8000		/* CM bit set, we'll set ICM later */
> @@ -881,6 +883,7 @@ enable_64b_mode:
>   	isync
>   #endif
>   	blr
> +SYM_FUNC_END(enable_64b_mode)
>   
>   /*
>    * This puts the TOC pointer into r2, offset by 0x8000 (as expected
> diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
> index fd6d8d3a548e..b36fb89ff718 100644
> --- a/arch/powerpc/kernel/misc_64.S
> +++ b/arch/powerpc/kernel/misc_64.S
> @@ -9,6 +9,7 @@
>    * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
>    */
>   
> +#include <linux/linkage.h>
>   #include <linux/sys.h>
>   #include <asm/unistd.h>
>   #include <asm/errno.h>
> @@ -353,7 +354,7 @@ _GLOBAL(kexec_smp_wait)
>    *
>    * don't overwrite r3 here, it is live for kexec_wait above.
>    */
> -real_mode:	/* assume normal blr return */
> +SYM_FUNC_START_LOCAL(real_mode)	/* assume normal blr return */
>   #ifdef CONFIG_PPC_BOOK3E
>   	/* Create an identity mapping. */
>   	b	kexec_create_tlb
> @@ -370,6 +371,7 @@ real_mode:	/* assume normal blr return */
>   	mtspr	SPRN_SRR0,r11
>   	rfid
>   #endif
> +SYM_FUNC_END(real_mode)
>   
>   /*
>    * kexec_sequence(newstack, start, image, control, clear_all(),
> diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
> index 5cc24d8cce94..fb96aed2b5c3 100644
> --- a/arch/powerpc/kernel/vector.S
> +++ b/arch/powerpc/kernel/vector.S
> @@ -9,6 +9,7 @@
>   #include <asm/ptrace.h>
>   #include <asm/export.h>
>   #include <asm/asm-compat.h>
> +#include <linux/linkage.h>
>   
>   /*
>    * Load state from memory into VMX registers including VSCR.
> @@ -186,7 +187,7 @@ fphalf:
>    * Internal routine to enable floating point and set FPSCR to 0.
>    * Don't call it from C; it doesn't use the normal calling convention.
>    */
> -fpenable:
> +SYM_FUNC_START_LOCAL(fpenable)
>   #ifdef CONFIG_PPC32
>   	stwu	r1,-64(r1)
>   #else
> @@ -203,6 +204,7 @@ fpenable:
>   	mffs	fr31
>   	MTFSF_L(fr1)
>   	blr
> +SYM_FUNC_END(fpenable)
>   
>   fpdisable:
>   	mtlr	r12
> diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S
> index 59d89e4b154a..c0deeea7eef3 100644
> --- a/arch/powerpc/kvm/book3s_hv_interrupts.S
> +++ b/arch/powerpc/kvm/book3s_hv_interrupts.S
> @@ -9,6 +9,7 @@
>    * Authors: Alexander Graf <agraf@suse.de>
>    */
>   
> +#include <linux/linkage.h>
>   #include <asm/ppc_asm.h>
>   #include <asm/kvm_asm.h>
>   #include <asm/reg.h>
> @@ -107,7 +108,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
>   /*
>    * void kvmhv_save_host_pmu(void)
>    */
> -kvmhv_save_host_pmu:
> +SYM_FUNC_START_LOCAL(kvmhv_save_host_pmu)
>   BEGIN_FTR_SECTION
>   	/* Work around P8 PMAE bug */
>   	li	r3, -1
> @@ -154,3 +155,4 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   	stw	r8, HSTATE_PMC5(r13)
>   	stw	r9, HSTATE_PMC6(r13)
>   31:	blr
> +SYM_FUNC_END(kvmhv_save_host_pmu)
> diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> index 7ded202bf995..de91118df0c5 100644
> --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> @@ -29,6 +29,7 @@
>   #include <asm/asm-compat.h>
>   #include <asm/feature-fixups.h>
>   #include <asm/cpuidle.h>
> +#include <linux/linkage.h>
>   
>   /* Values in HSTATE_NAPPING(r13) */
>   #define NAPPING_CEDE	1
> @@ -2358,7 +2359,7 @@ hmi_realmode:
>    * This routine calls kvmppc_read_intr, a C function, if an external
>    * interrupt is pending.
>    */
> -kvmppc_check_wake_reason:
> +SYM_FUNC_START_LOCAL(kvmppc_check_wake_reason)
>   	mfspr	r6, SPRN_SRR1
>   BEGIN_FTR_SECTION
>   	rlwinm	r6, r6, 45-31, 0xf	/* extract wake reason field (P8) */
> @@ -2427,6 +2428,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   	addi	r1, r1, PPC_MIN_STKFRM
>   	mtlr	r0
>   	blr
> +SYM_FUNC_END(kvmppc_check_wake_reason)
>   
>   /*
>    * Save away FP, VMX and VSX registers.
> @@ -2434,7 +2436,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>    * N.B. r30 and r31 are volatile across this function,
>    * thus it is not callable from C.
>    */
> -kvmppc_save_fp:
> +SYM_FUNC_START_LOCAL(kvmppc_save_fp)
>   	mflr	r30
>   	mr	r31,r3
>   	mfmsr	r5
> @@ -2462,6 +2464,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
>   	stw	r6,VCPU_VRSAVE(r31)
>   	mtlr	r30
>   	blr
> +SYM_FUNC_END(kvmppc_save_fp)
>   
>   /*
>    * Load up FP, VMX and VSX registers
> @@ -2469,7 +2472,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
>    * N.B. r30 and r31 are volatile across this function,
>    * thus it is not callable from C.
>    */
> -kvmppc_load_fp:
> +SYM_FUNC_START_LOCAL(kvmppc_load_fp)
>   	mflr	r30
>   	mr	r31,r4
>   	mfmsr	r9
> @@ -2498,6 +2501,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
>   	mtlr	r30
>   	mr	r4,r31
>   	blr
> +SYM_FUNC_END(kvmppc_load_fp)
>   
>   #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
>   /*
> @@ -2746,7 +2750,7 @@ kvmppc_bad_host_intr:
>    *   r9 has a vcpu pointer (in)
>    *   r0 is used as a scratch register
>    */
> -kvmppc_msr_interrupt:
> +SYM_FUNC_START_LOCAL(kvmppc_msr_interrupt)
>   	rldicl	r0, r11, 64 - MSR_TS_S_LG, 62
>   	cmpwi	r0, 2 /* Check if we are in transactional state..  */
>   	ld	r11, VCPU_INTR_MSR(r9)
> @@ -2755,13 +2759,14 @@ kvmppc_msr_interrupt:
>   	li	r0, 1
>   1:	rldimi	r11, r0, MSR_TS_S_LG, 63 - MSR_TS_T_LG
>   	blr
> +SYM_FUNC_END(kvmppc_msr_interrupt)
>   
>   /*
>    * void kvmhv_load_guest_pmu(struct kvm_vcpu *vcpu)
>    *
>    * Load up guest PMU state.  R3 points to the vcpu struct.
>    */
> -kvmhv_load_guest_pmu:
> +SYM_FUNC_START_LOCAL(kvmhv_load_guest_pmu)
>   	mr	r4, r3
>   	mflr	r0
>   	li	r3, 1
> @@ -2811,13 +2816,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   	isync
>   	mtlr	r0
>   	blr
> +SYM_FUNC_END(kvmhv_load_guest_pmu)
>   
>   /*
>    * void kvmhv_load_host_pmu(void)
>    *
>    * Reload host PMU state saved in the PACA by kvmhv_save_host_pmu.
>    */
> -kvmhv_load_host_pmu:
> +SYM_FUNC_START_LOCAL(kvmhv_load_host_pmu)
>   	mflr	r0
>   	lbz	r4, PACA_PMCINUSE(r13) /* is the host using the PMU? */
>   	cmpwi	r4, 0
> @@ -2859,6 +2865,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   	isync
>   	mtlr	r0
>   23:	blr
> +SYM_FUNC_END(kvmhv_load_host_pmu)
>   
>   /*
>    * void kvmhv_save_guest_pmu(struct kvm_vcpu *vcpu, bool pmu_in_use)
> @@ -2866,7 +2873,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>    * Save guest PMU state into the vcpu struct.
>    * r3 = vcpu, r4 = full save flag (PMU in use flag set in VPA)
>    */
> -kvmhv_save_guest_pmu:
> +SYM_FUNC_START_LOCAL(kvmhv_save_guest_pmu)
>   	mr	r9, r3
>   	mr	r8, r4
>   BEGIN_FTR_SECTION
> @@ -2942,6 +2949,7 @@ BEGIN_FTR_SECTION
>   	mtspr	SPRN_MMCRS, r4
>   END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>   22:	blr
> +SYM_FUNC_END(kvmhv_save_guest_pmu)
>   
>   /*
>    * This works around a hardware bug on POWER8E processors, where

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

* Re: [PATCH v2 04/16] powerpc: Curb objtool unannotated intra-function warnings
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:26     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:26 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> objtool throws the following unannotated intra-function call
> warnings:
> 
> arch/powerpc/kernel/entry_64.o: warning: objtool: .text+0x4: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xe64: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xee4: unannotated intra-function call
> 
> Fix these warnings by annotating intra-function
> call, using ANNOTATE_INTRA_FUNCTION_CALL macro,
> to indicate that the branch targets are valid.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/kernel/entry_64.S          | 2 ++
>   arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 +++
>   2 files changed, 5 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
> index 01ace4c56104..fb444bc64f3f 100644
> --- a/arch/powerpc/kernel/entry_64.S
> +++ b/arch/powerpc/kernel/entry_64.S
> @@ -14,6 +14,7 @@
>    *  code, and exception/interrupt return code for PowerPC.
>    */
>   
> +#include <linux/objtool.h>
>   #include <linux/errno.h>
>   #include <linux/err.h>
>   #include <asm/cache.h>
> @@ -73,6 +74,7 @@ flush_branch_caches:
>   
>   	// Flush the link stack
>   	.rept 64
> +	ANNOTATE_INTRA_FUNCTION_CALL
>   	bl	.+4
>   	.endr
>   	b	1f
> diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> index de91118df0c5..ea39a0cf591a 100644
> --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> @@ -30,6 +30,7 @@
>   #include <asm/feature-fixups.h>
>   #include <asm/cpuidle.h>
>   #include <linux/linkage.h>
> +#include <linux/objtool.h>
>   
>   /* Values in HSTATE_NAPPING(r13) */
>   #define NAPPING_CEDE	1
> @@ -1523,12 +1524,14 @@ kvm_flush_link_stack:
>   
>   	/* Flush the link stack. On Power8 it's up to 32 entries in size. */
>   	.rept 32
> +	ANNOTATE_INTRA_FUNCTION_CALL
>   	bl	.+4
>   	.endr
>   
>   	/* And on Power9 it's up to 64. */
>   BEGIN_FTR_SECTION
>   	.rept 32
> +	ANNOTATE_INTRA_FUNCTION_CALL
>   	bl	.+4
>   	.endr
>   END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)

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

* Re: [PATCH v2 04/16] powerpc: Curb objtool unannotated intra-function warnings
@ 2022-08-30  6:26     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:26 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> objtool throws the following unannotated intra-function call
> warnings:
> 
> arch/powerpc/kernel/entry_64.o: warning: objtool: .text+0x4: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xe64: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xee4: unannotated intra-function call
> 
> Fix these warnings by annotating intra-function
> call, using ANNOTATE_INTRA_FUNCTION_CALL macro,
> to indicate that the branch targets are valid.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/kernel/entry_64.S          | 2 ++
>   arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 +++
>   2 files changed, 5 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
> index 01ace4c56104..fb444bc64f3f 100644
> --- a/arch/powerpc/kernel/entry_64.S
> +++ b/arch/powerpc/kernel/entry_64.S
> @@ -14,6 +14,7 @@
>    *  code, and exception/interrupt return code for PowerPC.
>    */
>   
> +#include <linux/objtool.h>
>   #include <linux/errno.h>
>   #include <linux/err.h>
>   #include <asm/cache.h>
> @@ -73,6 +74,7 @@ flush_branch_caches:
>   
>   	// Flush the link stack
>   	.rept 64
> +	ANNOTATE_INTRA_FUNCTION_CALL
>   	bl	.+4
>   	.endr
>   	b	1f
> diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> index de91118df0c5..ea39a0cf591a 100644
> --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> @@ -30,6 +30,7 @@
>   #include <asm/feature-fixups.h>
>   #include <asm/cpuidle.h>
>   #include <linux/linkage.h>
> +#include <linux/objtool.h>
>   
>   /* Values in HSTATE_NAPPING(r13) */
>   #define NAPPING_CEDE	1
> @@ -1523,12 +1524,14 @@ kvm_flush_link_stack:
>   
>   	/* Flush the link stack. On Power8 it's up to 32 entries in size. */
>   	.rept 32
> +	ANNOTATE_INTRA_FUNCTION_CALL
>   	bl	.+4
>   	.endr
>   
>   	/* And on Power9 it's up to 64. */
>   BEGIN_FTR_SECTION
>   	.rept 32
> +	ANNOTATE_INTRA_FUNCTION_CALL
>   	bl	.+4
>   	.endr
>   END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)

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

* Re: [PATCH v2 05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:26     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:26 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> With objtool enabled, below warnings are seen when trying to build:
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2448: unannotated intra-function call
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2d68: unannotated intra-function call
> 
> Skip objtool from running on this file, for two main reasons:
> 
> Since this file comes from OpenSSL, and since it is a perl file
> which generates a .S file, it may not be the best choice to
> make too many code changes to such files, unless absolutely
> necessary.
> 
> Second reason is that, at least as far as the objtool --mcount
> functionality is concerned, we do not have to run objtool on
> that file because that file does not have any calls to _mcount.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   drivers/crypto/vmx/Makefile | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
> index 2560cfea1dec..7b41f0da6807 100644
> --- a/drivers/crypto/vmx/Makefile
> +++ b/drivers/crypto/vmx/Makefile
> @@ -9,3 +9,5 @@ targets += aesp8-ppc.S ghashp8-ppc.S
>   
>   $(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
>   	$(call if_changed,perl)
> +
> +OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y

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

* Re: [PATCH v2 05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
@ 2022-08-30  6:26     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:26 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> With objtool enabled, below warnings are seen when trying to build:
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2448: unannotated intra-function call
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2d68: unannotated intra-function call
> 
> Skip objtool from running on this file, for two main reasons:
> 
> Since this file comes from OpenSSL, and since it is a perl file
> which generates a .S file, it may not be the best choice to
> make too many code changes to such files, unless absolutely
> necessary.
> 
> Second reason is that, at least as far as the objtool --mcount
> functionality is concerned, we do not have to run objtool on
> that file because that file does not have any calls to _mcount.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   drivers/crypto/vmx/Makefile | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
> index 2560cfea1dec..7b41f0da6807 100644
> --- a/drivers/crypto/vmx/Makefile
> +++ b/drivers/crypto/vmx/Makefile
> @@ -9,3 +9,5 @@ targets += aesp8-ppc.S ghashp8-ppc.S
>   
>   $(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
>   	$(call if_changed,perl)
> +
> +OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y

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

* Re: [PATCH v2 07/16] powerpc: Skip objtool from running on VDSO files
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:27     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:27 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Do not run objtool on VDSO files, by using
> OBJECT_FILES_NON_STANDARD
> 
> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/kernel/vdso/Makefile | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> index 096b0bf1335f..a49a0d6a1c53 100644
> --- a/arch/powerpc/kernel/vdso/Makefile
> +++ b/arch/powerpc/kernel/vdso/Makefile
> @@ -102,3 +102,5 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@
>         cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
>   quiet_cmd_vdso64as = VDSO64A $@
>         cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
> +
> +OBJECT_FILES_NON_STANDARD := y

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

* Re: [PATCH v2 07/16] powerpc: Skip objtool from running on VDSO files
@ 2022-08-30  6:27     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:27 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Do not run objtool on VDSO files, by using
> OBJECT_FILES_NON_STANDARD
> 
> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/kernel/vdso/Makefile | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> index 096b0bf1335f..a49a0d6a1c53 100644
> --- a/arch/powerpc/kernel/vdso/Makefile
> +++ b/arch/powerpc/kernel/vdso/Makefile
> @@ -102,3 +102,5 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@
>         cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
>   quiet_cmd_vdso64as = VDSO64A $@
>         cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
> +
> +OBJECT_FILES_NON_STANDARD := y

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

* Re: [PATCH v2 11/16] objtool: Add --mnop as an option to --mcount
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:28     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:28 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Architectures can select HAVE_NOP_MCOUNT if they choose
> to nop out mcount call sites. If that config option is
> selected, then --mnop is passed as an option to objtool,
> along with --mcount.
> 
> Also, make sure that --mnop can be passed as an option
> to objtool only when --mcount is passed.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   Makefile                                |  4 +++-
>   arch/x86/Kconfig                        |  1 +
>   scripts/Makefile.lib                    |  1 +
>   tools/objtool/builtin-check.c           | 14 ++++++++++++++
>   tools/objtool/check.c                   | 19 ++++++++++---------
>   tools/objtool/include/objtool/builtin.h |  1 +
>   6 files changed, 30 insertions(+), 10 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index c7705f749601..99dd33d8bcfa 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -857,7 +857,9 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC
>     endif
>   endif
>   ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
> -  CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
> +  ifdef CONFIG_HAVE_NOP_MCOUNT
> +    CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
> +  endif
>   endif
>   ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
>     ifdef CONFIG_HAVE_C_RECORDMCOUNT
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index f9920f1341c8..a8dd138df637 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -189,6 +189,7 @@ config X86
>   	select HAVE_CONTEXT_TRACKING_USER_OFFSTACK	if HAVE_CONTEXT_TRACKING_USER
>   	select HAVE_C_RECORDMCOUNT
>   	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
> +	select HAVE_NOP_MCOUNT			if HAVE_OBJTOOL_MCOUNT
>   	select HAVE_BUILDTIME_MCOUNT_SORT
>   	select HAVE_DEBUG_KMEMLEAK
>   	select HAVE_DMA_CONTIGUOUS
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 3fb6a99e78c4..0610078e057a 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -234,6 +234,7 @@ objtool_args =								\
>   	$(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr)		\
>   	$(if $(CONFIG_X86_KERNEL_IBT), --ibt)				\
>   	$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount)		\
> +	$(if $(CONFIG_HAVE_NOP_MCOUNT), --mnop)				\
>   	$(if $(CONFIG_UNWINDER_ORC), --orc)				\
>   	$(if $(CONFIG_RETPOLINE), --retpoline)				\
>   	$(if $(CONFIG_RETHUNK), --rethunk)				\
> diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
> index 24fbe803a0d3..9bd347d3c244 100644
> --- a/tools/objtool/builtin-check.c
> +++ b/tools/objtool/builtin-check.c
> @@ -82,6 +82,7 @@ const struct option check_options[] = {
>   	OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"),
>   	OPT_BOOLEAN(0, "link", &opts.link, "object is a linked object"),
>   	OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel module"),
> +	OPT_BOOLEAN(0, "mnop", &opts.mnop, "nop out mcount call sites"),
>   	OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable instruction' warnings"),
>   	OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"),
>   	OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),
> @@ -150,6 +151,16 @@ static bool opts_valid(void)
>   	return false;
>   }
>   
> +static bool mnop_opts_valid(void)
> +{
> +	if (opts.mnop && !opts.mcount) {
> +		ERROR("--mnop requires --mcount");
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
>   static bool link_opts_valid(struct objtool_file *file)
>   {
>   	if (opts.link)
> @@ -198,6 +209,9 @@ int objtool_run(int argc, const char **argv)
>   	if (!file)
>   		return 1;
>   
> +	if (!mnop_opts_valid())
> +		return 1;
> +
>   	if (!link_opts_valid(file))
>   		return 1;
>   
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 0ecf41ee73f0..3cea58f73878 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -1231,17 +1231,18 @@ static void annotate_call_site(struct objtool_file *file,
>   	if (opts.mcount && sym->fentry) {
>   		if (sibling)
>   			WARN_FUNC("Tail call to __fentry__ !?!?", insn->sec, insn->offset);
> +		if (opts.mnop) {
> +			if (reloc) {
> +				reloc->type = R_NONE;
> +				elf_write_reloc(file->elf, reloc);
> +			}
>   
> -		if (reloc) {
> -			reloc->type = R_NONE;
> -			elf_write_reloc(file->elf, reloc);
> -		}
> -
> -		elf_write_insn(file->elf, insn->sec,
> -			       insn->offset, insn->len,
> -			       arch_nop_insn(insn->len));
> +			elf_write_insn(file->elf, insn->sec,
> +				       insn->offset, insn->len,
> +				       arch_nop_insn(insn->len));
>   
> -		insn->type = INSN_NOP;
> +			insn->type = INSN_NOP;
> +		}
>   
>   		list_add_tail(&insn->call_node, &file->mcount_loc_list);
>   		return;
> diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/include/objtool/builtin.h
> index 42a52f1a0add..0785707c5a92 100644
> --- a/tools/objtool/include/objtool/builtin.h
> +++ b/tools/objtool/include/objtool/builtin.h
> @@ -31,6 +31,7 @@ struct opts {
>   	bool backup;
>   	bool dryrun;
>   	bool link;
> +	bool mnop;
>   	bool module;
>   	bool no_unreachable;
>   	bool sec_address;

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

* Re: [PATCH v2 11/16] objtool: Add --mnop as an option to --mcount
@ 2022-08-30  6:28     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:28 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Architectures can select HAVE_NOP_MCOUNT if they choose
> to nop out mcount call sites. If that config option is
> selected, then --mnop is passed as an option to objtool,
> along with --mcount.
> 
> Also, make sure that --mnop can be passed as an option
> to objtool only when --mcount is passed.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   Makefile                                |  4 +++-
>   arch/x86/Kconfig                        |  1 +
>   scripts/Makefile.lib                    |  1 +
>   tools/objtool/builtin-check.c           | 14 ++++++++++++++
>   tools/objtool/check.c                   | 19 ++++++++++---------
>   tools/objtool/include/objtool/builtin.h |  1 +
>   6 files changed, 30 insertions(+), 10 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index c7705f749601..99dd33d8bcfa 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -857,7 +857,9 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC
>     endif
>   endif
>   ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
> -  CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
> +  ifdef CONFIG_HAVE_NOP_MCOUNT
> +    CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
> +  endif
>   endif
>   ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
>     ifdef CONFIG_HAVE_C_RECORDMCOUNT
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index f9920f1341c8..a8dd138df637 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -189,6 +189,7 @@ config X86
>   	select HAVE_CONTEXT_TRACKING_USER_OFFSTACK	if HAVE_CONTEXT_TRACKING_USER
>   	select HAVE_C_RECORDMCOUNT
>   	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
> +	select HAVE_NOP_MCOUNT			if HAVE_OBJTOOL_MCOUNT
>   	select HAVE_BUILDTIME_MCOUNT_SORT
>   	select HAVE_DEBUG_KMEMLEAK
>   	select HAVE_DMA_CONTIGUOUS
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 3fb6a99e78c4..0610078e057a 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -234,6 +234,7 @@ objtool_args =								\
>   	$(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr)		\
>   	$(if $(CONFIG_X86_KERNEL_IBT), --ibt)				\
>   	$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount)		\
> +	$(if $(CONFIG_HAVE_NOP_MCOUNT), --mnop)				\
>   	$(if $(CONFIG_UNWINDER_ORC), --orc)				\
>   	$(if $(CONFIG_RETPOLINE), --retpoline)				\
>   	$(if $(CONFIG_RETHUNK), --rethunk)				\
> diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
> index 24fbe803a0d3..9bd347d3c244 100644
> --- a/tools/objtool/builtin-check.c
> +++ b/tools/objtool/builtin-check.c
> @@ -82,6 +82,7 @@ const struct option check_options[] = {
>   	OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"),
>   	OPT_BOOLEAN(0, "link", &opts.link, "object is a linked object"),
>   	OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel module"),
> +	OPT_BOOLEAN(0, "mnop", &opts.mnop, "nop out mcount call sites"),
>   	OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable instruction' warnings"),
>   	OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"),
>   	OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),
> @@ -150,6 +151,16 @@ static bool opts_valid(void)
>   	return false;
>   }
>   
> +static bool mnop_opts_valid(void)
> +{
> +	if (opts.mnop && !opts.mcount) {
> +		ERROR("--mnop requires --mcount");
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
>   static bool link_opts_valid(struct objtool_file *file)
>   {
>   	if (opts.link)
> @@ -198,6 +209,9 @@ int objtool_run(int argc, const char **argv)
>   	if (!file)
>   		return 1;
>   
> +	if (!mnop_opts_valid())
> +		return 1;
> +
>   	if (!link_opts_valid(file))
>   		return 1;
>   
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 0ecf41ee73f0..3cea58f73878 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -1231,17 +1231,18 @@ static void annotate_call_site(struct objtool_file *file,
>   	if (opts.mcount && sym->fentry) {
>   		if (sibling)
>   			WARN_FUNC("Tail call to __fentry__ !?!?", insn->sec, insn->offset);
> +		if (opts.mnop) {
> +			if (reloc) {
> +				reloc->type = R_NONE;
> +				elf_write_reloc(file->elf, reloc);
> +			}
>   
> -		if (reloc) {
> -			reloc->type = R_NONE;
> -			elf_write_reloc(file->elf, reloc);
> -		}
> -
> -		elf_write_insn(file->elf, insn->sec,
> -			       insn->offset, insn->len,
> -			       arch_nop_insn(insn->len));
> +			elf_write_insn(file->elf, insn->sec,
> +				       insn->offset, insn->len,
> +				       arch_nop_insn(insn->len));
>   
> -		insn->type = INSN_NOP;
> +			insn->type = INSN_NOP;
> +		}
>   
>   		list_add_tail(&insn->call_node, &file->mcount_loc_list);
>   		return;
> diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/include/objtool/builtin.h
> index 42a52f1a0add..0785707c5a92 100644
> --- a/tools/objtool/include/objtool/builtin.h
> +++ b/tools/objtool/include/objtool/builtin.h
> @@ -31,6 +31,7 @@ struct opts {
>   	bool backup;
>   	bool dryrun;
>   	bool link;
> +	bool mnop;
>   	bool module;
>   	bool no_unreachable;
>   	bool sec_address;

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

* Re: [PATCH v2 12/16] objtool: Read special sections with alts only when specific options are selected
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:31     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:31 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch reads special sections which have alternate
> instructions, only when stackval or orc or uaccess or
> noinstr options are passed to objtool.

Unclear, I had to read it three time to understand.

What about something like:

--- >8 ---
Reading special sections which have alternate instructions is only 
needed for stack validation or orc or uaccess validation or noinstr 
validation.

Only call add_special_section_alts() when stackval or orc or uaccess or
noinstr options are passed to objtool.
--- >8 ---

> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   tools/objtool/check.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 3cea58f73878..5298a143ceac 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -2370,9 +2370,11 @@ static int decode_sections(struct objtool_file *file)
>   	 * Must be before add_jump_destinations(), which depends on 'func'
>   	 * being set for alternatives, to enable proper sibling call detection.
>   	 */
> -	ret = add_special_section_alts(file);
> -	if (ret)
> -		return ret;
> +	if (opts.stackval || opts.orc || opts.uaccess || opts.noinstr) {
> +		ret = add_special_section_alts(file);
> +		if (ret)
> +			return ret;
> +	}
>   
>   	ret = add_jump_destinations(file);
>   	if (ret)

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

* Re: [PATCH v2 12/16] objtool: Read special sections with alts only when specific options are selected
@ 2022-08-30  6:31     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:31 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch reads special sections which have alternate
> instructions, only when stackval or orc or uaccess or
> noinstr options are passed to objtool.

Unclear, I had to read it three time to understand.

What about something like:

--- >8 ---
Reading special sections which have alternate instructions is only 
needed for stack validation or orc or uaccess validation or noinstr 
validation.

Only call add_special_section_alts() when stackval or orc or uaccess or
noinstr options are passed to objtool.
--- >8 ---

> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   tools/objtool/check.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 3cea58f73878..5298a143ceac 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -2370,9 +2370,11 @@ static int decode_sections(struct objtool_file *file)
>   	 * Must be before add_jump_destinations(), which depends on 'func'
>   	 * being set for alternatives, to enable proper sibling call detection.
>   	 */
> -	ret = add_special_section_alts(file);
> -	if (ret)
> -		return ret;
> +	if (opts.stackval || opts.orc || opts.uaccess || opts.noinstr) {
> +		ret = add_special_section_alts(file);
> +		if (ret)
> +			return ret;
> +	}
>   
>   	ret = add_jump_destinations(file);
>   	if (ret)

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

* Re: [PATCH v2 13/16] objtool: Use macros to define arch specific reloc types
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:33     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:33 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Make relocation types architecture specific.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   tools/objtool/arch/x86/include/arch/elf.h | 2 ++
>   tools/objtool/check.c                     | 2 +-
>   2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/arch/x86/include/arch/elf.h b/tools/objtool/arch/x86/include/arch/elf.h
> index 69cc4264b28a..ac14987cf687 100644
> --- a/tools/objtool/arch/x86/include/arch/elf.h
> +++ b/tools/objtool/arch/x86/include/arch/elf.h
> @@ -2,5 +2,7 @@
>   #define _OBJTOOL_ARCH_ELF
>   
>   #define R_NONE R_X86_64_NONE
> +#define R_ABS64 R_X86_64_64
> +#define R_ABS32 R_X86_64_32
>   
>   #endif /* _OBJTOOL_ARCH_ELF */
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 5298a143ceac..f1d055467926 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -883,7 +883,7 @@ static int create_mcount_loc_sections(struct objtool_file *file)
>   		memset(loc, 0, addrsize);
>   
>   		if (elf_add_reloc_to_insn(file->elf, sec, idx,
> -					  R_X86_64_64,
> +					  addrsize == sizeof(u64) ? R_ABS64 : R_ABS32,
>   					  insn->sec, insn->offset))
>   			return -1;
>   

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

* Re: [PATCH v2 13/16] objtool: Use macros to define arch specific reloc types
@ 2022-08-30  6:33     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:33 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Make relocation types architecture specific.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   tools/objtool/arch/x86/include/arch/elf.h | 2 ++
>   tools/objtool/check.c                     | 2 +-
>   2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/arch/x86/include/arch/elf.h b/tools/objtool/arch/x86/include/arch/elf.h
> index 69cc4264b28a..ac14987cf687 100644
> --- a/tools/objtool/arch/x86/include/arch/elf.h
> +++ b/tools/objtool/arch/x86/include/arch/elf.h
> @@ -2,5 +2,7 @@
>   #define _OBJTOOL_ARCH_ELF
>   
>   #define R_NONE R_X86_64_NONE
> +#define R_ABS64 R_X86_64_64
> +#define R_ABS32 R_X86_64_32
>   
>   #endif /* _OBJTOOL_ARCH_ELF */
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 5298a143ceac..f1d055467926 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -883,7 +883,7 @@ static int create_mcount_loc_sections(struct objtool_file *file)
>   		memset(loc, 0, addrsize);
>   
>   		if (elf_add_reloc_to_insn(file->elf, sec, idx,
> -					  R_X86_64_64,
> +					  addrsize == sizeof(u64) ? R_ABS64 : R_ABS32,
>   					  insn->sec, insn->offset))
>   			return -1;
>   

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

* Re: [PATCH v2 14/16] objtool: Add arch specific function arch_ftrace_match()
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:36     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:36 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Add architecture specific function to look for
> relocation records pointing to arch specific
> symbols.
> 
> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   tools/objtool/arch/x86/decode.c      | 8 ++++++++
>   tools/objtool/check.c                | 2 +-
>   tools/objtool/include/objtool/arch.h | 2 ++
>   3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
> index c260006106be..025598b6b703 100644
> --- a/tools/objtool/arch/x86/decode.c
> +++ b/tools/objtool/arch/x86/decode.c
> @@ -23,6 +23,14 @@
>   #include <objtool/builtin.h>
>   #include <arch/elf.h>
>   
> +bool arch_ftrace_match(char *name)
> +{
> +	if (!strcmp(name, "__fentry__"))
> +		return true;
> +
> +	return false;

Could be simplified as:

	return !strcmp(name, "__fentry__");


Whatever:

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>



> +}
> +
>   static int is_x86_64(const struct elf *elf)
>   {
>   	switch (elf->ehdr.e_machine) {
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index f1d055467926..01ff7504f18d 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -2294,7 +2294,7 @@ static int classify_symbols(struct objtool_file *file)
>   			if (arch_is_rethunk(func))
>   				func->return_thunk = true;
>   
> -			if (!strcmp(func->name, "__fentry__"))
> +			if (arch_ftrace_match(func->name))
>   				func->fentry = true;
>   
>   			if (is_profiling_func(func->name))
> diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h
> index beb2f3aa94ff..2ba4b9897285 100644
> --- a/tools/objtool/include/objtool/arch.h
> +++ b/tools/objtool/include/objtool/arch.h
> @@ -69,6 +69,8 @@ struct stack_op {
>   
>   struct instruction;
>   
> +bool arch_ftrace_match(char *name);
> +
>   void arch_initial_func_cfi_state(struct cfi_init_state *state);
>   
>   int arch_decode_instruction(struct objtool_file *file, const struct section *sec,

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

* Re: [PATCH v2 14/16] objtool: Add arch specific function arch_ftrace_match()
@ 2022-08-30  6:36     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:36 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Add architecture specific function to look for
> relocation records pointing to arch specific
> symbols.
> 
> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   tools/objtool/arch/x86/decode.c      | 8 ++++++++
>   tools/objtool/check.c                | 2 +-
>   tools/objtool/include/objtool/arch.h | 2 ++
>   3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
> index c260006106be..025598b6b703 100644
> --- a/tools/objtool/arch/x86/decode.c
> +++ b/tools/objtool/arch/x86/decode.c
> @@ -23,6 +23,14 @@
>   #include <objtool/builtin.h>
>   #include <arch/elf.h>
>   
> +bool arch_ftrace_match(char *name)
> +{
> +	if (!strcmp(name, "__fentry__"))
> +		return true;
> +
> +	return false;

Could be simplified as:

	return !strcmp(name, "__fentry__");


Whatever:

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>



> +}
> +
>   static int is_x86_64(const struct elf *elf)
>   {
>   	switch (elf->ehdr.e_machine) {
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index f1d055467926..01ff7504f18d 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -2294,7 +2294,7 @@ static int classify_symbols(struct objtool_file *file)
>   			if (arch_is_rethunk(func))
>   				func->return_thunk = true;
>   
> -			if (!strcmp(func->name, "__fentry__"))
> +			if (arch_ftrace_match(func->name))
>   				func->fentry = true;
>   
>   			if (is_profiling_func(func->name))
> diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h
> index beb2f3aa94ff..2ba4b9897285 100644
> --- a/tools/objtool/include/objtool/arch.h
> +++ b/tools/objtool/include/objtool/arch.h
> @@ -69,6 +69,8 @@ struct stack_op {
>   
>   struct instruction;
>   
> +bool arch_ftrace_match(char *name);
> +
>   void arch_initial_func_cfi_state(struct cfi_init_state *state);
>   
>   int arch_decode_instruction(struct objtool_file *file, const struct section *sec,

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:41     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:41 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao, Elliott, Robert (Servers)



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch adds [stub] implementations for required
> functions, inorder to enable objtool build on powerpc.

Not all powerpc it seems, see below

> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> [Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>   arch/powerpc/Kconfig                          |  1 +
>   arch/powerpc/include/asm/asm.h                |  7 ++
>   tools/objtool/arch/powerpc/Build              |  2 +
>   tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
>   .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
>   tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
>   .../arch/powerpc/include/arch/special.h       | 21 ++++++
>   tools/objtool/arch/powerpc/special.c          | 19 +++++
>   8 files changed, 143 insertions(+)
>   create mode 100644 arch/powerpc/include/asm/asm.h
>   create mode 100644 tools/objtool/arch/powerpc/Build
>   create mode 100644 tools/objtool/arch/powerpc/decode.c
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
>   create mode 100644 tools/objtool/arch/powerpc/special.c
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 4c466acdc70d..dc05cd23c233 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -237,6 +237,7 @@ config PPC
>   	select HAVE_MOD_ARCH_SPECIFIC
>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>   	select HAVE_OPTPROBES
> +	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL

Why restrict it to MPROFILE_KERNEL ? In your RFC it was for all PPC64.

Recent discussion on the list shows new problem with recordmcount, see 
https://lore.kernel.org/all/MW5PR84MB184250EA1CAE04497C1E7CE9AB769@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM/

Those ones are with ppc64 big endian, so objtool would be welcome here 
as well.

>   	select HAVE_PERF_EVENTS
>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>   	select HAVE_PERF_REGS
> diff --git a/arch/powerpc/include/asm/asm.h b/arch/powerpc/include/asm/asm.h
> new file mode 100644
> index 000000000000..86f46b604e9a
> --- /dev/null
> +++ b/arch/powerpc/include/asm/asm.h
> @@ -0,0 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_POWERPC_ASM_H
> +#define _ASM_POWERPC_ASM_H
> +
> +#define _ASM_PTR	" .long "
> +
> +#endif /* _ASM_POWERPC_ASM_H */
> diff --git a/tools/objtool/arch/powerpc/Build b/tools/objtool/arch/powerpc/Build
> new file mode 100644
> index 000000000000..d24d5636a5b8
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/Build
> @@ -0,0 +1,2 @@
> +objtool-y += decode.o
> +objtool-y += special.o
> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
> new file mode 100644
> index 000000000000..8b6a14680da7
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/decode.c
> @@ -0,0 +1,74 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <objtool/check.h>
> +#include <objtool/elf.h>
> +#include <objtool/arch.h>
> +#include <objtool/warn.h>
> +#include <objtool/builtin.h>
> +#include <objtool/endianness.h>
> +
> +unsigned long arch_dest_reloc_offset(int addend)
> +{
> +	return addend;
> +}
> +
> +bool arch_callee_saved_reg(unsigned char reg)
> +{
> +	return false;
> +}
> +
> +int arch_decode_hint_reg(u8 sp_reg, int *base)
> +{
> +	exit(-1);
> +}
> +
> +const char *arch_nop_insn(int len)
> +{
> +	exit(-1);
> +}
> +
> +const char *arch_ret_insn(int len)
> +{
> +	exit(-1);
> +}
> +
> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
> +			    unsigned long offset, unsigned int maxlen,
> +			    unsigned int *len, enum insn_type *type,
> +			    unsigned long *immediate,
> +			    struct list_head *ops_list)
> +{
> +	u32 insn;
> +
> +	*immediate = 0;
> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
> +	*len = 4;
> +	*type = INSN_OTHER;
> +
> +	return 0;
> +}
> +
> +unsigned long arch_jump_destination(struct instruction *insn)
> +{
> +	return insn->offset +  insn->immediate;
> +}
> +
> +void arch_initial_func_cfi_state(struct cfi_init_state *state)
> +{
> +	int i;
> +
> +	for (i = 0; i < CFI_NUM_REGS; i++) {
> +		state->regs[i].base = CFI_UNDEFINED;
> +		state->regs[i].offset = 0;
> +	}
> +
> +	/* initial CFA (call frame address) */
> +	state->cfa.base = CFI_SP;
> +	state->cfa.offset = 0;
> +
> +	/* initial LR (return address) */
> +	state->regs[CFI_RA].base = CFI_CFA;
> +	state->regs[CFI_RA].offset = 0;
> +}
> diff --git a/tools/objtool/arch/powerpc/include/arch/cfi_regs.h b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
> new file mode 100644
> index 000000000000..59638ebeafc8
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#ifndef _OBJTOOL_CFI_REGS_H
> +#define _OBJTOOL_CFI_REGS_H
> +
> +#define CFI_BP 1
> +#define CFI_SP CFI_BP
> +#define CFI_RA 32
> +#define CFI_NUM_REGS 33
> +
> +#endif
> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
> new file mode 100644
> index 000000000000..3c8ebb7d2a6b
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
> @@ -0,0 +1,8 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#ifndef _OBJTOOL_ARCH_ELF
> +#define _OBJTOOL_ARCH_ELF
> +
> +#define R_NONE R_PPC_NONE
> +
> +#endif /* _OBJTOOL_ARCH_ELF */
> diff --git a/tools/objtool/arch/powerpc/include/arch/special.h b/tools/objtool/arch/powerpc/include/arch/special.h
> new file mode 100644
> index 000000000000..ffef9ada7133
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/include/arch/special.h
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +#ifndef _PPC_ARCH_SPECIAL_H
> +#define _PPC_ARCH_SPECIAL_H
> +
> +#define EX_ENTRY_SIZE 8
> +#define EX_ORIG_OFFSET 0
> +#define EX_NEW_OFFSET 4
> +
> +#define JUMP_ENTRY_SIZE 16
> +#define JUMP_ORIG_OFFSET 0
> +#define JUMP_NEW_OFFSET 4
> +#define JUMP_KEY_OFFSET 8
> +
> +#define ALT_ENTRY_SIZE 12
> +#define ALT_ORIG_OFFSET 0
> +#define ALT_NEW_OFFSET 4
> +#define ALT_FEATURE_OFFSET 8
> +#define ALT_ORIG_LEN_OFFSET 10
> +#define ALT_NEW_LEN_OFFSET 11
> +
> +#endif /* _PPC_ARCH_SPECIAL_H */
> diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
> new file mode 100644
> index 000000000000..d33868147196
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/special.c
> @@ -0,0 +1,19 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +#include <string.h>
> +#include <stdlib.h>
> +#include <objtool/special.h>
> +#include <objtool/builtin.h>
> +
> +
> +bool arch_support_alt_relocation(struct special_alt *special_alt,
> +				 struct instruction *insn,
> +				 struct reloc *reloc)
> +{
> +	exit(-1);
> +}
> +
> +struct reloc *arch_find_switch_table(struct objtool_file *file,
> +				    struct instruction *insn)
> +{
> +	exit(-1);
> +}

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2022-08-30  6:41     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:41 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin, Elliott, Robert (Servers)



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch adds [stub] implementations for required
> functions, inorder to enable objtool build on powerpc.

Not all powerpc it seems, see below

> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> [Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>   arch/powerpc/Kconfig                          |  1 +
>   arch/powerpc/include/asm/asm.h                |  7 ++
>   tools/objtool/arch/powerpc/Build              |  2 +
>   tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
>   .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
>   tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
>   .../arch/powerpc/include/arch/special.h       | 21 ++++++
>   tools/objtool/arch/powerpc/special.c          | 19 +++++
>   8 files changed, 143 insertions(+)
>   create mode 100644 arch/powerpc/include/asm/asm.h
>   create mode 100644 tools/objtool/arch/powerpc/Build
>   create mode 100644 tools/objtool/arch/powerpc/decode.c
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
>   create mode 100644 tools/objtool/arch/powerpc/special.c
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 4c466acdc70d..dc05cd23c233 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -237,6 +237,7 @@ config PPC
>   	select HAVE_MOD_ARCH_SPECIFIC
>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>   	select HAVE_OPTPROBES
> +	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL

Why restrict it to MPROFILE_KERNEL ? In your RFC it was for all PPC64.

Recent discussion on the list shows new problem with recordmcount, see 
https://lore.kernel.org/all/MW5PR84MB184250EA1CAE04497C1E7CE9AB769@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM/

Those ones are with ppc64 big endian, so objtool would be welcome here 
as well.

>   	select HAVE_PERF_EVENTS
>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>   	select HAVE_PERF_REGS
> diff --git a/arch/powerpc/include/asm/asm.h b/arch/powerpc/include/asm/asm.h
> new file mode 100644
> index 000000000000..86f46b604e9a
> --- /dev/null
> +++ b/arch/powerpc/include/asm/asm.h
> @@ -0,0 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_POWERPC_ASM_H
> +#define _ASM_POWERPC_ASM_H
> +
> +#define _ASM_PTR	" .long "
> +
> +#endif /* _ASM_POWERPC_ASM_H */
> diff --git a/tools/objtool/arch/powerpc/Build b/tools/objtool/arch/powerpc/Build
> new file mode 100644
> index 000000000000..d24d5636a5b8
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/Build
> @@ -0,0 +1,2 @@
> +objtool-y += decode.o
> +objtool-y += special.o
> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
> new file mode 100644
> index 000000000000..8b6a14680da7
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/decode.c
> @@ -0,0 +1,74 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <objtool/check.h>
> +#include <objtool/elf.h>
> +#include <objtool/arch.h>
> +#include <objtool/warn.h>
> +#include <objtool/builtin.h>
> +#include <objtool/endianness.h>
> +
> +unsigned long arch_dest_reloc_offset(int addend)
> +{
> +	return addend;
> +}
> +
> +bool arch_callee_saved_reg(unsigned char reg)
> +{
> +	return false;
> +}
> +
> +int arch_decode_hint_reg(u8 sp_reg, int *base)
> +{
> +	exit(-1);
> +}
> +
> +const char *arch_nop_insn(int len)
> +{
> +	exit(-1);
> +}
> +
> +const char *arch_ret_insn(int len)
> +{
> +	exit(-1);
> +}
> +
> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
> +			    unsigned long offset, unsigned int maxlen,
> +			    unsigned int *len, enum insn_type *type,
> +			    unsigned long *immediate,
> +			    struct list_head *ops_list)
> +{
> +	u32 insn;
> +
> +	*immediate = 0;
> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
> +	*len = 4;
> +	*type = INSN_OTHER;
> +
> +	return 0;
> +}
> +
> +unsigned long arch_jump_destination(struct instruction *insn)
> +{
> +	return insn->offset +  insn->immediate;
> +}
> +
> +void arch_initial_func_cfi_state(struct cfi_init_state *state)
> +{
> +	int i;
> +
> +	for (i = 0; i < CFI_NUM_REGS; i++) {
> +		state->regs[i].base = CFI_UNDEFINED;
> +		state->regs[i].offset = 0;
> +	}
> +
> +	/* initial CFA (call frame address) */
> +	state->cfa.base = CFI_SP;
> +	state->cfa.offset = 0;
> +
> +	/* initial LR (return address) */
> +	state->regs[CFI_RA].base = CFI_CFA;
> +	state->regs[CFI_RA].offset = 0;
> +}
> diff --git a/tools/objtool/arch/powerpc/include/arch/cfi_regs.h b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
> new file mode 100644
> index 000000000000..59638ebeafc8
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#ifndef _OBJTOOL_CFI_REGS_H
> +#define _OBJTOOL_CFI_REGS_H
> +
> +#define CFI_BP 1
> +#define CFI_SP CFI_BP
> +#define CFI_RA 32
> +#define CFI_NUM_REGS 33
> +
> +#endif
> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
> new file mode 100644
> index 000000000000..3c8ebb7d2a6b
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
> @@ -0,0 +1,8 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#ifndef _OBJTOOL_ARCH_ELF
> +#define _OBJTOOL_ARCH_ELF
> +
> +#define R_NONE R_PPC_NONE
> +
> +#endif /* _OBJTOOL_ARCH_ELF */
> diff --git a/tools/objtool/arch/powerpc/include/arch/special.h b/tools/objtool/arch/powerpc/include/arch/special.h
> new file mode 100644
> index 000000000000..ffef9ada7133
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/include/arch/special.h
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +#ifndef _PPC_ARCH_SPECIAL_H
> +#define _PPC_ARCH_SPECIAL_H
> +
> +#define EX_ENTRY_SIZE 8
> +#define EX_ORIG_OFFSET 0
> +#define EX_NEW_OFFSET 4
> +
> +#define JUMP_ENTRY_SIZE 16
> +#define JUMP_ORIG_OFFSET 0
> +#define JUMP_NEW_OFFSET 4
> +#define JUMP_KEY_OFFSET 8
> +
> +#define ALT_ENTRY_SIZE 12
> +#define ALT_ORIG_OFFSET 0
> +#define ALT_NEW_OFFSET 4
> +#define ALT_FEATURE_OFFSET 8
> +#define ALT_ORIG_LEN_OFFSET 10
> +#define ALT_NEW_LEN_OFFSET 11
> +
> +#endif /* _PPC_ARCH_SPECIAL_H */
> diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
> new file mode 100644
> index 000000000000..d33868147196
> --- /dev/null
> +++ b/tools/objtool/arch/powerpc/special.c
> @@ -0,0 +1,19 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +#include <string.h>
> +#include <stdlib.h>
> +#include <objtool/special.h>
> +#include <objtool/builtin.h>
> +
> +
> +bool arch_support_alt_relocation(struct special_alt *special_alt,
> +				 struct instruction *insn,
> +				 struct reloc *reloc)
> +{
> +	exit(-1);
> +}
> +
> +struct reloc *arch_find_switch_table(struct objtool_file *file,
> +				    struct instruction *insn)
> +{
> +	exit(-1);
> +}

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30  6:44     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:44 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch enables objtool --mcount on powerpc, and
> adds implementation specific to powerpc.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   arch/powerpc/Kconfig                          |  1 +
>   tools/objtool/arch/powerpc/decode.c           | 22 +++++++++++++++++++
>   tools/objtool/arch/powerpc/include/arch/elf.h |  2 ++
>   3 files changed, 25 insertions(+)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index dc05cd23c233..6be2e68fa9eb 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -238,6 +238,7 @@ config PPC
>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>   	select HAVE_OPTPROBES
>   	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
> +	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
>   	select HAVE_PERF_EVENTS
>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>   	select HAVE_PERF_REGS
> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
> index 8b6a14680da7..b71c265ed503 100644
> --- a/tools/objtool/arch/powerpc/decode.c
> +++ b/tools/objtool/arch/powerpc/decode.c
> @@ -9,6 +9,14 @@
>   #include <objtool/builtin.h>
>   #include <objtool/endianness.h>
>   
> +bool arch_ftrace_match(char *name)
> +{
> +	if (!strcmp(name, "_mcount"))
> +		return true;
> +
> +	return false;

Same as for x86, could be:

	return !strcmp(name, "_mcount");




Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>




> +}
> +
>   unsigned long arch_dest_reloc_offset(int addend)
>   {
>   	return addend;
> @@ -41,12 +49,26 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
>   			    struct list_head *ops_list)
>   {
>   	u32 insn;
> +	unsigned int opcode;
>   
>   	*immediate = 0;
>   	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>   	*len = 4;
>   	*type = INSN_OTHER;
>   
> +	opcode = insn >> 26;
> +
> +	switch (opcode) {
> +	case 18: /* bl */
> +		if ((insn & 3) == 1) {
> +			*type = INSN_CALL;
> +			*immediate = insn & 0x3fffffc;
> +			if (*immediate & 0x2000000)
> +				*immediate -= 0x4000000;
> +		}
> +		break;
> +	}
> +
>   	return 0;
>   }
>   
> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
> index 3c8ebb7d2a6b..73f9ae172fe5 100644
> --- a/tools/objtool/arch/powerpc/include/arch/elf.h
> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
> @@ -4,5 +4,7 @@
>   #define _OBJTOOL_ARCH_ELF
>   
>   #define R_NONE R_PPC_NONE
> +#define R_ABS64 R_PPC64_ADDR64
> +#define R_ABS32 R_PPC_ADDR32
>   
>   #endif /* _OBJTOOL_ARCH_ELF */

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
@ 2022-08-30  6:44     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30  6:44 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch enables objtool --mcount on powerpc, and
> adds implementation specific to powerpc.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   arch/powerpc/Kconfig                          |  1 +
>   tools/objtool/arch/powerpc/decode.c           | 22 +++++++++++++++++++
>   tools/objtool/arch/powerpc/include/arch/elf.h |  2 ++
>   3 files changed, 25 insertions(+)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index dc05cd23c233..6be2e68fa9eb 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -238,6 +238,7 @@ config PPC
>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>   	select HAVE_OPTPROBES
>   	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
> +	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
>   	select HAVE_PERF_EVENTS
>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>   	select HAVE_PERF_REGS
> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
> index 8b6a14680da7..b71c265ed503 100644
> --- a/tools/objtool/arch/powerpc/decode.c
> +++ b/tools/objtool/arch/powerpc/decode.c
> @@ -9,6 +9,14 @@
>   #include <objtool/builtin.h>
>   #include <objtool/endianness.h>
>   
> +bool arch_ftrace_match(char *name)
> +{
> +	if (!strcmp(name, "_mcount"))
> +		return true;
> +
> +	return false;

Same as for x86, could be:

	return !strcmp(name, "_mcount");




Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>




> +}
> +
>   unsigned long arch_dest_reloc_offset(int addend)
>   {
>   	return addend;
> @@ -41,12 +49,26 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
>   			    struct list_head *ops_list)
>   {
>   	u32 insn;
> +	unsigned int opcode;
>   
>   	*immediate = 0;
>   	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>   	*len = 4;
>   	*type = INSN_OTHER;
>   
> +	opcode = insn >> 26;
> +
> +	switch (opcode) {
> +	case 18: /* bl */
> +		if ((insn & 3) == 1) {
> +			*type = INSN_CALL;
> +			*immediate = insn & 0x3fffffc;
> +			if (*immediate & 0x2000000)
> +				*immediate -= 0x4000000;
> +		}
> +		break;
> +	}
> +
>   	return 0;
>   }
>   
> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
> index 3c8ebb7d2a6b..73f9ae172fe5 100644
> --- a/tools/objtool/arch/powerpc/include/arch/elf.h
> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
> @@ -4,5 +4,7 @@
>   #define _OBJTOOL_ARCH_ELF
>   
>   #define R_NONE R_PPC_NONE
> +#define R_ABS64 R_PPC64_ADDR64
> +#define R_ABS32 R_PPC_ADDR32
>   
>   #endif /* _OBJTOOL_ARCH_ELF */

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

* Re: [PATCH v2 03/16] powerpc: Fix objtool unannotated intra-function call warnings
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-30 12:42     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30 12:42 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> objtool throws unannotated intra-function call warnings
> in the following assembly files:
> 
> arch/powerpc/kernel/vector.o: warning: objtool: .text+0x53c: unannotated intra-function call
> 
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x60: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x124: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5d4: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5dc: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xcb8: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xd0c: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x1030: unannotated intra-function call
> 
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x358: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x728: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4d94: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4ec4: unannotated intra-function call
> 
> arch/powerpc/kvm/book3s_hv_interrupts.o: warning: objtool: .text+0x6c: unannotated intra-function call
> arch/powerpc/kernel/misc_64.o: warning: objtool: .text+0x64: unannotated intra-function call
> 
> objtool does not add STT_NOTYPE symbols with size 0 to the
> rbtree, which is why find_call_destination() function is not able
> to find the destination symbol for 'bl' instruction. For such symbols,
> objtool is throwing unannotated intra-function call warnings in
> assembly files. Fix these warnings by adding SYM_FUNC_START_LOCAL()
> and SYM_FUNC_END() annotations to those symbols to be able to set symbol
> type to STT_FUNC and set size of these symbols accordingly.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   arch/powerpc/kernel/exceptions-64s.S    |  7 +++++--
>   arch/powerpc/kernel/head_64.S           |  7 +++++--
>   arch/powerpc/kernel/misc_64.S           |  4 +++-
>   arch/powerpc/kernel/vector.S            |  4 +++-
>   arch/powerpc/kvm/book3s_hv_interrupts.S |  4 +++-
>   arch/powerpc/kvm/book3s_hv_rmhandlers.S | 22 +++++++++++++++-------
>   6 files changed, 34 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index 3d0dc133a9ae..4242c1a20bcd 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -20,6 +20,7 @@
>   #include <asm/head-64.h>
>   #include <asm/feature-fixups.h>
>   #include <asm/kup.h>
> +#include <linux/linkage.h>

Can you keep all <linux/...> all together _before_ the <asm/...> ones 
as usual ?

Christophe

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

* Re: [PATCH v2 03/16] powerpc: Fix objtool unannotated intra-function call warnings
@ 2022-08-30 12:42     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-30 12:42 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> objtool throws unannotated intra-function call warnings
> in the following assembly files:
> 
> arch/powerpc/kernel/vector.o: warning: objtool: .text+0x53c: unannotated intra-function call
> 
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x60: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x124: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5d4: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5dc: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xcb8: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xd0c: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x1030: unannotated intra-function call
> 
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x358: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x728: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4d94: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4ec4: unannotated intra-function call
> 
> arch/powerpc/kvm/book3s_hv_interrupts.o: warning: objtool: .text+0x6c: unannotated intra-function call
> arch/powerpc/kernel/misc_64.o: warning: objtool: .text+0x64: unannotated intra-function call
> 
> objtool does not add STT_NOTYPE symbols with size 0 to the
> rbtree, which is why find_call_destination() function is not able
> to find the destination symbol for 'bl' instruction. For such symbols,
> objtool is throwing unannotated intra-function call warnings in
> assembly files. Fix these warnings by adding SYM_FUNC_START_LOCAL()
> and SYM_FUNC_END() annotations to those symbols to be able to set symbol
> type to STT_FUNC and set size of these symbols accordingly.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   arch/powerpc/kernel/exceptions-64s.S    |  7 +++++--
>   arch/powerpc/kernel/head_64.S           |  7 +++++--
>   arch/powerpc/kernel/misc_64.S           |  4 +++-
>   arch/powerpc/kernel/vector.S            |  4 +++-
>   arch/powerpc/kvm/book3s_hv_interrupts.S |  4 +++-
>   arch/powerpc/kvm/book3s_hv_rmhandlers.S | 22 +++++++++++++++-------
>   6 files changed, 34 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index 3d0dc133a9ae..4242c1a20bcd 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -20,6 +20,7 @@
>   #include <asm/head-64.h>
>   #include <asm/feature-fixups.h>
>   #include <asm/kup.h>
> +#include <linux/linkage.h>

Can you keep all <linux/...> all together _before_ the <asm/...> ones 
as usual ?

Christophe

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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-31  3:24     ` Nicholas Piggin
  -1 siblings, 0 replies; 128+ messages in thread
From: Nicholas Piggin @ 2022-08-31  3:24 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, chenzhongjin, naveen.n.rao

On Mon Aug 29, 2022 at 3:52 PM AEST, Sathvika Vasireddy wrote:
> Powerpc instructions must be word-aligned. Currently,
> there is an alignment of 16 bytes (by default), and it is
> much more than what is required for powerpc (4 bytes).
>
> The default expansion of __ALIGN() macro is:
> #define __ALIGN       .align 4,0x90
>
> Since Powerpc Linux does not require a 16 byte alignment,
> override __ALIGN() and __ALIGN_STR() macros to use required
> 4 byte alignment.

Alignment can be desirable beyond the minimum requirement, for
example 16 byte alignment for functions could be helpful for
instruction fetch. So it should be explained why possible
benefits of the larger alignment are not worth it.

And if you have the patch in a series, it should be explained
why the patch is required for the series if it is not obvious.

Thanks,
Nick

>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>  arch/powerpc/include/asm/linkage.h | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
> index b71b9582e754..8df88fe61438 100644
> --- a/arch/powerpc/include/asm/linkage.h
> +++ b/arch/powerpc/include/asm/linkage.h
> @@ -2,8 +2,12 @@
>  #ifndef _ASM_POWERPC_LINKAGE_H
>  #define _ASM_POWERPC_LINKAGE_H
>  
> +#include <linux/stringify.h>
>  #include <asm/types.h>
>  
> +#define __ALIGN			.align 2
> +#define __ALIGN_STR		__stringify(__ALIGN)
> +
>  #ifdef CONFIG_PPC64_ELF_ABI_V1
>  #define cond_syscall(x) \
>  	asm ("\t.weak " #x "\n\t.set " #x ", sys_ni_syscall\n"		\
> -- 
> 2.31.1


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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
@ 2022-08-31  3:24     ` Nicholas Piggin
  0 siblings, 0 replies; 128+ messages in thread
From: Nicholas Piggin @ 2022-08-31  3:24 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, aik, mingo, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

On Mon Aug 29, 2022 at 3:52 PM AEST, Sathvika Vasireddy wrote:
> Powerpc instructions must be word-aligned. Currently,
> there is an alignment of 16 bytes (by default), and it is
> much more than what is required for powerpc (4 bytes).
>
> The default expansion of __ALIGN() macro is:
> #define __ALIGN       .align 4,0x90
>
> Since Powerpc Linux does not require a 16 byte alignment,
> override __ALIGN() and __ALIGN_STR() macros to use required
> 4 byte alignment.

Alignment can be desirable beyond the minimum requirement, for
example 16 byte alignment for functions could be helpful for
instruction fetch. So it should be explained why possible
benefits of the larger alignment are not worth it.

And if you have the patch in a series, it should be explained
why the patch is required for the series if it is not obvious.

Thanks,
Nick

>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>  arch/powerpc/include/asm/linkage.h | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
> index b71b9582e754..8df88fe61438 100644
> --- a/arch/powerpc/include/asm/linkage.h
> +++ b/arch/powerpc/include/asm/linkage.h
> @@ -2,8 +2,12 @@
>  #ifndef _ASM_POWERPC_LINKAGE_H
>  #define _ASM_POWERPC_LINKAGE_H
>  
> +#include <linux/stringify.h>
>  #include <asm/types.h>
>  
> +#define __ALIGN			.align 2
> +#define __ALIGN_STR		__stringify(__ALIGN)
> +
>  #ifdef CONFIG_PPC64_ELF_ABI_V1
>  #define cond_syscall(x) \
>  	asm ("\t.weak " #x "\n\t.set " #x ", sys_ni_syscall\n"		\
> -- 
> 2.31.1


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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
  2022-08-31  3:24     ` Nicholas Piggin
@ 2022-08-31  7:22       ` Michael Ellerman
  -1 siblings, 0 replies; 128+ messages in thread
From: Michael Ellerman @ 2022-08-31  7:22 UTC (permalink / raw)
  To: Nicholas Piggin, Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mingo, christophe.leroy,
	rostedt, mbenes, chenzhongjin, naveen.n.rao

"Nicholas Piggin" <npiggin@gmail.com> writes:
> On Mon Aug 29, 2022 at 3:52 PM AEST, Sathvika Vasireddy wrote:
>> Powerpc instructions must be word-aligned. Currently,
>> there is an alignment of 16 bytes (by default), and it is
>> much more than what is required for powerpc (4 bytes).
>>
>> The default expansion of __ALIGN() macro is:
>> #define __ALIGN       .align 4,0x90
>>
>> Since Powerpc Linux does not require a 16 byte alignment,
>> override __ALIGN() and __ALIGN_STR() macros to use required
>> 4 byte alignment.
>
> Alignment can be desirable beyond the minimum requirement, for
> example 16 byte alignment for functions could be helpful for
> instruction fetch. So it should be explained why possible
> benefits of the larger alignment are not worth it.

Using ".align 2" matches what our existing _GLOBAL macro does. So this
change basically just propagates that existing alignment into this new
macro, which is used for similar purposes.

So if we want to increase the alignment we should do that explicitly,
and update _GLOBAL at the same time.

The change log should probably just say ~= "use the same alignment as
the existing _GLOBAL macro".

What's more important, but not mentioned in the change log, is that we
don't want to pad with 0x90, because repeated 0x90s are not a nop or
trap on powerpc.

cheers

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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
@ 2022-08-31  7:22       ` Michael Ellerman
  0 siblings, 0 replies; 128+ messages in thread
From: Michael Ellerman @ 2022-08-31  7:22 UTC (permalink / raw)
  To: Nicholas Piggin, Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, aik, mingo, rostedt, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

"Nicholas Piggin" <npiggin@gmail.com> writes:
> On Mon Aug 29, 2022 at 3:52 PM AEST, Sathvika Vasireddy wrote:
>> Powerpc instructions must be word-aligned. Currently,
>> there is an alignment of 16 bytes (by default), and it is
>> much more than what is required for powerpc (4 bytes).
>>
>> The default expansion of __ALIGN() macro is:
>> #define __ALIGN       .align 4,0x90
>>
>> Since Powerpc Linux does not require a 16 byte alignment,
>> override __ALIGN() and __ALIGN_STR() macros to use required
>> 4 byte alignment.
>
> Alignment can be desirable beyond the minimum requirement, for
> example 16 byte alignment for functions could be helpful for
> instruction fetch. So it should be explained why possible
> benefits of the larger alignment are not worth it.

Using ".align 2" matches what our existing _GLOBAL macro does. So this
change basically just propagates that existing alignment into this new
macro, which is used for similar purposes.

So if we want to increase the alignment we should do that explicitly,
and update _GLOBAL at the same time.

The change log should probably just say ~= "use the same alignment as
the existing _GLOBAL macro".

What's more important, but not mentioned in the change log, is that we
don't want to pad with 0x90, because repeated 0x90s are not a nop or
trap on powerpc.

cheers

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-08-31 12:50     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-31 12:50 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch enables objtool --mcount on powerpc, and
> adds implementation specific to powerpc.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   arch/powerpc/Kconfig                          |  1 +
>   tools/objtool/arch/powerpc/decode.c           | 22 +++++++++++++++++++
>   tools/objtool/arch/powerpc/include/arch/elf.h |  2 ++
>   3 files changed, 25 insertions(+)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index dc05cd23c233..6be2e68fa9eb 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -238,6 +238,7 @@ config PPC
>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>   	select HAVE_OPTPROBES
>   	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
> +	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
>   	select HAVE_PERF_EVENTS
>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>   	select HAVE_PERF_REGS
> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
> index 8b6a14680da7..b71c265ed503 100644
> --- a/tools/objtool/arch/powerpc/decode.c
> +++ b/tools/objtool/arch/powerpc/decode.c
> @@ -9,6 +9,14 @@
>   #include <objtool/builtin.h>
>   #include <objtool/endianness.h>
>   
> +bool arch_ftrace_match(char *name)
> +{
> +	if (!strcmp(name, "_mcount"))
> +		return true;
> +
> +	return false;
> +}
> +
>   unsigned long arch_dest_reloc_offset(int addend)
>   {
>   	return addend;
> @@ -41,12 +49,26 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
>   			    struct list_head *ops_list)
>   {
>   	u32 insn;
> +	unsigned int opcode;
>   
>   	*immediate = 0;
>   	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>   	*len = 4;
>   	*type = INSN_OTHER;
>   
> +	opcode = insn >> 26;
> +
> +	switch (opcode) {
> +	case 18: /* bl */

case 18 is more than 'bl', it includes also 'b'.
In both cases, the calculation of *immediate is the same.

It would therefore be more correct to perform the calculation and setup 
of *immediate outside the 'if ((insn & 3) == 1)', that would avoid 
unnecessary churn the day we add support for branches without link.

> +		if ((insn & 3) == 1) {
> +			*type = INSN_CALL;
> +			*immediate = insn & 0x3fffffc;
> +			if (*immediate & 0x2000000)
> +				*immediate -= 0x4000000;
> +		}
> +		break;
> +	}
> +
>   	return 0;
>   }
>   
> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
> index 3c8ebb7d2a6b..73f9ae172fe5 100644
> --- a/tools/objtool/arch/powerpc/include/arch/elf.h
> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
> @@ -4,5 +4,7 @@
>   #define _OBJTOOL_ARCH_ELF
>   
>   #define R_NONE R_PPC_NONE
> +#define R_ABS64 R_PPC64_ADDR64
> +#define R_ABS32 R_PPC_ADDR32
>   
>   #endif /* _OBJTOOL_ARCH_ELF */

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
@ 2022-08-31 12:50     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-08-31 12:50 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch enables objtool --mcount on powerpc, and
> adds implementation specific to powerpc.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>   arch/powerpc/Kconfig                          |  1 +
>   tools/objtool/arch/powerpc/decode.c           | 22 +++++++++++++++++++
>   tools/objtool/arch/powerpc/include/arch/elf.h |  2 ++
>   3 files changed, 25 insertions(+)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index dc05cd23c233..6be2e68fa9eb 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -238,6 +238,7 @@ config PPC
>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>   	select HAVE_OPTPROBES
>   	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
> +	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
>   	select HAVE_PERF_EVENTS
>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>   	select HAVE_PERF_REGS
> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
> index 8b6a14680da7..b71c265ed503 100644
> --- a/tools/objtool/arch/powerpc/decode.c
> +++ b/tools/objtool/arch/powerpc/decode.c
> @@ -9,6 +9,14 @@
>   #include <objtool/builtin.h>
>   #include <objtool/endianness.h>
>   
> +bool arch_ftrace_match(char *name)
> +{
> +	if (!strcmp(name, "_mcount"))
> +		return true;
> +
> +	return false;
> +}
> +
>   unsigned long arch_dest_reloc_offset(int addend)
>   {
>   	return addend;
> @@ -41,12 +49,26 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
>   			    struct list_head *ops_list)
>   {
>   	u32 insn;
> +	unsigned int opcode;
>   
>   	*immediate = 0;
>   	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>   	*len = 4;
>   	*type = INSN_OTHER;
>   
> +	opcode = insn >> 26;
> +
> +	switch (opcode) {
> +	case 18: /* bl */

case 18 is more than 'bl', it includes also 'b'.
In both cases, the calculation of *immediate is the same.

It would therefore be more correct to perform the calculation and setup 
of *immediate outside the 'if ((insn & 3) == 1)', that would avoid 
unnecessary churn the day we add support for branches without link.

> +		if ((insn & 3) == 1) {
> +			*type = INSN_CALL;
> +			*immediate = insn & 0x3fffffc;
> +			if (*immediate & 0x2000000)
> +				*immediate -= 0x4000000;
> +		}
> +		break;
> +	}
> +
>   	return 0;
>   }
>   
> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
> index 3c8ebb7d2a6b..73f9ae172fe5 100644
> --- a/tools/objtool/arch/powerpc/include/arch/elf.h
> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
> @@ -4,5 +4,7 @@
>   #define _OBJTOOL_ARCH_ELF
>   
>   #define R_NONE R_PPC_NONE
> +#define R_ABS64 R_PPC64_ADDR64
> +#define R_ABS32 R_PPC_ADDR32
>   
>   #endif /* _OBJTOOL_ARCH_ELF */

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
  2022-08-31 12:50     ` Christophe Leroy
@ 2022-08-31 17:51       ` Segher Boessenkool
  -1 siblings, 0 replies; 128+ messages in thread
From: Segher Boessenkool @ 2022-08-31 17:51 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: peterz, chenzhongjin, linux-kernel, rostedt, aik, mingo,
	Sathvika Vasireddy, npiggin, jpoimboe, naveen.n.rao, mbenes,
	linuxppc-dev

On Wed, Aug 31, 2022 at 12:50:07PM +0000, Christophe Leroy wrote:
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> > +	opcode = insn >> 26;
> > +
> > +	switch (opcode) {
> > +	case 18: /* bl */
> 
> case 18 is more than 'bl', it includes also 'b'.
> In both cases, the calculation of *immediate is the same.

It also is "ba" and "bla", sometimes written as "b[l][a]".

> It would therefore be more correct to perform the calculation and setup 
> of *immediate outside the 'if ((insn & 3) == 1)', that would avoid 
> unnecessary churn the day we add support for branches without link.
> 
> > +		if ((insn & 3) == 1) {
> > +			*type = INSN_CALL;
> > +			*immediate = insn & 0x3fffffc;
> > +			if (*immediate & 0x2000000)
> > +				*immediate -= 0x4000000;
> > +		}
> > +		break;
> > +	}

Does this handle AA=1 correctly at all?  That is valid both with and
without relocations, just like AA=0.  Same for AA=1 LK=0 btw.

If you only handle AA=0, the code should explicitly test for that.


Segher

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
@ 2022-08-31 17:51       ` Segher Boessenkool
  0 siblings, 0 replies; 128+ messages in thread
From: Segher Boessenkool @ 2022-08-31 17:51 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Sathvika Vasireddy, linuxppc-dev, peterz, linux-kernel, rostedt,
	aik, mingo, npiggin, jpoimboe, naveen.n.rao, mbenes,
	chenzhongjin

On Wed, Aug 31, 2022 at 12:50:07PM +0000, Christophe Leroy wrote:
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> > +	opcode = insn >> 26;
> > +
> > +	switch (opcode) {
> > +	case 18: /* bl */
> 
> case 18 is more than 'bl', it includes also 'b'.
> In both cases, the calculation of *immediate is the same.

It also is "ba" and "bla", sometimes written as "b[l][a]".

> It would therefore be more correct to perform the calculation and setup 
> of *immediate outside the 'if ((insn & 3) == 1)', that would avoid 
> unnecessary churn the day we add support for branches without link.
> 
> > +		if ((insn & 3) == 1) {
> > +			*type = INSN_CALL;
> > +			*immediate = insn & 0x3fffffc;
> > +			if (*immediate & 0x2000000)
> > +				*immediate -= 0x4000000;
> > +		}
> > +		break;
> > +	}

Does this handle AA=1 correctly at all?  That is valid both with and
without relocations, just like AA=0.  Same for AA=1 LK=0 btw.

If you only handle AA=0, the code should explicitly test for that.


Segher

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-01  9:32     ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-09-01  9:32 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch adds [stub] implementations for required
> functions, inorder to enable objtool build on powerpc.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> [Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>   arch/powerpc/Kconfig                          |  1 +
>   arch/powerpc/include/asm/asm.h                |  7 ++
>   tools/objtool/arch/powerpc/Build              |  2 +
>   tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
>   .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
>   tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
>   .../arch/powerpc/include/arch/special.h       | 21 ++++++
>   tools/objtool/arch/powerpc/special.c          | 19 +++++
>   8 files changed, 143 insertions(+)
>   create mode 100644 arch/powerpc/include/asm/asm.h
>   create mode 100644 tools/objtool/arch/powerpc/Build
>   create mode 100644 tools/objtool/arch/powerpc/decode.c
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
>   create mode 100644 tools/objtool/arch/powerpc/special.c
> 


> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
> +			    unsigned long offset, unsigned int maxlen,
> +			    unsigned int *len, enum insn_type *type,
> +			    unsigned long *immediate,
> +			    struct list_head *ops_list)
> +{
> +	u32 insn;
> +
> +	*immediate = 0;
> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
> +	*len = 4;

Should be *len = 8 when insn >> 26 == 1.

I will send you something later on.

> +	*type = INSN_OTHER;
> +
> +	return 0;
> +}
> +
> +unsigned long arch_jump_destination(struct instruction *insn)
> +{
> +	return insn->offset +  insn->immediate;

Two spaces after the +
Should be only one.

> +}
> +
> +void arch_initial_func_cfi_state(struct cfi_init_state *state)
> +{
> +	int i;
> +
> +	for (i = 0; i < CFI_NUM_REGS; i++) {
> +		state->regs[i].base = CFI_UNDEFINED;
> +		state->regs[i].offset = 0;
> +	}
> +
> +	/* initial CFA (call frame address) */
> +	state->cfa.base = CFI_SP;
> +	state->cfa.offset = 0;
> +
> +	/* initial LR (return address) */
> +	state->regs[CFI_RA].base = CFI_CFA;
> +	state->regs[CFI_RA].offset = 0;
> +}

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2022-09-01  9:32     ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-09-01  9:32 UTC (permalink / raw)
  To: Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin



Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> This patch adds [stub] implementations for required
> functions, inorder to enable objtool build on powerpc.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> [Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>   arch/powerpc/Kconfig                          |  1 +
>   arch/powerpc/include/asm/asm.h                |  7 ++
>   tools/objtool/arch/powerpc/Build              |  2 +
>   tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
>   .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
>   tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
>   .../arch/powerpc/include/arch/special.h       | 21 ++++++
>   tools/objtool/arch/powerpc/special.c          | 19 +++++
>   8 files changed, 143 insertions(+)
>   create mode 100644 arch/powerpc/include/asm/asm.h
>   create mode 100644 tools/objtool/arch/powerpc/Build
>   create mode 100644 tools/objtool/arch/powerpc/decode.c
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
>   create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
>   create mode 100644 tools/objtool/arch/powerpc/special.c
> 


> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
> +			    unsigned long offset, unsigned int maxlen,
> +			    unsigned int *len, enum insn_type *type,
> +			    unsigned long *immediate,
> +			    struct list_head *ops_list)
> +{
> +	u32 insn;
> +
> +	*immediate = 0;
> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
> +	*len = 4;

Should be *len = 8 when insn >> 26 == 1.

I will send you something later on.

> +	*type = INSN_OTHER;
> +
> +	return 0;
> +}
> +
> +unsigned long arch_jump_destination(struct instruction *insn)
> +{
> +	return insn->offset +  insn->immediate;

Two spaces after the +
Should be only one.

> +}
> +
> +void arch_initial_func_cfi_state(struct cfi_init_state *state)
> +{
> +	int i;
> +
> +	for (i = 0; i < CFI_NUM_REGS; i++) {
> +		state->regs[i].base = CFI_UNDEFINED;
> +		state->regs[i].offset = 0;
> +	}
> +
> +	/* initial CFA (call frame address) */
> +	state->cfa.base = CFI_SP;
> +	state->cfa.offset = 0;
> +
> +	/* initial LR (return address) */
> +	state->regs[CFI_RA].base = CFI_CFA;
> +	state->regs[CFI_RA].offset = 0;
> +}

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2022-09-01  9:32     ` Christophe Leroy
@ 2022-09-01 15:11       ` Segher Boessenkool
  -1 siblings, 0 replies; 128+ messages in thread
From: Segher Boessenkool @ 2022-09-01 15:11 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: peterz, chenzhongjin, linux-kernel, rostedt, aik, mingo,
	Sathvika Vasireddy, npiggin, jpoimboe, naveen.n.rao, mbenes,
	linuxppc-dev

On Thu, Sep 01, 2022 at 09:32:46AM +0000, Christophe Leroy wrote:
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> > +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
> > +			    unsigned long offset, unsigned int maxlen,
> > +			    unsigned int *len, enum insn_type *type,
> > +			    unsigned long *immediate,
> > +			    struct list_head *ops_list)
> > +{
> > +	u32 insn;
> > +
> > +	*immediate = 0;
> > +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
> > +	*len = 4;
> 
> Should be *len = 8 when insn >> 26 == 1.

But please use ppc_inst_prefixed().  And just use ppc_inst_len() here?

Not having convenience abstraction functions like that will give you
much more work in the future -- currently all prefix insns use primary
opcode 1, sure, and nothing else does; but this can change.


Segher

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2022-09-01 15:11       ` Segher Boessenkool
  0 siblings, 0 replies; 128+ messages in thread
From: Segher Boessenkool @ 2022-09-01 15:11 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Sathvika Vasireddy, linuxppc-dev, peterz, linux-kernel, rostedt,
	aik, mingo, npiggin, jpoimboe, naveen.n.rao, mbenes,
	chenzhongjin

On Thu, Sep 01, 2022 at 09:32:46AM +0000, Christophe Leroy wrote:
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> > +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
> > +			    unsigned long offset, unsigned int maxlen,
> > +			    unsigned int *len, enum insn_type *type,
> > +			    unsigned long *immediate,
> > +			    struct list_head *ops_list)
> > +{
> > +	u32 insn;
> > +
> > +	*immediate = 0;
> > +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
> > +	*len = 4;
> 
> Should be *len = 8 when insn >> 26 == 1.

But please use ppc_inst_prefixed().  And just use ppc_inst_len() here?

Not having convenience abstraction functions like that will give you
much more work in the future -- currently all prefix insns use primary
opcode 1, sure, and nothing else does; but this can change.


Segher

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2022-09-01 15:11       ` Segher Boessenkool
@ 2022-09-01 16:38         ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-09-01 16:38 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Sathvika Vasireddy, linuxppc-dev, peterz, linux-kernel, rostedt,
	aik, mingo, npiggin, jpoimboe, naveen.n.rao, mbenes,
	chenzhongjin



Le 01/09/2022 à 17:11, Segher Boessenkool a écrit :
> On Thu, Sep 01, 2022 at 09:32:46AM +0000, Christophe Leroy wrote:
>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
>>> +			    unsigned long offset, unsigned int maxlen,
>>> +			    unsigned int *len, enum insn_type *type,
>>> +			    unsigned long *immediate,
>>> +			    struct list_head *ops_list)
>>> +{
>>> +	u32 insn;
>>> +
>>> +	*immediate = 0;
>>> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>>> +	*len = 4;
>>
>> Should be *len = 8 when insn >> 26 == 1.
> 
> But please use ppc_inst_prefixed().  And just use ppc_inst_len() here?

objtool is a userland app, there is no access to kernel headers here.

> 
> Not having convenience abstraction functions like that will give you
> much more work in the future -- currently all prefix insns use primary
> opcode 1, sure, and nothing else does; but this can change.
> 

Yes most likely. Then we have to rebuild some light abstraction for objtool.

Christophe

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2022-09-01 16:38         ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-09-01 16:38 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: peterz, chenzhongjin, linux-kernel, rostedt, aik, mingo,
	Sathvika Vasireddy, npiggin, jpoimboe, naveen.n.rao, mbenes,
	linuxppc-dev



Le 01/09/2022 à 17:11, Segher Boessenkool a écrit :
> On Thu, Sep 01, 2022 at 09:32:46AM +0000, Christophe Leroy wrote:
>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
>>> +			    unsigned long offset, unsigned int maxlen,
>>> +			    unsigned int *len, enum insn_type *type,
>>> +			    unsigned long *immediate,
>>> +			    struct list_head *ops_list)
>>> +{
>>> +	u32 insn;
>>> +
>>> +	*immediate = 0;
>>> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>>> +	*len = 4;
>>
>> Should be *len = 8 when insn >> 26 == 1.
> 
> But please use ppc_inst_prefixed().  And just use ppc_inst_len() here?

objtool is a userland app, there is no access to kernel headers here.

> 
> Not having convenience abstraction functions like that will give you
> much more work in the future -- currently all prefix insns use primary
> opcode 1, sure, and nothing else does; but this can change.
> 

Yes most likely. Then we have to rebuild some light abstraction for objtool.

Christophe

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2022-09-01 16:38         ` Christophe Leroy
@ 2022-09-01 19:01           ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:01 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Segher Boessenkool, Sathvika Vasireddy, linuxppc-dev,
	linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin

On Thu, Sep 01, 2022 at 04:38:52PM +0000, Christophe Leroy wrote:

> objtool is a userland app, there is no access to kernel headers here.

Please have a look at tools/include/ :-)

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2022-09-01 19:01           ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:01 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: aik, chenzhongjin, linux-kernel, rostedt, mingo,
	Sathvika Vasireddy, npiggin, jpoimboe, naveen.n.rao, mbenes,
	linuxppc-dev

On Thu, Sep 01, 2022 at 04:38:52PM +0000, Christophe Leroy wrote:

> objtool is a userland app, there is no access to kernel headers here.

Please have a look at tools/include/ :-)

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

* Re: [PATCH v2 05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-01 19:17     ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:17 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

On Mon, Aug 29, 2022 at 11:22:12AM +0530, Sathvika Vasireddy wrote:
> With objtool enabled, below warnings are seen when trying to build:
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2448: unannotated intra-function call
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2d68: unannotated intra-function call
> 
> Skip objtool from running on this file, for two main reasons:
> 
> Since this file comes from OpenSSL, and since it is a perl file
> which generates a .S file, it may not be the best choice to
> make too many code changes to such files, unless absolutely
> necessary.
> 
> Second reason is that, at least as far as the objtool --mcount
> functionality is concerned, we do not have to run objtool on
> that file because that file does not have any calls to _mcount.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>  drivers/crypto/vmx/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
> index 2560cfea1dec..7b41f0da6807 100644
> --- a/drivers/crypto/vmx/Makefile
> +++ b/drivers/crypto/vmx/Makefile
> @@ -9,3 +9,5 @@ targets += aesp8-ppc.S ghashp8-ppc.S
>  
>  $(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
>  	$(call if_changed,perl)
> +
> +OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y

Just be aware that the moment you start to run objtool on vmlinux.o this
annotation becomes unstuck.

Specifically things like LTO builds require this because there simply
isn't an object file before that.

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

* Re: [PATCH v2 05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
@ 2022-09-01 19:17     ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:17 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

On Mon, Aug 29, 2022 at 11:22:12AM +0530, Sathvika Vasireddy wrote:
> With objtool enabled, below warnings are seen when trying to build:
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2448: unannotated intra-function call
> 
> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2d68: unannotated intra-function call
> 
> Skip objtool from running on this file, for two main reasons:
> 
> Since this file comes from OpenSSL, and since it is a perl file
> which generates a .S file, it may not be the best choice to
> make too many code changes to such files, unless absolutely
> necessary.
> 
> Second reason is that, at least as far as the objtool --mcount
> functionality is concerned, we do not have to run objtool on
> that file because that file does not have any calls to _mcount.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>  drivers/crypto/vmx/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
> index 2560cfea1dec..7b41f0da6807 100644
> --- a/drivers/crypto/vmx/Makefile
> +++ b/drivers/crypto/vmx/Makefile
> @@ -9,3 +9,5 @@ targets += aesp8-ppc.S ghashp8-ppc.S
>  
>  $(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
>  	$(call if_changed,perl)
> +
> +OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y

Just be aware that the moment you start to run objtool on vmlinux.o this
annotation becomes unstuck.

Specifically things like LTO builds require this because there simply
isn't an object file before that.

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

* Re: [PATCH v2 07/16] powerpc: Skip objtool from running on VDSO files
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-01 19:19     ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:19 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

On Mon, Aug 29, 2022 at 11:22:14AM +0530, Sathvika Vasireddy wrote:
> Do not run objtool on VDSO files, by using
> OBJECT_FILES_NON_STANDARD
> 
> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>  arch/powerpc/kernel/vdso/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> index 096b0bf1335f..a49a0d6a1c53 100644
> --- a/arch/powerpc/kernel/vdso/Makefile
> +++ b/arch/powerpc/kernel/vdso/Makefile
> @@ -102,3 +102,5 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@
>        cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
>  quiet_cmd_vdso64as = VDSO64A $@
>        cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
> +
> +OBJECT_FILES_NON_STANDARD := y

Just to clarify; your linker script will place the VDSO in .rodata or a
similar !.text section, right?

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

* Re: [PATCH v2 07/16] powerpc: Skip objtool from running on VDSO files
@ 2022-09-01 19:19     ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:19 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

On Mon, Aug 29, 2022 at 11:22:14AM +0530, Sathvika Vasireddy wrote:
> Do not run objtool on VDSO files, by using
> OBJECT_FILES_NON_STANDARD
> 
> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>  arch/powerpc/kernel/vdso/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> index 096b0bf1335f..a49a0d6a1c53 100644
> --- a/arch/powerpc/kernel/vdso/Makefile
> +++ b/arch/powerpc/kernel/vdso/Makefile
> @@ -102,3 +102,5 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@
>        cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
>  quiet_cmd_vdso64as = VDSO64A $@
>        cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
> +
> +OBJECT_FILES_NON_STANDARD := y

Just to clarify; your linker script will place the VDSO in .rodata or a
similar !.text section, right?

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

* Re: [PATCH v2 08/16] objtool: Fix SEGFAULT
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-01 19:20     ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:20 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

On Mon, Aug 29, 2022 at 11:22:15AM +0530, Sathvika Vasireddy wrote:
> From: Christophe Leroy <christophe.leroy@csgroup.eu>
> 
> find_insn() will return NULL in case of failure. Check insn in order
> to avoid a kernel Oops for NULL pointer dereference.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  tools/objtool/check.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 91678252a9b6..ed2fdfeb1d9c 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -205,7 +205,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
>  		return false;
>  
>  	insn = find_insn(file, func->sec, func->offset);
> -	if (!insn->func)
> +	if (!insn || !insn->func)
>  		return false;

I suppose this is ok, but how can the lookup for func->sec, func->offset
*not* find an instruction ?!

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

* Re: [PATCH v2 08/16] objtool: Fix SEGFAULT
@ 2022-09-01 19:20     ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:20 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

On Mon, Aug 29, 2022 at 11:22:15AM +0530, Sathvika Vasireddy wrote:
> From: Christophe Leroy <christophe.leroy@csgroup.eu>
> 
> find_insn() will return NULL in case of failure. Check insn in order
> to avoid a kernel Oops for NULL pointer dereference.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  tools/objtool/check.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 91678252a9b6..ed2fdfeb1d9c 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -205,7 +205,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
>  		return false;
>  
>  	insn = find_insn(file, func->sec, func->offset);
> -	if (!insn->func)
> +	if (!insn || !insn->func)
>  		return false;

I suppose this is ok, but how can the lookup for func->sec, func->offset
*not* find an instruction ?!

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

* Re: [PATCH v2 09/16] objtool: Use target file endianness instead of a compiled constant
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-01 19:22     ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:22 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

On Mon, Aug 29, 2022 at 11:22:16AM +0530, Sathvika Vasireddy wrote:
> From: Christophe Leroy <christophe.leroy@csgroup.eu>
> 
> Some architectures like powerpc support both endianness, it's
> therefore not possible to fix the endianness via arch/endianness.h
> because there is no easy way to get the target endianness at
> build time.
> 
> Use the endianness recorded in the file objtool is working on.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH v2 09/16] objtool: Use target file endianness instead of a compiled constant
@ 2022-09-01 19:22     ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:22 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

On Mon, Aug 29, 2022 at 11:22:16AM +0530, Sathvika Vasireddy wrote:
> From: Christophe Leroy <christophe.leroy@csgroup.eu>
> 
> Some architectures like powerpc support both endianness, it's
> therefore not possible to fix the endianness via arch/endianness.h
> because there is no easy way to get the target endianness at
> build time.
> 
> Use the endianness recorded in the file objtool is working on.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH v2 10/16] objtool: Use target file class size instead of a compiled constant
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-01 19:23     ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:23 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

On Mon, Aug 29, 2022 at 11:22:17AM +0530, Sathvika Vasireddy wrote:
> From: Christophe Leroy <christophe.leroy@csgroup.eu>
> 
> In order to allow using objtool on cross-built kernels,
> determine size of long from elf data instead of using
> sizeof(long) at build time.
> 
> For the time being this covers only mcount.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

> ---
>  tools/objtool/check.c               | 16 +++++++++-------
>  tools/objtool/elf.c                 |  8 ++++++--
>  tools/objtool/include/objtool/elf.h |  8 ++++++++
>  3 files changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index a948b2551520..0ecf41ee73f0 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -851,9 +851,9 @@ static int create_ibt_endbr_seal_sections(struct objtool_file *file)
>  static int create_mcount_loc_sections(struct objtool_file *file)
>  {
>  	struct section *sec;
> -	unsigned long *loc;
>  	struct instruction *insn;
>  	int idx;
> +	int addrsize = elf_class_addrsize(file->elf);

If there is a respin, please make this a reverse-x-mas-tree thingy.

>  
>  	sec = find_section_by_name(file->elf, "__mcount_loc");
>  	if (sec) {
> @@ -869,23 +869,25 @@ static int create_mcount_loc_sections(struct objtool_file *file)

> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -1124,6 +1124,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
>  {
>  	char *relocname;
>  	struct section *sec;
> +	int addrsize = elf_class_addrsize(elf);
>  

idem.

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

* Re: [PATCH v2 10/16] objtool: Use target file class size instead of a compiled constant
@ 2022-09-01 19:23     ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:23 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

On Mon, Aug 29, 2022 at 11:22:17AM +0530, Sathvika Vasireddy wrote:
> From: Christophe Leroy <christophe.leroy@csgroup.eu>
> 
> In order to allow using objtool on cross-built kernels,
> determine size of long from elf data instead of using
> sizeof(long) at build time.
> 
> For the time being this covers only mcount.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

> ---
>  tools/objtool/check.c               | 16 +++++++++-------
>  tools/objtool/elf.c                 |  8 ++++++--
>  tools/objtool/include/objtool/elf.h |  8 ++++++++
>  3 files changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index a948b2551520..0ecf41ee73f0 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -851,9 +851,9 @@ static int create_ibt_endbr_seal_sections(struct objtool_file *file)
>  static int create_mcount_loc_sections(struct objtool_file *file)
>  {
>  	struct section *sec;
> -	unsigned long *loc;
>  	struct instruction *insn;
>  	int idx;
> +	int addrsize = elf_class_addrsize(file->elf);

If there is a respin, please make this a reverse-x-mas-tree thingy.

>  
>  	sec = find_section_by_name(file->elf, "__mcount_loc");
>  	if (sec) {
> @@ -869,23 +869,25 @@ static int create_mcount_loc_sections(struct objtool_file *file)

> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -1124,6 +1124,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
>  {
>  	char *relocname;
>  	struct section *sec;
> +	int addrsize = elf_class_addrsize(elf);
>  

idem.

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

* Re: [PATCH v2 11/16] objtool: Add --mnop as an option to --mcount
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-01 19:25     ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:25 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

On Mon, Aug 29, 2022 at 11:22:18AM +0530, Sathvika Vasireddy wrote:
> Architectures can select HAVE_NOP_MCOUNT if they choose
> to nop out mcount call sites. If that config option is
> selected, then --mnop is passed as an option to objtool,
> along with --mcount.
> 
> Also, make sure that --mnop can be passed as an option
> to objtool only when --mcount is passed.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

IIRC you want to nop the things yourself because PLT entries or
something?

Anyway, patch looks fine, even though the Changelog doesn't relaly
justify the change.

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH v2 11/16] objtool: Add --mnop as an option to --mcount
@ 2022-09-01 19:25     ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:25 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

On Mon, Aug 29, 2022 at 11:22:18AM +0530, Sathvika Vasireddy wrote:
> Architectures can select HAVE_NOP_MCOUNT if they choose
> to nop out mcount call sites. If that config option is
> selected, then --mnop is passed as an option to objtool,
> along with --mcount.
> 
> Also, make sure that --mnop can be passed as an option
> to objtool only when --mcount is passed.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

IIRC you want to nop the things yourself because PLT entries or
something?

Anyway, patch looks fine, even though the Changelog doesn't relaly
justify the change.

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH v2 13/16] objtool: Use macros to define arch specific reloc types
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-01 19:28     ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:28 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

On Mon, Aug 29, 2022 at 11:22:20AM +0530, Sathvika Vasireddy wrote:
> Make relocation types architecture specific.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH v2 13/16] objtool: Use macros to define arch specific reloc types
@ 2022-09-01 19:28     ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-01 19:28 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

On Mon, Aug 29, 2022 at 11:22:20AM +0530, Sathvika Vasireddy wrote:
> Make relocation types architecture specific.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH v2 07/16] powerpc: Skip objtool from running on VDSO files
  2022-09-01 19:19     ` Peter Zijlstra
@ 2022-09-02  7:40       ` Michael Ellerman
  -1 siblings, 0 replies; 128+ messages in thread
From: Michael Ellerman @ 2022-09-02  7:40 UTC (permalink / raw)
  To: Peter Zijlstra, Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

Peter Zijlstra <peterz@infradead.org> writes:
> On Mon, Aug 29, 2022 at 11:22:14AM +0530, Sathvika Vasireddy wrote:
>> Do not run objtool on VDSO files, by using
>> OBJECT_FILES_NON_STANDARD
>> 
>> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>> ---
>>  arch/powerpc/kernel/vdso/Makefile | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
>> index 096b0bf1335f..a49a0d6a1c53 100644
>> --- a/arch/powerpc/kernel/vdso/Makefile
>> +++ b/arch/powerpc/kernel/vdso/Makefile
>> @@ -102,3 +102,5 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@
>>        cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
>>  quiet_cmd_vdso64as = VDSO64A $@
>>        cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
>> +
>> +OBJECT_FILES_NON_STANDARD := y
>
> Just to clarify; your linker script will place the VDSO in .rodata or a
> similar !.text section, right?

Not the linker script, but we incbin it into .data.

See arch/powerpc/kernel/vdso64_wrapper.S

cheers

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

* Re: [PATCH v2 07/16] powerpc: Skip objtool from running on VDSO files
@ 2022-09-02  7:40       ` Michael Ellerman
  0 siblings, 0 replies; 128+ messages in thread
From: Michael Ellerman @ 2022-09-02  7:40 UTC (permalink / raw)
  To: Peter Zijlstra, Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

Peter Zijlstra <peterz@infradead.org> writes:
> On Mon, Aug 29, 2022 at 11:22:14AM +0530, Sathvika Vasireddy wrote:
>> Do not run objtool on VDSO files, by using
>> OBJECT_FILES_NON_STANDARD
>> 
>> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>> ---
>>  arch/powerpc/kernel/vdso/Makefile | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
>> index 096b0bf1335f..a49a0d6a1c53 100644
>> --- a/arch/powerpc/kernel/vdso/Makefile
>> +++ b/arch/powerpc/kernel/vdso/Makefile
>> @@ -102,3 +102,5 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@
>>        cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
>>  quiet_cmd_vdso64as = VDSO64A $@
>>        cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
>> +
>> +OBJECT_FILES_NON_STANDARD := y
>
> Just to clarify; your linker script will place the VDSO in .rodata or a
> similar !.text section, right?

Not the linker script, but we incbin it into .data.

See arch/powerpc/kernel/vdso64_wrapper.S

cheers

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

* Re: [PATCH v2 08/16] objtool: Fix SEGFAULT
  2022-09-01 19:20     ` Peter Zijlstra
@ 2022-09-02  8:06       ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-09-02  8:06 UTC (permalink / raw)
  To: Peter Zijlstra, Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo, rostedt,
	mbenes, npiggin, chenzhongjin, naveen.n.rao



Le 01/09/2022 à 21:20, Peter Zijlstra a écrit :
> On Mon, Aug 29, 2022 at 11:22:15AM +0530, Sathvika Vasireddy wrote:
>> From: Christophe Leroy <christophe.leroy@csgroup.eu>
>>
>> find_insn() will return NULL in case of failure. Check insn in order
>> to avoid a kernel Oops for NULL pointer dereference.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>>   tools/objtool/check.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
>> index 91678252a9b6..ed2fdfeb1d9c 100644
>> --- a/tools/objtool/check.c
>> +++ b/tools/objtool/check.c
>> @@ -205,7 +205,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
>>   		return false;
>>   
>>   	insn = find_insn(file, func->sec, func->offset);
>> -	if (!insn->func)
>> +	if (!insn || !insn->func)
>>   		return false;
> 
> I suppose this is ok, but how can the lookup for func->sec, func->offset
> *not* find an instruction ?!

That happened to me at the begining when the port to powerpc was not 
fully functionnal.

I guess that could also happen with a corrupted object file so better 
safe than sorry.

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

* Re: [PATCH v2 08/16] objtool: Fix SEGFAULT
@ 2022-09-02  8:06       ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-09-02  8:06 UTC (permalink / raw)
  To: Peter Zijlstra, Sathvika Vasireddy
  Cc: aik, chenzhongjin, linux-kernel, rostedt, mingo, npiggin,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev



Le 01/09/2022 à 21:20, Peter Zijlstra a écrit :
> On Mon, Aug 29, 2022 at 11:22:15AM +0530, Sathvika Vasireddy wrote:
>> From: Christophe Leroy <christophe.leroy@csgroup.eu>
>>
>> find_insn() will return NULL in case of failure. Check insn in order
>> to avoid a kernel Oops for NULL pointer dereference.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>>   tools/objtool/check.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
>> index 91678252a9b6..ed2fdfeb1d9c 100644
>> --- a/tools/objtool/check.c
>> +++ b/tools/objtool/check.c
>> @@ -205,7 +205,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
>>   		return false;
>>   
>>   	insn = find_insn(file, func->sec, func->offset);
>> -	if (!insn->func)
>> +	if (!insn || !insn->func)
>>   		return false;
> 
> I suppose this is ok, but how can the lookup for func->sec, func->offset
> *not* find an instruction ?!

That happened to me at the begining when the port to powerpc was not 
fully functionnal.

I guess that could also happen with a corrupted object file so better 
safe than sorry.

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

* Re: [PATCH v2 08/16] objtool: Fix SEGFAULT
  2022-09-02  8:06       ` Christophe Leroy
@ 2022-09-02  8:42         ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-02  8:42 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Sathvika Vasireddy, linuxppc-dev, jpoimboe, linux-kernel, aik,
	mpe, mingo, rostedt, mbenes, npiggin, chenzhongjin, naveen.n.rao

On Fri, Sep 02, 2022 at 08:06:28AM +0000, Christophe Leroy wrote:
> 
> 
> Le 01/09/2022 à 21:20, Peter Zijlstra a écrit :
> > On Mon, Aug 29, 2022 at 11:22:15AM +0530, Sathvika Vasireddy wrote:
> >> From: Christophe Leroy <christophe.leroy@csgroup.eu>
> >>
> >> find_insn() will return NULL in case of failure. Check insn in order
> >> to avoid a kernel Oops for NULL pointer dereference.
> >>
> >> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> >> ---
> >>   tools/objtool/check.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> >> index 91678252a9b6..ed2fdfeb1d9c 100644
> >> --- a/tools/objtool/check.c
> >> +++ b/tools/objtool/check.c
> >> @@ -205,7 +205,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
> >>   		return false;
> >>   
> >>   	insn = find_insn(file, func->sec, func->offset);
> >> -	if (!insn->func)
> >> +	if (!insn || !insn->func)
> >>   		return false;
> > 
> > I suppose this is ok, but how can the lookup for func->sec, func->offset
> > *not* find an instruction ?!
> 
> That happened to me at the begining when the port to powerpc was not 
> fully functionnal.
> 
> I guess that could also happen with a corrupted object file so better 
> safe than sorry.

Fair enough.

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH v2 08/16] objtool: Fix SEGFAULT
@ 2022-09-02  8:42         ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-02  8:42 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: aik, chenzhongjin, linux-kernel, rostedt, mingo,
	Sathvika Vasireddy, npiggin, jpoimboe, naveen.n.rao, mbenes,
	linuxppc-dev

On Fri, Sep 02, 2022 at 08:06:28AM +0000, Christophe Leroy wrote:
> 
> 
> Le 01/09/2022 à 21:20, Peter Zijlstra a écrit :
> > On Mon, Aug 29, 2022 at 11:22:15AM +0530, Sathvika Vasireddy wrote:
> >> From: Christophe Leroy <christophe.leroy@csgroup.eu>
> >>
> >> find_insn() will return NULL in case of failure. Check insn in order
> >> to avoid a kernel Oops for NULL pointer dereference.
> >>
> >> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> >> ---
> >>   tools/objtool/check.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> >> index 91678252a9b6..ed2fdfeb1d9c 100644
> >> --- a/tools/objtool/check.c
> >> +++ b/tools/objtool/check.c
> >> @@ -205,7 +205,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
> >>   		return false;
> >>   
> >>   	insn = find_insn(file, func->sec, func->offset);
> >> -	if (!insn->func)
> >> +	if (!insn || !insn->func)
> >>   		return false;
> > 
> > I suppose this is ok, but how can the lookup for func->sec, func->offset
> > *not* find an instruction ?!
> 
> That happened to me at the begining when the port to powerpc was not 
> fully functionnal.
> 
> I guess that could also happen with a corrupted object file so better 
> safe than sorry.

Fair enough.

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH v2 01/16] powerpc: Replace unreachable() with it's builtin variant in __WARN_FLAGS()
  2022-08-30  6:15     ` Christophe Leroy
@ 2022-09-05 10:18       ` Naveen N. Rao
  -1 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:18 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev, Sathvika Vasireddy
  Cc: aik, chenzhongjin, jpoimboe, linux-kernel, mbenes, mingo, mpe,
	npiggin, peterz, rostedt

Christophe Leroy wrote:
> 
> 
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> objtool is throwing *unannotated intra-function call* warnings in
>> .c files with a few instructions that are marked unreachable. The
>> problem comes from the annotate_unreachable() macro that is
>> called by unreachable(). This annotation is adding a call to a
>> function with size 0, and objtool does not add such symbols
>> to the rbtree. Due to this reason, find_call_destination() function
>> is not able to find the destination symbol for that call.
>> 
>> With the annotation (annotate_unreachable()), gcc seems to
>> generate a 'bl' to unreachable symbol with size 0. But with
>> the builtin variant of unreachable (__builtin_unreachable()),
>> gcc does not emit calls to such symbols and the warnings
>> go away. Given that the codegen remains same, and that
>> there are no 'bl' instructions to such symbols emitted, fix
>> these warnings by replacing unreachable() with it's builtin
>> variant in __WARN_FLAGS().
> 
> How can you say that the codegen remains the same if with the original 
> you get stale 'bl' instructions and with the alternative you don't ?

I guess the reference to codegen remaining the same is more to do with 
unreachable vs. __builtin_unreachable() in the absence of 
CONFIG_OBJTOOL. But yeah, the changelog needs to be reworked to clarify 
that.

> 
>> 
>> Also, add barrier_before_unreachable() before __builtin_unreachable()
>> to work around a gcc bug [1], for the problem reported at [2].
> 
> Here my comment was not related to the gcc bug [1] but to gcc bug 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365 , which was worked 
> around by commit 173a3efd3edb ("bug.h: work around GCC PR82365 in BUG()")
> 
> By chance it also solve the problem [1] as you mention.

That's a good commit to reference, but please also retain a link to the 
new PR.


- Naveen


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

* Re: [PATCH v2 01/16] powerpc: Replace unreachable() with it's builtin variant in __WARN_FLAGS()
@ 2022-09-05 10:18       ` Naveen N. Rao
  0 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:18 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev, Sathvika Vasireddy
  Cc: aik, linux-kernel, npiggin, peterz, mingo, rostedt, jpoimboe,
	mbenes, chenzhongjin

Christophe Leroy wrote:
> 
> 
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> objtool is throwing *unannotated intra-function call* warnings in
>> .c files with a few instructions that are marked unreachable. The
>> problem comes from the annotate_unreachable() macro that is
>> called by unreachable(). This annotation is adding a call to a
>> function with size 0, and objtool does not add such symbols
>> to the rbtree. Due to this reason, find_call_destination() function
>> is not able to find the destination symbol for that call.
>> 
>> With the annotation (annotate_unreachable()), gcc seems to
>> generate a 'bl' to unreachable symbol with size 0. But with
>> the builtin variant of unreachable (__builtin_unreachable()),
>> gcc does not emit calls to such symbols and the warnings
>> go away. Given that the codegen remains same, and that
>> there are no 'bl' instructions to such symbols emitted, fix
>> these warnings by replacing unreachable() with it's builtin
>> variant in __WARN_FLAGS().
> 
> How can you say that the codegen remains the same if with the original 
> you get stale 'bl' instructions and with the alternative you don't ?

I guess the reference to codegen remaining the same is more to do with 
unreachable vs. __builtin_unreachable() in the absence of 
CONFIG_OBJTOOL. But yeah, the changelog needs to be reworked to clarify 
that.

> 
>> 
>> Also, add barrier_before_unreachable() before __builtin_unreachable()
>> to work around a gcc bug [1], for the problem reported at [2].
> 
> Here my comment was not related to the gcc bug [1] but to gcc bug 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365 , which was worked 
> around by commit 173a3efd3edb ("bug.h: work around GCC PR82365 in BUG()")
> 
> By chance it also solve the problem [1] as you mention.

That's a good commit to reference, but please also retain a link to the 
new PR.


- Naveen


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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2022-08-30  6:41     ` Christophe Leroy
@ 2022-09-05 10:37       ` Naveen N. Rao
  -1 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:37 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev, Sathvika Vasireddy
  Cc: aik, chenzhongjin, Elliott, Robert (Servers),
	jpoimboe, linux-kernel, mbenes, mingo, mpe, npiggin, peterz,
	rostedt

Christophe Leroy wrote:
> 
> 
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> 
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 4c466acdc70d..dc05cd23c233 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -237,6 +237,7 @@ config PPC
>>   	select HAVE_MOD_ARCH_SPECIFIC
>>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>>   	select HAVE_OPTPROBES
>> +	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
> 
> Why restrict it to MPROFILE_KERNEL ? In your RFC it was for all PPC64.
> 
> Recent discussion on the list shows new problem with recordmcount, see 
> https://lore.kernel.org/all/MW5PR84MB184250EA1CAE04497C1E7CE9AB769@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM/
> 
> Those ones are with ppc64 big endian, so objtool would be welcome here 
> as well.

I don't think adding support for objtool on ppc64 elfv1 is a good idea. 
While it might solve the immediate issue with recordmcount, I worry that 
the function descriptors and dot symbols in ppc64 elfv1 might throw up 
issues in the future causing maintenance overhead.


- Naveen

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2022-09-05 10:37       ` Naveen N. Rao
  0 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:37 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev, Sathvika Vasireddy
  Cc: aik, linux-kernel, npiggin, peterz, mingo, rostedt, jpoimboe,
	mbenes, chenzhongjin, Elliott, Robert (Servers)

Christophe Leroy wrote:
> 
> 
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> 
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 4c466acdc70d..dc05cd23c233 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -237,6 +237,7 @@ config PPC
>>   	select HAVE_MOD_ARCH_SPECIFIC
>>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>>   	select HAVE_OPTPROBES
>> +	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
> 
> Why restrict it to MPROFILE_KERNEL ? In your RFC it was for all PPC64.
> 
> Recent discussion on the list shows new problem with recordmcount, see 
> https://lore.kernel.org/all/MW5PR84MB184250EA1CAE04497C1E7CE9AB769@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM/
> 
> Those ones are with ppc64 big endian, so objtool would be welcome here 
> as well.

I don't think adding support for objtool on ppc64 elfv1 is a good idea. 
While it might solve the immediate issue with recordmcount, I worry that 
the function descriptors and dot symbols in ppc64 elfv1 might throw up 
issues in the future causing maintenance overhead.


- Naveen

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
  2022-08-31 17:51       ` Segher Boessenkool
@ 2022-09-05 10:45         ` Naveen N. Rao
  -1 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:45 UTC (permalink / raw)
  To: Christophe Leroy, Segher Boessenkool
  Cc: aik, chenzhongjin, jpoimboe, linux-kernel, linuxppc-dev, mbenes,
	mingo, npiggin, peterz, rostedt, Sathvika Vasireddy

Segher Boessenkool wrote:
> On Wed, Aug 31, 2022 at 12:50:07PM +0000, Christophe Leroy wrote:
>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> > +	opcode = insn >> 26;
>> > +
>> > +	switch (opcode) {
>> > +	case 18: /* bl */
>> 
>> case 18 is more than 'bl', it includes also 'b'.
>> In both cases, the calculation of *immediate is the same.
> 
> It also is "ba" and "bla", sometimes written as "b[l][a]".
> 
>> It would therefore be more correct to perform the calculation and setup 
>> of *immediate outside the 'if ((insn & 3) == 1)', that would avoid 
>> unnecessary churn the day we add support for branches without link.

Yeah, and probably move the comments around:

+	case 18: /* b[l][a] */
+		if ((insn & 3) == 1) { /* bl */

>> 
>> > +		if ((insn & 3) == 1) {
>> > +			*type = INSN_CALL;
>> > +			*immediate = insn & 0x3fffffc;
>> > +			if (*immediate & 0x2000000)
>> > +				*immediate -= 0x4000000;
>> > +		}
>> > +		break;
>> > +	}
> 
> Does this handle AA=1 correctly at all?  That is valid both with and
> without relocations, just like AA=0.  Same for AA=1 LK=0 btw.
> 
> If you only handle AA=0, the code should explicitly test for that.

The code does test for AA=0 LK=1 with the if statement there?


- Naveen

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
@ 2022-09-05 10:45         ` Naveen N. Rao
  0 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:45 UTC (permalink / raw)
  To: Christophe Leroy, Segher Boessenkool
  Cc: aik, chenzhongjin, linux-kernel, npiggin, peterz, mingo,
	Sathvika Vasireddy, rostedt, jpoimboe, mbenes, linuxppc-dev

Segher Boessenkool wrote:
> On Wed, Aug 31, 2022 at 12:50:07PM +0000, Christophe Leroy wrote:
>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> > +	opcode = insn >> 26;
>> > +
>> > +	switch (opcode) {
>> > +	case 18: /* bl */
>> 
>> case 18 is more than 'bl', it includes also 'b'.
>> In both cases, the calculation of *immediate is the same.
> 
> It also is "ba" and "bla", sometimes written as "b[l][a]".
> 
>> It would therefore be more correct to perform the calculation and setup 
>> of *immediate outside the 'if ((insn & 3) == 1)', that would avoid 
>> unnecessary churn the day we add support for branches without link.

Yeah, and probably move the comments around:

+	case 18: /* b[l][a] */
+		if ((insn & 3) == 1) { /* bl */

>> 
>> > +		if ((insn & 3) == 1) {
>> > +			*type = INSN_CALL;
>> > +			*immediate = insn & 0x3fffffc;
>> > +			if (*immediate & 0x2000000)
>> > +				*immediate -= 0x4000000;
>> > +		}
>> > +		break;
>> > +	}
> 
> Does this handle AA=1 correctly at all?  That is valid both with and
> without relocations, just like AA=0.  Same for AA=1 LK=0 btw.
> 
> If you only handle AA=0, the code should explicitly test for that.

The code does test for AA=0 LK=1 with the if statement there?


- Naveen

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

* Re: [PATCH v2 05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
  2022-09-01 19:17     ` Peter Zijlstra
@ 2022-09-05 10:47       ` Naveen N. Rao
  -1 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:47 UTC (permalink / raw)
  To: Peter Zijlstra, Sathvika Vasireddy
  Cc: aik, chenzhongjin, christophe.leroy, jpoimboe, linux-kernel,
	linuxppc-dev, mbenes, mingo, mpe, npiggin, rostedt

Peter Zijlstra wrote:
> On Mon, Aug 29, 2022 at 11:22:12AM +0530, Sathvika Vasireddy wrote:
>> With objtool enabled, below warnings are seen when trying to build:
>> 
>> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
>> 
>> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2448: unannotated intra-function call
>> 
>> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2d68: unannotated intra-function call
>> 
>> Skip objtool from running on this file, for two main reasons:
>> 
>> Since this file comes from OpenSSL, and since it is a perl file
>> which generates a .S file, it may not be the best choice to
>> make too many code changes to such files, unless absolutely
>> necessary.
>> 
>> Second reason is that, at least as far as the objtool --mcount
>> functionality is concerned, we do not have to run objtool on
>> that file because that file does not have any calls to _mcount.
>> 
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>> ---
>>  drivers/crypto/vmx/Makefile | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
>> index 2560cfea1dec..7b41f0da6807 100644
>> --- a/drivers/crypto/vmx/Makefile
>> +++ b/drivers/crypto/vmx/Makefile
>> @@ -9,3 +9,5 @@ targets += aesp8-ppc.S ghashp8-ppc.S
>>  
>>  $(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
>>  	$(call if_changed,perl)
>> +
>> +OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y
> 
> Just be aware that the moment you start to run objtool on vmlinux.o this
> annotation becomes unstuck.
> 
> Specifically things like LTO builds require this because there simply
> isn't an object file before that.

Good point. LTO isn't supported today with ftrace on powerpc, so I guess 
we are ok with this patch for now.

To add LTO support, I guess we will need to add some annotations to this 
file later on.


- Naveen

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

* Re: [PATCH v2 05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
@ 2022-09-05 10:47       ` Naveen N. Rao
  0 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:47 UTC (permalink / raw)
  To: Peter Zijlstra, Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, mbenes, linuxppc-dev

Peter Zijlstra wrote:
> On Mon, Aug 29, 2022 at 11:22:12AM +0530, Sathvika Vasireddy wrote:
>> With objtool enabled, below warnings are seen when trying to build:
>> 
>> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
>> 
>> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2448: unannotated intra-function call
>> 
>> drivers/crypto/vmx/aesp8-ppc.o: warning: objtool: .text+0x2d68: unannotated intra-function call
>> 
>> Skip objtool from running on this file, for two main reasons:
>> 
>> Since this file comes from OpenSSL, and since it is a perl file
>> which generates a .S file, it may not be the best choice to
>> make too many code changes to such files, unless absolutely
>> necessary.
>> 
>> Second reason is that, at least as far as the objtool --mcount
>> functionality is concerned, we do not have to run objtool on
>> that file because that file does not have any calls to _mcount.
>> 
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>> ---
>>  drivers/crypto/vmx/Makefile | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
>> index 2560cfea1dec..7b41f0da6807 100644
>> --- a/drivers/crypto/vmx/Makefile
>> +++ b/drivers/crypto/vmx/Makefile
>> @@ -9,3 +9,5 @@ targets += aesp8-ppc.S ghashp8-ppc.S
>>  
>>  $(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
>>  	$(call if_changed,perl)
>> +
>> +OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y
> 
> Just be aware that the moment you start to run objtool on vmlinux.o this
> annotation becomes unstuck.
> 
> Specifically things like LTO builds require this because there simply
> isn't an object file before that.

Good point. LTO isn't supported today with ftrace on powerpc, so I guess 
we are ok with this patch for now.

To add LTO support, I guess we will need to add some annotations to this 
file later on.


- Naveen

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

* Re: [PATCH v2 11/16] objtool: Add --mnop as an option to --mcount
  2022-09-01 19:25     ` Peter Zijlstra
@ 2022-09-05 10:55       ` Naveen N. Rao
  -1 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:55 UTC (permalink / raw)
  To: Peter Zijlstra, Sathvika Vasireddy
  Cc: aik, chenzhongjin, christophe.leroy, jpoimboe, linux-kernel,
	linuxppc-dev, mbenes, mingo, mpe, npiggin, rostedt

Peter Zijlstra wrote:
> On Mon, Aug 29, 2022 at 11:22:18AM +0530, Sathvika Vasireddy wrote:
>> Architectures can select HAVE_NOP_MCOUNT if they choose
>> to nop out mcount call sites. If that config option is
>> selected, then --mnop is passed as an option to objtool,
>> along with --mcount.
>> 
>> Also, make sure that --mnop can be passed as an option
>> to objtool only when --mcount is passed.
>> 
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> 
> IIRC you want to nop the things yourself because PLT entries or
> something?

For two reasons:
1. We want to maintain a pointer to 'struct module' as part of the 
ftrace rec so that we can patch ftrace sites in modules to go to module 
stubs.
2. We depend on compiler generated long branches to support large 
kernels.

> 
> Anyway, patch looks fine, even though the Changelog doesn't relaly
> justify the change.

Sure. We should add that powerpc kernel does not support nop'ed out 
ftrace locations.

> 
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> 

Thanks,
Naveen

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

* Re: [PATCH v2 11/16] objtool: Add --mnop as an option to --mcount
@ 2022-09-05 10:55       ` Naveen N. Rao
  0 siblings, 0 replies; 128+ messages in thread
From: Naveen N. Rao @ 2022-09-05 10:55 UTC (permalink / raw)
  To: Peter Zijlstra, Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, mbenes, linuxppc-dev

Peter Zijlstra wrote:
> On Mon, Aug 29, 2022 at 11:22:18AM +0530, Sathvika Vasireddy wrote:
>> Architectures can select HAVE_NOP_MCOUNT if they choose
>> to nop out mcount call sites. If that config option is
>> selected, then --mnop is passed as an option to objtool,
>> along with --mcount.
>> 
>> Also, make sure that --mnop can be passed as an option
>> to objtool only when --mcount is passed.
>> 
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> 
> IIRC you want to nop the things yourself because PLT entries or
> something?

For two reasons:
1. We want to maintain a pointer to 'struct module' as part of the 
ftrace rec so that we can patch ftrace sites in modules to go to module 
stubs.
2. We depend on compiler generated long branches to support large 
kernels.

> 
> Anyway, patch looks fine, even though the Changelog doesn't relaly
> justify the change.

Sure. We should add that powerpc kernel does not support nop'ed out 
ftrace locations.

> 
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> 

Thanks,
Naveen

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

* Re: [PATCH v2 03/16] powerpc: Fix objtool unannotated intra-function call warnings
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-05 11:02     ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-05 11:02 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

On Mon, Aug 29, 2022 at 11:22:10AM +0530, Sathvika Vasireddy wrote:

> objtool does not add STT_NOTYPE symbols with size 0 to the

I suspect we can fix that once:

  https://lkml.kernel.org/r/20220902130949.789826745@infradead.org

lands.

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

* Re: [PATCH v2 03/16] powerpc: Fix objtool unannotated intra-function call warnings
@ 2022-09-05 11:02     ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-05 11:02 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

On Mon, Aug 29, 2022 at 11:22:10AM +0530, Sathvika Vasireddy wrote:

> objtool does not add STT_NOTYPE symbols with size 0 to the

I suspect we can fix that once:

  https://lkml.kernel.org/r/20220902130949.789826745@infradead.org

lands.

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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
  2022-08-29  5:52   ` Sathvika Vasireddy
@ 2022-09-05 11:03     ` Peter Zijlstra
  -1 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-05 11:03 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: linuxppc-dev, jpoimboe, linux-kernel, aik, mpe, mingo,
	christophe.leroy, rostedt, mbenes, npiggin, chenzhongjin,
	naveen.n.rao

On Mon, Aug 29, 2022 at 11:22:09AM +0530, Sathvika Vasireddy wrote:
> Powerpc instructions must be word-aligned. Currently,
> there is an alignment of 16 bytes (by default), and it is
> much more than what is required for powerpc (4 bytes).
> 
> The default expansion of __ALIGN() macro is:
> #define __ALIGN       .align 4,0x90
> 
> Since Powerpc Linux does not require a 16 byte alignment,
> override __ALIGN() and __ALIGN_STR() macros to use required
> 4 byte alignment.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>  arch/powerpc/include/asm/linkage.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
> index b71b9582e754..8df88fe61438 100644
> --- a/arch/powerpc/include/asm/linkage.h
> +++ b/arch/powerpc/include/asm/linkage.h
> @@ -2,8 +2,12 @@
>  #ifndef _ASM_POWERPC_LINKAGE_H
>  #define _ASM_POWERPC_LINKAGE_H
>  
> +#include <linux/stringify.h>
>  #include <asm/types.h>
>  
> +#define __ALIGN			.align 2
> +#define __ALIGN_STR		__stringify(__ALIGN)


Related thread:

  https://lkml.kernel.org/r/YxXJswK9QjhCGmPN@hirez.programming.kicks-ass.net

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

* Re: [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros
@ 2022-09-05 11:03     ` Peter Zijlstra
  0 siblings, 0 replies; 128+ messages in thread
From: Peter Zijlstra @ 2022-09-05 11:03 UTC (permalink / raw)
  To: Sathvika Vasireddy
  Cc: aik, chenzhongjin, npiggin, linux-kernel, mingo, rostedt,
	jpoimboe, naveen.n.rao, mbenes, linuxppc-dev

On Mon, Aug 29, 2022 at 11:22:09AM +0530, Sathvika Vasireddy wrote:
> Powerpc instructions must be word-aligned. Currently,
> there is an alignment of 16 bytes (by default), and it is
> much more than what is required for powerpc (4 bytes).
> 
> The default expansion of __ALIGN() macro is:
> #define __ALIGN       .align 4,0x90
> 
> Since Powerpc Linux does not require a 16 byte alignment,
> override __ALIGN() and __ALIGN_STR() macros to use required
> 4 byte alignment.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
>  arch/powerpc/include/asm/linkage.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/linkage.h b/arch/powerpc/include/asm/linkage.h
> index b71b9582e754..8df88fe61438 100644
> --- a/arch/powerpc/include/asm/linkage.h
> +++ b/arch/powerpc/include/asm/linkage.h
> @@ -2,8 +2,12 @@
>  #ifndef _ASM_POWERPC_LINKAGE_H
>  #define _ASM_POWERPC_LINKAGE_H
>  
> +#include <linux/stringify.h>
>  #include <asm/types.h>
>  
> +#define __ALIGN			.align 2
> +#define __ALIGN_STR		__stringify(__ALIGN)


Related thread:

  https://lkml.kernel.org/r/YxXJswK9QjhCGmPN@hirez.programming.kicks-ass.net

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
  2022-09-05 10:45         ` Naveen N. Rao
@ 2022-09-05 20:43           ` Segher Boessenkool
  -1 siblings, 0 replies; 128+ messages in thread
From: Segher Boessenkool @ 2022-09-05 20:43 UTC (permalink / raw)
  To: Naveen N. Rao
  Cc: aik, chenzhongjin, linux-kernel, peterz, mingo, rostedt, npiggin,
	jpoimboe, Sathvika Vasireddy, mbenes, linuxppc-dev

Hi!

On Mon, Sep 05, 2022 at 04:15:07PM +0530, Naveen N. Rao wrote:
> Segher Boessenkool wrote:
> >>> +		if ((insn & 3) == 1) {
> >>> +			*type = INSN_CALL;
> >>> +			*immediate = insn & 0x3fffffc;
> >>> +			if (*immediate & 0x2000000)
> >>> +				*immediate -= 0x4000000;
> >>> +		}
> >>> +		break;
> >>> +	}
> >
> >Does this handle AA=1 correctly at all?  That is valid both with and
> >without relocations, just like AA=0.  Same for AA=1 LK=0 btw.
> >
> >If you only handle AA=0, the code should explicitly test for that.
> 
> The code does test for AA=0 LK=1 with the if statement there?

Yes, but that is not what I said :-)

It may be fine to not *handle* AA=1 at all, but the code should at least
scream bloody murder when it encounters it anyway :-)


Segher

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
@ 2022-09-05 20:43           ` Segher Boessenkool
  0 siblings, 0 replies; 128+ messages in thread
From: Segher Boessenkool @ 2022-09-05 20:43 UTC (permalink / raw)
  To: Naveen N. Rao
  Cc: Christophe Leroy, aik, chenzhongjin, jpoimboe, linux-kernel,
	linuxppc-dev, mbenes, mingo, npiggin, peterz, rostedt,
	Sathvika Vasireddy

Hi!

On Mon, Sep 05, 2022 at 04:15:07PM +0530, Naveen N. Rao wrote:
> Segher Boessenkool wrote:
> >>> +		if ((insn & 3) == 1) {
> >>> +			*type = INSN_CALL;
> >>> +			*immediate = insn & 0x3fffffc;
> >>> +			if (*immediate & 0x2000000)
> >>> +				*immediate -= 0x4000000;
> >>> +		}
> >>> +		break;
> >>> +	}
> >
> >Does this handle AA=1 correctly at all?  That is valid both with and
> >without relocations, just like AA=0.  Same for AA=1 LK=0 btw.
> >
> >If you only handle AA=0, the code should explicitly test for that.
> 
> The code does test for AA=0 LK=1 with the if statement there?

Yes, but that is not what I said :-)

It may be fine to not *handle* AA=1 at all, but the code should at least
scream bloody murder when it encounters it anyway :-)


Segher

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
  2022-09-05 20:43           ` Segher Boessenkool
@ 2022-09-06  6:22             ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-09-06  6:22 UTC (permalink / raw)
  To: Segher Boessenkool, Naveen N. Rao
  Cc: aik, chenzhongjin, jpoimboe, linux-kernel, linuxppc-dev, mbenes,
	mingo, npiggin, peterz, rostedt, Sathvika Vasireddy



Le 05/09/2022 à 22:43, Segher Boessenkool a écrit :
> Hi!
> 
> On Mon, Sep 05, 2022 at 04:15:07PM +0530, Naveen N. Rao wrote:
>> Segher Boessenkool wrote:
>>>>> +		if ((insn & 3) == 1) {
>>>>> +			*type = INSN_CALL;
>>>>> +			*immediate = insn & 0x3fffffc;
>>>>> +			if (*immediate & 0x2000000)
>>>>> +				*immediate -= 0x4000000;
>>>>> +		}
>>>>> +		break;
>>>>> +	}
>>>
>>> Does this handle AA=1 correctly at all?  That is valid both with and
>>> without relocations, just like AA=0.  Same for AA=1 LK=0 btw.
>>>
>>> If you only handle AA=0, the code should explicitly test for that.
>>
>> The code does test for AA=0 LK=1 with the if statement there?
> 
> Yes, but that is not what I said :-)
> 
> It may be fine to not *handle* AA=1 at all, but the code should at least
> scream bloody murder when it encounters it anyway :-)
> 


By the way, I proposed a cleanup patch that handles it, see 
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/ebe11b73d1015a17034a2c4bedf093fa57f5d29f.1662032631.git.christophe.leroy@csgroup.eu/

Christophe

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

* Re: [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation
@ 2022-09-06  6:22             ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2022-09-06  6:22 UTC (permalink / raw)
  To: Segher Boessenkool, Naveen N. Rao
  Cc: aik, chenzhongjin, linux-kernel, npiggin, peterz, mingo,
	Sathvika Vasireddy, rostedt, jpoimboe, mbenes, linuxppc-dev



Le 05/09/2022 à 22:43, Segher Boessenkool a écrit :
> Hi!
> 
> On Mon, Sep 05, 2022 at 04:15:07PM +0530, Naveen N. Rao wrote:
>> Segher Boessenkool wrote:
>>>>> +		if ((insn & 3) == 1) {
>>>>> +			*type = INSN_CALL;
>>>>> +			*immediate = insn & 0x3fffffc;
>>>>> +			if (*immediate & 0x2000000)
>>>>> +				*immediate -= 0x4000000;
>>>>> +		}
>>>>> +		break;
>>>>> +	}
>>>
>>> Does this handle AA=1 correctly at all?  That is valid both with and
>>> without relocations, just like AA=0.  Same for AA=1 LK=0 btw.
>>>
>>> If you only handle AA=0, the code should explicitly test for that.
>>
>> The code does test for AA=0 LK=1 with the if statement there?
> 
> Yes, but that is not what I said :-)
> 
> It may be fine to not *handle* AA=1 at all, but the code should at least
> scream bloody murder when it encounters it anyway :-)
> 


By the way, I proposed a cleanup patch that handles it, see 
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/ebe11b73d1015a17034a2c4bedf093fa57f5d29f.1662032631.git.christophe.leroy@csgroup.eu/

Christophe

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2022-08-30  6:41     ` Christophe Leroy
@ 2023-02-04  8:19       ` Randy Dunlap
  -1 siblings, 0 replies; 128+ messages in thread
From: Randy Dunlap @ 2023-02-04  8:19 UTC (permalink / raw)
  To: Christophe Leroy, Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao, Elliott, Robert (Servers)

Hi--

On 8/29/22 23:41, Christophe Leroy wrote:
> 
> 
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> This patch adds [stub] implementations for required
>> functions, inorder to enable objtool build on powerpc.
> 
> Not all powerpc it seems, see below
> 

When cross-compiling PPC32 (on x86_64), I get 3600+ of these:

/bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
/bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
/bin/sh: line 1: ./tools/objtool/objtool: No such file or directory

Is there some way that objtool should work when cross-compiling?

Thanks.

>>
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>> [Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>>   arch/powerpc/Kconfig                          |  1 +
>>   arch/powerpc/include/asm/asm.h                |  7 ++
>>   tools/objtool/arch/powerpc/Build              |  2 +
>>   tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
>>   .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
>>   tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
>>   .../arch/powerpc/include/arch/special.h       | 21 ++++++
>>   tools/objtool/arch/powerpc/special.c          | 19 +++++
>>   8 files changed, 143 insertions(+)
>>   create mode 100644 arch/powerpc/include/asm/asm.h
>>   create mode 100644 tools/objtool/arch/powerpc/Build
>>   create mode 100644 tools/objtool/arch/powerpc/decode.c
>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
>>   create mode 100644 tools/objtool/arch/powerpc/special.c
>>
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 4c466acdc70d..dc05cd23c233 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -237,6 +237,7 @@ config PPC
>>   	select HAVE_MOD_ARCH_SPECIFIC
>>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>>   	select HAVE_OPTPROBES
>> +	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
> 
> Why restrict it to MPROFILE_KERNEL ? In your RFC it was for all PPC64.
> 
> Recent discussion on the list shows new problem with recordmcount, see 
> https://lore.kernel.org/all/MW5PR84MB184250EA1CAE04497C1E7CE9AB769@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM/
> 
> Those ones are with ppc64 big endian, so objtool would be welcome here 
> as well.
> 
>>   	select HAVE_PERF_EVENTS
>>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>>   	select HAVE_PERF_REGS
>> diff --git a/arch/powerpc/include/asm/asm.h b/arch/powerpc/include/asm/asm.h
>> new file mode 100644
>> index 000000000000..86f46b604e9a
>> --- /dev/null
>> +++ b/arch/powerpc/include/asm/asm.h
>> @@ -0,0 +1,7 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +#ifndef _ASM_POWERPC_ASM_H
>> +#define _ASM_POWERPC_ASM_H
>> +
>> +#define _ASM_PTR	" .long "
>> +
>> +#endif /* _ASM_POWERPC_ASM_H */
>> diff --git a/tools/objtool/arch/powerpc/Build b/tools/objtool/arch/powerpc/Build
>> new file mode 100644
>> index 000000000000..d24d5636a5b8
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/Build
>> @@ -0,0 +1,2 @@
>> +objtool-y += decode.o
>> +objtool-y += special.o
>> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
>> new file mode 100644
>> index 000000000000..8b6a14680da7
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/decode.c
>> @@ -0,0 +1,74 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +#include <objtool/check.h>
>> +#include <objtool/elf.h>
>> +#include <objtool/arch.h>
>> +#include <objtool/warn.h>
>> +#include <objtool/builtin.h>
>> +#include <objtool/endianness.h>
>> +
>> +unsigned long arch_dest_reloc_offset(int addend)
>> +{
>> +	return addend;
>> +}
>> +
>> +bool arch_callee_saved_reg(unsigned char reg)
>> +{
>> +	return false;
>> +}
>> +
>> +int arch_decode_hint_reg(u8 sp_reg, int *base)
>> +{
>> +	exit(-1);
>> +}
>> +
>> +const char *arch_nop_insn(int len)
>> +{
>> +	exit(-1);
>> +}
>> +
>> +const char *arch_ret_insn(int len)
>> +{
>> +	exit(-1);
>> +}
>> +
>> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
>> +			    unsigned long offset, unsigned int maxlen,
>> +			    unsigned int *len, enum insn_type *type,
>> +			    unsigned long *immediate,
>> +			    struct list_head *ops_list)
>> +{
>> +	u32 insn;
>> +
>> +	*immediate = 0;
>> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>> +	*len = 4;
>> +	*type = INSN_OTHER;
>> +
>> +	return 0;
>> +}
>> +
>> +unsigned long arch_jump_destination(struct instruction *insn)
>> +{
>> +	return insn->offset +  insn->immediate;
>> +}
>> +
>> +void arch_initial_func_cfi_state(struct cfi_init_state *state)
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < CFI_NUM_REGS; i++) {
>> +		state->regs[i].base = CFI_UNDEFINED;
>> +		state->regs[i].offset = 0;
>> +	}
>> +
>> +	/* initial CFA (call frame address) */
>> +	state->cfa.base = CFI_SP;
>> +	state->cfa.offset = 0;
>> +
>> +	/* initial LR (return address) */
>> +	state->regs[CFI_RA].base = CFI_CFA;
>> +	state->regs[CFI_RA].offset = 0;
>> +}
>> diff --git a/tools/objtool/arch/powerpc/include/arch/cfi_regs.h b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>> new file mode 100644
>> index 000000000000..59638ebeafc8
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>> @@ -0,0 +1,11 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +
>> +#ifndef _OBJTOOL_CFI_REGS_H
>> +#define _OBJTOOL_CFI_REGS_H
>> +
>> +#define CFI_BP 1
>> +#define CFI_SP CFI_BP
>> +#define CFI_RA 32
>> +#define CFI_NUM_REGS 33
>> +
>> +#endif
>> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
>> new file mode 100644
>> index 000000000000..3c8ebb7d2a6b
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
>> @@ -0,0 +1,8 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +
>> +#ifndef _OBJTOOL_ARCH_ELF
>> +#define _OBJTOOL_ARCH_ELF
>> +
>> +#define R_NONE R_PPC_NONE
>> +
>> +#endif /* _OBJTOOL_ARCH_ELF */
>> diff --git a/tools/objtool/arch/powerpc/include/arch/special.h b/tools/objtool/arch/powerpc/include/arch/special.h
>> new file mode 100644
>> index 000000000000..ffef9ada7133
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/include/arch/special.h
>> @@ -0,0 +1,21 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +#ifndef _PPC_ARCH_SPECIAL_H
>> +#define _PPC_ARCH_SPECIAL_H
>> +
>> +#define EX_ENTRY_SIZE 8
>> +#define EX_ORIG_OFFSET 0
>> +#define EX_NEW_OFFSET 4
>> +
>> +#define JUMP_ENTRY_SIZE 16
>> +#define JUMP_ORIG_OFFSET 0
>> +#define JUMP_NEW_OFFSET 4
>> +#define JUMP_KEY_OFFSET 8
>> +
>> +#define ALT_ENTRY_SIZE 12
>> +#define ALT_ORIG_OFFSET 0
>> +#define ALT_NEW_OFFSET 4
>> +#define ALT_FEATURE_OFFSET 8
>> +#define ALT_ORIG_LEN_OFFSET 10
>> +#define ALT_NEW_LEN_OFFSET 11
>> +
>> +#endif /* _PPC_ARCH_SPECIAL_H */
>> diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
>> new file mode 100644
>> index 000000000000..d33868147196
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/special.c
>> @@ -0,0 +1,19 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +#include <string.h>
>> +#include <stdlib.h>
>> +#include <objtool/special.h>
>> +#include <objtool/builtin.h>
>> +
>> +
>> +bool arch_support_alt_relocation(struct special_alt *special_alt,
>> +				 struct instruction *insn,
>> +				 struct reloc *reloc)
>> +{
>> +	exit(-1);
>> +}
>> +
>> +struct reloc *arch_find_switch_table(struct objtool_file *file,
>> +				    struct instruction *insn)
>> +{
>> +	exit(-1);
>> +}

-- 
~Randy

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2023-02-04  8:19       ` Randy Dunlap
  0 siblings, 0 replies; 128+ messages in thread
From: Randy Dunlap @ 2023-02-04  8:19 UTC (permalink / raw)
  To: Christophe Leroy, Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin, Elliott, Robert (Servers)

Hi--

On 8/29/22 23:41, Christophe Leroy wrote:
> 
> 
> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>> This patch adds [stub] implementations for required
>> functions, inorder to enable objtool build on powerpc.
> 
> Not all powerpc it seems, see below
> 

When cross-compiling PPC32 (on x86_64), I get 3600+ of these:

/bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
/bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
/bin/sh: line 1: ./tools/objtool/objtool: No such file or directory

Is there some way that objtool should work when cross-compiling?

Thanks.

>>
>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>> [Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>>   arch/powerpc/Kconfig                          |  1 +
>>   arch/powerpc/include/asm/asm.h                |  7 ++
>>   tools/objtool/arch/powerpc/Build              |  2 +
>>   tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
>>   .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
>>   tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
>>   .../arch/powerpc/include/arch/special.h       | 21 ++++++
>>   tools/objtool/arch/powerpc/special.c          | 19 +++++
>>   8 files changed, 143 insertions(+)
>>   create mode 100644 arch/powerpc/include/asm/asm.h
>>   create mode 100644 tools/objtool/arch/powerpc/Build
>>   create mode 100644 tools/objtool/arch/powerpc/decode.c
>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
>>   create mode 100644 tools/objtool/arch/powerpc/special.c
>>
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 4c466acdc70d..dc05cd23c233 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -237,6 +237,7 @@ config PPC
>>   	select HAVE_MOD_ARCH_SPECIFIC
>>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>>   	select HAVE_OPTPROBES
>> +	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
> 
> Why restrict it to MPROFILE_KERNEL ? In your RFC it was for all PPC64.
> 
> Recent discussion on the list shows new problem with recordmcount, see 
> https://lore.kernel.org/all/MW5PR84MB184250EA1CAE04497C1E7CE9AB769@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM/
> 
> Those ones are with ppc64 big endian, so objtool would be welcome here 
> as well.
> 
>>   	select HAVE_PERF_EVENTS
>>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>>   	select HAVE_PERF_REGS
>> diff --git a/arch/powerpc/include/asm/asm.h b/arch/powerpc/include/asm/asm.h
>> new file mode 100644
>> index 000000000000..86f46b604e9a
>> --- /dev/null
>> +++ b/arch/powerpc/include/asm/asm.h
>> @@ -0,0 +1,7 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +#ifndef _ASM_POWERPC_ASM_H
>> +#define _ASM_POWERPC_ASM_H
>> +
>> +#define _ASM_PTR	" .long "
>> +
>> +#endif /* _ASM_POWERPC_ASM_H */
>> diff --git a/tools/objtool/arch/powerpc/Build b/tools/objtool/arch/powerpc/Build
>> new file mode 100644
>> index 000000000000..d24d5636a5b8
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/Build
>> @@ -0,0 +1,2 @@
>> +objtool-y += decode.o
>> +objtool-y += special.o
>> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
>> new file mode 100644
>> index 000000000000..8b6a14680da7
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/decode.c
>> @@ -0,0 +1,74 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +#include <objtool/check.h>
>> +#include <objtool/elf.h>
>> +#include <objtool/arch.h>
>> +#include <objtool/warn.h>
>> +#include <objtool/builtin.h>
>> +#include <objtool/endianness.h>
>> +
>> +unsigned long arch_dest_reloc_offset(int addend)
>> +{
>> +	return addend;
>> +}
>> +
>> +bool arch_callee_saved_reg(unsigned char reg)
>> +{
>> +	return false;
>> +}
>> +
>> +int arch_decode_hint_reg(u8 sp_reg, int *base)
>> +{
>> +	exit(-1);
>> +}
>> +
>> +const char *arch_nop_insn(int len)
>> +{
>> +	exit(-1);
>> +}
>> +
>> +const char *arch_ret_insn(int len)
>> +{
>> +	exit(-1);
>> +}
>> +
>> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
>> +			    unsigned long offset, unsigned int maxlen,
>> +			    unsigned int *len, enum insn_type *type,
>> +			    unsigned long *immediate,
>> +			    struct list_head *ops_list)
>> +{
>> +	u32 insn;
>> +
>> +	*immediate = 0;
>> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>> +	*len = 4;
>> +	*type = INSN_OTHER;
>> +
>> +	return 0;
>> +}
>> +
>> +unsigned long arch_jump_destination(struct instruction *insn)
>> +{
>> +	return insn->offset +  insn->immediate;
>> +}
>> +
>> +void arch_initial_func_cfi_state(struct cfi_init_state *state)
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < CFI_NUM_REGS; i++) {
>> +		state->regs[i].base = CFI_UNDEFINED;
>> +		state->regs[i].offset = 0;
>> +	}
>> +
>> +	/* initial CFA (call frame address) */
>> +	state->cfa.base = CFI_SP;
>> +	state->cfa.offset = 0;
>> +
>> +	/* initial LR (return address) */
>> +	state->regs[CFI_RA].base = CFI_CFA;
>> +	state->regs[CFI_RA].offset = 0;
>> +}
>> diff --git a/tools/objtool/arch/powerpc/include/arch/cfi_regs.h b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>> new file mode 100644
>> index 000000000000..59638ebeafc8
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>> @@ -0,0 +1,11 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +
>> +#ifndef _OBJTOOL_CFI_REGS_H
>> +#define _OBJTOOL_CFI_REGS_H
>> +
>> +#define CFI_BP 1
>> +#define CFI_SP CFI_BP
>> +#define CFI_RA 32
>> +#define CFI_NUM_REGS 33
>> +
>> +#endif
>> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
>> new file mode 100644
>> index 000000000000..3c8ebb7d2a6b
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
>> @@ -0,0 +1,8 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +
>> +#ifndef _OBJTOOL_ARCH_ELF
>> +#define _OBJTOOL_ARCH_ELF
>> +
>> +#define R_NONE R_PPC_NONE
>> +
>> +#endif /* _OBJTOOL_ARCH_ELF */
>> diff --git a/tools/objtool/arch/powerpc/include/arch/special.h b/tools/objtool/arch/powerpc/include/arch/special.h
>> new file mode 100644
>> index 000000000000..ffef9ada7133
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/include/arch/special.h
>> @@ -0,0 +1,21 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +#ifndef _PPC_ARCH_SPECIAL_H
>> +#define _PPC_ARCH_SPECIAL_H
>> +
>> +#define EX_ENTRY_SIZE 8
>> +#define EX_ORIG_OFFSET 0
>> +#define EX_NEW_OFFSET 4
>> +
>> +#define JUMP_ENTRY_SIZE 16
>> +#define JUMP_ORIG_OFFSET 0
>> +#define JUMP_NEW_OFFSET 4
>> +#define JUMP_KEY_OFFSET 8
>> +
>> +#define ALT_ENTRY_SIZE 12
>> +#define ALT_ORIG_OFFSET 0
>> +#define ALT_NEW_OFFSET 4
>> +#define ALT_FEATURE_OFFSET 8
>> +#define ALT_ORIG_LEN_OFFSET 10
>> +#define ALT_NEW_LEN_OFFSET 11
>> +
>> +#endif /* _PPC_ARCH_SPECIAL_H */
>> diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
>> new file mode 100644
>> index 000000000000..d33868147196
>> --- /dev/null
>> +++ b/tools/objtool/arch/powerpc/special.c
>> @@ -0,0 +1,19 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +#include <string.h>
>> +#include <stdlib.h>
>> +#include <objtool/special.h>
>> +#include <objtool/builtin.h>
>> +
>> +
>> +bool arch_support_alt_relocation(struct special_alt *special_alt,
>> +				 struct instruction *insn,
>> +				 struct reloc *reloc)
>> +{
>> +	exit(-1);
>> +}
>> +
>> +struct reloc *arch_find_switch_table(struct objtool_file *file,
>> +				    struct instruction *insn)
>> +{
>> +	exit(-1);
>> +}

-- 
~Randy

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2023-02-04  8:19       ` Randy Dunlap
@ 2023-02-04  8:21         ` Randy Dunlap
  -1 siblings, 0 replies; 128+ messages in thread
From: Randy Dunlap @ 2023-02-04  8:21 UTC (permalink / raw)
  To: Christophe Leroy, Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao, Elliott, Robert (Servers)



On 2/4/23 00:19, Randy Dunlap wrote:
> Hi--
> 
> On 8/29/22 23:41, Christophe Leroy wrote:
>>
>>
>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>> This patch adds [stub] implementations for required
>>> functions, inorder to enable objtool build on powerpc.
>>
>> Not all powerpc it seems, see below
>>
> 
> When cross-compiling PPC32 (on x86_64), I get 3600+ of these:
> 
> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
> 
> Is there some way that objtool should work when cross-compiling?
> 

Oops. Its build failed. I seem to be missing header file(s)
and possibly a library.
I'll check on those...

Cheers.

> 
>>>
>>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>>> [Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
>>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>>> ---
>>>   arch/powerpc/Kconfig                          |  1 +
>>>   arch/powerpc/include/asm/asm.h                |  7 ++
>>>   tools/objtool/arch/powerpc/Build              |  2 +
>>>   tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
>>>   .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
>>>   tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
>>>   .../arch/powerpc/include/arch/special.h       | 21 ++++++
>>>   tools/objtool/arch/powerpc/special.c          | 19 +++++
>>>   8 files changed, 143 insertions(+)
>>>   create mode 100644 arch/powerpc/include/asm/asm.h
>>>   create mode 100644 tools/objtool/arch/powerpc/Build
>>>   create mode 100644 tools/objtool/arch/powerpc/decode.c
>>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
>>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
>>>   create mode 100644 tools/objtool/arch/powerpc/special.c
>>>
>>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>>> index 4c466acdc70d..dc05cd23c233 100644
>>> --- a/arch/powerpc/Kconfig
>>> +++ b/arch/powerpc/Kconfig
>>> @@ -237,6 +237,7 @@ config PPC
>>>   	select HAVE_MOD_ARCH_SPECIFIC
>>>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>>>   	select HAVE_OPTPROBES
>>> +	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
>>
>> Why restrict it to MPROFILE_KERNEL ? In your RFC it was for all PPC64.
>>
>> Recent discussion on the list shows new problem with recordmcount, see 
>> https://lore.kernel.org/all/MW5PR84MB184250EA1CAE04497C1E7CE9AB769@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM/
>>
>> Those ones are with ppc64 big endian, so objtool would be welcome here 
>> as well.
>>
>>>   	select HAVE_PERF_EVENTS
>>>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>>>   	select HAVE_PERF_REGS
>>> diff --git a/arch/powerpc/include/asm/asm.h b/arch/powerpc/include/asm/asm.h
>>> new file mode 100644
>>> index 000000000000..86f46b604e9a
>>> --- /dev/null
>>> +++ b/arch/powerpc/include/asm/asm.h
>>> @@ -0,0 +1,7 @@
>>> +/* SPDX-License-Identifier: GPL-2.0 */
>>> +#ifndef _ASM_POWERPC_ASM_H
>>> +#define _ASM_POWERPC_ASM_H
>>> +
>>> +#define _ASM_PTR	" .long "
>>> +
>>> +#endif /* _ASM_POWERPC_ASM_H */
>>> diff --git a/tools/objtool/arch/powerpc/Build b/tools/objtool/arch/powerpc/Build
>>> new file mode 100644
>>> index 000000000000..d24d5636a5b8
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/Build
>>> @@ -0,0 +1,2 @@
>>> +objtool-y += decode.o
>>> +objtool-y += special.o
>>> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
>>> new file mode 100644
>>> index 000000000000..8b6a14680da7
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/decode.c
>>> @@ -0,0 +1,74 @@
>>> +// SPDX-License-Identifier: GPL-2.0-or-later
>>> +
>>> +#include <stdio.h>
>>> +#include <stdlib.h>
>>> +#include <objtool/check.h>
>>> +#include <objtool/elf.h>
>>> +#include <objtool/arch.h>
>>> +#include <objtool/warn.h>
>>> +#include <objtool/builtin.h>
>>> +#include <objtool/endianness.h>
>>> +
>>> +unsigned long arch_dest_reloc_offset(int addend)
>>> +{
>>> +	return addend;
>>> +}
>>> +
>>> +bool arch_callee_saved_reg(unsigned char reg)
>>> +{
>>> +	return false;
>>> +}
>>> +
>>> +int arch_decode_hint_reg(u8 sp_reg, int *base)
>>> +{
>>> +	exit(-1);
>>> +}
>>> +
>>> +const char *arch_nop_insn(int len)
>>> +{
>>> +	exit(-1);
>>> +}
>>> +
>>> +const char *arch_ret_insn(int len)
>>> +{
>>> +	exit(-1);
>>> +}
>>> +
>>> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
>>> +			    unsigned long offset, unsigned int maxlen,
>>> +			    unsigned int *len, enum insn_type *type,
>>> +			    unsigned long *immediate,
>>> +			    struct list_head *ops_list)
>>> +{
>>> +	u32 insn;
>>> +
>>> +	*immediate = 0;
>>> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>>> +	*len = 4;
>>> +	*type = INSN_OTHER;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +unsigned long arch_jump_destination(struct instruction *insn)
>>> +{
>>> +	return insn->offset +  insn->immediate;
>>> +}
>>> +
>>> +void arch_initial_func_cfi_state(struct cfi_init_state *state)
>>> +{
>>> +	int i;
>>> +
>>> +	for (i = 0; i < CFI_NUM_REGS; i++) {
>>> +		state->regs[i].base = CFI_UNDEFINED;
>>> +		state->regs[i].offset = 0;
>>> +	}
>>> +
>>> +	/* initial CFA (call frame address) */
>>> +	state->cfa.base = CFI_SP;
>>> +	state->cfa.offset = 0;
>>> +
>>> +	/* initial LR (return address) */
>>> +	state->regs[CFI_RA].base = CFI_CFA;
>>> +	state->regs[CFI_RA].offset = 0;
>>> +}
>>> diff --git a/tools/objtool/arch/powerpc/include/arch/cfi_regs.h b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>>> new file mode 100644
>>> index 000000000000..59638ebeafc8
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>>> @@ -0,0 +1,11 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>>> +
>>> +#ifndef _OBJTOOL_CFI_REGS_H
>>> +#define _OBJTOOL_CFI_REGS_H
>>> +
>>> +#define CFI_BP 1
>>> +#define CFI_SP CFI_BP
>>> +#define CFI_RA 32
>>> +#define CFI_NUM_REGS 33
>>> +
>>> +#endif
>>> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
>>> new file mode 100644
>>> index 000000000000..3c8ebb7d2a6b
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
>>> @@ -0,0 +1,8 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>>> +
>>> +#ifndef _OBJTOOL_ARCH_ELF
>>> +#define _OBJTOOL_ARCH_ELF
>>> +
>>> +#define R_NONE R_PPC_NONE
>>> +
>>> +#endif /* _OBJTOOL_ARCH_ELF */
>>> diff --git a/tools/objtool/arch/powerpc/include/arch/special.h b/tools/objtool/arch/powerpc/include/arch/special.h
>>> new file mode 100644
>>> index 000000000000..ffef9ada7133
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/include/arch/special.h
>>> @@ -0,0 +1,21 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>>> +#ifndef _PPC_ARCH_SPECIAL_H
>>> +#define _PPC_ARCH_SPECIAL_H
>>> +
>>> +#define EX_ENTRY_SIZE 8
>>> +#define EX_ORIG_OFFSET 0
>>> +#define EX_NEW_OFFSET 4
>>> +
>>> +#define JUMP_ENTRY_SIZE 16
>>> +#define JUMP_ORIG_OFFSET 0
>>> +#define JUMP_NEW_OFFSET 4
>>> +#define JUMP_KEY_OFFSET 8
>>> +
>>> +#define ALT_ENTRY_SIZE 12
>>> +#define ALT_ORIG_OFFSET 0
>>> +#define ALT_NEW_OFFSET 4
>>> +#define ALT_FEATURE_OFFSET 8
>>> +#define ALT_ORIG_LEN_OFFSET 10
>>> +#define ALT_NEW_LEN_OFFSET 11
>>> +
>>> +#endif /* _PPC_ARCH_SPECIAL_H */
>>> diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
>>> new file mode 100644
>>> index 000000000000..d33868147196
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/special.c
>>> @@ -0,0 +1,19 @@
>>> +// SPDX-License-Identifier: GPL-2.0-or-later
>>> +#include <string.h>
>>> +#include <stdlib.h>
>>> +#include <objtool/special.h>
>>> +#include <objtool/builtin.h>
>>> +
>>> +
>>> +bool arch_support_alt_relocation(struct special_alt *special_alt,
>>> +				 struct instruction *insn,
>>> +				 struct reloc *reloc)
>>> +{
>>> +	exit(-1);
>>> +}
>>> +
>>> +struct reloc *arch_find_switch_table(struct objtool_file *file,
>>> +				    struct instruction *insn)
>>> +{
>>> +	exit(-1);
>>> +}
> 

-- 
~Randy

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2023-02-04  8:21         ` Randy Dunlap
  0 siblings, 0 replies; 128+ messages in thread
From: Randy Dunlap @ 2023-02-04  8:21 UTC (permalink / raw)
  To: Christophe Leroy, Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin, Elliott, Robert (Servers)



On 2/4/23 00:19, Randy Dunlap wrote:
> Hi--
> 
> On 8/29/22 23:41, Christophe Leroy wrote:
>>
>>
>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>> This patch adds [stub] implementations for required
>>> functions, inorder to enable objtool build on powerpc.
>>
>> Not all powerpc it seems, see below
>>
> 
> When cross-compiling PPC32 (on x86_64), I get 3600+ of these:
> 
> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
> 
> Is there some way that objtool should work when cross-compiling?
> 

Oops. Its build failed. I seem to be missing header file(s)
and possibly a library.
I'll check on those...

Cheers.

> 
>>>
>>> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
>>> [Christophe Leroy: powerpc: Add missing asm/asm.h for objtool]
>>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>>> ---
>>>   arch/powerpc/Kconfig                          |  1 +
>>>   arch/powerpc/include/asm/asm.h                |  7 ++
>>>   tools/objtool/arch/powerpc/Build              |  2 +
>>>   tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
>>>   .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
>>>   tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
>>>   .../arch/powerpc/include/arch/special.h       | 21 ++++++
>>>   tools/objtool/arch/powerpc/special.c          | 19 +++++
>>>   8 files changed, 143 insertions(+)
>>>   create mode 100644 arch/powerpc/include/asm/asm.h
>>>   create mode 100644 tools/objtool/arch/powerpc/Build
>>>   create mode 100644 tools/objtool/arch/powerpc/decode.c
>>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
>>>   create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
>>>   create mode 100644 tools/objtool/arch/powerpc/special.c
>>>
>>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>>> index 4c466acdc70d..dc05cd23c233 100644
>>> --- a/arch/powerpc/Kconfig
>>> +++ b/arch/powerpc/Kconfig
>>> @@ -237,6 +237,7 @@ config PPC
>>>   	select HAVE_MOD_ARCH_SPECIFIC
>>>   	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
>>>   	select HAVE_OPTPROBES
>>> +	select HAVE_OBJTOOL			if PPC32 || MPROFILE_KERNEL
>>
>> Why restrict it to MPROFILE_KERNEL ? In your RFC it was for all PPC64.
>>
>> Recent discussion on the list shows new problem with recordmcount, see 
>> https://lore.kernel.org/all/MW5PR84MB184250EA1CAE04497C1E7CE9AB769@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM/
>>
>> Those ones are with ppc64 big endian, so objtool would be welcome here 
>> as well.
>>
>>>   	select HAVE_PERF_EVENTS
>>>   	select HAVE_PERF_EVENTS_NMI		if PPC64
>>>   	select HAVE_PERF_REGS
>>> diff --git a/arch/powerpc/include/asm/asm.h b/arch/powerpc/include/asm/asm.h
>>> new file mode 100644
>>> index 000000000000..86f46b604e9a
>>> --- /dev/null
>>> +++ b/arch/powerpc/include/asm/asm.h
>>> @@ -0,0 +1,7 @@
>>> +/* SPDX-License-Identifier: GPL-2.0 */
>>> +#ifndef _ASM_POWERPC_ASM_H
>>> +#define _ASM_POWERPC_ASM_H
>>> +
>>> +#define _ASM_PTR	" .long "
>>> +
>>> +#endif /* _ASM_POWERPC_ASM_H */
>>> diff --git a/tools/objtool/arch/powerpc/Build b/tools/objtool/arch/powerpc/Build
>>> new file mode 100644
>>> index 000000000000..d24d5636a5b8
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/Build
>>> @@ -0,0 +1,2 @@
>>> +objtool-y += decode.o
>>> +objtool-y += special.o
>>> diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
>>> new file mode 100644
>>> index 000000000000..8b6a14680da7
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/decode.c
>>> @@ -0,0 +1,74 @@
>>> +// SPDX-License-Identifier: GPL-2.0-or-later
>>> +
>>> +#include <stdio.h>
>>> +#include <stdlib.h>
>>> +#include <objtool/check.h>
>>> +#include <objtool/elf.h>
>>> +#include <objtool/arch.h>
>>> +#include <objtool/warn.h>
>>> +#include <objtool/builtin.h>
>>> +#include <objtool/endianness.h>
>>> +
>>> +unsigned long arch_dest_reloc_offset(int addend)
>>> +{
>>> +	return addend;
>>> +}
>>> +
>>> +bool arch_callee_saved_reg(unsigned char reg)
>>> +{
>>> +	return false;
>>> +}
>>> +
>>> +int arch_decode_hint_reg(u8 sp_reg, int *base)
>>> +{
>>> +	exit(-1);
>>> +}
>>> +
>>> +const char *arch_nop_insn(int len)
>>> +{
>>> +	exit(-1);
>>> +}
>>> +
>>> +const char *arch_ret_insn(int len)
>>> +{
>>> +	exit(-1);
>>> +}
>>> +
>>> +int arch_decode_instruction(struct objtool_file *file, const struct section *sec,
>>> +			    unsigned long offset, unsigned int maxlen,
>>> +			    unsigned int *len, enum insn_type *type,
>>> +			    unsigned long *immediate,
>>> +			    struct list_head *ops_list)
>>> +{
>>> +	u32 insn;
>>> +
>>> +	*immediate = 0;
>>> +	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
>>> +	*len = 4;
>>> +	*type = INSN_OTHER;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +unsigned long arch_jump_destination(struct instruction *insn)
>>> +{
>>> +	return insn->offset +  insn->immediate;
>>> +}
>>> +
>>> +void arch_initial_func_cfi_state(struct cfi_init_state *state)
>>> +{
>>> +	int i;
>>> +
>>> +	for (i = 0; i < CFI_NUM_REGS; i++) {
>>> +		state->regs[i].base = CFI_UNDEFINED;
>>> +		state->regs[i].offset = 0;
>>> +	}
>>> +
>>> +	/* initial CFA (call frame address) */
>>> +	state->cfa.base = CFI_SP;
>>> +	state->cfa.offset = 0;
>>> +
>>> +	/* initial LR (return address) */
>>> +	state->regs[CFI_RA].base = CFI_CFA;
>>> +	state->regs[CFI_RA].offset = 0;
>>> +}
>>> diff --git a/tools/objtool/arch/powerpc/include/arch/cfi_regs.h b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>>> new file mode 100644
>>> index 000000000000..59638ebeafc8
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/include/arch/cfi_regs.h
>>> @@ -0,0 +1,11 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>>> +
>>> +#ifndef _OBJTOOL_CFI_REGS_H
>>> +#define _OBJTOOL_CFI_REGS_H
>>> +
>>> +#define CFI_BP 1
>>> +#define CFI_SP CFI_BP
>>> +#define CFI_RA 32
>>> +#define CFI_NUM_REGS 33
>>> +
>>> +#endif
>>> diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h
>>> new file mode 100644
>>> index 000000000000..3c8ebb7d2a6b
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/include/arch/elf.h
>>> @@ -0,0 +1,8 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>>> +
>>> +#ifndef _OBJTOOL_ARCH_ELF
>>> +#define _OBJTOOL_ARCH_ELF
>>> +
>>> +#define R_NONE R_PPC_NONE
>>> +
>>> +#endif /* _OBJTOOL_ARCH_ELF */
>>> diff --git a/tools/objtool/arch/powerpc/include/arch/special.h b/tools/objtool/arch/powerpc/include/arch/special.h
>>> new file mode 100644
>>> index 000000000000..ffef9ada7133
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/include/arch/special.h
>>> @@ -0,0 +1,21 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>>> +#ifndef _PPC_ARCH_SPECIAL_H
>>> +#define _PPC_ARCH_SPECIAL_H
>>> +
>>> +#define EX_ENTRY_SIZE 8
>>> +#define EX_ORIG_OFFSET 0
>>> +#define EX_NEW_OFFSET 4
>>> +
>>> +#define JUMP_ENTRY_SIZE 16
>>> +#define JUMP_ORIG_OFFSET 0
>>> +#define JUMP_NEW_OFFSET 4
>>> +#define JUMP_KEY_OFFSET 8
>>> +
>>> +#define ALT_ENTRY_SIZE 12
>>> +#define ALT_ORIG_OFFSET 0
>>> +#define ALT_NEW_OFFSET 4
>>> +#define ALT_FEATURE_OFFSET 8
>>> +#define ALT_ORIG_LEN_OFFSET 10
>>> +#define ALT_NEW_LEN_OFFSET 11
>>> +
>>> +#endif /* _PPC_ARCH_SPECIAL_H */
>>> diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
>>> new file mode 100644
>>> index 000000000000..d33868147196
>>> --- /dev/null
>>> +++ b/tools/objtool/arch/powerpc/special.c
>>> @@ -0,0 +1,19 @@
>>> +// SPDX-License-Identifier: GPL-2.0-or-later
>>> +#include <string.h>
>>> +#include <stdlib.h>
>>> +#include <objtool/special.h>
>>> +#include <objtool/builtin.h>
>>> +
>>> +
>>> +bool arch_support_alt_relocation(struct special_alt *special_alt,
>>> +				 struct instruction *insn,
>>> +				 struct reloc *reloc)
>>> +{
>>> +	exit(-1);
>>> +}
>>> +
>>> +struct reloc *arch_find_switch_table(struct objtool_file *file,
>>> +				    struct instruction *insn)
>>> +{
>>> +	exit(-1);
>>> +}
> 

-- 
~Randy

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2023-02-04  8:21         ` Randy Dunlap
@ 2023-02-04  8:30           ` Randy Dunlap
  -1 siblings, 0 replies; 128+ messages in thread
From: Randy Dunlap @ 2023-02-04  8:30 UTC (permalink / raw)
  To: Christophe Leroy, Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao, Elliott, Robert (Servers)



On 2/4/23 00:21, Randy Dunlap wrote:
> 
> 
> On 2/4/23 00:19, Randy Dunlap wrote:
>> Hi--
>>
>> On 8/29/22 23:41, Christophe Leroy wrote:
>>>
>>>
>>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>>> This patch adds [stub] implementations for required
>>>> functions, inorder to enable objtool build on powerpc.
>>>
>>> Not all powerpc it seems, see below
>>>
>>
>> When cross-compiling PPC32 (on x86_64), I get 3600+ of these:
>>
>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>
>> Is there some way that objtool should work when cross-compiling?
>>
> 
> Oops. Its build failed. I seem to be missing header file(s)
> and possibly a library.
> I'll check on those...
> 

It's complaining about libelf.h but I have that, so I don't know where
it is looking other than /usr/include/libelf.h, which exists.
Maybe the tool isn't setup (ready) for cross-compiling?


Here's the build output for objtool:

<stdin>:1:10: fatal error: libelf.h: No such file or directory
compilation terminated.
elf.c: In function ‘read_sections’:
elf.c:273:9: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations]
  273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
      |         ^~
In file included from /usr/include/gelf.h:32,
                 from /work/lnx/next/linux-next-20230203/tools/objtool/include/objtool/elf.h:10,
                 from elf.c:22:
/usr/include/libelf.h:310:12: note: declared here
  310 | extern int elf_getshnum (Elf *__elf, size_t *__dst)
      |            ^~~~~~~~~~~~
elf.c:278:9: error: ‘elf_getshstrndx’ is deprecated [-Werror=deprecated-declarations]
  278 |         if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
      |         ^~
/usr/include/libelf.h:322:12: note: declared here
  322 | extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
      |            ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[4]: *** [/work/lnx/next/linux-next-20230203/tools/build/Makefile.build:96: /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/elf.o] Error 1

make[3]: *** [Makefile:66: /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/objtool-in.o] Error 2


Thanks.
-- 
~Randy

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2023-02-04  8:30           ` Randy Dunlap
  0 siblings, 0 replies; 128+ messages in thread
From: Randy Dunlap @ 2023-02-04  8:30 UTC (permalink / raw)
  To: Christophe Leroy, Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin, Elliott, Robert (Servers)



On 2/4/23 00:21, Randy Dunlap wrote:
> 
> 
> On 2/4/23 00:19, Randy Dunlap wrote:
>> Hi--
>>
>> On 8/29/22 23:41, Christophe Leroy wrote:
>>>
>>>
>>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>>> This patch adds [stub] implementations for required
>>>> functions, inorder to enable objtool build on powerpc.
>>>
>>> Not all powerpc it seems, see below
>>>
>>
>> When cross-compiling PPC32 (on x86_64), I get 3600+ of these:
>>
>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>
>> Is there some way that objtool should work when cross-compiling?
>>
> 
> Oops. Its build failed. I seem to be missing header file(s)
> and possibly a library.
> I'll check on those...
> 

It's complaining about libelf.h but I have that, so I don't know where
it is looking other than /usr/include/libelf.h, which exists.
Maybe the tool isn't setup (ready) for cross-compiling?


Here's the build output for objtool:

<stdin>:1:10: fatal error: libelf.h: No such file or directory
compilation terminated.
elf.c: In function ‘read_sections’:
elf.c:273:9: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations]
  273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
      |         ^~
In file included from /usr/include/gelf.h:32,
                 from /work/lnx/next/linux-next-20230203/tools/objtool/include/objtool/elf.h:10,
                 from elf.c:22:
/usr/include/libelf.h:310:12: note: declared here
  310 | extern int elf_getshnum (Elf *__elf, size_t *__dst)
      |            ^~~~~~~~~~~~
elf.c:278:9: error: ‘elf_getshstrndx’ is deprecated [-Werror=deprecated-declarations]
  278 |         if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
      |         ^~
/usr/include/libelf.h:322:12: note: declared here
  322 | extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
      |            ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[4]: *** [/work/lnx/next/linux-next-20230203/tools/build/Makefile.build:96: /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/elf.o] Error 1

make[3]: *** [Makefile:66: /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/objtool-in.o] Error 2


Thanks.
-- 
~Randy

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2023-02-04  8:30           ` Randy Dunlap
@ 2023-02-04 11:55             ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2023-02-04 11:55 UTC (permalink / raw)
  To: Randy Dunlap, Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao, Elliott, Robert (Servers)

Hi,

Le 04/02/2023 à 09:30, Randy Dunlap a écrit :
> 
> 
> On 2/4/23 00:21, Randy Dunlap wrote:
>>
>>
>> On 2/4/23 00:19, Randy Dunlap wrote:
>>> Hi--
>>>
>>> On 8/29/22 23:41, Christophe Leroy wrote:
>>>>
>>>>
>>>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>>>> This patch adds [stub] implementations for required
>>>>> functions, inorder to enable objtool build on powerpc.
>>>>
>>>> Not all powerpc it seems, see below
>>>>
>>>
>>> When cross-compiling PPC32 (on x86_64), I get 3600+ of these:
>>>
>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>>
>>> Is there some way that objtool should work when cross-compiling?
>>>
>>
>> Oops. Its build failed. I seem to be missing header file(s)
>> and possibly a library.
>> I'll check on those...
>>
> 
> It's complaining about libelf.h but I have that, so I don't know where
> it is looking other than /usr/include/libelf.h, which exists.
> Maybe the tool isn't setup (ready) for cross-compiling?
> 
> 
> Here's the build output for objtool:
> 
> <stdin>:1:10: fatal error: libelf.h: No such file or directory
> compilation terminated.
> elf.c: In function ‘read_sections’:
> elf.c:273:9: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations]
>    273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
>        |         ^~
> In file included from /usr/include/gelf.h:32,
>                   from /work/lnx/next/linux-next-20230203/tools/objtool/include/objtool/elf.h:10,
>                   from elf.c:22:
> /usr/include/libelf.h:310:12: note: declared here
>    310 | extern int elf_getshnum (Elf *__elf, size_t *__dst)
>        |            ^~~~~~~~~~~~
> elf.c:278:9: error: ‘elf_getshstrndx’ is deprecated [-Werror=deprecated-declarations]
>    278 |         if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
>        |         ^~
> /usr/include/libelf.h:322:12: note: declared here
>    322 | extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
>        |            ^~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[4]: *** [/work/lnx/next/linux-next-20230203/tools/build/Makefile.build:96: /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/elf.o] Error 1
> 
> make[3]: *** [Makefile:66: /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/objtool-in.o] Error 2

I have no problem crossbuilding for PPC32 from x86_64, I have a fedora 
36 on the x86.

$ rpm -q -f /usr/include/libelf.h
elfutils-libelf-devel-0.187-4.fc36.x86_64

Here is build output with V=1, pmac32_defconfig + CONFIG_FUNCTION_TRACER=y

...
mkdir -p ./tools
make LDFLAGS= MAKEFLAGS=" " O=/home/chleroy/linux-powerpc subdir=tools 
-C ./tools/ objtool
mkdir -p /home/chleroy/linux-powerpc/tools/objtool && make 
O=/home/chleroy/linux-powerpc subdir=tools/objtool --no-print-directory 
-C objtool
make -C /home/chleroy/linux-powerpc/tools/build CFLAGS= LDFLAGS= 
/home/chleroy/linux-powerpc/tools/objtool/fixdep
make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build dir=. 
obj=fixdep
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.fixdep.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/fixdep.o 
-D"BUILD_STR(s)=#s"   -c -o 
/home/chleroy/linux-powerpc/tools/objtool/fixdep.o fixdep.c
    ld -r -o /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o 
/home/chleroy/linux-powerpc/tools/objtool/fixdep.o
gcc   -o /home/chleroy/linux-powerpc/tools/objtool/fixdep 
/home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o
make -C /home/chleroy/linux-powerpc/tools/lib/subcmd/ 
OUTPUT=/home/chleroy/linux-powerpc/tools/objtool/
make -C /home/chleroy/linux-powerpc/tools/build CFLAGS= LDFLAGS= 
/home/chleroy/linux-powerpc/tools/objtool/fixdep
make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build dir=. 
obj=fixdep
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.exec-cmd.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o -ggdb3 
-Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o exec-cmd.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.help.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/help.o -ggdb3 -Wall 
-Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/help.o help.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.pager.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/pager.o -ggdb3 -Wall 
-Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/pager.o pager.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.parse-options.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/parse-options.o -ggdb3 
-Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/parse-options.o parse-options.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.run-command.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/run-command.o -ggdb3 
-Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/run-command.o run-command.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.sigchain.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/sigchain.o -ggdb3 
-Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/sigchain.o sigchain.c
    ld -r -o /home/chleroy/linux-powerpc/tools/objtool/libsubcmd-in.o 
/home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o 
/home/chleroy/linux-powerpc/tools/objtool/help.o 
/home/chleroy/linux-powerpc/tools/objtool/pager.o 
/home/chleroy/linux-powerpc/tools/objtool/parse-options.o 
/home/chleroy/linux-powerpc/tools/objtool/run-command.o 
/home/chleroy/linux-powerpc/tools/objtool/sigchain.o 
/home/chleroy/linux-powerpc/tools/objtool/subcmd-config.o
rm -f /home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a && ar rcs 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd-in.o
make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build 
dir=./arch/powerpc obj=objtool
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/.decode.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o 
-Werror -Wbad-function-cast -Wdeclaration-after-statement 
-Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations 
-Wmissing-prototypes -Wnested-externs -Wno-system-headers 
-Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes 
-Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat 
-Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default 
-Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall 
-Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 
-std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o 
arch/powerpc/decode.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/.special.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o 
-Werror -Wbad-function-cast -Wdeclaration-after-statement 
-Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations 
-Wmissing-prototypes -Wnested-externs -Wno-system-headers 
-Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes 
-Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat 
-Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default 
-Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall 
-Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 
-std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o 
arch/powerpc/special.c
    ld -r -o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.weak.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/weak.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/weak.o weak.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.check.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/check.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/check.o check.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.special.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/special.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/special.o special.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.builtin-check.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/builtin-check.o 
-Werror -Wbad-function-cast -Wdeclaration-after-statement 
-Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations 
-Wmissing-prototypes -Wnested-externs -Wno-system-headers 
-Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes 
-Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat 
-Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default 
-Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall 
-Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 
-std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/builtin-check.o builtin-check.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.elf.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/elf.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/elf.o elf.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.objtool.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/objtool.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/objtool.o objtool.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.libstring.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/libstring.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/libstring.o ../lib/string.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.libctype.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/libctype.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/libctype.o ../lib/ctype.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.str_error_r.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/str_error_r.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/str_error_r.o ../lib/str_error_r.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.librbtree.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/librbtree.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/librbtree.o ../lib/rbtree.c
    ld -r -o /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o 
/home/chleroy/linux-powerpc/tools/objtool/weak.o 
/home/chleroy/linux-powerpc/tools/objtool/check.o 
/home/chleroy/linux-powerpc/tools/objtool/special.o 
/home/chleroy/linux-powerpc/tools/objtool/builtin-check.o 
/home/chleroy/linux-powerpc/tools/objtool/elf.o 
/home/chleroy/linux-powerpc/tools/objtool/objtool.o 
/home/chleroy/linux-powerpc/tools/objtool/libstring.o 
/home/chleroy/linux-powerpc/tools/objtool/libctype.o 
/home/chleroy/linux-powerpc/tools/objtool/str_error_r.o 
/home/chleroy/linux-powerpc/tools/objtool/librbtree.o
gcc /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o -lelf 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a   -o 
/home/chleroy/linux-powerpc/tools/objtool/objtool
...
make -f ./scripts/Makefile.build obj=. need-builtin=1 need-modorder=1
make -f ./scripts/Makefile.build obj=init \
need-builtin=1 \
need-modorder=1 \

   powerpc64-linux-gcc -Wp,-MMD,init/.main.o.d -nostdinc 
-I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include 
-I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi 
-I./include/uapi -I./include/generated/uapi -include 
./include/linux/compiler-version.h -include ./include/linux/kconfig.h 
-include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc 
-fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes 
-Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE 
-Werror=implicit-function-declaration -Werror=implicit-int 
-Werror=return-type -Wno-format-security -funsigned-char -std=gnu11 
-mbig-endian -m32 -msoft-float -pipe -ffixed-r2 -mmultiple 
-mno-readonly-in-sdata -mcpu=powerpc -mno-prefixed -mno-pcrel 
-mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables 
-mno-string -Wa,-maltivec -mbig-endian -mstack-protector-guard=tls 
-mstack-protector-guard-reg=r2 -fno-delete-null-pointer-checks 
-Wno-frame-address -Wno-format-truncation -Wno-format-overflow 
-Wno-address-of-packed-member -O2 -fno-allow-store-data-races 
-Wframe-larger-than=1024 -fstack-protector-strong -Wno-main 
-Wno-unused-but-set-variable -Wno-unused-const-variable 
-Wno-dangling-pointer -ftrivial-auto-var-init=zero 
-fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla 
-Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation 
-Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized 
-Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 
-fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time 
-Werror=incompatible-pointer-types -Werror=designated-init 
-Wno-packed-not-aligned -mstack-protector-guard-offset=544 
-fno-function-sections -fno-data-sections 
-DKBUILD_MODFILE='"init/main"' -DKBUILD_BASENAME='"main"' 
-DKBUILD_MODNAME='"main"' -D__KBUILD_MODNAME=kmod_main -c -o init/main.o 
init/main.c   ; ./tools/objtool/objtool --mcount   init/main.o
   ./scripts/check-local-export init/main.o
    { echo ; echo 'init/main.o: $(wildcard ./tools/objtool/objtool)' ; } 
 >> init/.main.o.cmd
set -e; mkdir -p init/; trap "rm -f init/.utsversion-tmp.h.tmp" EXIT; { 
utsver=$(echo '#'""   "" | cut -b -64); echo '#'define UTS_VERSION 
\""${utsver}"\"; } > init/.utsversion-tmp.h.tmp; if [ ! -r 
init/utsversion-tmp.h ] || ! cmp -s init/utsversion-tmp.h 
init/.utsversion-tmp.h.tmp; then : '  UPD     init/utsversion-tmp.h'; mv 
-f init/.utsversion-tmp.h.tmp init/utsversion-tmp.h; fi
   powerpc64-linux-gcc -Wp,-MMD,init/.version.o.d -nostdinc 
-I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include 
-I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi 
-I./include/uapi -I./include/generated/uapi -include 
./include/linux/compiler-version.h -include ./include/linux/kconfig.h 
-include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc 
-fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes 
-Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE 
-Werror=implicit-function-declaration -Werror=implicit-int 
-Werror=return-type -Wno-format-security -funsigned-char -std=gnu11 
-mbig-endian -m32 -msoft-float -pipe -ffixed-r2 -mmultiple 
-mno-readonly-in-sdata -mcpu=powerpc -mno-prefixed -mno-pcrel 
-mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables 
-mno-string -Wa,-maltivec -mbig-endian -mstack-protector-guard=tls 
-mstack-protector-guard-reg=r2 -fno-delete-null-pointer-checks 
-Wno-frame-address -Wno-format-truncation -Wno-format-overflow 
-Wno-address-of-packed-member -O2 -fno-allow-store-data-races 
-Wframe-larger-than=1024 -fstack-protector-strong -Wno-main 
-Wno-unused-but-set-variable -Wno-unused-const-variable 
-Wno-dangling-pointer -ftrivial-auto-var-init=zero 
-fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla 
-Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation 
-Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized 
-Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 
-fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time 
-Werror=incompatible-pointer-types -Werror=designated-init 
-Wno-packed-not-aligned -mstack-protector-guard-offset=544 
-fno-function-sections -fno-data-sections -include init/utsversion-tmp.h 
    -DKBUILD_MODFILE='"init/version"' -DKBUILD_BASENAME='"version"' 
-DKBUILD_MODNAME='"version"' -D__KBUILD_MODNAME=kmod_version -c -o 
init/version.o init/version.c   ; ./tools/objtool/objtool --mcount 
init/version.o
   ./scripts/check-local-export init/version.o
    { echo ; echo 'init/version.o: $(wildcard ./tools/objtool/objtool)' 
; } >> init/.version.o.cmd
...

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2023-02-04 11:55             ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2023-02-04 11:55 UTC (permalink / raw)
  To: Randy Dunlap, Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin, Elliott, Robert (Servers)

Hi,

Le 04/02/2023 à 09:30, Randy Dunlap a écrit :
> 
> 
> On 2/4/23 00:21, Randy Dunlap wrote:
>>
>>
>> On 2/4/23 00:19, Randy Dunlap wrote:
>>> Hi--
>>>
>>> On 8/29/22 23:41, Christophe Leroy wrote:
>>>>
>>>>
>>>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>>>> This patch adds [stub] implementations for required
>>>>> functions, inorder to enable objtool build on powerpc.
>>>>
>>>> Not all powerpc it seems, see below
>>>>
>>>
>>> When cross-compiling PPC32 (on x86_64), I get 3600+ of these:
>>>
>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>>
>>> Is there some way that objtool should work when cross-compiling?
>>>
>>
>> Oops. Its build failed. I seem to be missing header file(s)
>> and possibly a library.
>> I'll check on those...
>>
> 
> It's complaining about libelf.h but I have that, so I don't know where
> it is looking other than /usr/include/libelf.h, which exists.
> Maybe the tool isn't setup (ready) for cross-compiling?
> 
> 
> Here's the build output for objtool:
> 
> <stdin>:1:10: fatal error: libelf.h: No such file or directory
> compilation terminated.
> elf.c: In function ‘read_sections’:
> elf.c:273:9: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations]
>    273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
>        |         ^~
> In file included from /usr/include/gelf.h:32,
>                   from /work/lnx/next/linux-next-20230203/tools/objtool/include/objtool/elf.h:10,
>                   from elf.c:22:
> /usr/include/libelf.h:310:12: note: declared here
>    310 | extern int elf_getshnum (Elf *__elf, size_t *__dst)
>        |            ^~~~~~~~~~~~
> elf.c:278:9: error: ‘elf_getshstrndx’ is deprecated [-Werror=deprecated-declarations]
>    278 |         if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
>        |         ^~
> /usr/include/libelf.h:322:12: note: declared here
>    322 | extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
>        |            ^~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[4]: *** [/work/lnx/next/linux-next-20230203/tools/build/Makefile.build:96: /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/elf.o] Error 1
> 
> make[3]: *** [Makefile:66: /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/objtool-in.o] Error 2

I have no problem crossbuilding for PPC32 from x86_64, I have a fedora 
36 on the x86.

$ rpm -q -f /usr/include/libelf.h
elfutils-libelf-devel-0.187-4.fc36.x86_64

Here is build output with V=1, pmac32_defconfig + CONFIG_FUNCTION_TRACER=y

...
mkdir -p ./tools
make LDFLAGS= MAKEFLAGS=" " O=/home/chleroy/linux-powerpc subdir=tools 
-C ./tools/ objtool
mkdir -p /home/chleroy/linux-powerpc/tools/objtool && make 
O=/home/chleroy/linux-powerpc subdir=tools/objtool --no-print-directory 
-C objtool
make -C /home/chleroy/linux-powerpc/tools/build CFLAGS= LDFLAGS= 
/home/chleroy/linux-powerpc/tools/objtool/fixdep
make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build dir=. 
obj=fixdep
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.fixdep.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/fixdep.o 
-D"BUILD_STR(s)=#s"   -c -o 
/home/chleroy/linux-powerpc/tools/objtool/fixdep.o fixdep.c
    ld -r -o /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o 
/home/chleroy/linux-powerpc/tools/objtool/fixdep.o
gcc   -o /home/chleroy/linux-powerpc/tools/objtool/fixdep 
/home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o
make -C /home/chleroy/linux-powerpc/tools/lib/subcmd/ 
OUTPUT=/home/chleroy/linux-powerpc/tools/objtool/
make -C /home/chleroy/linux-powerpc/tools/build CFLAGS= LDFLAGS= 
/home/chleroy/linux-powerpc/tools/objtool/fixdep
make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build dir=. 
obj=fixdep
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.exec-cmd.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o -ggdb3 
-Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o exec-cmd.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.help.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/help.o -ggdb3 -Wall 
-Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/help.o help.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.pager.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/pager.o -ggdb3 -Wall 
-Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/pager.o pager.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.parse-options.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/parse-options.o -ggdb3 
-Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/parse-options.o parse-options.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.run-command.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/run-command.o -ggdb3 
-Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/run-command.o run-command.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.sigchain.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/sigchain.o -ggdb3 
-Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
-I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
-Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
-Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
-Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
-D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/sigchain.o sigchain.c
    ld -r -o /home/chleroy/linux-powerpc/tools/objtool/libsubcmd-in.o 
/home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o 
/home/chleroy/linux-powerpc/tools/objtool/help.o 
/home/chleroy/linux-powerpc/tools/objtool/pager.o 
/home/chleroy/linux-powerpc/tools/objtool/parse-options.o 
/home/chleroy/linux-powerpc/tools/objtool/run-command.o 
/home/chleroy/linux-powerpc/tools/objtool/sigchain.o 
/home/chleroy/linux-powerpc/tools/objtool/subcmd-config.o
rm -f /home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a && ar rcs 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd-in.o
make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build 
dir=./arch/powerpc obj=objtool
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/.decode.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o 
-Werror -Wbad-function-cast -Wdeclaration-after-statement 
-Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations 
-Wmissing-prototypes -Wnested-externs -Wno-system-headers 
-Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes 
-Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat 
-Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default 
-Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall 
-Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 
-std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o 
arch/powerpc/decode.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/.special.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o 
-Werror -Wbad-function-cast -Wdeclaration-after-statement 
-Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations 
-Wmissing-prototypes -Wnested-externs -Wno-system-headers 
-Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes 
-Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat 
-Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default 
-Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall 
-Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 
-std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o 
arch/powerpc/special.c
    ld -r -o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.weak.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/weak.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/weak.o weak.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.check.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/check.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/check.o check.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.special.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/special.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/special.o special.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.builtin-check.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/builtin-check.o 
-Werror -Wbad-function-cast -Wdeclaration-after-statement 
-Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations 
-Wmissing-prototypes -Wnested-externs -Wno-system-headers 
-Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes 
-Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat 
-Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default 
-Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall 
-Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 
-std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/builtin-check.o builtin-check.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.elf.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/elf.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/elf.o elf.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.objtool.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/objtool.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/objtool.o objtool.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.libstring.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/libstring.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/libstring.o ../lib/string.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.libctype.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/libctype.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/libctype.o ../lib/ctype.c
   gcc 
-Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.str_error_r.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/str_error_r.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/str_error_r.o ../lib/str_error_r.c
   gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.librbtree.o.d 
-Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/librbtree.o -Werror 
-Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
-Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
-Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
-Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
-Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
-Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
-Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
-I/home/chleroy/linux-powerpc/tools/include 
-I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
-I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/objtool/include 
-I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
-I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
/home/chleroy/linux-powerpc/tools/objtool/librbtree.o ../lib/rbtree.c
    ld -r -o /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o 
/home/chleroy/linux-powerpc/tools/objtool/weak.o 
/home/chleroy/linux-powerpc/tools/objtool/check.o 
/home/chleroy/linux-powerpc/tools/objtool/special.o 
/home/chleroy/linux-powerpc/tools/objtool/builtin-check.o 
/home/chleroy/linux-powerpc/tools/objtool/elf.o 
/home/chleroy/linux-powerpc/tools/objtool/objtool.o 
/home/chleroy/linux-powerpc/tools/objtool/libstring.o 
/home/chleroy/linux-powerpc/tools/objtool/libctype.o 
/home/chleroy/linux-powerpc/tools/objtool/str_error_r.o 
/home/chleroy/linux-powerpc/tools/objtool/librbtree.o
gcc /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o -lelf 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a   -o 
/home/chleroy/linux-powerpc/tools/objtool/objtool
...
make -f ./scripts/Makefile.build obj=. need-builtin=1 need-modorder=1
make -f ./scripts/Makefile.build obj=init \
need-builtin=1 \
need-modorder=1 \

   powerpc64-linux-gcc -Wp,-MMD,init/.main.o.d -nostdinc 
-I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include 
-I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi 
-I./include/uapi -I./include/generated/uapi -include 
./include/linux/compiler-version.h -include ./include/linux/kconfig.h 
-include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc 
-fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes 
-Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE 
-Werror=implicit-function-declaration -Werror=implicit-int 
-Werror=return-type -Wno-format-security -funsigned-char -std=gnu11 
-mbig-endian -m32 -msoft-float -pipe -ffixed-r2 -mmultiple 
-mno-readonly-in-sdata -mcpu=powerpc -mno-prefixed -mno-pcrel 
-mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables 
-mno-string -Wa,-maltivec -mbig-endian -mstack-protector-guard=tls 
-mstack-protector-guard-reg=r2 -fno-delete-null-pointer-checks 
-Wno-frame-address -Wno-format-truncation -Wno-format-overflow 
-Wno-address-of-packed-member -O2 -fno-allow-store-data-races 
-Wframe-larger-than=1024 -fstack-protector-strong -Wno-main 
-Wno-unused-but-set-variable -Wno-unused-const-variable 
-Wno-dangling-pointer -ftrivial-auto-var-init=zero 
-fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla 
-Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation 
-Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized 
-Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 
-fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time 
-Werror=incompatible-pointer-types -Werror=designated-init 
-Wno-packed-not-aligned -mstack-protector-guard-offset=544 
-fno-function-sections -fno-data-sections 
-DKBUILD_MODFILE='"init/main"' -DKBUILD_BASENAME='"main"' 
-DKBUILD_MODNAME='"main"' -D__KBUILD_MODNAME=kmod_main -c -o init/main.o 
init/main.c   ; ./tools/objtool/objtool --mcount   init/main.o
   ./scripts/check-local-export init/main.o
    { echo ; echo 'init/main.o: $(wildcard ./tools/objtool/objtool)' ; } 
 >> init/.main.o.cmd
set -e; mkdir -p init/; trap "rm -f init/.utsversion-tmp.h.tmp" EXIT; { 
utsver=$(echo '#'""   "" | cut -b -64); echo '#'define UTS_VERSION 
\""${utsver}"\"; } > init/.utsversion-tmp.h.tmp; if [ ! -r 
init/utsversion-tmp.h ] || ! cmp -s init/utsversion-tmp.h 
init/.utsversion-tmp.h.tmp; then : '  UPD     init/utsversion-tmp.h'; mv 
-f init/.utsversion-tmp.h.tmp init/utsversion-tmp.h; fi
   powerpc64-linux-gcc -Wp,-MMD,init/.version.o.d -nostdinc 
-I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include 
-I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi 
-I./include/uapi -I./include/generated/uapi -include 
./include/linux/compiler-version.h -include ./include/linux/kconfig.h 
-include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc 
-fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes 
-Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE 
-Werror=implicit-function-declaration -Werror=implicit-int 
-Werror=return-type -Wno-format-security -funsigned-char -std=gnu11 
-mbig-endian -m32 -msoft-float -pipe -ffixed-r2 -mmultiple 
-mno-readonly-in-sdata -mcpu=powerpc -mno-prefixed -mno-pcrel 
-mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables 
-mno-string -Wa,-maltivec -mbig-endian -mstack-protector-guard=tls 
-mstack-protector-guard-reg=r2 -fno-delete-null-pointer-checks 
-Wno-frame-address -Wno-format-truncation -Wno-format-overflow 
-Wno-address-of-packed-member -O2 -fno-allow-store-data-races 
-Wframe-larger-than=1024 -fstack-protector-strong -Wno-main 
-Wno-unused-but-set-variable -Wno-unused-const-variable 
-Wno-dangling-pointer -ftrivial-auto-var-init=zero 
-fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla 
-Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation 
-Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized 
-Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 
-fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time 
-Werror=incompatible-pointer-types -Werror=designated-init 
-Wno-packed-not-aligned -mstack-protector-guard-offset=544 
-fno-function-sections -fno-data-sections -include init/utsversion-tmp.h 
    -DKBUILD_MODFILE='"init/version"' -DKBUILD_BASENAME='"version"' 
-DKBUILD_MODNAME='"version"' -D__KBUILD_MODNAME=kmod_version -c -o 
init/version.o init/version.c   ; ./tools/objtool/objtool --mcount 
init/version.o
   ./scripts/check-local-export init/version.o
    { echo ; echo 'init/version.o: $(wildcard ./tools/objtool/objtool)' 
; } >> init/.version.o.cmd
...

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2023-02-04 11:55             ` Christophe Leroy
@ 2023-02-04 13:10               ` Christophe Leroy
  -1 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2023-02-04 13:10 UTC (permalink / raw)
  To: Randy Dunlap, Sathvika Vasireddy, linuxppc-dev
  Cc: jpoimboe, peterz, linux-kernel, aik, mpe, mingo, rostedt, mbenes,
	npiggin, chenzhongjin, naveen.n.rao, Elliott, Robert (Servers)



Le 04/02/2023 à 12:55, Christophe Leroy a écrit :
> Hi,
> 
> Le 04/02/2023 à 09:30, Randy Dunlap a écrit :
>>
>>
>> On 2/4/23 00:21, Randy Dunlap wrote:
>>>
>>>
>>> On 2/4/23 00:19, Randy Dunlap wrote:
>>>> Hi--
>>>>
>>>> On 8/29/22 23:41, Christophe Leroy wrote:
>>>>>
>>>>>
>>>>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>>>>> This patch adds [stub] implementations for required
>>>>>> functions, inorder to enable objtool build on powerpc.
>>>>>
>>>>> Not all powerpc it seems, see below
>>>>>
>>>>
>>>> When cross-compiling PPC32 (on x86_64), I get 3600+ of these:
>>>>
>>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>>>
>>>> Is there some way that objtool should work when cross-compiling?
>>>>
>>>
>>> Oops. Its build failed. I seem to be missing header file(s)
>>> and possibly a library.
>>> I'll check on those...
>>>
>>
>> It's complaining about libelf.h but I have that, so I don't know where
>> it is looking other than /usr/include/libelf.h, which exists.
>> Maybe the tool isn't setup (ready) for cross-compiling?
>>
>>
>> Here's the build output for objtool:
>>
>> <stdin>:1:10: fatal error: libelf.h: No such file or directory
>> compilation terminated.
>> elf.c: In function ‘read_sections’:
>> elf.c:273:9: error: ‘elf_getshnum’ is deprecated 
>> [-Werror=deprecated-declarations]
>>    273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
>>        |         ^~
>> In file included from /usr/include/gelf.h:32,
>>                   from 
>> /work/lnx/next/linux-next-20230203/tools/objtool/include/objtool/elf.h:10,
>>                   from elf.c:22:
>> /usr/include/libelf.h:310:12: note: declared here
>>    310 | extern int elf_getshnum (Elf *__elf, size_t *__dst)
>>        |            ^~~~~~~~~~~~
>> elf.c:278:9: error: ‘elf_getshstrndx’ is deprecated 
>> [-Werror=deprecated-declarations]
>>    278 |         if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
>>        |         ^~
>> /usr/include/libelf.h:322:12: note: declared here
>>    322 | extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
>>        |            ^~~~~~~~~~~~~~~
>> cc1: all warnings being treated as errors
>> make[4]: *** 
>> [/work/lnx/next/linux-next-20230203/tools/build/Makefile.build:96: 
>> /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/elf.o] Error 1
>>
>> make[3]: *** [Makefile:66: 
>> /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/objtool-in.o] 
>> Error 2
> 
> I have no problem crossbuilding for PPC32 from x86_64, I have a fedora 
> 36 on the x86.
> 
> $ rpm -q -f /usr/include/libelf.h
> elfutils-libelf-devel-0.187-4.fc36.x86_64
> 
> Here is build output with V=1, pmac32_defconfig + CONFIG_FUNCTION_TRACER=y
> 
> ...
> mkdir -p ./tools
> make LDFLAGS= MAKEFLAGS=" " O=/home/chleroy/linux-powerpc subdir=tools 
> -C ./tools/ objtool
> mkdir -p /home/chleroy/linux-powerpc/tools/objtool && make 
> O=/home/chleroy/linux-powerpc subdir=tools/objtool --no-print-directory 
> -C objtool
> make -C /home/chleroy/linux-powerpc/tools/build CFLAGS= LDFLAGS= 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep
> make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build dir=. 
> obj=fixdep
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.fixdep.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/fixdep.o 
> -D"BUILD_STR(s)=#s"   -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep.o fixdep.c
>     ld -r -o /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep.o
> gcc   -o /home/chleroy/linux-powerpc/tools/objtool/fixdep 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o
> make -C /home/chleroy/linux-powerpc/tools/lib/subcmd/ 
> OUTPUT=/home/chleroy/linux-powerpc/tools/objtool/
> make -C /home/chleroy/linux-powerpc/tools/build CFLAGS= LDFLAGS= 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep
> make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build dir=. 
> obj=fixdep
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.exec-cmd.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o -ggdb3 
> -Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o exec-cmd.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.help.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/help.o -ggdb3 -Wall 
> -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/help.o help.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.pager.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/pager.o -ggdb3 -Wall 
> -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/pager.o pager.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.parse-options.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/parse-options.o -ggdb3 
> -Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/parse-options.o parse-options.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.run-command.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/run-command.o -ggdb3 
> -Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/run-command.o run-command.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.sigchain.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/sigchain.o -ggdb3 
> -Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/sigchain.o sigchain.c
>     ld -r -o /home/chleroy/linux-powerpc/tools/objtool/libsubcmd-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o 
> /home/chleroy/linux-powerpc/tools/objtool/help.o 
> /home/chleroy/linux-powerpc/tools/objtool/pager.o 
> /home/chleroy/linux-powerpc/tools/objtool/parse-options.o 
> /home/chleroy/linux-powerpc/tools/objtool/run-command.o 
> /home/chleroy/linux-powerpc/tools/objtool/sigchain.o 
> /home/chleroy/linux-powerpc/tools/objtool/subcmd-config.o
> rm -f /home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a && ar rcs 
> /home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a 
> /home/chleroy/linux-powerpc/tools/objtool/libsubcmd-in.o
> make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build 
> dir=./arch/powerpc obj=objtool
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/.decode.o.d -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o -Werror -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g -I/home/chleroy/linux-powerpc/tools/include -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include -I/home/chleroy/linux-powerpc/tools/objtool/include -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o arch/powerpc/decode.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/.special.o.d -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o -Werror -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g -I/home/chleroy/linux-powerpc/tools/include -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include -I/home/chleroy/linux-powerpc/tools/objtool/include -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o arch/powerpc/special.c
>     ld -r -o 
> /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o 
> /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.weak.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/weak.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/weak.o weak.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.check.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/check.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/check.o check.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.special.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/special.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/special.o special.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.builtin-check.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/builtin-check.o 
> -Werror -Wbad-function-cast -Wdeclaration-after-statement 
> -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations 
> -Wmissing-prototypes -Wnested-externs -Wno-system-headers 
> -Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes 
> -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat 
> -Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default 
> -Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall 
> -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 
> -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o builtin-check.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.elf.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/elf.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/elf.o elf.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.objtool.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/objtool.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/objtool.o objtool.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.libstring.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/libstring.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/libstring.o ../lib/string.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.libctype.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/libctype.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/libctype.o ../lib/ctype.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.str_error_r.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/str_error_r.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/str_error_r.o 
> ../lib/str_error_r.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.librbtree.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/librbtree.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/librbtree.o ../lib/rbtree.c
>     ld -r -o /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/weak.o 
> /home/chleroy/linux-powerpc/tools/objtool/check.o 
> /home/chleroy/linux-powerpc/tools/objtool/special.o 
> /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o 
> /home/chleroy/linux-powerpc/tools/objtool/elf.o 
> /home/chleroy/linux-powerpc/tools/objtool/objtool.o 
> /home/chleroy/linux-powerpc/tools/objtool/libstring.o 
> /home/chleroy/linux-powerpc/tools/objtool/libctype.o 
> /home/chleroy/linux-powerpc/tools/objtool/str_error_r.o 
> /home/chleroy/linux-powerpc/tools/objtool/librbtree.o
> gcc /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o -lelf 
> /home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a   -o 
> /home/chleroy/linux-powerpc/tools/objtool/objtool
> ...
> make -f ./scripts/Makefile.build obj=. need-builtin=1 need-modorder=1
> make -f ./scripts/Makefile.build obj=init \
> need-builtin=1 \
> need-modorder=1 \
> 
>    powerpc64-linux-gcc -Wp,-MMD,init/.main.o.d -nostdinc 
> -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include 
> -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi 
> -I./include/uapi -I./include/generated/uapi -include 
> ./include/linux/compiler-version.h -include ./include/linux/kconfig.h 
> -include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc 
> -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes 
> -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE 
> -Werror=implicit-function-declaration -Werror=implicit-int 
> -Werror=return-type -Wno-format-security -funsigned-char -std=gnu11 
> -mbig-endian -m32 -msoft-float -pipe -ffixed-r2 -mmultiple 
> -mno-readonly-in-sdata -mcpu=powerpc -mno-prefixed -mno-pcrel 
> -mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables 
> -mno-string -Wa,-maltivec -mbig-endian -mstack-protector-guard=tls 
> -mstack-protector-guard-reg=r2 -fno-delete-null-pointer-checks 
> -Wno-frame-address -Wno-format-truncation -Wno-format-overflow 
> -Wno-address-of-packed-member -O2 -fno-allow-store-data-races 
> -Wframe-larger-than=1024 -fstack-protector-strong -Wno-main 
> -Wno-unused-but-set-variable -Wno-unused-const-variable 
> -Wno-dangling-pointer -ftrivial-auto-var-init=zero 
> -fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla 
> -Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation 
> -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized 
> -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 
> -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time 
> -Werror=incompatible-pointer-types -Werror=designated-init 
> -Wno-packed-not-aligned -mstack-protector-guard-offset=544 
> -fno-function-sections -fno-data-sections -DKBUILD_MODFILE='"init/main"' 
> -DKBUILD_BASENAME='"main"' -DKBUILD_MODNAME='"main"' 
> -D__KBUILD_MODNAME=kmod_main -c -o init/main.o init/main.c   ; 
> ./tools/objtool/objtool --mcount   init/main.o
>    ./scripts/check-local-export init/main.o
>     { echo ; echo 'init/main.o: $(wildcard ./tools/objtool/objtool)' ; } 
>  >> init/.main.o.cmd
> set -e; mkdir -p init/; trap "rm -f init/.utsversion-tmp.h.tmp" EXIT; { 
> utsver=$(echo '#'""   "" | cut -b -64); echo '#'define UTS_VERSION 
> \""${utsver}"\"; } > init/.utsversion-tmp.h.tmp; if [ ! -r 
> init/utsversion-tmp.h ] || ! cmp -s init/utsversion-tmp.h 
> init/.utsversion-tmp.h.tmp; then : '  UPD     init/utsversion-tmp.h'; mv 
> -f init/.utsversion-tmp.h.tmp init/utsversion-tmp.h; fi
>    powerpc64-linux-gcc -Wp,-MMD,init/.version.o.d -nostdinc 
> -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include 
> -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi 
> -I./include/uapi -I./include/generated/uapi -include 
> ./include/linux/compiler-version.h -include ./include/linux/kconfig.h 
> -include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc 
> -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes 
> -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE 
> -Werror=implicit-function-declaration -Werror=implicit-int 
> -Werror=return-type -Wno-format-security -funsigned-char -std=gnu11 
> -mbig-endian -m32 -msoft-float -pipe -ffixed-r2 -mmultiple 
> -mno-readonly-in-sdata -mcpu=powerpc -mno-prefixed -mno-pcrel 
> -mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables 
> -mno-string -Wa,-maltivec -mbig-endian -mstack-protector-guard=tls 
> -mstack-protector-guard-reg=r2 -fno-delete-null-pointer-checks 
> -Wno-frame-address -Wno-format-truncation -Wno-format-overflow 
> -Wno-address-of-packed-member -O2 -fno-allow-store-data-races 
> -Wframe-larger-than=1024 -fstack-protector-strong -Wno-main 
> -Wno-unused-but-set-variable -Wno-unused-const-variable 
> -Wno-dangling-pointer -ftrivial-auto-var-init=zero 
> -fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla 
> -Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation 
> -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized 
> -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 
> -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time 
> -Werror=incompatible-pointer-types -Werror=designated-init 
> -Wno-packed-not-aligned -mstack-protector-guard-offset=544 
> -fno-function-sections -fno-data-sections -include init/utsversion-tmp.h 
>     -DKBUILD_MODFILE='"init/version"' -DKBUILD_BASENAME='"version"' 
> -DKBUILD_MODNAME='"version"' -D__KBUILD_MODNAME=kmod_version -c -o 
> init/version.o init/version.c   ; ./tools/objtool/objtool --mcount 
> init/version.o
>    ./scripts/check-local-export init/version.o
>     { echo ; echo 'init/version.o: $(wildcard ./tools/objtool/objtool)' 
> ; } >> init/.version.o.cmd
> ...


Ok, got the same problem as you with next-20230203

   DESCEND objtool
<stdin>:1:10: fatal error: libelf.h: No such file or directory
compilation terminated.
   HOSTCC  /home/chleroy/linux-powerpc/tools/objtool/fixdep.o
   HOSTLD  /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o
   LINK    /home/chleroy/linux-powerpc/tools/objtool/fixdep
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/exec-cmd.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/help.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/pager.o
   CC 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/parse-options.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/run-command.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/sigchain.o
   CC 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/subcmd-config.o
   LD 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd-in.o
   AR      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd.a
   INSTALL libsubcmd_headers
   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o
   LD 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/weak.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/check.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/special.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/elf.o
elf.c: In function 'read_sections':
elf.c:273:9: error: 'elf_getshnum' is deprecated 
[-Werror=deprecated-declarations]
   273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
       |         ^~
In file included from /usr/include/gelf.h:32,
                  from 
/home/chleroy/linux-powerpc/tools/objtool/include/objtool/elf.h:10,
                  from elf.c:22:
/usr/include/libelf.h:310:12: note: declared here
   310 | extern int elf_getshnum (Elf *__elf, size_t *__dst)
       |            ^~~~~~~~~~~~
elf.c:278:9: error: 'elf_getshstrndx' is deprecated 
[-Werror=deprecated-declarations]
   278 |         if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
       |         ^~
/usr/include/libelf.h:322:12: note: declared here
   322 | extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
       |            ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [/home/chleroy/linux-powerpc/tools/build/Makefile.build:97: 
/home/chleroy/linux-powerpc/tools/objtool/elf.o] Error 1
make[2]: *** [Makefile:66: 
/home/chleroy/linux-powerpc/tools/objtool/objtool-in.o] Error 2
make[1]: *** [Makefile:73: objtool] Error 2
make: *** [Makefile:1439: tools/objtool] Error 2


That's odd, because if I do it manually it works:


$ make LDFLAGS= MAKEFLAGS=" " O=/home/chleroy/linux-powerpc subdir=tools 
-C ./tools/ objtool
make : on entre dans le répertoire « /home/chleroy/linux-powerpc/tools »
   DESCEND objtool
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/exec-cmd.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/help.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/pager.o
   CC 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/parse-options.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/run-command.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/sigchain.o
   CC 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/subcmd-config.o
   LD 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd-in.o
   AR      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd.a
   INSTALL libsubcmd_headers
   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/x86/special.o
   GEN 
/home/chleroy/linux-powerpc/tools/objtool/arch/x86/lib/inat-tables.c
   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/x86/decode.o
   LD      /home/chleroy/linux-powerpc/tools/objtool/arch/x86/objtool-in.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/weak.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/check.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/special.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/elf.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/objtool.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/orc_gen.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/orc_dump.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libstring.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libctype.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/str_error_r.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/librbtree.o
   LD      /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o
   LINK    /home/chleroy/linux-powerpc/tools/objtool/objtool
make : on quitte le répertoire « /home/chleroy/linux-powerpc/tools »
[chleroy@PO20335 linux-powerpc]$ file 
/home/chleroy/linux-powerpc/tools/objtool/objtool
/home/chleroy/linux-powerpc/tools/objtool/objtool: ELF 64-bit LSB 
executable, x86-64, version 1 (SYSV), dynamically linked, interpreter 
/lib64/ld-linux-x86-64.so.2, 
BuildID[sha1]=1f445df36c222194c5bce8147a30a1fa1120f318, for GNU/Linux 
3.2.0, with debug_info, not stripped


Christophe

Christophe

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2023-02-04 13:10               ` Christophe Leroy
  0 siblings, 0 replies; 128+ messages in thread
From: Christophe Leroy @ 2023-02-04 13:10 UTC (permalink / raw)
  To: Randy Dunlap, Sathvika Vasireddy, linuxppc-dev
  Cc: peterz, linux-kernel, rostedt, aik, mingo, npiggin, jpoimboe,
	naveen.n.rao, mbenes, chenzhongjin, Elliott, Robert (Servers)



Le 04/02/2023 à 12:55, Christophe Leroy a écrit :
> Hi,
> 
> Le 04/02/2023 à 09:30, Randy Dunlap a écrit :
>>
>>
>> On 2/4/23 00:21, Randy Dunlap wrote:
>>>
>>>
>>> On 2/4/23 00:19, Randy Dunlap wrote:
>>>> Hi--
>>>>
>>>> On 8/29/22 23:41, Christophe Leroy wrote:
>>>>>
>>>>>
>>>>> Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
>>>>>> This patch adds [stub] implementations for required
>>>>>> functions, inorder to enable objtool build on powerpc.
>>>>>
>>>>> Not all powerpc it seems, see below
>>>>>
>>>>
>>>> When cross-compiling PPC32 (on x86_64), I get 3600+ of these:
>>>>
>>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>>> /bin/sh: line 1: ./tools/objtool/objtool: No such file or directory
>>>>
>>>> Is there some way that objtool should work when cross-compiling?
>>>>
>>>
>>> Oops. Its build failed. I seem to be missing header file(s)
>>> and possibly a library.
>>> I'll check on those...
>>>
>>
>> It's complaining about libelf.h but I have that, so I don't know where
>> it is looking other than /usr/include/libelf.h, which exists.
>> Maybe the tool isn't setup (ready) for cross-compiling?
>>
>>
>> Here's the build output for objtool:
>>
>> <stdin>:1:10: fatal error: libelf.h: No such file or directory
>> compilation terminated.
>> elf.c: In function ‘read_sections’:
>> elf.c:273:9: error: ‘elf_getshnum’ is deprecated 
>> [-Werror=deprecated-declarations]
>>    273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
>>        |         ^~
>> In file included from /usr/include/gelf.h:32,
>>                   from 
>> /work/lnx/next/linux-next-20230203/tools/objtool/include/objtool/elf.h:10,
>>                   from elf.c:22:
>> /usr/include/libelf.h:310:12: note: declared here
>>    310 | extern int elf_getshnum (Elf *__elf, size_t *__dst)
>>        |            ^~~~~~~~~~~~
>> elf.c:278:9: error: ‘elf_getshstrndx’ is deprecated 
>> [-Werror=deprecated-declarations]
>>    278 |         if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
>>        |         ^~
>> /usr/include/libelf.h:322:12: note: declared here
>>    322 | extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
>>        |            ^~~~~~~~~~~~~~~
>> cc1: all warnings being treated as errors
>> make[4]: *** 
>> [/work/lnx/next/linux-next-20230203/tools/build/Makefile.build:96: 
>> /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/elf.o] Error 1
>>
>> make[3]: *** [Makefile:66: 
>> /work/lnx/next/linux-next-20230203/PPC32/tools/objtool/objtool-in.o] 
>> Error 2
> 
> I have no problem crossbuilding for PPC32 from x86_64, I have a fedora 
> 36 on the x86.
> 
> $ rpm -q -f /usr/include/libelf.h
> elfutils-libelf-devel-0.187-4.fc36.x86_64
> 
> Here is build output with V=1, pmac32_defconfig + CONFIG_FUNCTION_TRACER=y
> 
> ...
> mkdir -p ./tools
> make LDFLAGS= MAKEFLAGS=" " O=/home/chleroy/linux-powerpc subdir=tools 
> -C ./tools/ objtool
> mkdir -p /home/chleroy/linux-powerpc/tools/objtool && make 
> O=/home/chleroy/linux-powerpc subdir=tools/objtool --no-print-directory 
> -C objtool
> make -C /home/chleroy/linux-powerpc/tools/build CFLAGS= LDFLAGS= 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep
> make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build dir=. 
> obj=fixdep
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.fixdep.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/fixdep.o 
> -D"BUILD_STR(s)=#s"   -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep.o fixdep.c
>     ld -r -o /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep.o
> gcc   -o /home/chleroy/linux-powerpc/tools/objtool/fixdep 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o
> make -C /home/chleroy/linux-powerpc/tools/lib/subcmd/ 
> OUTPUT=/home/chleroy/linux-powerpc/tools/objtool/
> make -C /home/chleroy/linux-powerpc/tools/build CFLAGS= LDFLAGS= 
> /home/chleroy/linux-powerpc/tools/objtool/fixdep
> make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build dir=. 
> obj=fixdep
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.exec-cmd.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o -ggdb3 
> -Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o exec-cmd.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.help.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/help.o -ggdb3 -Wall 
> -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/help.o help.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.pager.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/pager.o -ggdb3 -Wall 
> -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/pager.o pager.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.parse-options.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/parse-options.o -ggdb3 
> -Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/parse-options.o parse-options.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.run-command.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/run-command.o -ggdb3 
> -Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/run-command.o run-command.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.sigchain.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/sigchain.o -ggdb3 
> -Wall -Wextra -std=gnu99 -fPIC -O6 -Werror -D_LARGEFILE64_SOURCE 
> -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 
> -I/home/chleroy/linux-powerpc/tools/include/ -Wbad-function-cast 
> -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self 
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs 
> -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls 
> -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef 
> -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow 
> -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/sigchain.o sigchain.c
>     ld -r -o /home/chleroy/linux-powerpc/tools/objtool/libsubcmd-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/exec-cmd.o 
> /home/chleroy/linux-powerpc/tools/objtool/help.o 
> /home/chleroy/linux-powerpc/tools/objtool/pager.o 
> /home/chleroy/linux-powerpc/tools/objtool/parse-options.o 
> /home/chleroy/linux-powerpc/tools/objtool/run-command.o 
> /home/chleroy/linux-powerpc/tools/objtool/sigchain.o 
> /home/chleroy/linux-powerpc/tools/objtool/subcmd-config.o
> rm -f /home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a && ar rcs 
> /home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a 
> /home/chleroy/linux-powerpc/tools/objtool/libsubcmd-in.o
> make -f /home/chleroy/linux-powerpc/tools/build/Makefile.build 
> dir=./arch/powerpc obj=objtool
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/.decode.o.d -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o -Werror -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g -I/home/chleroy/linux-powerpc/tools/include -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include -I/home/chleroy/linux-powerpc/tools/objtool/include -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o arch/powerpc/decode.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/.special.o.d -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o -Werror -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g -I/home/chleroy/linux-powerpc/tools/include -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include -I/home/chleroy/linux-powerpc/tools/objtool/include -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o arch/powerpc/special.c
>     ld -r -o 
> /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o 
> /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.weak.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/weak.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/weak.o weak.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.check.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/check.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/check.o check.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.special.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/special.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/special.o special.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.builtin-check.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/builtin-check.o 
> -Werror -Wbad-function-cast -Wdeclaration-after-statement 
> -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations 
> -Wmissing-prototypes -Wnested-externs -Wno-system-headers 
> -Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes 
> -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat 
> -Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-default 
> -Wno-switch-enum -Wno-packed -Wno-nested-externs -Wall 
> -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 
> -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o builtin-check.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.elf.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/elf.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/elf.o elf.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.objtool.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/objtool.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/objtool.o objtool.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.libstring.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/libstring.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/libstring.o ../lib/string.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.libctype.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/libctype.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/libctype.o ../lib/ctype.c
>    gcc 
> -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.str_error_r.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/str_error_r.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/str_error_r.o 
> ../lib/str_error_r.c
>    gcc -Wp,-MD,/home/chleroy/linux-powerpc/tools/objtool/.librbtree.o.d 
> -Wp,-MT,/home/chleroy/linux-powerpc/tools/objtool/librbtree.o -Werror 
> -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security 
> -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes 
> -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked 
> -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum 
> -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 
> -Wshadow -Wno-switch-default -Wno-switch-enum -Wno-packed 
> -Wno-nested-externs -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
> -fomit-frame-pointer -std=gnu11 -Wdeclaration-after-statement -g 
> -I/home/chleroy/linux-powerpc/tools/include 
> -I/home/chleroy/linux-powerpc/tools/arch/x86/include/uapi 
> -I/home/chleroy/linux-powerpc/tools/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/include 
> -I/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/include 
> -I/home/chleroy/linux-powerpc/tools/lib -D"BUILD_STR(s)=#s" -c -o 
> /home/chleroy/linux-powerpc/tools/objtool/librbtree.o ../lib/rbtree.c
>     ld -r -o /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o 
> /home/chleroy/linux-powerpc/tools/objtool/weak.o 
> /home/chleroy/linux-powerpc/tools/objtool/check.o 
> /home/chleroy/linux-powerpc/tools/objtool/special.o 
> /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o 
> /home/chleroy/linux-powerpc/tools/objtool/elf.o 
> /home/chleroy/linux-powerpc/tools/objtool/objtool.o 
> /home/chleroy/linux-powerpc/tools/objtool/libstring.o 
> /home/chleroy/linux-powerpc/tools/objtool/libctype.o 
> /home/chleroy/linux-powerpc/tools/objtool/str_error_r.o 
> /home/chleroy/linux-powerpc/tools/objtool/librbtree.o
> gcc /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o -lelf 
> /home/chleroy/linux-powerpc/tools/objtool/libsubcmd.a   -o 
> /home/chleroy/linux-powerpc/tools/objtool/objtool
> ...
> make -f ./scripts/Makefile.build obj=. need-builtin=1 need-modorder=1
> make -f ./scripts/Makefile.build obj=init \
> need-builtin=1 \
> need-modorder=1 \
> 
>    powerpc64-linux-gcc -Wp,-MMD,init/.main.o.d -nostdinc 
> -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include 
> -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi 
> -I./include/uapi -I./include/generated/uapi -include 
> ./include/linux/compiler-version.h -include ./include/linux/kconfig.h 
> -include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc 
> -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes 
> -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE 
> -Werror=implicit-function-declaration -Werror=implicit-int 
> -Werror=return-type -Wno-format-security -funsigned-char -std=gnu11 
> -mbig-endian -m32 -msoft-float -pipe -ffixed-r2 -mmultiple 
> -mno-readonly-in-sdata -mcpu=powerpc -mno-prefixed -mno-pcrel 
> -mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables 
> -mno-string -Wa,-maltivec -mbig-endian -mstack-protector-guard=tls 
> -mstack-protector-guard-reg=r2 -fno-delete-null-pointer-checks 
> -Wno-frame-address -Wno-format-truncation -Wno-format-overflow 
> -Wno-address-of-packed-member -O2 -fno-allow-store-data-races 
> -Wframe-larger-than=1024 -fstack-protector-strong -Wno-main 
> -Wno-unused-but-set-variable -Wno-unused-const-variable 
> -Wno-dangling-pointer -ftrivial-auto-var-init=zero 
> -fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla 
> -Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation 
> -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized 
> -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 
> -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time 
> -Werror=incompatible-pointer-types -Werror=designated-init 
> -Wno-packed-not-aligned -mstack-protector-guard-offset=544 
> -fno-function-sections -fno-data-sections -DKBUILD_MODFILE='"init/main"' 
> -DKBUILD_BASENAME='"main"' -DKBUILD_MODNAME='"main"' 
> -D__KBUILD_MODNAME=kmod_main -c -o init/main.o init/main.c   ; 
> ./tools/objtool/objtool --mcount   init/main.o
>    ./scripts/check-local-export init/main.o
>     { echo ; echo 'init/main.o: $(wildcard ./tools/objtool/objtool)' ; } 
>  >> init/.main.o.cmd
> set -e; mkdir -p init/; trap "rm -f init/.utsversion-tmp.h.tmp" EXIT; { 
> utsver=$(echo '#'""   "" | cut -b -64); echo '#'define UTS_VERSION 
> \""${utsver}"\"; } > init/.utsversion-tmp.h.tmp; if [ ! -r 
> init/utsversion-tmp.h ] || ! cmp -s init/utsversion-tmp.h 
> init/.utsversion-tmp.h.tmp; then : '  UPD     init/utsversion-tmp.h'; mv 
> -f init/.utsversion-tmp.h.tmp init/utsversion-tmp.h; fi
>    powerpc64-linux-gcc -Wp,-MMD,init/.version.o.d -nostdinc 
> -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include 
> -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi 
> -I./include/uapi -I./include/generated/uapi -include 
> ./include/linux/compiler-version.h -include ./include/linux/kconfig.h 
> -include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc 
> -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes 
> -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE 
> -Werror=implicit-function-declaration -Werror=implicit-int 
> -Werror=return-type -Wno-format-security -funsigned-char -std=gnu11 
> -mbig-endian -m32 -msoft-float -pipe -ffixed-r2 -mmultiple 
> -mno-readonly-in-sdata -mcpu=powerpc -mno-prefixed -mno-pcrel 
> -mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables 
> -mno-string -Wa,-maltivec -mbig-endian -mstack-protector-guard=tls 
> -mstack-protector-guard-reg=r2 -fno-delete-null-pointer-checks 
> -Wno-frame-address -Wno-format-truncation -Wno-format-overflow 
> -Wno-address-of-packed-member -O2 -fno-allow-store-data-races 
> -Wframe-larger-than=1024 -fstack-protector-strong -Wno-main 
> -Wno-unused-but-set-variable -Wno-unused-const-variable 
> -Wno-dangling-pointer -ftrivial-auto-var-init=zero 
> -fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla 
> -Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation 
> -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized 
> -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 
> -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time 
> -Werror=incompatible-pointer-types -Werror=designated-init 
> -Wno-packed-not-aligned -mstack-protector-guard-offset=544 
> -fno-function-sections -fno-data-sections -include init/utsversion-tmp.h 
>     -DKBUILD_MODFILE='"init/version"' -DKBUILD_BASENAME='"version"' 
> -DKBUILD_MODNAME='"version"' -D__KBUILD_MODNAME=kmod_version -c -o 
> init/version.o init/version.c   ; ./tools/objtool/objtool --mcount 
> init/version.o
>    ./scripts/check-local-export init/version.o
>     { echo ; echo 'init/version.o: $(wildcard ./tools/objtool/objtool)' 
> ; } >> init/.version.o.cmd
> ...


Ok, got the same problem as you with next-20230203

   DESCEND objtool
<stdin>:1:10: fatal error: libelf.h: No such file or directory
compilation terminated.
   HOSTCC  /home/chleroy/linux-powerpc/tools/objtool/fixdep.o
   HOSTLD  /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o
   LINK    /home/chleroy/linux-powerpc/tools/objtool/fixdep
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/exec-cmd.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/help.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/pager.o
   CC 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/parse-options.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/run-command.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/sigchain.o
   CC 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/subcmd-config.o
   LD 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd-in.o
   AR      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd.a
   INSTALL libsubcmd_headers
   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o
   LD 
/home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/weak.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/check.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/special.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/elf.o
elf.c: In function 'read_sections':
elf.c:273:9: error: 'elf_getshnum' is deprecated 
[-Werror=deprecated-declarations]
   273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
       |         ^~
In file included from /usr/include/gelf.h:32,
                  from 
/home/chleroy/linux-powerpc/tools/objtool/include/objtool/elf.h:10,
                  from elf.c:22:
/usr/include/libelf.h:310:12: note: declared here
   310 | extern int elf_getshnum (Elf *__elf, size_t *__dst)
       |            ^~~~~~~~~~~~
elf.c:278:9: error: 'elf_getshstrndx' is deprecated 
[-Werror=deprecated-declarations]
   278 |         if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
       |         ^~
/usr/include/libelf.h:322:12: note: declared here
   322 | extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
       |            ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [/home/chleroy/linux-powerpc/tools/build/Makefile.build:97: 
/home/chleroy/linux-powerpc/tools/objtool/elf.o] Error 1
make[2]: *** [Makefile:66: 
/home/chleroy/linux-powerpc/tools/objtool/objtool-in.o] Error 2
make[1]: *** [Makefile:73: objtool] Error 2
make: *** [Makefile:1439: tools/objtool] Error 2


That's odd, because if I do it manually it works:


$ make LDFLAGS= MAKEFLAGS=" " O=/home/chleroy/linux-powerpc subdir=tools 
-C ./tools/ objtool
make : on entre dans le répertoire « /home/chleroy/linux-powerpc/tools »
   DESCEND objtool
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/exec-cmd.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/help.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/pager.o
   CC 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/parse-options.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/run-command.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/sigchain.o
   CC 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/subcmd-config.o
   LD 
/home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd-in.o
   AR      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd.a
   INSTALL libsubcmd_headers
   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/x86/special.o
   GEN 
/home/chleroy/linux-powerpc/tools/objtool/arch/x86/lib/inat-tables.c
   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/x86/decode.o
   LD      /home/chleroy/linux-powerpc/tools/objtool/arch/x86/objtool-in.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/weak.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/check.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/special.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/elf.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/objtool.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/orc_gen.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/orc_dump.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libstring.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/libctype.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/str_error_r.o
   CC      /home/chleroy/linux-powerpc/tools/objtool/librbtree.o
   LD      /home/chleroy/linux-powerpc/tools/objtool/objtool-in.o
   LINK    /home/chleroy/linux-powerpc/tools/objtool/objtool
make : on quitte le répertoire « /home/chleroy/linux-powerpc/tools »
[chleroy@PO20335 linux-powerpc]$ file 
/home/chleroy/linux-powerpc/tools/objtool/objtool
/home/chleroy/linux-powerpc/tools/objtool/objtool: ELF 64-bit LSB 
executable, x86-64, version 1 (SYSV), dynamically linked, interpreter 
/lib64/ld-linux-x86-64.so.2, 
BuildID[sha1]=1f445df36c222194c5bce8147a30a1fa1120f318, for GNU/Linux 
3.2.0, with debug_info, not stripped


Christophe

Christophe

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
  2023-02-04 13:10               ` Christophe Leroy
@ 2023-02-04 15:47                 ` Josh Poimboeuf
  -1 siblings, 0 replies; 128+ messages in thread
From: Josh Poimboeuf @ 2023-02-04 15:47 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Randy Dunlap, Sathvika Vasireddy, linuxppc-dev, jpoimboe, peterz,
	linux-kernel, aik, mpe, mingo, rostedt, mbenes, npiggin,
	chenzhongjin, naveen.n.rao, Elliott, Robert (Servers)

On Sat, Feb 04, 2023 at 02:10:34PM +0100, Christophe Leroy wrote:
> Ok, got the same problem as you with next-20230203
> 
>   DESCEND objtool
> <stdin>:1:10: fatal error: libelf.h: No such file or directory
> compilation terminated.
>   HOSTCC  /home/chleroy/linux-powerpc/tools/objtool/fixdep.o
>   HOSTLD  /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o
>   LINK    /home/chleroy/linux-powerpc/tools/objtool/fixdep
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/exec-cmd.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/help.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/pager.o
>   CC /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/parse-options.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/run-command.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/sigchain.o
>   CC /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/subcmd-config.o
>   LD /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd-in.o
>   AR      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd.a
>   INSTALL libsubcmd_headers
>   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o
>   LD /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/weak.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/check.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/special.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/elf.o
> elf.c: In function 'read_sections':
> elf.c:273:9: error: 'elf_getshnum' is deprecated
> [-Werror=deprecated-declarations]
>   273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
>       |         ^~

This should be fixed with the latest tip/objtool/core which was rebased
today.  Here's the diff:

diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index 29a8cd7449bf..83b100c1e7f6 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -36,7 +36,7 @@ OBJTOOL_CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBE
 OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
 
 # Allow old libelf to be used:
-elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
+elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(HOSTCC) $(OBJTOOL_CFLAGS) -x c -E - | grep elf_getshdr)
 OBJTOOL_CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
 
 # Always want host compilation.

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

* Re: [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc
@ 2023-02-04 15:47                 ` Josh Poimboeuf
  0 siblings, 0 replies; 128+ messages in thread
From: Josh Poimboeuf @ 2023-02-04 15:47 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: peterz, chenzhongjin, Randy Dunlap, linux-kernel, rostedt, aik,
	mingo, Sathvika Vasireddy, npiggin, jpoimboe, naveen.n.rao,
	mbenes, linuxppc-dev, Elliott, Robert (Servers)

On Sat, Feb 04, 2023 at 02:10:34PM +0100, Christophe Leroy wrote:
> Ok, got the same problem as you with next-20230203
> 
>   DESCEND objtool
> <stdin>:1:10: fatal error: libelf.h: No such file or directory
> compilation terminated.
>   HOSTCC  /home/chleroy/linux-powerpc/tools/objtool/fixdep.o
>   HOSTLD  /home/chleroy/linux-powerpc/tools/objtool/fixdep-in.o
>   LINK    /home/chleroy/linux-powerpc/tools/objtool/fixdep
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/exec-cmd.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/help.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/pager.o
>   CC /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/parse-options.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/run-command.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/sigchain.o
>   CC /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/subcmd-config.o
>   LD /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd-in.o
>   AR      /home/chleroy/linux-powerpc/tools/objtool/libsubcmd/libsubcmd.a
>   INSTALL libsubcmd_headers
>   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/decode.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/special.o
>   LD /home/chleroy/linux-powerpc/tools/objtool/arch/powerpc/objtool-in.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/weak.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/check.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/special.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/builtin-check.o
>   CC      /home/chleroy/linux-powerpc/tools/objtool/elf.o
> elf.c: In function 'read_sections':
> elf.c:273:9: error: 'elf_getshnum' is deprecated
> [-Werror=deprecated-declarations]
>   273 |         if (elf_getshdrnum(elf->elf, &sections_nr)) {
>       |         ^~

This should be fixed with the latest tip/objtool/core which was rebased
today.  Here's the diff:

diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index 29a8cd7449bf..83b100c1e7f6 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -36,7 +36,7 @@ OBJTOOL_CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBE
 OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
 
 # Allow old libelf to be used:
-elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
+elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(HOSTCC) $(OBJTOOL_CFLAGS) -x c -E - | grep elf_getshdr)
 OBJTOOL_CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
 
 # Always want host compilation.

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

end of thread, other threads:[~2023-02-04 15:48 UTC | newest]

Thread overview: 128+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29  5:52 [PATCH v2 00/16] objtool: Enable and implement --mcount option on powerpc Sathvika Vasireddy
2022-08-29  5:52 ` Sathvika Vasireddy
2022-08-29  5:52 ` [PATCH v2 01/16] powerpc: Replace unreachable() with it's builtin variant in __WARN_FLAGS() Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:15   ` Christophe Leroy
2022-08-30  6:15     ` Christophe Leroy
2022-09-05 10:18     ` Naveen N. Rao
2022-09-05 10:18       ` Naveen N. Rao
2022-08-29  5:52 ` [PATCH v2 02/16] powerpc: override __ALIGN() and __ALIGN_STR() macros Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-29 13:26   ` Christophe Leroy
2022-08-29 13:26     ` Christophe Leroy
2022-08-29 14:39     ` Sathvika Vasireddy
2022-08-29 14:39       ` Sathvika Vasireddy
2022-08-31  3:24   ` Nicholas Piggin
2022-08-31  3:24     ` Nicholas Piggin
2022-08-31  7:22     ` Michael Ellerman
2022-08-31  7:22       ` Michael Ellerman
2022-09-05 11:03   ` Peter Zijlstra
2022-09-05 11:03     ` Peter Zijlstra
2022-08-29  5:52 ` [PATCH v2 03/16] powerpc: Fix objtool unannotated intra-function call warnings Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:16   ` Christophe Leroy
2022-08-30  6:16     ` Christophe Leroy
2022-08-30 12:42   ` Christophe Leroy
2022-08-30 12:42     ` Christophe Leroy
2022-09-05 11:02   ` Peter Zijlstra
2022-09-05 11:02     ` Peter Zijlstra
2022-08-29  5:52 ` [PATCH v2 04/16] powerpc: Curb objtool unannotated intra-function warnings Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:26   ` Christophe Leroy
2022-08-30  6:26     ` Christophe Leroy
2022-08-29  5:52 ` [PATCH v2 05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:26   ` Christophe Leroy
2022-08-30  6:26     ` Christophe Leroy
2022-09-01 19:17   ` Peter Zijlstra
2022-09-01 19:17     ` Peter Zijlstra
2022-09-05 10:47     ` Naveen N. Rao
2022-09-05 10:47       ` Naveen N. Rao
2022-08-29  5:52 ` [PATCH v2 06/16] powerpc: Fix objtool unannotated intra-function call warnings on PPC32 Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-29  5:52 ` [PATCH v2 07/16] powerpc: Skip objtool from running on VDSO files Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:27   ` Christophe Leroy
2022-08-30  6:27     ` Christophe Leroy
2022-09-01 19:19   ` Peter Zijlstra
2022-09-01 19:19     ` Peter Zijlstra
2022-09-02  7:40     ` Michael Ellerman
2022-09-02  7:40       ` Michael Ellerman
2022-08-29  5:52 ` [PATCH v2 08/16] objtool: Fix SEGFAULT Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-09-01 19:20   ` Peter Zijlstra
2022-09-01 19:20     ` Peter Zijlstra
2022-09-02  8:06     ` Christophe Leroy
2022-09-02  8:06       ` Christophe Leroy
2022-09-02  8:42       ` Peter Zijlstra
2022-09-02  8:42         ` Peter Zijlstra
2022-08-29  5:52 ` [PATCH v2 09/16] objtool: Use target file endianness instead of a compiled constant Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-09-01 19:22   ` Peter Zijlstra
2022-09-01 19:22     ` Peter Zijlstra
2022-08-29  5:52 ` [PATCH v2 10/16] objtool: Use target file class size " Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-09-01 19:23   ` Peter Zijlstra
2022-09-01 19:23     ` Peter Zijlstra
2022-08-29  5:52 ` [PATCH v2 11/16] objtool: Add --mnop as an option to --mcount Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:28   ` Christophe Leroy
2022-08-30  6:28     ` Christophe Leroy
2022-09-01 19:25   ` Peter Zijlstra
2022-09-01 19:25     ` Peter Zijlstra
2022-09-05 10:55     ` Naveen N. Rao
2022-09-05 10:55       ` Naveen N. Rao
2022-08-29  5:52 ` [PATCH v2 12/16] objtool: Read special sections with alts only when specific options are selected Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:31   ` Christophe Leroy
2022-08-30  6:31     ` Christophe Leroy
2022-08-29  5:52 ` [PATCH v2 13/16] objtool: Use macros to define arch specific reloc types Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:33   ` Christophe Leroy
2022-08-30  6:33     ` Christophe Leroy
2022-09-01 19:28   ` Peter Zijlstra
2022-09-01 19:28     ` Peter Zijlstra
2022-08-29  5:52 ` [PATCH v2 14/16] objtool: Add arch specific function arch_ftrace_match() Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:36   ` Christophe Leroy
2022-08-30  6:36     ` Christophe Leroy
2022-08-29  5:52 ` [PATCH v2 15/16] objtool/powerpc: Enable objtool to be built on ppc Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:41   ` Christophe Leroy
2022-08-30  6:41     ` Christophe Leroy
2022-09-05 10:37     ` Naveen N. Rao
2022-09-05 10:37       ` Naveen N. Rao
2023-02-04  8:19     ` Randy Dunlap
2023-02-04  8:19       ` Randy Dunlap
2023-02-04  8:21       ` Randy Dunlap
2023-02-04  8:21         ` Randy Dunlap
2023-02-04  8:30         ` Randy Dunlap
2023-02-04  8:30           ` Randy Dunlap
2023-02-04 11:55           ` Christophe Leroy
2023-02-04 11:55             ` Christophe Leroy
2023-02-04 13:10             ` Christophe Leroy
2023-02-04 13:10               ` Christophe Leroy
2023-02-04 15:47               ` Josh Poimboeuf
2023-02-04 15:47                 ` Josh Poimboeuf
2022-09-01  9:32   ` Christophe Leroy
2022-09-01  9:32     ` Christophe Leroy
2022-09-01 15:11     ` Segher Boessenkool
2022-09-01 15:11       ` Segher Boessenkool
2022-09-01 16:38       ` Christophe Leroy
2022-09-01 16:38         ` Christophe Leroy
2022-09-01 19:01         ` Peter Zijlstra
2022-09-01 19:01           ` Peter Zijlstra
2022-08-29  5:52 ` [PATCH v2 16/16] objtool/powerpc: Add --mcount specific implementation Sathvika Vasireddy
2022-08-29  5:52   ` Sathvika Vasireddy
2022-08-30  6:44   ` Christophe Leroy
2022-08-30  6:44     ` Christophe Leroy
2022-08-31 12:50   ` Christophe Leroy
2022-08-31 12:50     ` Christophe Leroy
2022-08-31 17:51     ` Segher Boessenkool
2022-08-31 17:51       ` Segher Boessenkool
2022-09-05 10:45       ` Naveen N. Rao
2022-09-05 10:45         ` Naveen N. Rao
2022-09-05 20:43         ` Segher Boessenkool
2022-09-05 20:43           ` Segher Boessenkool
2022-09-06  6:22           ` Christophe Leroy
2022-09-06  6:22             ` Christophe Leroy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.