linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] objtool: Fix noreturn detection for ignored functions
@ 2020-09-10 15:24 Josh Poimboeuf
  2020-09-11 16:51 ` Linus Torvalds
  2020-09-18 17:46 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
  0 siblings, 2 replies; 3+ messages in thread
From: Josh Poimboeuf @ 2020-09-10 15:24 UTC (permalink / raw)
  To: x86; +Cc: Peter Zijlstra, linux-kernel, Linus Torvalds

When a function is annotated with STACK_FRAME_NON_STANDARD, objtool
doesn't validate its code paths.  It also skips sibling call detection
within the function.

But sibling call detection is actually needed for the case where the
ignored function doesn't have any return instructions.  Otherwise
objtool naively marks the function as implicit static noreturn, which
affects the reachability of its callers, resulting in "unreachable
instruction" warnings.

Fix it by just enabling sibling call detection for ignored functions.
The 'insn->ignore' check in add_jump_destinations() is no longer needed
after commit e6da9567959e ("objtool: Don't use ignore flag for fake
jumps").

Fixes the following warning:

  arch/x86/kvm/vmx/vmx.o: warning: objtool: vmx_handle_exit_irqoff()+0x142: unreachable instruction

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 tools/objtool/check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index e034a8f24f46..90a66891441a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -619,7 +619,7 @@ static int add_jump_destinations(struct objtool_file *file)
 		if (!is_static_jump(insn))
 			continue;
 
-		if (insn->ignore || insn->offset == FAKE_JUMP_OFFSET)
+		if (insn->offset == FAKE_JUMP_OFFSET)
 			continue;
 
 		reloc = find_reloc_by_dest_range(file->elf, insn->sec,
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] objtool: Fix noreturn detection for ignored functions
  2020-09-10 15:24 [PATCH] objtool: Fix noreturn detection for ignored functions Josh Poimboeuf
@ 2020-09-11 16:51 ` Linus Torvalds
  2020-09-18 17:46 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Torvalds @ 2020-09-11 16:51 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: the arch/x86 maintainers, Peter Zijlstra, Linux Kernel Mailing List

On Thu, Sep 10, 2020 at 8:25 AM Josh Poimboeuf <jpoimboe@redhat.com> wrote:
>
> Fixes the following warning:

Ack, confirmed. I assume I'll be getting this through the usual channels.

[ In the meantime, Peter Oberparleiter figured out what was wrong with
GCOV and it's been re-enabled on my system, so I'm not seeing this
warning any more because GCOV ends up effectively modifying the code
generation to the point where the situation doesn't happen with
allmodconfig any more. But ithat is just one particular config ]

           Linus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: objtool/urgent] objtool: Fix noreturn detection for ignored functions
  2020-09-10 15:24 [PATCH] objtool: Fix noreturn detection for ignored functions Josh Poimboeuf
  2020-09-11 16:51 ` Linus Torvalds
@ 2020-09-18 17:46 ` tip-bot2 for Josh Poimboeuf
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2020-09-18 17:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Linus Torvalds, Josh Poimboeuf, Borislav Petkov, x86, LKML

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

Commit-ID:     db6c6a0df840e3f52c84cc302cc1a08ba11a4416
Gitweb:        https://git.kernel.org/tip/db6c6a0df840e3f52c84cc302cc1a08ba11a4416
Author:        Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate:    Thu, 10 Sep 2020 10:24:57 -05:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 18 Sep 2020 19:37:51 +02:00

objtool: Fix noreturn detection for ignored functions

When a function is annotated with STACK_FRAME_NON_STANDARD, objtool
doesn't validate its code paths.  It also skips sibling call detection
within the function.

But sibling call detection is actually needed for the case where the
ignored function doesn't have any return instructions.  Otherwise
objtool naively marks the function as implicit static noreturn, which
affects the reachability of its callers, resulting in "unreachable
instruction" warnings.

Fix it by just enabling sibling call detection for ignored functions.
The 'insn->ignore' check in add_jump_destinations() is no longer needed
after

  e6da9567959e ("objtool: Don't use ignore flag for fake jumps").

Fixes the following warning:

  arch/x86/kvm/vmx/vmx.o: warning: objtool: vmx_handle_exit_irqoff()+0x142: unreachable instruction

which triggers on an allmodconfig with CONFIG_GCOV_KERNEL unset.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lkml.kernel.org/r/5b1e2536cdbaa5246b60d7791b76130a74082c62.1599751464.git.jpoimboe@redhat.com
---
 tools/objtool/check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index e034a8f..90a6689 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -619,7 +619,7 @@ static int add_jump_destinations(struct objtool_file *file)
 		if (!is_static_jump(insn))
 			continue;
 
-		if (insn->ignore || insn->offset == FAKE_JUMP_OFFSET)
+		if (insn->offset == FAKE_JUMP_OFFSET)
 			continue;
 
 		reloc = find_reloc_by_dest_range(file->elf, insn->sec,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-18 17:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 15:24 [PATCH] objtool: Fix noreturn detection for ignored functions Josh Poimboeuf
2020-09-11 16:51 ` Linus Torvalds
2020-09-18 17:46 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf

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).