2021-06-09 17:17:35

by Punit Agrawal

[permalink] [raw]
Subject: [RFC PATCH 4/5] csky: ftrace: Drop duplicate implementation of arch_check_ftrace_location()

The csky specific arch_check_ftrace_location() shadows a weak
implementation of the function in core code that offers the same
functionality but with additional error checking.

Drop the architecture specific function as a step towards further
cleanup in core code.

Signed-off-by: Punit Agrawal <[email protected]>
Cc: Guo Ren <[email protected]>
---
arch/csky/kernel/probes/ftrace.c | 7 -------
1 file changed, 7 deletions(-)

diff --git a/arch/csky/kernel/probes/ftrace.c b/arch/csky/kernel/probes/ftrace.c
index ef2bb9bd9605..b388228abbf2 100644
--- a/arch/csky/kernel/probes/ftrace.c
+++ b/arch/csky/kernel/probes/ftrace.c
@@ -2,13 +2,6 @@

#include <linux/kprobes.h>

-int arch_check_ftrace_location(struct kprobe *p)
-{
- if (ftrace_location((unsigned long)p->addr))
- p->flags |= KPROBE_FLAG_FTRACE;
- return 0;
-}
-
/* Ftrace callback handler for kprobes -- called under preepmt disabled */
void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
struct ftrace_ops *ops, struct ftrace_regs *fregs)
--
2.30.2


2021-06-09 17:25:45

by Guo Ren

[permalink] [raw]
Subject: Re: [RFC PATCH 4/5] csky: ftrace: Drop duplicate implementation of arch_check_ftrace_location()

csky using -mcount not -fpatchable-function-entry, so
/* Given address is not on the instruction boundary */
if ((unsigned long)p->addr != ftrace_addr)
return -EILSEQ;
all right?

On Wed, Jun 9, 2021 at 6:51 PM Punit Agrawal <[email protected]> wrote:
>
> The csky specific arch_check_ftrace_location() shadows a weak
> implementation of the function in core code that offers the same
> functionality but with additional error checking.
>
> Drop the architecture specific function as a step towards further
> cleanup in core code.
>
> Signed-off-by: Punit Agrawal <[email protected]>
> Cc: Guo Ren <[email protected]>
> ---
> arch/csky/kernel/probes/ftrace.c | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/arch/csky/kernel/probes/ftrace.c b/arch/csky/kernel/probes/ftrace.c
> index ef2bb9bd9605..b388228abbf2 100644
> --- a/arch/csky/kernel/probes/ftrace.c
> +++ b/arch/csky/kernel/probes/ftrace.c
> @@ -2,13 +2,6 @@
>
> #include <linux/kprobes.h>
>
> -int arch_check_ftrace_location(struct kprobe *p)
> -{
> - if (ftrace_location((unsigned long)p->addr))
> - p->flags |= KPROBE_FLAG_FTRACE;
> - return 0;
> -}
> -
> /* Ftrace callback handler for kprobes -- called under preepmt disabled */
> void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
> struct ftrace_ops *ops, struct ftrace_regs *fregs)
> --
> 2.30.2
>


--
Best Regards
Guo Ren

ML: https://lore.kernel.org/linux-csky/

2021-06-09 17:49:47

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [RFC PATCH 4/5] csky: ftrace: Drop duplicate implementation of arch_check_ftrace_location()

Hi Guo,

On Wed, 9 Jun 2021 20:33:18 +0800
Guo Ren <[email protected]> wrote:

> csky using -mcount not -fpatchable-function-entry, so
> /* Given address is not on the instruction boundary */
> if ((unsigned long)p->addr != ftrace_addr)
> return -EILSEQ;
> all right?

Even if -mcount is used, that check is still needed since the
ftrace hooked address will be the ftrace_addr. If user tries to
probe the second instruction in mcount code, kprobes needs to stop it.

Thank you,

>
> On Wed, Jun 9, 2021 at 6:51 PM Punit Agrawal <[email protected]> wrote:
> >
> > The csky specific arch_check_ftrace_location() shadows a weak
> > implementation of the function in core code that offers the same
> > functionality but with additional error checking.
> >
> > Drop the architecture specific function as a step towards further
> > cleanup in core code.
> >
> > Signed-off-by: Punit Agrawal <[email protected]>
> > Cc: Guo Ren <[email protected]>
> > ---
> > arch/csky/kernel/probes/ftrace.c | 7 -------
> > 1 file changed, 7 deletions(-)
> >
> > diff --git a/arch/csky/kernel/probes/ftrace.c b/arch/csky/kernel/probes/ftrace.c
> > index ef2bb9bd9605..b388228abbf2 100644
> > --- a/arch/csky/kernel/probes/ftrace.c
> > +++ b/arch/csky/kernel/probes/ftrace.c
> > @@ -2,13 +2,6 @@
> >
> > #include <linux/kprobes.h>
> >
> > -int arch_check_ftrace_location(struct kprobe *p)
> > -{
> > - if (ftrace_location((unsigned long)p->addr))
> > - p->flags |= KPROBE_FLAG_FTRACE;
> > - return 0;
> > -}
> > -
> > /* Ftrace callback handler for kprobes -- called under preepmt disabled */
> > void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
> > struct ftrace_ops *ops, struct ftrace_regs *fregs)
> > --
> > 2.30.2
> >
>
>
> --
> Best Regards
> Guo Ren
>
> ML: https://lore.kernel.org/linux-csky/


--
Masami Hiramatsu <[email protected]>

2021-06-10 00:10:41

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [RFC PATCH 4/5] csky: ftrace: Drop duplicate implementation of arch_check_ftrace_location()

On Wed, 9 Jun 2021 19:50:18 +0900
Punit Agrawal <[email protected]> wrote:

> The csky specific arch_check_ftrace_location() shadows a weak
> implementation of the function in core code that offers the same
> functionality but with additional error checking.
>
> Drop the architecture specific function as a step towards further
> cleanup in core code.
>

Looks good to me.

Acked-by: Masami Hiramatsu <[email protected]>

Thank you,

> Signed-off-by: Punit Agrawal <[email protected]>
> Cc: Guo Ren <[email protected]>
> ---
> arch/csky/kernel/probes/ftrace.c | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/arch/csky/kernel/probes/ftrace.c b/arch/csky/kernel/probes/ftrace.c
> index ef2bb9bd9605..b388228abbf2 100644
> --- a/arch/csky/kernel/probes/ftrace.c
> +++ b/arch/csky/kernel/probes/ftrace.c
> @@ -2,13 +2,6 @@
>
> #include <linux/kprobes.h>
>
> -int arch_check_ftrace_location(struct kprobe *p)
> -{
> - if (ftrace_location((unsigned long)p->addr))
> - p->flags |= KPROBE_FLAG_FTRACE;
> - return 0;
> -}
> -
> /* Ftrace callback handler for kprobes -- called under preepmt disabled */
> void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
> struct ftrace_ops *ops, struct ftrace_regs *fregs)
> --
> 2.30.2
>


--
Masami Hiramatsu <[email protected]>