Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp4935130rwn; Mon, 12 Sep 2022 01:24:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR4t1eFO0doLbkJ38LCdRIx8mfS7WuWqZubNLpj4JEGdNJZjnRojWRPs104oaouaQmOnb8Ac X-Received: by 2002:a05:6a00:9a5:b0:538:73c:bf8f with SMTP id u37-20020a056a0009a500b00538073cbf8fmr26656444pfg.9.1662971047430; Mon, 12 Sep 2022 01:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662971047; cv=none; d=google.com; s=arc-20160816; b=SzuAvc4IOb5Wa5hKzRC89hTKNt3+x8wBRM2PzLld7zsmIlTTVhIYX1dKkGm2Pme1Eo GdDu7OpnFzN1iK6d+Gwh5JWZA+1qjllFOrFT7Fv4jdBqiq/ypqRKW3v2S4cTozDmCeny 70ky19xXqIJp+BNMgUWKT8jhBYJapxqwVHXrOWkd54cn11M0FR5AMrAIPfnNEX5aN0iU asDgbExo+tnSm8iGJCmjnSwaPT3xt0b/jqyQSvvzjXZXo5XFrOdZ38lv5vJqznLf6uUD O9SR+qRykp87CFQ+ohtOMcU4SPq+jPIvcS+qH/KjsepDc2eTamN2v8eE+PNOo62bnEpq edAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=327AK2IFvla7JDhUGVTdBEYzeLlp8k7IchMrrhlr3Ew=; b=NbIEH3/Gs6hSzUR4bczYTVA7/U6rhU4eF0YlRFCE2UP0Ol/fgqgFfobxmmxVmW4W4N B8ZIAOxXarr//p49uLMyz6vBD4EMotfx50ym7OaLuFV9DUoSgosoeA0c8btvwmwbvGdX QwS82ywRucDowSdECS1LoQX2o0bX3UacEp9OBw9ij8yNasmbmH3J7uHxxF5wik2VVMYY dB9QcyFFRaUBaft9XgTg3Kl93xb72YpJPNqgMf8LTJ12Ha4KwQnZgAnI3hJS2Nt2vbZw BjVy6XjIZ0PzogDmOhDNPo7RsCnlmqKbLqSzkL7iC7yka4eRP0QIU1AcJuKIUfhgHEex VvNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=F1dXj0fj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a63d443000000b00434df80335bsi8261610pgj.859.2022.09.12.01.23.55; Mon, 12 Sep 2022 01:24:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=F1dXj0fj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230253AbiILIWz (ORCPT + 99 others); Mon, 12 Sep 2022 04:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbiILIWN (ORCPT ); Mon, 12 Sep 2022 04:22:13 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C592D1EC for ; Mon, 12 Sep 2022 01:22:10 -0700 (PDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28C7pmdS032686; Mon, 12 Sep 2022 08:21:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=327AK2IFvla7JDhUGVTdBEYzeLlp8k7IchMrrhlr3Ew=; b=F1dXj0fjlbMY1whmmwjSMEB1qIzR8WNqTwRW9n0yPsIPgYJc/h7t7vl4pyRrEFLIQtOI mh8T0J470kwE2+El1gLlmPljF9trf6bfoRT+fUTB9h8p80PY7J6xZoOlAa7ivZFPNXFE 90UTqsKvIj37/h86O5N5h7sxJNeKTrW7JLtrWj9symdx+iug6fgnxHcvOUTGiyHvO40i gRBxyG+6YEuNASmORaSqT63R4gDSAFoIvj1mkBZSFyrEKuaG+pb7UdjutnNY9d11KYKX ZBrqt70XMZz5bUg/8H0pblcweKTozmyNA04fpsqp3OxYTrLvcbVYNa/wedTLtbTNLkDV cw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jj0rk8tew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Sep 2022 08:21:39 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 28C7uAWb014900; Mon, 12 Sep 2022 08:21:38 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jj0rk8tdq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Sep 2022 08:21:38 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28C86h9D017332; Mon, 12 Sep 2022 08:21:36 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma02fra.de.ibm.com with ESMTP id 3jgj791hdg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Sep 2022 08:21:35 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28C8LvVS22086032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Sep 2022 08:21:57 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7975BA404D; Mon, 12 Sep 2022 08:21:33 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 994CBA4040; Mon, 12 Sep 2022 08:21:28 +0000 (GMT) Received: from li-c3569c4c-1ef8-11b2-a85c-ee139cda3133.ibm.com.com (unknown [9.43.91.220]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 12 Sep 2022 08:21:28 +0000 (GMT) From: Sathvika Vasireddy To: linuxppc-dev@lists.ozlabs.org Cc: jpoimboe@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org, aik@ozlabs.ru, mpe@ellerman.id.au, mingo@redhat.com, christophe.leroy@csgroup.eu, rostedt@goodmis.org, mbenes@suse.cz, npiggin@gmail.com, chenzhongjin@huawei.com, naveen.n.rao@linux.vnet.ibm.com, sv@linux.ibm.com Subject: [PATCH v3 11/16] objtool: Add --mnop as an option to --mcount Date: Mon, 12 Sep 2022 13:50:15 +0530 Message-Id: <20220912082020.226755-12-sv@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220912082020.226755-1-sv@linux.ibm.com> References: <20220912082020.226755-1-sv@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: f-UpfHywhKaa08peDOdLibaBzSvO0QRy X-Proofpoint-ORIG-GUID: r0u5S1irKZI97Rw1pB047pRisE7jL9KJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-12_04,2022-09-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 malwarescore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209120027 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some architectures (powerpc) may not support ftrace locations being nop'ed out at build time. Introduce --mnop as an option to objtool for enabling nop'ing of ftrace locations. Re-purpose CONFIG_HAVE_NOP_MCOUNT as a means for architectures to indicate support for the same. Also, make sure that --mnop can be passed as an option to objtool only when --mcount is passed. Acked-by: Peter Zijlstra (Intel) Reviewed-by: Christophe Leroy Signed-off-by: Sathvika Vasireddy --- 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 a4f71076cacb..9c1f4b038f65 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 738de23cb9e8..35827e6c6df9 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1233,17 +1233,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