lkml.org 
[lkml]   [2023]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH v6 07/13] riscv/kprobe: Prepare detour buffer for optimized kprobe
    Date
    Chen Guokai <chenguokai17@mails.ucas.ac.cn> writes:

    > diff --git a/arch/riscv/kernel/probes/opt.c b/arch/riscv/kernel/probes/opt.c
    > index d84aa1420fa2..a47f7d2bf3a6 100644
    > --- a/arch/riscv/kernel/probes/opt.c
    > +++ b/arch/riscv/kernel/probes/opt.c
    > @@ -11,9 +11,32 @@
    > #include <linux/kprobes.h>
    > #include <asm/kprobes.h>
    > #include <asm/patch.h>
    > +#include <asm/asm-offsets.h>
    >
    > #include "simulate-insn.h"
    > #include "decode-insn.h"
    > +#include "../../net/bpf_jit.h"
    > +
    > +static void optimized_callback(struct optimized_kprobe *op,
    > + struct pt_regs *regs)
    > +{
    > + if (kprobe_disabled(&op->kp))
    > + return;
    > +
    > + preempt_disable();
    > + if (kprobe_running()) {
    > + kprobes_inc_nmissed_count(&op->kp);
    > + } else {
    > + __this_cpu_write(current_kprobe, &op->kp);
    > + /* Save skipped registers */
    > + instruction_pointer_set(regs, (unsigned long)op->kp.addr);
    > + get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
    > + opt_pre_handler(&op->kp, regs);
    > + __this_cpu_write(current_kprobe, NULL);
    > + }
    > + preempt_enable();
    > +}
    > +NOKPROBE_SYMBOL(optimized_callback)
    >
    > static int in_auipc_jalr_range(long val)
    > {
    > @@ -30,6 +53,11 @@ static int in_auipc_jalr_range(long val)
    > #endif
    > }
    >
    > +#define DETOUR_ADDR(code, offs) \
    > + ((void *)((unsigned long)(code) + (offs)))
    > +#define DETOUR_INSN(code, offs) \
    > + (*(kprobe_opcode_t *)((unsigned long)(code) + (offs)))

    Can this cause a misaligned u32 load exception?


    Björn

    \
     
     \ /
      Last update: 2023-03-27 00:06    [W:4.824 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site