linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot2 for Ilie Halip" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Rong Chen <rong.a.chen@intel.com>, Marco Elver <elver@google.com>,
	Philip Li <philip.li@intel.com>, Borislav Petkov <bp@alien8.de>,
	kasan-dev@googlegroups.com, x86@kernel.org,
	clang-built-linux@googlegroups.com,
	kbuild test robot <lkp@intel.com>,
	Ilie Halip <ilie.halip@gmail.com>,
	Sedat Dilek <sedat.dilek@gmail.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [tip: objtool/core] objtool: Ignore unreachable trap after call to noreturn functions
Date: Mon, 21 Sep 2020 16:51:11 -0000	[thread overview]
Message-ID: <160070707105.15536.14094674309505985856.tip-bot2@tip-bot2> (raw)
In-Reply-To: <CAKwvOdmptEpi8fiOyWUo=AiZJiX+Z+VHJOM2buLPrWsMTwLnyw@mail.gmail.com>

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     14db1f0a93331d0958e90da522c429ff0890d2d6
Gitweb:        https://git.kernel.org/tip/14db1f0a93331d0958e90da522c429ff0890d2d6
Author:        Ilie Halip <ilie.halip@gmail.com>
AuthorDate:    Sat, 19 Sep 2020 09:41:18 +03:00
Committer:     Josh Poimboeuf <jpoimboe@redhat.com>
CommitterDate: Mon, 21 Sep 2020 10:20:10 -05:00

objtool: Ignore unreachable trap after call to noreturn functions

With CONFIG_UBSAN_TRAP enabled, the compiler may insert a trap
instruction after a call to a noreturn function. In this case, objtool
warns that the UD2 instruction is unreachable.

This is a behavior seen with Clang, from the oldest version capable of
building the mainline x64_64 kernel (9.0), to the latest experimental
version (12.0).

Objtool silences similar warnings (trap after dead end instructions), so
so expand that check to include dead end functions.

Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Rong Chen <rong.a.chen@intel.com>
Cc: Marco Elver <elver@google.com>
Cc: Philip Li <philip.li@intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: kasan-dev@googlegroups.com
Cc: x86@kernel.org
Cc: clang-built-linux@googlegroups.com
BugLink: https://github.com/ClangBuiltLinux/linux/issues/1148
Link: https://lore.kernel.org/lkml/CAKwvOdmptEpi8fiOyWUo=AiZJiX+Z+VHJOM2buLPrWsMTwLnyw@mail.gmail.com
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Ilie Halip <ilie.halip@gmail.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 tools/objtool/check.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a4796e3..2df9f76 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2638,9 +2638,10 @@ static bool is_ubsan_insn(struct instruction *insn)
 			"__ubsan_handle_builtin_unreachable"));
 }
 
-static bool ignore_unreachable_insn(struct instruction *insn)
+static bool ignore_unreachable_insn(struct objtool_file *file, struct instruction *insn)
 {
 	int i;
+	struct instruction *prev_insn;
 
 	if (insn->ignore || insn->type == INSN_NOP)
 		return true;
@@ -2668,8 +2669,11 @@ static bool ignore_unreachable_insn(struct instruction *insn)
 	 * __builtin_unreachable().  The BUG() macro has an unreachable() after
 	 * the UD2, which causes GCC's undefined trap logic to emit another UD2
 	 * (or occasionally a JMP to UD2).
+	 *
+	 * It may also insert a UD2 after calling a __noreturn function.
 	 */
-	if (list_prev_entry(insn, list)->dead_end &&
+	prev_insn = list_prev_entry(insn, list);
+	if ((prev_insn->dead_end || dead_end_function(file, prev_insn->call_dest)) &&
 	    (insn->type == INSN_BUG ||
 	     (insn->type == INSN_JUMP_UNCONDITIONAL &&
 	      insn->jump_dest && insn->jump_dest->type == INSN_BUG)))
@@ -2796,7 +2800,7 @@ static int validate_reachable_instructions(struct objtool_file *file)
 		return 0;
 
 	for_each_insn(file, insn) {
-		if (insn->visited || ignore_unreachable_insn(insn))
+		if (insn->visited || ignore_unreachable_insn(file, insn))
 			continue;
 
 		WARN_FUNC("unreachable instruction", insn->sec, insn->offset);

  parent reply	other threads:[~2020-09-21 16:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 13:42 [tip:x86/seves] BUILD SUCCESS WITH WARNING e6eb15c9ba3165698488ae5c34920eea20eaa38e kernel test robot
2020-09-15 13:55 ` Borislav Petkov
2020-09-15 14:18   ` Rong Chen
2020-09-15 14:41     ` Borislav Petkov
2020-09-15 16:05     ` Borislav Petkov
2020-09-15 17:02       ` Josh Poimboeuf
2020-09-15 17:21         ` Borislav Petkov
2020-09-15 17:34           ` Borislav Petkov
2020-09-15 17:41             ` Nick Desaulniers
2020-09-15 18:01               ` Borislav Petkov
2020-09-15 18:04                 ` Nick Desaulniers
2020-09-15 17:40           ` Nick Desaulniers
2020-09-15 18:09             ` Marco Elver
2020-09-16  8:30               ` peterz
2020-09-16  8:46                 ` Marco Elver
2020-09-16  9:06                   ` peterz
2020-09-16  9:33                     ` Marco Elver
2020-09-16 18:22                   ` Nick Desaulniers
2020-09-16 18:51                     ` Marco Elver
2020-09-17  4:11                       ` Fangrui Song
     [not found]                       ` <333D40A0-4550-4309-9693-1ABA4AC75399@arm.com>
2020-09-17 11:04                         ` Mark Rutland
2020-09-17 11:16                           ` Daniel Kiss
2020-09-17 18:39                     ` Josh Poimboeuf
2020-09-15 17:44         ` Nick Desaulniers
2020-09-15 20:12         ` Nick Desaulniers
2020-09-15 20:49           ` Borislav Petkov
2020-09-15 21:02             ` Josh Poimboeuf
2020-09-15 21:14               ` Borislav Petkov
2020-09-15 22:34               ` Nick Desaulniers
2020-09-16  7:03                 ` Ilie Halip
2020-09-16  8:59                 ` Marco Elver
2020-09-21 16:51                 ` tip-bot2 for Ilie Halip [this message]
2020-09-15 21:50             ` Arvind Sankar
2020-09-15 21:59               ` Nick Desaulniers
2020-09-15 22:44                 ` Arvind Sankar
2020-09-16 11:34               ` Borislav Petkov
2020-09-16 18:28                 ` Nick Desaulniers
2020-09-16 18:48                   ` Borislav Petkov
2020-09-15 21:13           ` Nick Desaulniers
2020-09-15 21:28             ` Josh Poimboeuf
2020-09-15 23:35               ` Marco Elver

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=160070707105.15536.14094674309505985856.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bp@alien8.de \
    --cc=clang-built-linux@googlegroups.com \
    --cc=elver@google.com \
    --cc=ilie.halip@gmail.com \
    --cc=jpoimboe@redhat.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=ndesaulniers@google.com \
    --cc=philip.li@intel.com \
    --cc=rong.a.chen@intel.com \
    --cc=sedat.dilek@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).