[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAhV-H5Q9g3u2txE5qf7r9tb8R+-g+8bYOPQMHHe=bT+Xj_Zug@mail.gmail.com>
Date: Sun, 28 Sep 2025 20:52:37 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Xi Ruoyao <xry111@...111.site>
Cc: Tiezhu Yang <yangtiezhu@...ngson.cn>, WANG Rui <wangrui@...ngson.cn>,
loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] LoongArch: Add -fno-isolate-erroneous-paths-dereference
in Makefile
On Tue, Sep 23, 2025 at 8:39 PM Xi Ruoyao <xry111@...111.site> wrote:
>
> On Tue, 2025-09-23 at 14:17 +0800, Tiezhu Yang wrote:
> > Currently, when compiling with GCC, there is no "break 0x7" instruction
> > for zero division due to using the option -mno-check-zero-division, but
> > the compiler still generates "break 0x0" instruction for zero division.
> >
> > Here is a simple example:
> >
> > $ cat test.c
> > int div(int a)
> > {
> > return a / 0;
> > }
> > $ gcc -O2 -S test.c -o test.s
> >
> > GCC generates "break 0" On LoongArch and "ud2" on x86, objtool decodes
> > "ud2" as INSN_BUG for x86, so decode "break 0" as INSN_BUG can fix the
> > objtool warnings for LoongArch, but this is not the intention.
> >
> > When decoding "break 0" as INSN_TRAP in the previous commit, the aim is
> > to handle "break 0" as a trap. The generated "break 0" for zero division
> > by GCC is not proper, it should generate a break instruction with proper
> > bug type, so add the GCC option -fno-isolate-erroneous-paths-dereference
> > to avoid generating the unexpected "break 0" instruction for now.
>
> I just proposed GCC to use the same "documented undefined instruction"
> as Clang:
> https://gcc.gnu.org/pipermail/gcc-patches/2025-September/695981.html.
I have discussed it with Tiezhu offline, and we prefer "break 0x1".
Huacai
>
> --
> Xi Ruoyao <xry111@...111.site>
Powered by blists - more mailing lists