Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

objtool: Add --mnop as an option to --mcount

Some architectures (powerpc) may not support ftrace locations being nop'ed
out at build time. Introduce CONFIG_HAVE_OBJTOOL_NOP_MCOUNT for objtool, as
a means for architectures to enable nop'ing of ftrace locations. Add --mnop
as an option to objtool --mcount, to indicate support for the same.

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

Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20221114175754.1131267-12-sv@linux.ibm.com

authored by

Sathvika Vasireddy and committed by
Michael Ellerman
280981d6 86ea7f36

+39 -10
+3 -1
Makefile
··· 933 933 endif 934 934 endif 935 935 ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL 936 - CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT 936 + ifdef CONFIG_HAVE_OBJTOOL_NOP_MCOUNT 937 + CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT 938 + endif 937 939 endif 938 940 ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT 939 941 ifdef CONFIG_HAVE_C_RECORDMCOUNT
+1
arch/x86/Kconfig
··· 195 195 select HAVE_CONTEXT_TRACKING_USER_OFFSTACK if HAVE_CONTEXT_TRACKING_USER 196 196 select HAVE_C_RECORDMCOUNT 197 197 select HAVE_OBJTOOL_MCOUNT if HAVE_OBJTOOL 198 + select HAVE_OBJTOOL_NOP_MCOUNT if HAVE_OBJTOOL_MCOUNT 198 199 select HAVE_BUILDTIME_MCOUNT_SORT 199 200 select HAVE_DEBUG_KMEMLEAK 200 201 select HAVE_DMA_CONTIGUOUS
+7
kernel/trace/Kconfig
··· 82 82 help 83 83 Arch supports objtool --mcount 84 84 85 + config HAVE_OBJTOOL_NOP_MCOUNT 86 + bool 87 + help 88 + Arch supports the objtool options --mcount with --mnop. 89 + An architecture can select this if it wants to enable nop'ing 90 + of ftrace locations. 91 + 85 92 config HAVE_C_RECORDMCOUNT 86 93 bool 87 94 help
+3
scripts/Makefile.lib
··· 256 256 objtool-args-$(CONFIG_HAVE_NOINSTR_HACK) += --hacks=noinstr 257 257 objtool-args-$(CONFIG_X86_KERNEL_IBT) += --ibt 258 258 objtool-args-$(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL) += --mcount 259 + ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL 260 + objtool-args-$(CONFIG_HAVE_OBJTOOL_NOP_MCOUNT) += --mnop 261 + endif 259 262 objtool-args-$(CONFIG_UNWINDER_ORC) += --orc 260 263 objtool-args-$(CONFIG_RETPOLINE) += --retpoline 261 264 objtool-args-$(CONFIG_RETHUNK) += --rethunk
+14
tools/objtool/builtin-check.c
··· 82 82 OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"), 83 83 OPT_BOOLEAN(0, "link", &opts.link, "object is a linked object"), 84 84 OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel module"), 85 + OPT_BOOLEAN(0, "mnop", &opts.mnop, "nop out mcount call sites"), 85 86 OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable instruction' warnings"), 86 87 OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"), 87 88 OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"), ··· 151 150 return false; 152 151 } 153 152 153 + static bool mnop_opts_valid(void) 154 + { 155 + if (opts.mnop && !opts.mcount) { 156 + ERROR("--mnop requires --mcount"); 157 + return false; 158 + } 159 + 160 + return true; 161 + } 162 + 154 163 static bool link_opts_valid(struct objtool_file *file) 155 164 { 156 165 if (opts.link) ··· 207 196 208 197 file = objtool_open_read(objname); 209 198 if (!file) 199 + return 1; 200 + 201 + if (!mnop_opts_valid()) 210 202 return 1; 211 203 212 204 if (!link_opts_valid(file))
+10 -9
tools/objtool/check.c
··· 1256 1256 if (opts.mcount && sym->fentry) { 1257 1257 if (sibling) 1258 1258 WARN_FUNC("Tail call to __fentry__ !?!?", insn->sec, insn->offset); 1259 + if (opts.mnop) { 1260 + if (reloc) { 1261 + reloc->type = R_NONE; 1262 + elf_write_reloc(file->elf, reloc); 1263 + } 1259 1264 1260 - if (reloc) { 1261 - reloc->type = R_NONE; 1262 - elf_write_reloc(file->elf, reloc); 1265 + elf_write_insn(file->elf, insn->sec, 1266 + insn->offset, insn->len, 1267 + arch_nop_insn(insn->len)); 1268 + 1269 + insn->type = INSN_NOP; 1263 1270 } 1264 - 1265 - elf_write_insn(file->elf, insn->sec, 1266 - insn->offset, insn->len, 1267 - arch_nop_insn(insn->len)); 1268 - 1269 - insn->type = INSN_NOP; 1270 1271 1271 1272 list_add_tail(&insn->call_node, &file->mcount_loc_list); 1272 1273 return;
+1
tools/objtool/include/objtool/builtin.h
··· 31 31 bool backup; 32 32 bool dryrun; 33 33 bool link; 34 + bool mnop; 34 35 bool module; 35 36 bool no_unreachable; 36 37 bool sec_address;