Skip to content

Commit 288f677

Browse files
sunnanyongpalmer-dabbelt
authored andcommitted
riscv: ftrace: Use ftrace_get_regs helper
Use ftrace_get_regs() helper call to get pt_regs from ftrace_regs struct, this makes the code simpler. Signed-off-by: Nanyong Sun <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 86b276c commit 288f677

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

arch/riscv/kernel/probes/ftrace.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,39 @@
44

55
/* Ftrace callback handler for kprobes -- called under preepmt disabed */
66
void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
7-
struct ftrace_ops *ops, struct ftrace_regs *regs)
7+
struct ftrace_ops *ops, struct ftrace_regs *fregs)
88
{
99
struct kprobe *p;
10+
struct pt_regs *regs;
1011
struct kprobe_ctlblk *kcb;
1112

1213
p = get_kprobe((kprobe_opcode_t *)ip);
1314
if (unlikely(!p) || kprobe_disabled(p))
1415
return;
1516

17+
regs = ftrace_get_regs(fregs);
1618
kcb = get_kprobe_ctlblk();
1719
if (kprobe_running()) {
1820
kprobes_inc_nmissed_count(p);
1921
} else {
20-
unsigned long orig_ip = instruction_pointer(&(regs->regs));
22+
unsigned long orig_ip = instruction_pointer(regs);
2123

22-
instruction_pointer_set(&(regs->regs), ip);
24+
instruction_pointer_set(regs, ip);
2325

2426
__this_cpu_write(current_kprobe, p);
2527
kcb->kprobe_status = KPROBE_HIT_ACTIVE;
26-
if (!p->pre_handler || !p->pre_handler(p, &(regs->regs))) {
28+
if (!p->pre_handler || !p->pre_handler(p, regs)) {
2729
/*
2830
* Emulate singlestep (and also recover regs->pc)
2931
* as if there is a nop
3032
*/
31-
instruction_pointer_set(&(regs->regs),
33+
instruction_pointer_set(regs,
3234
(unsigned long)p->addr + MCOUNT_INSN_SIZE);
3335
if (unlikely(p->post_handler)) {
3436
kcb->kprobe_status = KPROBE_HIT_SSDONE;
35-
p->post_handler(p, &(regs->regs), 0);
37+
p->post_handler(p, regs, 0);
3638
}
37-
instruction_pointer_set(&(regs->regs), orig_ip);
39+
instruction_pointer_set(regs, orig_ip);
3840
}
3941

4042
/*

0 commit comments

Comments
 (0)