From: Christophe Leroy <christophe.leroy@csgroup.eu> To: Sathvika Vasireddy <sv@linux.ibm.com>, "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org> Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "jpoimboe@redhat.com" <jpoimboe@redhat.com>, "peterz@infradead.org" <peterz@infradead.org>, "mbenes@suse.cz" <mbenes@suse.cz>, "aik@ozlabs.ru" <aik@ozlabs.ru>, "mpe@ellerman.id.au" <mpe@ellerman.id.au>, "rostedt@goodmis.org" <rostedt@goodmis.org>, "naveen.n.rao@linux.vnet.ibm.com" <naveen.n.rao@linux.vnet.ibm.com> Subject: Re: [RFC PATCH 3/4] objtool/powerpc: Enable objtool to be built on ppc Date: Tue, 24 May 2022 09:13:01 +0000 [thread overview] Message-ID: <005ffe8a-166e-d3bb-4e42-0ece6f5aada7@csgroup.eu> (raw) In-Reply-To: <20220523175548.922671-4-sv@linux.ibm.com> Le 23/05/2022 à 19:55, Sathvika Vasireddy a écrit : > This patch adds [stub] implementations for required > functions, inorder to enable objtool build on powerpc. Should we put some exit() or abort() in the stubs that are not supposed to be used at all ? > > Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com> > --- > arch/powerpc/Kconfig | 1 + > tools/objtool/arch/powerpc/Build | 2 + > tools/objtool/arch/powerpc/decode.c | 73 +++++++++++++++++++ > .../arch/powerpc/include/arch/cfi_regs.h | 11 +++ > tools/objtool/arch/powerpc/include/arch/elf.h | 8 ++ > .../arch/powerpc/include/arch/endianness.h | 9 +++ > .../arch/powerpc/include/arch/special.h | 21 ++++++ > tools/objtool/arch/powerpc/special.c | 19 +++++ > 8 files changed, 144 insertions(+) > 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/endianness.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 174edabb74fa..732a3f91ee5e 100644 > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -232,6 +232,7 @@ config PPC > select HAVE_MOD_ARCH_SPECIFIC > select HAVE_NMI if PERF_EVENTS || (PPC64 && PPC_BOOK3S) > select HAVE_OPTPROBES > + select HAVE_OBJTOOL if PPC64 > select HAVE_PERF_EVENTS > select HAVE_PERF_EVENTS_NMI if PPC64 > select HAVE_PERF_REGS > 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..e3b77a6ce357 > --- /dev/null > +++ b/tools/objtool/arch/powerpc/decode.c > @@ -0,0 +1,73 @@ > +// 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> > + > +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) > +{ > + return 0; > +} > + > +const char *arch_nop_insn(int len) > +{ > + return NULL; > +} > + > +const char *arch_ret_insn(int len) > +{ > + return NULL; > +} > + > +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; > + memcpy(&insn, sec->data->d_buf+offset, 4); > + *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/endianness.h b/tools/objtool/arch/powerpc/include/arch/endianness.h > new file mode 100644 > index 000000000000..7c362527da20 > --- /dev/null > +++ b/tools/objtool/arch/powerpc/include/arch/endianness.h > @@ -0,0 +1,9 @@ > +/* 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/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..e3e75cbab858 > --- /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 <objtool/special.h> > +#include <objtool/builtin.h> > + > + > +bool arch_support_alt_relocation(struct special_alt *special_alt, > + struct instruction *insn, > + struct reloc *reloc) > +{ > + return false; > +} > + > +struct reloc *arch_find_switch_table(struct objtool_file *file, > + struct instruction *insn) > +{ > + return NULL; > +}
WARNING: multiple messages have this Message-ID (diff)
From: Christophe Leroy <christophe.leroy@csgroup.eu> To: Sathvika Vasireddy <sv@linux.ibm.com>, "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org> Cc: "peterz@infradead.org" <peterz@infradead.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "rostedt@goodmis.org" <rostedt@goodmis.org>, "aik@ozlabs.ru" <aik@ozlabs.ru>, "jpoimboe@redhat.com" <jpoimboe@redhat.com>, "naveen.n.rao@linux.vnet.ibm.com" <naveen.n.rao@linux.vnet.ibm.com>, "mbenes@suse.cz" <mbenes@suse.cz> Subject: Re: [RFC PATCH 3/4] objtool/powerpc: Enable objtool to be built on ppc Date: Tue, 24 May 2022 09:13:01 +0000 [thread overview] Message-ID: <005ffe8a-166e-d3bb-4e42-0ece6f5aada7@csgroup.eu> (raw) In-Reply-To: <20220523175548.922671-4-sv@linux.ibm.com> Le 23/05/2022 à 19:55, Sathvika Vasireddy a écrit : > This patch adds [stub] implementations for required > functions, inorder to enable objtool build on powerpc. Should we put some exit() or abort() in the stubs that are not supposed to be used at all ? > > Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com> > --- > arch/powerpc/Kconfig | 1 + > tools/objtool/arch/powerpc/Build | 2 + > tools/objtool/arch/powerpc/decode.c | 73 +++++++++++++++++++ > .../arch/powerpc/include/arch/cfi_regs.h | 11 +++ > tools/objtool/arch/powerpc/include/arch/elf.h | 8 ++ > .../arch/powerpc/include/arch/endianness.h | 9 +++ > .../arch/powerpc/include/arch/special.h | 21 ++++++ > tools/objtool/arch/powerpc/special.c | 19 +++++ > 8 files changed, 144 insertions(+) > 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/endianness.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 174edabb74fa..732a3f91ee5e 100644 > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -232,6 +232,7 @@ config PPC > select HAVE_MOD_ARCH_SPECIFIC > select HAVE_NMI if PERF_EVENTS || (PPC64 && PPC_BOOK3S) > select HAVE_OPTPROBES > + select HAVE_OBJTOOL if PPC64 > select HAVE_PERF_EVENTS > select HAVE_PERF_EVENTS_NMI if PPC64 > select HAVE_PERF_REGS > 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..e3b77a6ce357 > --- /dev/null > +++ b/tools/objtool/arch/powerpc/decode.c > @@ -0,0 +1,73 @@ > +// 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> > + > +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) > +{ > + return 0; > +} > + > +const char *arch_nop_insn(int len) > +{ > + return NULL; > +} > + > +const char *arch_ret_insn(int len) > +{ > + return NULL; > +} > + > +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; > + memcpy(&insn, sec->data->d_buf+offset, 4); > + *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/endianness.h b/tools/objtool/arch/powerpc/include/arch/endianness.h > new file mode 100644 > index 000000000000..7c362527da20 > --- /dev/null > +++ b/tools/objtool/arch/powerpc/include/arch/endianness.h > @@ -0,0 +1,9 @@ > +/* 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/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..e3e75cbab858 > --- /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 <objtool/special.h> > +#include <objtool/builtin.h> > + > + > +bool arch_support_alt_relocation(struct special_alt *special_alt, > + struct instruction *insn, > + struct reloc *reloc) > +{ > + return false; > +} > + > +struct reloc *arch_find_switch_table(struct objtool_file *file, > + struct instruction *insn) > +{ > + return NULL; > +}
next prev parent reply other threads:[~2022-05-24 9:13 UTC|newest] Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-23 17:55 [RFC PATCH 0/4] objtool: Enable and implement --mcount option on powerpc Sathvika Vasireddy 2022-05-23 17:55 ` Sathvika Vasireddy 2022-05-23 17:55 ` [RFC PATCH 1/4] objtool: Add --mnop as an option to --mcount Sathvika Vasireddy 2022-05-23 17:55 ` Sathvika Vasireddy 2022-05-24 8:54 ` Christophe Leroy 2022-05-24 8:54 ` Christophe Leroy 2022-05-24 10:15 ` Naveen N. Rao 2022-05-24 10:15 ` Naveen N. Rao 2022-05-24 10:20 ` Christophe Leroy 2022-05-24 10:20 ` Christophe Leroy 2022-05-24 10:31 ` Naveen N. Rao 2022-05-24 10:31 ` Naveen N. Rao 2022-05-25 11:36 ` Peter Zijlstra 2022-05-25 11:36 ` Peter Zijlstra 2022-05-26 11:51 ` Naveen N. Rao 2022-05-26 11:51 ` Naveen N. Rao 2022-05-23 17:55 ` [RFC PATCH 2/4] objtool: Enable objtool to run only on files with ftrace enabled Sathvika Vasireddy 2022-05-23 17:55 ` Sathvika Vasireddy 2022-05-24 8:57 ` Christophe Leroy 2022-05-24 8:57 ` Christophe Leroy 2022-05-24 10:53 ` Sathvika Vasireddy 2022-05-24 10:53 ` Sathvika Vasireddy 2022-05-24 13:28 ` Christophe Leroy 2022-05-24 13:28 ` Christophe Leroy 2022-05-23 17:55 ` [RFC PATCH 3/4] objtool/powerpc: Enable objtool to be built on ppc Sathvika Vasireddy 2022-05-23 17:55 ` Sathvika Vasireddy 2022-05-24 9:13 ` Christophe Leroy [this message] 2022-05-24 9:13 ` Christophe Leroy 2022-05-23 17:55 ` [RFC PATCH 4/4] objtool/powerpc: Add --mcount specific implementation Sathvika Vasireddy 2022-05-23 17:55 ` Sathvika Vasireddy 2022-05-24 9:35 ` Christophe Leroy 2022-05-24 9:35 ` Christophe Leroy 2022-05-24 11:00 ` Sathvika Vasireddy 2022-05-24 11:00 ` Sathvika Vasireddy 2022-05-24 13:33 ` Christophe Leroy 2022-05-24 13:33 ` Christophe Leroy 2022-05-25 17:27 ` Christophe Leroy 2022-05-31 6:20 ` Christophe Leroy 2022-05-31 6:20 ` Christophe Leroy 2022-06-16 13:34 ` Naveen N. Rao 2022-06-16 13:34 ` Naveen N. Rao 2022-06-16 13:40 ` Christophe Leroy 2022-06-16 13:40 ` Christophe Leroy 2022-06-16 13:57 ` Peter Zijlstra 2022-06-16 13:57 ` Peter Zijlstra 2022-06-16 14:06 ` Christophe Leroy 2022-06-16 14:06 ` Christophe Leroy 2022-06-17 14:04 ` Naveen N. Rao 2022-06-17 14:04 ` Naveen N. Rao
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=005ffe8a-166e-d3bb-4e42-0ece6f5aada7@csgroup.eu \ --to=christophe.leroy@csgroup.eu \ --cc=aik@ozlabs.ru \ --cc=jpoimboe@redhat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mbenes@suse.cz \ --cc=mpe@ellerman.id.au \ --cc=naveen.n.rao@linux.vnet.ibm.com \ --cc=peterz@infradead.org \ --cc=rostedt@goodmis.org \ --cc=sv@linux.ibm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.