Commit 8dcbc611 authored by Guo Ren's avatar Guo Ren

csky: kprobe: Fixup code in simulate without 'long'

The type of 'val' is 'unsigned long' in simulate_blz32, so 'val < 0'
can't be true.

Cast 'val' to 'long' here to determine branch token or not,

Fixup instructions: bnezad32, bhsz32, bhz32, blsz32, blz32

Link: https://lore.kernel.org/linux-csky/CAJF2gTQjKXR9gpo06WAWG1aquiT87mATiMGorXs6ChxOxoe90Q@mail.gmail.com/T/#tSigned-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
Co-developed-by: default avatarMenglong Dong <dong.menglong@zte.com.cn>
Signed-off-by: default avatarMenglong Dong <dong.menglong@zte.com.cn>
parent af94002b
...@@ -274,9 +274,9 @@ void __kprobes ...@@ -274,9 +274,9 @@ void __kprobes
simulate_bnezad32(u32 opcode, long addr, struct pt_regs *regs) simulate_bnezad32(u32 opcode, long addr, struct pt_regs *regs)
{ {
unsigned long tmp = opcode & 0x1f; unsigned long tmp = opcode & 0x1f;
unsigned long val; long val;
csky_insn_reg_get_val(regs, tmp, &val); csky_insn_reg_get_val(regs, tmp, (unsigned long *)&val);
val -= 1; val -= 1;
...@@ -286,7 +286,7 @@ simulate_bnezad32(u32 opcode, long addr, struct pt_regs *regs) ...@@ -286,7 +286,7 @@ simulate_bnezad32(u32 opcode, long addr, struct pt_regs *regs)
} else } else
instruction_pointer_set(regs, addr + 4); instruction_pointer_set(regs, addr + 4);
csky_insn_reg_set_val(regs, tmp, val); csky_insn_reg_set_val(regs, tmp, (unsigned long)val);
} }
void __kprobes void __kprobes
...@@ -297,13 +297,11 @@ simulate_bhsz32(u32 opcode, long addr, struct pt_regs *regs) ...@@ -297,13 +297,11 @@ simulate_bhsz32(u32 opcode, long addr, struct pt_regs *regs)
csky_insn_reg_get_val(regs, tmp, &val); csky_insn_reg_get_val(regs, tmp, &val);
if (val >= 0) { if ((long) val >= 0) {
instruction_pointer_set(regs, instruction_pointer_set(regs,
addr + sign_extend32((opcode & 0xffff0000) >> 15, 15)); addr + sign_extend32((opcode & 0xffff0000) >> 15, 15));
} else } else
instruction_pointer_set(regs, addr + 4); instruction_pointer_set(regs, addr + 4);
csky_insn_reg_set_val(regs, tmp, val);
} }
void __kprobes void __kprobes
...@@ -314,13 +312,11 @@ simulate_bhz32(u32 opcode, long addr, struct pt_regs *regs) ...@@ -314,13 +312,11 @@ simulate_bhz32(u32 opcode, long addr, struct pt_regs *regs)
csky_insn_reg_get_val(regs, tmp, &val); csky_insn_reg_get_val(regs, tmp, &val);
if (val > 0) { if ((long) val > 0) {
instruction_pointer_set(regs, instruction_pointer_set(regs,
addr + sign_extend32((opcode & 0xffff0000) >> 15, 15)); addr + sign_extend32((opcode & 0xffff0000) >> 15, 15));
} else } else
instruction_pointer_set(regs, addr + 4); instruction_pointer_set(regs, addr + 4);
csky_insn_reg_set_val(regs, tmp, val);
} }
void __kprobes void __kprobes
...@@ -331,13 +327,11 @@ simulate_blsz32(u32 opcode, long addr, struct pt_regs *regs) ...@@ -331,13 +327,11 @@ simulate_blsz32(u32 opcode, long addr, struct pt_regs *regs)
csky_insn_reg_get_val(regs, tmp, &val); csky_insn_reg_get_val(regs, tmp, &val);
if (val <= 0) { if ((long) val <= 0) {
instruction_pointer_set(regs, instruction_pointer_set(regs,
addr + sign_extend32((opcode & 0xffff0000) >> 15, 15)); addr + sign_extend32((opcode & 0xffff0000) >> 15, 15));
} else } else
instruction_pointer_set(regs, addr + 4); instruction_pointer_set(regs, addr + 4);
csky_insn_reg_set_val(regs, tmp, val);
} }
void __kprobes void __kprobes
...@@ -348,13 +342,11 @@ simulate_blz32(u32 opcode, long addr, struct pt_regs *regs) ...@@ -348,13 +342,11 @@ simulate_blz32(u32 opcode, long addr, struct pt_regs *regs)
csky_insn_reg_get_val(regs, tmp, &val); csky_insn_reg_get_val(regs, tmp, &val);
if (val < 0) { if ((long) val < 0) {
instruction_pointer_set(regs, instruction_pointer_set(regs,
addr + sign_extend32((opcode & 0xffff0000) >> 15, 15)); addr + sign_extend32((opcode & 0xffff0000) >> 15, 15));
} else } else
instruction_pointer_set(regs, addr + 4); instruction_pointer_set(regs, addr + 4);
csky_insn_reg_set_val(regs, tmp, val);
} }
void __kprobes void __kprobes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment