All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Xie <xiehuan09@gmail.com>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>,
	WANG Xuerui <kernel@xen0n.name>,
	 Masami Hiramatsu <mhiramat@kernel.org>,
	loongarch@lists.linux.dev,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v12 0/5] Add kprobe and kretprobe support for LoongArch
Date: Tue, 7 Feb 2023 12:32:08 +0800	[thread overview]
Message-ID: <CAEr6+EDRciZc1_QB7VZO8dhw78U_LZPAnkG24z5cY-oZJEQiLw@mail.gmail.com> (raw)
In-Reply-To: <CAAhV-H7O-R33AQvCXmZQXDb-ACjZ5MYdWULHuKXYdnvt+UPjJA@mail.gmail.com>

On Tue, Feb 7, 2023 at 12:03 PM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> Hi, Jeff,
>
> The code has been updated here,
> https://github.com/loongson/linux/commits/loongarch-next, you can test
> again.

It looks good to me.

Tested-by: Jeff Xie <xiehuan09@gmail.com>


> Huacai
>
> On Tue, Feb 7, 2023 at 11:14 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> >
> >
> >
> > On 02/06/2023 08:48 PM, Jeff Xie wrote:
> > > On Mon, Feb 6, 2023 at 8:13 PM Huacai Chen <chenhuacai@kernel.org> wrote:
> > >>
> > >> Hi, Jeff,
> > >>
> > >> Now I add kprobes on ftrace support in
> > >> https://github.com/loongson/linux/commits/loongarch-next, please test
> > >> again. Thank you.
> > >>
> > >
> > > When using the kprobe example module kprobe_example.ko, I haven't seen
> > > any errors.
> > >
> > > But when using the ftrace to probe the symbol + offset, the kernel will panic:
> > > e.g. probe the scheduler_tick+4 is fine, but when probe the
> > > scheduler_tick+5, the kernel will panic.
> > >
> >
> > Thanks for your test.
> >
> > We can see that the instruction address is 4-byte alignment,
> > this is because the instruction length is 32-bit on LoongArch.
> >
> > $ objdump -d vmlinux > dump.txt
> > $ grep -A 20 scheduler_tick dump.txt | head -21
> > 9000000000279fc8 <scheduler_tick>:
> > 9000000000279fc8:       03400000        andi            $zero, $zero, 0x0
> > 9000000000279fcc:       03400000        andi            $zero, $zero, 0x0
> > 9000000000279fd0:       02ff4063        addi.d          $sp, $sp, -48(0xfd0)
> > 9000000000279fd4:       29c08077        st.d            $s0, $sp, 32(0x20)
> > 9000000000279fd8:       29c06078        st.d            $s1, $sp, 24(0x18)
> > 9000000000279fdc:       29c04079        st.d            $s2, $sp, 16(0x10)
> > 9000000000279fe0:       29c0207a        st.d            $s3, $sp, 8(0x8)
> > 9000000000279fe4:       29c0a061        st.d            $ra, $sp, 40(0x28)
> > 9000000000279fe8:       2700007b        stptr.d         $s4, $sp, 0
> > 9000000000279fec:       24001844        ldptr.w         $a0, $tp, 24(0x18)
> > 9000000000279ff0:       1a02edd9        pcalau12i       $s2, 5998(0x176e)
> > 9000000000279ff4:       1a034bac        pcalau12i       $t0, 6749(0x1a5d)
> > 9000000000279ff8:       02f56339        addi.d          $s2, $s2, -680(0xd58)
> > 9000000000279ffc:       00410c9a        slli.d          $s3, $a0, 0x3
> > 900000000027a000:       28aae18d        ld.w            $t1, $t0, -1352(0xab8)
> > 900000000027a004:       380c6b2e        ldx.d           $t2, $s2, $s3
> > 900000000027a008:       1a022fcc        pcalau12i       $t0, 4478(0x117e)
> > 900000000027a00c:       02f20198        addi.d          $s1, $t0, -896(0xc80)
> > 900000000027a010:       00150317        move            $s0, $s1
> > 900000000027a014:       004081ac        slli.w          $t0, $t1, 0x0
> >
> > So we should check the probe address at the beginning of
> > arch_prepare_kprobe(), some other archs do the same thing.
> >
> > $ git diff
> > diff --git a/arch/loongarch/kernel/kprobes.c
> > b/arch/loongarch/kernel/kprobes.c
> > index bdab707b6edf..56c8c4b09a42 100644
> > --- a/arch/loongarch/kernel/kprobes.c
> > +++ b/arch/loongarch/kernel/kprobes.c
> > @@ -79,6 +79,9 @@ NOKPROBE_SYMBOL(arch_prepare_simulate);
> >
> >   int arch_prepare_kprobe(struct kprobe *p)
> >   {
> > +       if ((unsigned long)p->addr & 0x3)
> > +               return -EILSEQ;
> > +
> >          /* copy instruction */
> >          p->opcode = *p->addr;
> >
> >
> > Thanks,
> > Tiezhu
> >
> >



-- 
Thanks,
JeffXie

      reply	other threads:[~2023-02-07  4:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18  2:00 [PATCH v12 0/5] Add kprobe and kretprobe support for LoongArch Tiezhu Yang
2023-01-18  2:00 ` [PATCH v12 1/5] LoongArch: Simulate branch and PC* instructions Tiezhu Yang
2023-01-18  2:00 ` [PATCH v12 2/5] LoongArch: Add kprobe support Tiezhu Yang
2023-01-18  2:00 ` [PATCH v12 3/5] LoongArch: Add kretprobe support Tiezhu Yang
2023-01-18  2:01 ` [PATCH v12 4/5] LoongArch: Mark some assembler symbols as non-kprobe-able Tiezhu Yang
2023-01-18  4:14   ` Huacai Chen
2023-01-18  4:23     ` Tiezhu Yang
2023-01-18  6:05       ` Jinyang He
2023-01-18  6:24         ` Tiezhu Yang
2023-01-18  7:17           ` Huacai Chen
2023-01-19 15:31             ` Masami Hiramatsu
2023-01-20 13:23               ` Huacai Chen
2023-02-01 12:55                 ` Masami Hiramatsu
2023-01-18  7:20           ` Jinyang He
2023-01-18  2:01 ` [PATCH v12 5/5] samples/kprobes: Add LoongArch support Tiezhu Yang
2023-01-18  3:30 ` [PATCH v12 0/5] Add kprobe and kretprobe support for LoongArch Huacai Chen
2023-02-01  4:56   ` Huacai Chen
2023-02-01  9:40     ` Jeff Xie
2023-02-02  2:23       ` Tiezhu Yang
2023-02-02  3:33         ` Jeff Xie
2023-02-02 23:59           ` Masami Hiramatsu
2023-02-06 12:13           ` Huacai Chen
2023-02-06 12:48             ` Jeff Xie
2023-02-07  3:14               ` Tiezhu Yang
2023-02-07  4:03                 ` Huacai Chen
2023-02-07  4:32                   ` Jeff Xie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEr6+EDRciZc1_QB7VZO8dhw78U_LZPAnkG24z5cY-oZJEQiLw@mail.gmail.com \
    --to=xiehuan09@gmail.com \
    --cc=chenhuacai@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=mhiramat@kernel.org \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.