]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
objtool/LoongArch: Mark types based on break immediate code
authorTiezhu Yang <yangtiezhu@loongson.cn>
Thu, 18 Sep 2025 11:43:36 +0000 (19:43 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Thu, 18 Sep 2025 11:43:36 +0000 (19:43 +0800)
If the break immediate code is 0, it should mark the type as
INSN_TRAP. If the break immediate code is 1, it should mark the
type as INSN_BUG.

While at it, format the code style and add the code comment for nop.

Cc: stable@vger.kernel.org
Suggested-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
tools/objtool/arch/loongarch/decode.c

index b6fdc68053cc4e0326f1172faf7b4cbd22b3748d..428ba6de38219196506be4f3ba6eccd475df28c8 100644 (file)
@@ -310,10 +310,16 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
        if (decode_insn_reg2i16_fomat(inst, insn))
                return 0;
 
-       if (inst.word == 0)
+       if (inst.word == 0) {
+               /* andi $zero, $zero, 0x0 */
                insn->type = INSN_NOP;
-       else if (inst.reg0i15_format.opcode == break_op) {
-               /* break */
+       } else if (inst.reg0i15_format.opcode == break_op &&
+                  inst.reg0i15_format.immediate == 0x0) {
+               /* break 0x0 */
+               insn->type = INSN_TRAP;
+       } else if (inst.reg0i15_format.opcode == break_op &&
+                  inst.reg0i15_format.immediate == 0x1) {
+               /* break 0x1 */
                insn->type = INSN_BUG;
        } else if (inst.reg2_format.opcode == ertn_op) {
                /* ertn */