44#include <linux/preempt.h>
55#include <asm/break.h>
66
7- static const union loongarch_instruction breakpoint_insn = {
8- .reg0i15_format = {
9- .opcode = break_op ,
10- .immediate = BRK_KPROBE_BP ,
11- }
12- };
13-
14- static const union loongarch_instruction singlestep_insn = {
15- .reg0i15_format = {
16- .opcode = break_op ,
17- .immediate = BRK_KPROBE_SSTEPBP ,
18- }
19- };
7+ #define KPROBE_BP_INSN larch_insn_gen_break(BRK_KPROBE_BP)
8+ #define KPROBE_SSTEPBP_INSN larch_insn_gen_break(BRK_KPROBE_SSTEPBP)
209
2110DEFINE_PER_CPU (struct kprobe * , current_kprobe );
2211DEFINE_PER_CPU (struct kprobe_ctlblk , kprobe_ctlblk );
2312
2413static void arch_prepare_ss_slot (struct kprobe * p )
2514{
2615 p -> ainsn .insn [0 ] = * p -> addr ;
27- p -> ainsn .insn [1 ] = singlestep_insn ;
16+ p -> ainsn .insn [1 ] = KPROBE_SSTEPBP_INSN ;
2817 p -> ainsn .restore = (unsigned long )p -> addr + LOONGARCH_INSN_SIZE ;
2918}
3019NOKPROBE_SYMBOL (arch_prepare_ss_slot );
@@ -37,17 +26,20 @@ NOKPROBE_SYMBOL(arch_prepare_simulate);
3726
3827int arch_prepare_kprobe (struct kprobe * p )
3928{
29+ union loongarch_instruction insn ;
30+
4031 if ((unsigned long )p -> addr & 0x3 )
4132 return - EILSEQ ;
4233
4334 /* copy instruction */
4435 p -> opcode = * p -> addr ;
36+ insn .word = p -> opcode ;
4537
4638 /* decode instruction */
47- if (insns_not_supported (p -> opcode ))
39+ if (insns_not_supported (insn ))
4840 return - EINVAL ;
4941
50- if (insns_need_simulation (p -> opcode )) {
42+ if (insns_need_simulation (insn )) {
5143 p -> ainsn .insn = NULL ;
5244 } else {
5345 p -> ainsn .insn = get_insn_slot ();
@@ -68,7 +60,7 @@ NOKPROBE_SYMBOL(arch_prepare_kprobe);
6860/* Install breakpoint in text */
6961void arch_arm_kprobe (struct kprobe * p )
7062{
71- * p -> addr = breakpoint_insn ;
63+ * p -> addr = KPROBE_BP_INSN ;
7264 flush_insn_slot (p );
7365}
7466NOKPROBE_SYMBOL (arch_arm_kprobe );
@@ -163,6 +155,8 @@ NOKPROBE_SYMBOL(post_kprobe_handler);
163155static void setup_singlestep (struct kprobe * p , struct pt_regs * regs ,
164156 struct kprobe_ctlblk * kcb , int reenter )
165157{
158+ union loongarch_instruction insn ;
159+
166160 if (reenter ) {
167161 save_previous_kprobe (kcb );
168162 set_current_kprobe (p );
@@ -178,7 +172,8 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
178172 regs -> csr_era = (unsigned long )p -> ainsn .insn ;
179173 } else {
180174 /* simulate single steping */
181- arch_simulate_insn (p -> opcode , regs );
175+ insn .word = p -> opcode ;
176+ arch_simulate_insn (insn , regs );
182177 /* now go for post processing */
183178 post_kprobe_handler (p , kcb , regs );
184179 }
@@ -253,7 +248,7 @@ bool kprobe_breakpoint_handler(struct pt_regs *regs)
253248 }
254249 }
255250
256- if (addr -> word != breakpoint_insn . word ) {
251+ if (* addr != KPROBE_BP_INSN ) {
257252 /*
258253 * The breakpoint instruction was removed right
259254 * after we hit it. Another cpu has removed
0 commit comments