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 5/8] objtool: Ignore exc_double_fault() __noreturn warnings
Date: Tue, 18 Apr 2023 14:27:51 -0700	[thread overview]
Message-ID: <a45b085071d3a7d049a20f9e78754452336ecbe8.1681853186.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1681853186.git.jpoimboe@kernel.org>

This is a hack, but it works for now.

Problem is, exc_double_fault() may or may not return, depending on
whether CONFIG_X86_ESPFIX64 is set.  But objtool has no visibility to
the kernel config.

"Fix" it by silencing the exc_double_fault() __noreturn warning.

This removes the following warning:

  vmlinux.o: warning: objtool: xenpv_exc_double_fault+0xd: exc_double_fault() is missing a __noreturn annotation

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/check.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index dd10128ab013..1cace399d32a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4505,6 +4505,35 @@ static int validate_sls(struct objtool_file *file)
 	return warnings;
 }
 
+static bool ignore_noreturn_call(struct instruction *insn)
+{
+	struct symbol *call_dest = insn_call_dest(insn);
+
+	/*
+	 * FIXME: hack, we need a real noreturn solution
+	 *
+	 * Problem is, exc_double_fault() may or may not return, depending on
+	 * whether CONFIG_X86_ESPFIX64 is set.  But objtool has no visibility
+	 * to the kernel config.
+	 *
+	 * Other potential ways to fix it:
+	 *
+	 *   - have compiler communicate __noreturn functions somehow
+	 *   - remove CONFIG_X86_ESPFIX64
+	 *   - read the .config file
+	 *   - add a cmdline option
+	 *   - create a generic objtool annotation format (vs a bunch of custom
+	 *     formats) and annotate it
+	 */
+	if (!strcmp(call_dest->name, "exc_double_fault")) {
+		/* prevent further unreachable warnings for the caller */
+		insn->sym->warned = 1;
+		return true;
+	}
+
+	return false;
+}
+
 static int validate_reachable_instructions(struct objtool_file *file)
 {
 	struct instruction *insn, *prev_insn;
@@ -4521,7 +4550,7 @@ static int validate_reachable_instructions(struct objtool_file *file)
 		prev_insn = prev_insn_same_sec(file, insn);
 		if (prev_insn && prev_insn->dead_end) {
 			call_dest = insn_call_dest(prev_insn);
-			if (call_dest) {
+			if (call_dest && !ignore_noreturn_call(prev_insn)) {
 				WARN_INSN(insn, "%s() is missing a __noreturn annotation",
 					  call_dest->name);
 				warnings++;
-- 
2.39.2


  parent 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 ` [PATCH v3 1/8] objtool: Limit unreachable warnings to once per function Josh Poimboeuf
2023-05-18 11:08   ` [tip: objtool/core] " 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 ` Josh Poimboeuf [this message]
2023-05-18 11:08   ` [tip: objtool/core] objtool: Ignore exc_double_fault() __noreturn warnings 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=a45b085071d3a7d049a20f9e78754452336ecbe8.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.