]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
LoongArch: Add cflag -fno-isolate-erroneous-paths-dereference
authorTiezhu Yang <yangtiezhu@loongson.cn>
Thu, 2 Oct 2025 14:38:57 +0000 (22:38 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Thu, 2 Oct 2025 14:38:57 +0000 (22:38 +0800)
commitabb2a5572264b425e6dd9c213b735a82ab0ca68a
tree776759c7c1d927b0515f98addf97afc23e980570
parent2b5f6638204cc0e0f6ecd55b963ebb895ec61f3b
LoongArch: Add cflag -fno-isolate-erroneous-paths-dereference

Currently, when compiling with GCC, there is no "break 7" instruction
for zero division due to using the option -mno-check-zero-division, but
the compiler still generates "break 0" 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.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202509200413.7uihAxJ5-lkp@intel.com/
Fixes: baad7830ee9a ("objtool/LoongArch: Mark types based on break immediate code")
Suggested-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/Makefile