From: Peter Zijlstra <peterz@infradead.org>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
Huacai Chen <chenhuacai@kernel.org>,
loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 02/10] objtool: Handle special cases of dead end insn
Date: Tue, 26 Nov 2024 15:32:43 +0100 [thread overview]
Message-ID: <20241126143243.GN38837@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <bb36374e-aca2-92e1-209d-1524e31147ab@loongson.cn>
On Tue, Nov 26, 2024 at 06:42:15PM +0800, Tiezhu Yang wrote:
> On 11/26/2024 02:45 PM, Josh Poimboeuf wrote:
> > On Fri, Nov 22, 2024 at 12:49:57PM +0800, Tiezhu Yang wrote:
> > > There are some "unreachable instruction" objtool warnings when compling
> > > with Clang on LoongArch, this is because the "break" instruction is set
> > > as dead end due to its type is INSN_BUG in decode_instructions() at the
> > > beginning, and it does not set insn->dead_end of the "break" instruction
> > > as false after checking ".rela.discard.reachable" in add_dead_ends(), so
> > > the next instruction of "break" is marked as unreachable.
> > >
> > > Actually, it can find the reachable instruction after parsing the section
> > > ".rela.discard.reachable", in some cases, the "break" instruction may not
> > > be the first previous instruction with scheduling by Machine Instruction
> > > Scheduler of LLVM, it should find more times and then set insn->dead_end
> > > of the "break" instruction as false.
> > >
> > > This is preparation for later patch on LoongArch, there is no effect for
> > > the other archs with this patch.
> > >
> > > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> >
> > I'm having trouble understanding this commit log, is the problem that
> > the compiler is sometimes inserting code between 'break' and the
> > unreachable() inline asm?
> >
> > If so, this sounds like a problem that was already solved for x86 with:
> >
> > bfb1a7c91fb7 ("x86/bug: Merge annotate_reachable() into _BUG_FLAGS() asm")
> >
> > Can you check if that fixes it?
>
> I will try, thank you.
>
I was poking at the reachable annotations and ended up with this:
--- a/arch/loongarch/include/asm/bug.h
+++ b/arch/loongarch/include/asm/bug.h
@@ -4,6 +4,7 @@
#include <asm/break.h>
#include <linux/stringify.h>
+#include <linux/objtool.h>
#ifndef CONFIG_DEBUG_BUGVERBOSE
#define _BUGVERBOSE_LOCATION(file, line)
@@ -37,21 +38,21 @@
#define ASM_BUG() ASM_BUG_FLAGS(0)
-#define __BUG_FLAGS(flags) \
- asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)));
+#define __BUG_FLAGS(flags, extra) \
+ asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)) \
+ extra);
#define __WARN_FLAGS(flags) \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \
- annotate_reachable(); \
+ __BUG_FLAGS(BUGFLAG_WARNING|(flags), ASM_REACHABLE); \
instrumentation_end(); \
} while (0)
#define BUG() \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(0); \
+ __BUG_FLAGS(0, ""); \
unreachable(); \
} while (0)
next prev parent reply other threads:[~2024-11-26 14:32 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 4:49 [PATCH v4 00/10] Add jump table support for objtool on LoongArch Tiezhu Yang
2024-11-22 4:49 ` [PATCH v4 01/10] objtool: Handle various symbol types of rodata Tiezhu Yang
2024-11-26 6:44 ` Josh Poimboeuf
2024-11-26 10:41 ` Tiezhu Yang
2024-11-27 0:52 ` Josh Poimboeuf
2024-11-27 6:39 ` Tiezhu Yang
2024-11-27 18:53 ` Josh Poimboeuf
2024-11-28 2:26 ` Tiezhu Yang
2024-11-22 4:49 ` [PATCH v4 02/10] objtool: Handle special cases of dead end insn Tiezhu Yang
2024-11-26 6:45 ` Josh Poimboeuf
2024-11-26 10:42 ` Tiezhu Yang
2024-11-26 14:32 ` Peter Zijlstra [this message]
2024-11-26 15:22 ` Peter Zijlstra
2024-11-27 5:45 ` Tiezhu Yang
2024-11-22 4:49 ` [PATCH v4 03/10] objtool: Handle different entry size of rodata Tiezhu Yang
2024-11-26 7:02 ` Josh Poimboeuf
2024-11-26 10:59 ` Tiezhu Yang
2024-11-26 13:22 ` Tiezhu Yang
2024-11-27 0:57 ` Josh Poimboeuf
2024-11-27 6:59 ` Tiezhu Yang
2024-11-27 0:53 ` Josh Poimboeuf
2024-11-22 4:49 ` [PATCH v4 04/10] objtool: Handle PC relative relocation type Tiezhu Yang
2024-11-26 7:19 ` Josh Poimboeuf
2024-11-26 11:00 ` Tiezhu Yang
2024-11-26 13:24 ` Tiezhu Yang
2024-11-27 0:58 ` Josh Poimboeuf
2024-11-22 4:50 ` [PATCH v4 05/10] objtool: Handle unreachable entry of rodata Tiezhu Yang
2024-11-26 7:25 ` Josh Poimboeuf
2024-11-26 11:04 ` Tiezhu Yang
2024-11-27 0:55 ` Josh Poimboeuf
2024-11-22 4:50 ` [PATCH v4 06/10] objtool: Handle unsorted table offset " Tiezhu Yang
2024-11-26 13:28 ` Tiezhu Yang
2024-11-27 1:20 ` Josh Poimboeuf
2024-11-27 7:01 ` Tiezhu Yang
2024-11-28 0:10 ` Josh Poimboeuf
2024-11-28 0:16 ` Josh Poimboeuf
2024-11-28 1:00 ` Josh Poimboeuf
2024-11-28 2:28 ` Tiezhu Yang
2024-12-02 7:42 ` Tiezhu Yang
2024-12-03 15:58 ` Peter Zijlstra
2024-11-22 4:50 ` [PATCH v4 07/10] objtool/LoongArch: Get each table size " Tiezhu Yang
2024-11-22 4:50 ` [PATCH v4 08/10] objtool/LoongArch: Add support for switch table Tiezhu Yang
2024-11-22 4:50 ` [PATCH v4 09/10] objtool/LoongArch: Add support for goto table Tiezhu Yang
2024-11-22 4:50 ` [PATCH v4 10/10] LoongArch: Enable jump table for objtool Tiezhu Yang
2024-11-24 5:33 ` [PATCH v4 00/10] Add jump table support for objtool on LoongArch Huacai Chen
2024-11-26 7:29 ` Josh Poimboeuf
2024-11-26 9:18 ` Huacai Chen
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=20241126143243.GN38837@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=chenhuacai@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=yangtiezhu@loongson.cn \
/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