2022-11-14 18:38:31

by Sathvika Vasireddy

[permalink] [raw]
Subject: [PATCH v6 00/16] objtool: Enable and implement --mcount option on powerpc

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

Changelog:

----
v6:

* Patch 06/16 - Add annotations to assembly files
arch/powerpc/kernel/cpu_setup_e500.S and arch/powerpc/kernel/head_85xx.S
----
v5:

* Patch 02/16 - Add Reviewed-by tag from Christophe Leroy

* Patch 03/16 - Fix merge conflicts with latest powerpc/merge branch

* Patch 06/16 - Files arch/powerpc/kernel/cpu_setup_fsl_booke.S and
arch/powerpc/kernel/head_fsl_booke.S are not present
today. Removed annotations in those assembly files.

* Patch 11/16 - Add Reviewed-by tag from Christophe Leroy
- Changed scripts/Makefile.lib file to make
CONFIG_HAVE_OBJTOOL_NOP_MCOUNT depend on
CONFIG_FTRACE_MCOUNT_USE_OBJTOOL.

* Patch 12/16 - Add Reviewed-by tag from Christophe Leroy

* Patch 16/16 - Add Reviewed-by tag from Christophe Leroy

* For this series - Add Acked-by tag from Josh Poimboeuf
- Add Tested-by tag from Naveen N. Rao
- Add Reviewed-by tag from Naveen N. Rao
----
v4:

* Patch 11/16 - Introduce a new config option
CONFIG_HAVE_OBJTOOL_NOP_MCOUNT as a means for
architectures to enable nop'ing ftrace locations.

- Remove Acked-by tag from Peter Zijlstra (Intel),
and Reviewed-by tag from Christophe Leroy.
[This is done because I reworked the patch to add
a new config option to objtool. Please let me know
if you want me to retain the tags. Thanks!]

* Patch 16/16 - Rework the patch to handle only 'bl' instruction
decoding.

----
v3:

* Patch 01/16 - Rework patch subject.
- Rework changelog.
- Add Reviewed-by tag from Christophe Leroy.

* Patch 02/16 - Rework changelog to update details based on feedback
from Nicholas Piggin and Michael Ellerman.
- Use quotes instead of __stringify macro, based on
suggestion from Christophe Leroy.

* Patch 03/16 - Add Reviewed-by tag from Christophe Leroy.
- Based on Christophe's suggestion, keep all <linux/...>
before <asm/...>.
- Rework changelog.

* Patch 04/16 - Add Reviewed-by tag from Christophe Leroy.

* Patch 05/16 - Add Reviewed-by tag from Christophe Leroy.

* Patch 06/16 - No change.

* Patch 07/16 - Add Reviewed-by tag from Christophe Leroy.

* Patch 08/16 - Add Acked-by tag from Peter Zijlstra.

* Patch 09/16 - Add Acked-by tag from Peter Zijlstra.

* Patch 10/16 - Reorder local variable declarations to use reverse
xmas tree format.
- Add Signed-off-by tag from Sathvika Vasireddy indicating
changes done.
- Add Acked-by tag from Peter Zijlstra.

* Patch 11/16 - Update changelog to indicate that powerpc kernel does
not support nop'ed out ftrace locations.
- Add Acked-by tag from Peter Zijlstra.
- Add Reviewed-by tag from Christophe Leroy.

* Patch 12/16 - Per Christophe's comment, rework changelog.

* Patch 13/16 - Add Acked-by tag from Peter Zijlstra.
- Add Reviewed-by tag from Christophe Leroy.

* Patch 14/16 - Simplify arch_ftrace_match() function, based on
Christophe's suggestion.
- Add Reviewed-by tag from Christophe Leroy.

* Patch 15/16 - Include code from Christophe Leroy to use local vars for
type and imm, and to adapt len for prefixed
instructions.

* Patch 16/16 - Based on suggestion from Christophe Leroy, setup
immediate value calculation outside the check for
specific instruction under case 18.
- Set instruction type to INSN_CALL for 'bla'
instruction as well.

----
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: Fix __WARN_FLAGS() for use with Objtool
powerpc: Override __ALIGN and __ALIGN_STR macros
powerpc: Fix objtool unannotated intra-function call warnings
powerpc: Curb objtool unannotated intra-function 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 | 3 +
arch/powerpc/kernel/cpu_setup_6xx.S | 26 +++--
arch/powerpc/kernel/cpu_setup_e500.S | 8 +-
arch/powerpc/kernel/entry_32.S | 9 +-
arch/powerpc/kernel/entry_64.S | 2 +
arch/powerpc/kernel/exceptions-64s.S | 4 +-
arch/powerpc/kernel/head_40x.S | 5 +-
arch/powerpc/kernel/head_64.S | 7 +-
arch/powerpc/kernel/head_85xx.S | 5 +-
arch/powerpc/kernel/head_8xx.S | 5 +-
arch/powerpc/kernel/head_book3s_32.S | 29 +++--
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 +
kernel/trace/Kconfig | 7 ++
scripts/Makefile.lib | 3 +
tools/objtool/arch/powerpc/Build | 2 +
tools/objtool/arch/powerpc/decode.c | 101 ++++++++++++++++++
.../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 | 5 +
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 | 53 ++++-----
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 +-
46 files changed, 418 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



2022-11-14 18:38:51

by Sathvika Vasireddy

[permalink] [raw]
Subject: [PATCH v6 08/16] objtool: Fix SEGFAULT

From: Christophe Leroy <[email protected]>

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

