Re: [PATCH] objtool: prefer memory clobber & %= to volatile & __COUNTER__
From: Josh Poimboeuf
Date: Tue Jan 18 2022 - 19:03:40 EST
On Wed, Jan 19, 2022 at 12:33:02AM +0100, Borislav Petkov wrote:
> On Tue, Jan 18, 2022 at 03:01:20PM -0800, Josh Poimboeuf wrote:
> > With the two WARN_ONs in media_request_object_complete(), GCC apparently
> > considers the two reachable() asm statements as duplicates, and it
> > removes the second one.
>
> Could that be the same thing:
>
> net/xfrm/xfrm_output.o: warning: objtool: xfrm_output_resume()+0x2e0: unreachable instruction
>
> I see two WARN_ONs in asm output there too...
If one of the '__bug_table' asm snippets isn't immediately followed by
the .L[un]reachable asm, then yeah, it's the same issue.
For example it's supposed to look something like this:
# 472 "net/xfrm/xfrm_output.c" 1
1: .byte 0x0f, 0x0b
.pushsection __bug_table,"aw"
2: .long 1b - 2b # bug_entry::bug_addr
.long .LC4 - 2b # bug_entry::file #
.word 472 # bug_entry::line #
.word 2307 # bug_entry::flags #
.org 2b+12 #
.popsection
# 0 "" 2
# 472 "net/xfrm/xfrm_output.c" 1
.Lreachable1666:
.pushsection .discard.reachable
.long .Lreachable1666 - .
.popsection
NOT just this:
# 472 "net/xfrm/xfrm_output.c" 1
1: .byte 0x0f, 0x0b
.pushsection __bug_table,"aw"
2: .long 1b - 2b # bug_entry::bug_addr
.long .LC4 - 2b # bug_entry::file #
.word 472 # bug_entry::line #
.word 2307 # bug_entry::flags #
.org 2b+12 #
.popsection
# some other code here...
There's a bunch of those throughout the code base. The current
annotate_[un]reachable() implementations are carefully written to avoid
that happening.
--
Josh