[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <53b3b0e4c12f048d17e95111ac97b59fa35dea23.camel@xry111.site>
Date: Tue, 23 Sep 2025 20:39:25 +0800
From: Xi Ruoyao <xry111@...111.site>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>, Huacai Chen <chenhuacai@...nel.org>
Cc: 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, 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.
--
Xi Ruoyao <xry111@...111.site>
Powered by blists - more mailing lists