Tested-by: Naveen N. Rao <[email protected]>
Reviewed-by: Naveen N. Rao <[email protected]>
Acked-by: Josh Poimboeuf <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Christophe Leroy <[email protected]>
---
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 43ec14c29a60..8427af808221 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -207,7 +207,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


2022-11-14 18:38:52

by Sathvika Vasireddy

[permalink] [raw]
Subject: [PATCH v6 09/16] objtool: Use target file endianness instead of a compiled constant

From: Christophe Leroy <[email protected]>

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.

Tested-by: Naveen N. Rao <[email protected]>
Reviewed-by: Naveen N. Rao <[email protected]>
Acked-by: Josh Poimboeuf <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Christophe Leroy <[email protected]>
---
.../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 8427af808221..ad5dab175701 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2100,7 +2100,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


2022-11-14 18:39:09

by Sathvika Vasireddy

[permalink] [raw]
Subject: [PATCH v6 15/16] objtool/powerpc: Enable objtool to be built on ppc

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

Tested-by: Naveen N. Rao <[email protected]>
Reviewed-by: Naveen N. Rao <[email protected]>
Acked-by: Josh Poimboeuf <[email protected]>
Signed-off-by: Sathvika Vasireddy <[email protected]>
[Christophe Leroy: powerpc: Add missing asm/asm.h for objtool,
Use local variables for type and imm in arch_decode_instruction(),
Adapt len for prefixed instructions.]
Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/asm.h | 7 ++
tools/objtool/arch/powerpc/Build | 2 +
tools/objtool/arch/powerpc/decode.c | 85 +++++++++++++++++++
.../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, 154 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 2ca5418457ed..82e3e5e175ae 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -239,6 +239,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..dcd0975cad6b
--- /dev/null
+++ b/tools/objtool/arch/powerpc/decode.c
@@ -0,0 +1,85 @@
+// 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)
+{
+ unsigned int opcode;
+ enum insn_type typ;
+ unsigned long imm;
+ u32 insn;
+
+ insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
+ opcode = insn >> 26;
+ typ = INSN_OTHER;
+ imm = 0;
+
+ if (opcode == 1)
+ *len = 8;
+ else
+ *len = 4;
+
+ *type = typ;
+ *immediate = imm;
+
+ 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


2022-12-08 14:13:45

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH v6 00/16] objtool: Enable and implement --mcount option on powerpc

On Mon, 14 Nov 2022 23:27:38 +0530, Sathvika Vasireddy wrote:
> This patchset enables and implements objtool --mcount
> option on powerpc. This applies atop powerpc/merge branch.
>
> Changelog:
>
> ----
> v6:
>
> [...]

Applied to powerpc/next (and topic/objtool).

[01/16] powerpc: Fix __WARN_FLAGS() for use with Objtool
https://git.kernel.org/powerpc/c/93e3f45a26310e3f3f8558be40df411e23ab742c
[02/16] powerpc: Override __ALIGN and __ALIGN_STR macros
https://git.kernel.org/powerpc/c/01f2cf0b990e58ae89142f57c7e02d33621311d2
[03/16] powerpc: Fix objtool unannotated intra-function call warnings
https://git.kernel.org/powerpc/c/29a011fc79e625b2b02f25262657f7c4c59ae9f7
[04/16] powerpc: Curb objtool unannotated intra-function call warnings
https://git.kernel.org/powerpc/c/8d0c21b50655bfe136a76cf384495ba1f9c87224
[05/16] powerpc: Skip objtool from running on drivers/crypto/vmx/aesp8-ppc.o
https://git.kernel.org/powerpc/c/1c137323e9a2a970b4a5bf8cf3c50e0ea1cefbeb
[06/16] powerpc: Fix objtool unannotated intra-function call warnings on PPC32
https://git.kernel.org/powerpc/c/2da37761671b5bdedbe04e6469cfa57cd6b6ae45
[07/16] powerpc: Skip objtool from running on VDSO files
https://git.kernel.org/powerpc/c/d0160bd5d389da247fb5affb6a35ea393d22fedb
[08/16] objtool: Fix SEGFAULT
https://git.kernel.org/powerpc/c/efb11fdb3e1a9f694fa12b70b21e69e55ec59c36
[09/16] objtool: Use target file endianness instead of a compiled constant
https://git.kernel.org/powerpc/c/0646c28b417b7fe307c9da72ca1c508e43b57dc0
[10/16] objtool: Use target file class size instead of a compiled constant
https://git.kernel.org/powerpc/c/86ea7f361537f825a699e86fdc9e49be19f128d1
[11/16] objtool: Add --mnop as an option to --mcount
https://git.kernel.org/powerpc/c/280981d6994e0700abd36647b141e73059851e66
[12/16] objtool: Read special sections with alts only when specific options are selected
https://git.kernel.org/powerpc/c/de6fbcedf5abce4c321eeb15d7d286b79804b8b6
[13/16] objtool: Use macros to define arch specific reloc types
https://git.kernel.org/powerpc/c/c1449735211dd8c4c2d54fa0ece6890ecbd74e24
[14/16] objtool: Add arch specific function arch_ftrace_match()
https://git.kernel.org/powerpc/c/4ca993d498987332ceeedee5380101b84accaf35
[15/16] objtool/powerpc: Enable objtool to be built on ppc
https://git.kernel.org/powerpc/c/e52ec98c5ab18c0710ea22bf52f45e60a725adaf
[16/16] objtool/powerpc: Add --mcount specific implementation
https://git.kernel.org/powerpc/c/c984aef8c8326035570ff6e01d0ff9e79a5dfa76

cheers