From nobody Wed Feb 11 03:42:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0ECAC761A6 for ; Mon, 27 Mar 2023 16:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233131AbjC0QBp (ORCPT ); Mon, 27 Mar 2023 12:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232558AbjC0QBR (ORCPT ); Mon, 27 Mar 2023 12:01:17 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 318B061AA for ; Mon, 27 Mar 2023 09:00:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 6A302CE1895 for ; Mon, 27 Mar 2023 16:00:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8987AC433EF; Mon, 27 Mar 2023 16:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679932855; bh=bYtZM+fVMt9qB3FBfutuXiVUqLBuKD6bVnTa58kw0c4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fe77Ph3byGHORIBfErdD+mVoeIP2sM1YLoQpXcTU8uUmT0Mi0ltNPXcjNEqat5nfq vAlmx04lOmS0ABs1gV2fZ+GuQpzu+xcCiqXmXWbbhyvZgp7+p5bTf8PL5lnwqj+aVj c5/CNYra7ebHh5TyKogdYYCbayNuBbCBQjiK8j6VWTXq271ipXmDYY4MpR1WhgTleb dqbLjTvjW1YT5lvyUXviy2Ud2srDdPl5py7Ty3LmLUI/V/0YOm/a51ywXVhG1LmV6B JesC/cgl4tz2kHv3l46Wwe9v1BTKOak5ZpCG/hnliWuvoiC/PS0JPmOgYw+3oUXnc7 bT6z4qOAnJpmw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra Subject: [PATCH 1/5] objtool: Add '--verbose' option for disassembling affected functions Date: Mon, 27 Mar 2023 09:00:44 -0700 Message-Id: <217a005fe22f9d33f99fed499d6508af9f5cabd0.1679932620.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When a warning is associated with a function, add an option to disassemble that function. This makes it easier for reporters to submit the information needed to diagnose objtool warnings. Signed-off-by: Josh Poimboeuf --- tools/objtool/Documentation/objtool.txt | 5 ++++ tools/objtool/builtin-check.c | 1 + tools/objtool/include/objtool/builtin.h | 1 + tools/objtool/include/objtool/warn.h | 38 +++++++++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Docume= ntation/objtool.txt index 8e53fc6735ef..7c1a46af322f 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -244,6 +244,11 @@ To achieve the validation, objtool enforces the follow= ing rules: Objtool warnings ---------------- =20 +NOTE: When requesting help with an objtool warning, please re-run the +kernel build with `OBJTOOL_ARGS=3D"--verbose" make ` and send +the full warning output (including any function disassembly below the +warning) to the objtool maintainers. + For asm files, if you're getting an error which doesn't make sense, first make sure that the affected code follows the above rules. =20 diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index 7c175198d09f..b8de42f6778e 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -93,6 +93,7 @@ static const struct option check_options[] =3D { 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"), + OPT_BOOLEAN('v', "verbose", &opts.verbose, "verbose warnings"), =20 OPT_END(), }; diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/includ= e/objtool/builtin.h index 2a108e648b7a..fcca6662c8b4 100644 --- a/tools/objtool/include/objtool/builtin.h +++ b/tools/objtool/include/objtool/builtin.h @@ -37,6 +37,7 @@ struct opts { bool no_unreachable; bool sec_address; bool stats; + bool verbose; }; =20 extern struct opts opts; diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/o= bjtool/warn.h index a3e79ae75f2e..b85aa440ee1f 100644 --- a/tools/objtool/include/objtool/warn.h +++ b/tools/objtool/include/objtool/warn.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include =20 @@ -41,6 +42,41 @@ static inline char *offstr(struct section *sec, unsigned= long offset) return str; } =20 +static inline void objdump_func(struct section *sec, unsigned long offset) +{ + struct symbol *sym =3D find_func_containing(sec, offset); + const char *script_relative =3D "scripts/objdump-func"; + bool is_text =3D (sec->sh.sh_flags & SHF_EXECINSTR); + char *cmd, *srctree, *script; + + if (is_text) + sym =3D find_func_containing(sec, offset); + if (!sym) + sym =3D find_symbol_containing(sec, offset); + if (!sym) + return; + + srctree =3D getenv("abs_srctree"); + if (!srctree) + return; + + script =3D malloc(strlen(srctree) + strlen(script_relative) + 2); + if (!script) + return; + + sprintf(script, "%s/%s", srctree, script_relative); + + if (access(script, X_OK)) + return; + + cmd =3D malloc(strlen(script) + strlen(objname) + strlen(sym->name) + 10); + if (!cmd) + return; + + sprintf(cmd, "%s %s %s 1>&2", script, objname, sym->name); + system(cmd); +} + #define WARN(format, ...) \ fprintf(stderr, \ "%s: warning: objtool: " format "\n", \ @@ -51,6 +87,8 @@ static inline char *offstr(struct section *sec, unsigned = long offset) char *_str =3D offstr(sec, offset); \ WARN("%s: " format, _str, ##__VA_ARGS__); \ free(_str); \ + if (opts.verbose) \ + objdump_func(sec, offset); \ }) =20 #define BT_FUNC(format, insn, ...) \ --=20 2.39.2 From nobody Wed Feb 11 03:42:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6030C6FD1D for ; Mon, 27 Mar 2023 16:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233114AbjC0QBi (ORCPT ); Mon, 27 Mar 2023 12:01:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbjC0QBO (ORCPT ); Mon, 27 Mar 2023 12:01:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 223306181 for ; Mon, 27 Mar 2023 09:00:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9FDEC61360 for ; Mon, 27 Mar 2023 16:00:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE4DBC433A0; Mon, 27 Mar 2023 16:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679932856; bh=cs2v2L19PFI4Qr/i72VjLOqDUF7s1Wn6MGxQhSSimu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C2SNBv4/oV5HVK55UwiwjP/7gI449xEUPzntxXzYyIOMgx8cEOEqsJN5BCl3XKnD9 HFKXK7eddyNJXaCniPst8agGIweJj1vz+44vj590+kKwLbAorTQmAIOAzKS6nKVwV9 Mx9njW+yjbCwPYHztyIevU1qcIEW8V3CHsrHcZKTk0q152nBKdrDgIvMWIpMesWIdM z1hySE8w3imxYYw8tGMSGMI08Ub+VQtAEqLPt3OGTVoSPXaUMzx2YfNiAlbR+tjhN4 9213HzYPRShcAzedB9KtYb6rAbLRvM6CIxXlO2Pzg9vzzGZY1IVSmSVS1nzy5GRWtK 3vq8/B+fF+0BQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra Subject: [PATCH 2/5] objtool: Combine '--backtrace' with '--verbose' Date: Mon, 27 Mar 2023 09:00:45 -0700 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Get rid of the '--backtrace' option, instead including that functionality in '--verbose'. This makes it easy to gather all the information needed for diagnosing objtool warnings. Signed-off-by: Josh Poimboeuf --- tools/objtool/Documentation/objtool.txt | 4 ++-- tools/objtool/builtin-check.c | 1 - tools/objtool/check.c | 22 ++++++++-------------- tools/objtool/include/objtool/builtin.h | 1 - tools/objtool/include/objtool/warn.h | 14 ++++++++------ 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Docume= ntation/objtool.txt index 7c1a46af322f..ec6f82fb414c 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -246,8 +246,8 @@ Objtool warnings =20 NOTE: When requesting help with an objtool warning, please re-run the kernel build with `OBJTOOL_ARGS=3D"--verbose" make ` and send -the full warning output (including any function disassembly below the -warning) to the objtool maintainers. +the full warning output (including any function disassembly or objtool +backtrace below the warning) to the objtool maintainers. =20 For asm files, if you're getting an error which doesn't make sense, first make sure that the affected code follows the above rules. diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index b8de42f6778e..937ba5d78e08 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -84,7 +84,6 @@ static const struct option check_options[] =3D { OPT_CALLBACK_OPTARG(0, "dump", NULL, NULL, "orc", "dump metadata", parse_= dump), =20 OPT_GROUP("Options:"), - OPT_BOOLEAN(0, "backtrace", &opts.backtrace, "unwind on error"), OPT_BOOLEAN(0, "backup", &opts.backup, "create .orig files before modific= ation"), OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"), OPT_BOOLEAN(0, "link", &opts.link, "object is a linked object"), diff --git a/tools/objtool/check.c b/tools/objtool/check.c index cae6ac6ff246..a652b9e5c805 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3708,8 +3708,7 @@ static int validate_branch(struct objtool_file *file,= struct symbol *func, =20 ret =3D validate_branch(file, func, alt->insn, state); if (ret) { - if (opts.backtrace) - BT_FUNC("(alt)", insn); + BT_FUNC("(alt)", insn); return ret; } } @@ -3755,8 +3754,7 @@ static int validate_branch(struct objtool_file *file,= struct symbol *func, ret =3D validate_branch(file, func, insn->jump_dest, state); if (ret) { - if (opts.backtrace) - BT_FUNC("(branch)", insn); + BT_FUNC("(branch)", insn); return ret; } } @@ -3855,7 +3853,7 @@ static int validate_unwind_hint(struct objtool_file *= file, { if (insn->hint && !insn->visited && !insn->ignore) { int ret =3D validate_branch(file, insn_func(insn), insn, *state); - if (ret && opts.backtrace) + if (ret) BT_FUNC("<=3D=3D=3D (hint)", insn); return ret; } @@ -3914,8 +3912,7 @@ static int validate_unret(struct objtool_file *file, = struct instruction *insn) =20 ret =3D validate_unret(file, alt->insn); if (ret) { - if (opts.backtrace) - BT_FUNC("(alt)", insn); + BT_FUNC("(alt)", insn); return ret; } } @@ -3942,10 +3939,8 @@ static int validate_unret(struct objtool_file *file,= struct instruction *insn) } ret =3D validate_unret(file, insn->jump_dest); if (ret) { - if (opts.backtrace) { - BT_FUNC("(branch%s)", insn, - insn->type =3D=3D INSN_JUMP_CONDITIONAL ? "-cond" : ""); - } + BT_FUNC("(branch%s)", insn, + insn->type =3D=3D INSN_JUMP_CONDITIONAL ? "-cond" : ""); return ret; } =20 @@ -3967,8 +3962,7 @@ static int validate_unret(struct objtool_file *file, = struct instruction *insn) =20 ret =3D validate_unret(file, dest); if (ret) { - if (opts.backtrace) - BT_FUNC("(call)", insn); + BT_FUNC("(call)", insn); return ret; } /* @@ -4254,7 +4248,7 @@ static int validate_symbol(struct objtool_file *file,= struct section *sec, state->uaccess =3D sym->uaccess_safe; =20 ret =3D validate_branch(file, insn_func(insn), insn, *state); - if (ret && opts.backtrace) + if (ret) BT_FUNC("<=3D=3D=3D (sym)", insn); return ret; } diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/includ= e/objtool/builtin.h index fcca6662c8b4..38aef760465e 100644 --- a/tools/objtool/include/objtool/builtin.h +++ b/tools/objtool/include/objtool/builtin.h @@ -28,7 +28,6 @@ struct opts { bool cfi; =20 /* options: */ - bool backtrace; bool backup; bool dryrun; bool link; diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/o= bjtool/warn.h index b85aa440ee1f..a9ec1ed6a2e3 100644 --- a/tools/objtool/include/objtool/warn.h +++ b/tools/objtool/include/objtool/warn.h @@ -91,12 +91,14 @@ static inline void objdump_func(struct section *sec, un= signed long offset) objdump_func(sec, offset); \ }) =20 -#define BT_FUNC(format, insn, ...) \ -({ \ - struct instruction *_insn =3D (insn); \ - char *_str =3D offstr(_insn->sec, _insn->offset); \ - WARN(" %s: " format, _str, ##__VA_ARGS__); \ - free(_str); \ +#define BT_FUNC(format, insn, ...) \ +({ \ + if (opts.verbose) { \ + struct instruction *_insn =3D (insn); \ + char *_str =3D offstr(_insn->sec, _insn->offset); \ + WARN(" %s: " format, _str, ##__VA_ARGS__); \ + free(_str); \ + } \ }) =20 #define WARN_ELF(format, ...) \ --=20 2.39.2 From nobody Wed Feb 11 03:42:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68FD4C6FD1D for ; Mon, 27 Mar 2023 16:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233104AbjC0QBf (ORCPT ); Mon, 27 Mar 2023 12:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232885AbjC0QBN (ORCPT ); Mon, 27 Mar 2023 12:01:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6413A65A1 for ; Mon, 27 Mar 2023 09:00:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F34606136E for ; Mon, 27 Mar 2023 16:00:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AA57C4339B; Mon, 27 Mar 2023 16:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679932856; bh=q9Vpi9kjIy4hLyGLwLZZ/FrbCreS4bEtiQO84AJpizA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ce8fKwBD6Dw2NN7jzRcnIZfQhhi1c3/If+5JYNRxH8r9ImWozIW/nFAt3O5YlUHCM a/lkGW/n8x4sQc9a1cKMi78zWRO8e8aa8xolV3pvq+A0vsqTHaxoIPpPYuAGFNRiUg 2Ncezskn9wnNWwDYTdX0D16z4PQ9REaLLcZyTm8Yb3d8z0+BspRNbBctgTCpKzaF5A Fb89O1bUAoxOvuLfQ4oyeY0R5+wALY4GC4Axz/L9uX7JDGfM/LPRXJqNTTQtA/CYAt UCxdhbKwY6t872sHXpD0DfyVBInkwKIqUUlODfvrQSElN6Py31W+Zrc+TanMf6N4ZV hwJLMXRYIg+fA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra Subject: [PATCH 3/5] objtool: Remove superfluous dead_end_function() check Date: Mon, 27 Mar 2023 09:00:46 -0700 Message-Id: <5e314b6d68090f3aa32e5e02551e6a8db62d6728.1679932620.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" annotate_call_site() already sets 'insn->dead_end' for calls to dead end functions. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index a652b9e5c805..73dd091c0075 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4140,8 +4140,7 @@ static bool ignore_unreachable_insn(struct objtool_fi= le *file, struct instructio * It may also insert a UD2 after calling a __noreturn function. */ prev_insn =3D prev_insn_same_sec(file, insn); - if ((prev_insn->dead_end || - dead_end_function(file, insn_call_dest(prev_insn))) && + if (prev_insn->dead_end && (insn->type =3D=3D INSN_BUG || (insn->type =3D=3D INSN_JUMP_UNCONDITIONAL && insn->jump_dest && insn->jump_dest->type =3D=3D INSN_BUG))) --=20 2.39.2 From nobody Wed Feb 11 03:42:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 061FFC76195 for ; Mon, 27 Mar 2023 16:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232813AbjC0QBb (ORCPT ); Mon, 27 Mar 2023 12:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232781AbjC0QBN (ORCPT ); Mon, 27 Mar 2023 12:01:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60707659E for ; Mon, 27 Mar 2023 09:00:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E42F46136A for ; Mon, 27 Mar 2023 16:00:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CE07C433A7; Mon, 27 Mar 2023 16:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679932856; bh=u69Tg1vdhRZztJGiueD2tMeEsNcJF/AVA/Gcuwho7Uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W9sFA8/7euAUx/U00p8kXj+DzpvXxXElLAYtrLNsyf+VP/iQWZsdLAt8Qwu0XaJNH TxHgm5nbvc8dBKA2gh2kcYT7mlqCHwLCKedOZe9VuPZMEr6jqHTKtaNSQtyUTKZMFW +UAHxmvcdxn+WoTt5gbwCHWCRQvZCLBcfnloCe26Km1AgLIGuJLwnmAlm4y9Uo6vH2 WW1C8nAHkmp7NmFuDpTDyk/Q0PLWnU3d3LaTHqDRh3VHM7AMYj0bjf7LR2Zn8JUP/1 n563m3/LNTN0axjJBXYCHiGCF5EM44y9o6oIl1UB6bLeuJV1DQWXm0wdnrvx8A9snu CJg6hplRTKZfg== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra Subject: [PATCH 4/5] objtool: Add per-function rate limiting for unreachable warnings Date: Mon, 27 Mar 2023 09:00:47 -0700 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Unreachable instruction warnings are rate limited to once per object file. That no longer makes sense for vmlinux validation, which might have other unreachable instructions lurking in other places. Change it to once per function. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 4 ++++ tools/objtool/include/objtool/elf.h | 1 + 2 files changed, 5 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 73dd091c0075..67a684225702 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4557,6 +4557,10 @@ static int validate_reachable_instructions(struct ob= jtool_file *file) if (insn->visited || ignore_unreachable_insn(file, insn)) continue; =20 + if (insn->sym->warned) + continue; + insn->sym->warned =3D 1; + WARN_FUNC("unreachable instruction", insn->sec, insn->offset); return 1; } diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/ob= jtool/elf.h index ad0024da262b..a668173a5869 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -61,6 +61,7 @@ struct symbol { u8 return_thunk : 1; u8 fentry : 1; u8 profiling_func : 1; + u8 warned : 1; struct list_head pv_target; struct list_head reloc_list; }; --=20 2.39.2 From nobody Wed Feb 11 03:42:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94B0DC6FD1D for ; Mon, 27 Mar 2023 16:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233121AbjC0QBm (ORCPT ); Mon, 27 Mar 2023 12:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233029AbjC0QBQ (ORCPT ); Mon, 27 Mar 2023 12:01:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F3E46B4 for ; Mon, 27 Mar 2023 09:00:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3EE2161372 for ; Mon, 27 Mar 2023 16:00:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDADAC433AF; Mon, 27 Mar 2023 16:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679932857; bh=ouspNU+K1gyvLb2HKblJJmDAoAUT2VISUiIQf8ijcJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NP503enpxBHNNnrS7Xth/nqQzgMG8Q5fF3zn5DjpS4GO09w7OndJq7BQZaSkEHR9f pZaINcTY3qQQLFViJxpdupawo5yVMaEGetHFePzy2boiN0Kl79hOh1V6q1qbagGXdx kYPr1iAqTKWgSI42IXMUmUozTGvaarCM6kQHwdnr/5/rXuXZCDcUZtEO1VOWYKGOUg VCgeG27rugpUG0hrUj/lTn9HPJo9P95G96E7tINdDeirzHiC0GPljT2VyMJhaqq1xI tnC3eFYkoQXSWjlcGxow4K/XqCbbnCjHr+CcZ97LTreSFjFzn74AJuEI5O34BybXuj bRqRvea9cFs1A== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra Subject: [PATCH 5/5] objtool: Add "missing __noreturn" warning Date: Mon, 27 Mar 2023 09:00:48 -0700 Message-Id: <4f22aa05702ca037630fa6c1f7fd54d13914a631.1679932620.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Most "unreachable instruction" warnings these days seem to actually be the result of a missing __noreturn annotation. Add an explicit check for that. Signed-off-by: Josh Poimboeuf --- tools/objtool/Documentation/objtool.txt | 7 +++++++ tools/objtool/check.c | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Docume= ntation/objtool.txt index ec6f82fb414c..e04d16490c3b 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -423,6 +423,13 @@ the objtool maintainers. names and does not use module_init() / module_exit() macros to create them. =20 +13. file.o: warning: func(): missing __noreturn + + Objtool has detected that the function doesn't return, but is missing + the __noreturn annotation. NOTE: In addition to adding the + __noreturn annotation, the function name also needs to be added to + 'global_noreturns' in tools/objtool/check.c. + =20 If the error doesn't seem to make sense, it could be a bug in objtool. Feel free to ask the objtool maintainer for help. diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 67a684225702..1ed3024af2b1 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4548,7 +4548,8 @@ static int validate_sls(struct objtool_file *file) =20 static int validate_reachable_instructions(struct objtool_file *file) { - struct instruction *insn; + struct instruction *insn, *prev_insn; + struct symbol *call_dest; =20 if (file->ignore_unreachables) return 0; @@ -4561,8 +4562,19 @@ static int validate_reachable_instructions(struct ob= jtool_file *file) continue; insn->sym->warned =3D 1; =20 + prev_insn =3D prev_insn_same_sec(file, insn); + if (prev_insn) + call_dest =3D insn_call_dest(prev_insn); + if (prev_insn && prev_insn->dead_end && call_dest) { + if (call_dest->warned) + continue; + call_dest->warned =3D 1; + + WARN("%s(): missing __noreturn", call_dest->name); + continue; + } + WARN_FUNC("unreachable instruction", insn->sec, insn->offset); - return 1; } =20 return 0; --=20 2.39.2