All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@kernel.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Miroslav Benes <mbenes@suse.cz>,
	Nick Desaulniers <ndesaulniers@google.com>
Subject: [PATCH v3 1/8] objtool: Limit unreachable warnings to once per function
Date: Tue, 18 Apr 2023 14:27:47 -0700	[thread overview]
Message-ID: <9d38f881bfc34e031c74e4e90064ccb3e49f599a.1681853186.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1681853186.git.jpoimboe@kernel.org>

Unreachable instruction warnings are limited to once per object file.
That no longer makes sense for vmlinux validation, which might have
more unreachable instructions lurking in other places.  Change it to
once per function.

Note this affects some other (much rarer) non-fatal warnings as well.
In general I think one-warning-per-function makes sense, as related
warnings can accumulate quickly and we want to eventually get back to
failing the build with -Werror anyway.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/check.c                | 5 +++--
 tools/objtool/include/objtool/elf.h  | 1 +
 tools/objtool/include/objtool/warn.h | 7 ++++++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 5b600bbf2389..a00931342c7e 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4514,6 +4514,7 @@ static int validate_sls(struct objtool_file *file)
 static int validate_reachable_instructions(struct objtool_file *file)
 {
 	struct instruction *insn;
+	int warnings = 0;
 
 	if (file->ignore_unreachables)
 		return 0;
@@ -4523,10 +4524,10 @@ static int validate_reachable_instructions(struct objtool_file *file)
 			continue;
 
 		WARN_INSN(insn, "unreachable instruction");
-		return 1;
+		warnings++;
 	}
 
-	return 0;
+	return warnings;
 }
 
 int check(struct objtool_file *file)
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index e1ca588eb69d..78e2d0fc21ca 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;
 };
diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h
index b1c920dc9516..f195deab456e 100644
--- a/tools/objtool/include/objtool/warn.h
+++ b/tools/objtool/include/objtool/warn.h
@@ -55,7 +55,12 @@ static inline char *offstr(struct section *sec, unsigned long offset)
 
 #define WARN_INSN(insn, format, ...)					\
 ({									\
-	WARN_FUNC(format, insn->sec, insn->offset,  ##__VA_ARGS__);	\
+	struct instruction *_insn = (insn);				\
+	if (!_insn->sym || !_insn->sym->warned)				\
+		WARN_FUNC(format, _insn->sec, _insn->offset,		\
+			  ##__VA_ARGS__);				\
+	if (_insn->sym)							\
+		_insn->sym->warned = 1;					\
 })
 
 #define BT_FUNC(format, insn, ...)			\
-- 
2.39.2


  reply	other threads:[~2023-04-18 21:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-18 21:27 [PATCH v3 0/8] objtool: warning improvements Josh Poimboeuf
2023-04-18 21:27 ` Josh Poimboeuf [this message]
2023-05-18 11:08   ` [tip: objtool/core] objtool: Limit unreachable warnings to once per function tip-bot2 for Josh Poimboeuf
2023-04-18 21:27 ` [PATCH v3 2/8] objtool: Add verbose option for disassembling affected functions Josh Poimboeuf
2023-05-18 11:08   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-04-18 21:27 ` [PATCH v3 3/8] objtool: Include backtrace in verbose mode Josh Poimboeuf
2023-05-18 11:08   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-04-18 21:27 ` [PATCH v3 4/8] objtool: Detect missing __noreturn annotations Josh Poimboeuf
2023-05-18 11:08   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-04-18 21:27 ` [PATCH v3 5/8] objtool: Ignore exc_double_fault() __noreturn warnings Josh Poimboeuf
2023-05-18 11:08   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-04-18 21:27 ` [PATCH v3 6/8] objtool: Remove superfluous global_noreturns entries Josh Poimboeuf
2023-05-18 11:08   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-04-18 21:27 ` [PATCH v3 7/8] tools/lib/subcmd: Replace NORETURN usage with __noreturn Josh Poimboeuf
2023-05-18 11:08   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-04-18 21:27 ` [PATCH v3 8/8] objtool: Move noreturn function list to separate file Josh Poimboeuf
2023-05-18 11:08   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-04-19 14:51 ` [PATCH v3 0/8] objtool: warning improvements Miroslav Benes

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=9d38f881bfc34e031c74e4e90064ccb3e49f599a.1681853186.git.jpoimboe@kernel.org \
    --to=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /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: link
Be 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.