While debugging the selftests/bpf: get_cgroup_id_user test failure on arm64
where the test is expecting trace file
/sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id
but this path not enabled after enabling required kernel configuration also.
CONFIG_FTRACE_SYSCALLS=y
strace output:
open(\"/sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id\",
O_RDONLY) = -1 ENOENT (No such file or directory)
This problem noticed on Linux mainline kernel version 4.20.0-rc3.
Best regards
Naresh Kamboju
Hi Masami,
On Wed, Nov 28, 2018 at 01:29:45AM +0900, Masami Hiramatsu wrote:
> Since commit 4378a7d4be30 ("arm64: implement syscall wrappers")
> introduced "__arm64_" prefix to all syscall wrapper symbols in
> sys_call_table, syscall tracer can not find corresponding
> metadata from syscall name. In the result, we have no syscall
> ftrace events on arm64 kernel, and some bpf testcases are failed
> on arm64.
>
> To fix this issue, this introduces custom
> arch_syscall_match_sym_name() which skips first 8 bytes when
> comparing the syscall and symbol names.
>
> Fixes: 4378a7d4be30 ("arm64: implement syscall wrappers")
> Reported-by: Naresh Kamboju <[email protected]>
> Signed-off-by: Masami Hiramatsu <[email protected]>
> Cc: [email protected]
> ---
> arch/arm64/include/asm/ftrace.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
> index caa955f10e19..a710f79db442 100644
> --- a/arch/arm64/include/asm/ftrace.h
> +++ b/arch/arm64/include/asm/ftrace.h
> @@ -56,6 +56,15 @@ static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
> {
> return is_compat_task();
> }
> +
> +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
> +
> +static inline bool arch_syscall_match_sym_name(const char *sym,
> + const char *name)
> +{
> + /* Since all syscall functions have __arm64_ prefix, we must skip it */
> + return !strcmp(sym + 8, name);
> +}
This looks fine to me, but I'm curious about whether this is supposed to
work with compat syscalls as well, where the prefix is "__arm64_compat_".
If we broadly follow the x86 lead, we'd have:
return (!strncmp(sym, "__arm64_", 8) && !strcmp(sym + 8, name)) ||
(!strncmp(sym, "__arm64_compat_", 15) && !strcmp(sym + 15, name));
Do we need to handle compat (i.e. 32-bit) tasks here?
Will
On Tue, 27 Nov 2018 16:58:49 +0000
Will Deacon <[email protected]> wrote:
> This looks fine to me, but I'm curious about whether this is supposed to
> work with compat syscalls as well, where the prefix is "__arm64_compat_".
>
> If we broadly follow the x86 lead, we'd have:
>
> return (!strncmp(sym, "__arm64_", 8) && !strcmp(sym + 8, name)) ||
> (!strncmp(sym, "__arm64_compat_", 15) && !strcmp(sym + 15, name));
>
> Do we need to handle compat (i.e. 32-bit) tasks here?
Only if you want to trace compat syscalls as well ;-)
-- Steve
Hi,
I found that the commit 4378a7d4be30 ("arm64: implement syscall
wrappers") changed
the syscall wrapper function names by adding __arm64_ prefix. So arm64
kernel should
have its own arch_syscall_match_sym_name().
Thank you,
2018年11月28日(水) 0:22 Naresh Kamboju <[email protected]>:
>
> While debugging the selftests/bpf: get_cgroup_id_user test failure on arm64
> where the test is expecting trace file
> /sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id
> but this path not enabled after enabling required kernel configuration also.
> CONFIG_FTRACE_SYSCALLS=y
>
> strace output:
> open(\"/sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id\",
> O_RDONLY) = -1 ENOENT (No such file or directory)
>
> This problem noticed on Linux mainline kernel version 4.20.0-rc3.
>
> Best regards
> Naresh Kamboju
--
Masami Hiramatsu
On Wed, 28 Nov 2018 01:29:45 +0900
Masami Hiramatsu <[email protected]> wrote:
> Since commit 4378a7d4be30 ("arm64: implement syscall wrappers")
> introduced "__arm64_" prefix to all syscall wrapper symbols in
> sys_call_table, syscall tracer can not find corresponding
> metadata from syscall name. In the result, we have no syscall
> ftrace events on arm64 kernel, and some bpf testcases are failed
> on arm64.
>
> To fix this issue, this introduces custom
> arch_syscall_match_sym_name() which skips first 8 bytes when
> comparing the syscall and symbol names.
>
Acked-by: Steven Rostedt (VMware) <[email protected]>
-- Steve
> Fixes: 4378a7d4be30 ("arm64: implement syscall wrappers")
> Reported-by: Naresh Kamboju <[email protected]>
> Signed-off-by: Masami Hiramatsu <[email protected]>
> Cc: [email protected]
> ---
> arch/arm64/include/asm/ftrace.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
> index caa955f10e19..a710f79db442 100644
> --- a/arch/arm64/include/asm/ftrace.h
> +++ b/arch/arm64/include/asm/ftrace.h
> @@ -56,6 +56,15 @@ static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
> {
> return is_compat_task();
> }
> +
> +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
> +
> +static inline bool arch_syscall_match_sym_name(const char *sym,
> + const char *name)
> +{
> + /* Since all syscall functions have __arm64_ prefix, we must skip it */
> + return !strcmp(sym + 8, name);
> +}
> #endif /* ifndef __ASSEMBLY__ */
>
> #endif /* __ASM_FTRACE_H */
Since commit 4378a7d4be30 ("arm64: implement syscall wrappers")
introduced "__arm64_" prefix to all syscall wrapper symbols in
sys_call_table, syscall tracer can not find corresponding
metadata from syscall name. In the result, we have no syscall
ftrace events on arm64 kernel, and some bpf testcases are failed
on arm64.
To fix this issue, this introduces custom
arch_syscall_match_sym_name() which skips first 8 bytes when
comparing the syscall and symbol names.
Fixes: 4378a7d4be30 ("arm64: implement syscall wrappers")
Reported-by: Naresh Kamboju <[email protected]>
Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: [email protected]
---
arch/arm64/include/asm/ftrace.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
index caa955f10e19..a710f79db442 100644
--- a/arch/arm64/include/asm/ftrace.h
+++ b/arch/arm64/include/asm/ftrace.h
@@ -56,6 +56,15 @@ static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
{
return is_compat_task();
}
+
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+
+static inline bool arch_syscall_match_sym_name(const char *sym,
+ const char *name)
+{
+ /* Since all syscall functions have __arm64_ prefix, we must skip it */
+ return !strcmp(sym + 8, name);
+}
#endif /* ifndef __ASSEMBLY__ */
#endif /* __ASM_FTRACE_H */
Hi Will,
On Tue, 27 Nov 2018 13:18:59 -0500
Steven Rostedt <[email protected]> wrote:
> On Tue, 27 Nov 2018 16:58:49 +0000
> Will Deacon <[email protected]> wrote:
>
> > This looks fine to me, but I'm curious about whether this is supposed to
> > work with compat syscalls as well, where the prefix is "__arm64_compat_".
> >
> > If we broadly follow the x86 lead, we'd have:
> >
> > return (!strncmp(sym, "__arm64_", 8) && !strcmp(sym + 8, name)) ||
> > (!strncmp(sym, "__arm64_compat_", 15) && !strcmp(sym + 15, name));
> >
> > Do we need to handle compat (i.e. 32-bit) tasks here?
>
> Only if you want to trace compat syscalls as well ;-)
Actually I thought about that, but I found below comment in
arch/arm64/include/asm/ftrace.h
* Because AArch32 mode does not share the same syscall table with AArch64,
* tracing compat syscalls may result in reporting bogus syscalls or even
* hang-up, so just do not trace them.
That's why I dropped compat syscall support.
Thank you,
--
Masami Hiramatsu <[email protected]>
Hi Masami San,
Thanks for the patch it solved the problem.
On Tue, 27 Nov 2018 at 21:41, Masami Hiramatsu
<[email protected]> wrote:
>
> Hi,
>
> I found that the commit 4378a7d4be30 ("arm64: implement syscall
> wrappers") changed
> the syscall wrapper function names by adding __arm64_ prefix. So arm64
> kernel should
> have its own arch_syscall_match_sym_name().
arm64: ftrace: Fix to enable syscall events on arm64
From: Masami Hiramatsu <[email protected]>
Since commit 4378a7d4be30 ("arm64: implement syscall wrappers")
introduced "__arm64_" prefix to all syscall wrapper symbols in
sys_call_table, syscall tracer can not find corresponding
metadata from syscall name. In the result, we have no syscall
ftrace events on arm64 kernel, and some bpf testcases are failed
on arm64.
To fix this issue, this introduces custom
arch_syscall_match_sym_name() which skips first 8 bytes when
comparing the syscall and symbol names.
Fixes: 4378a7d4be30 ("arm64: implement syscall wrappers")
Signed-off-by: Masami Hiramatsu <[email protected]>
Reported-by: Naresh Kamboju <[email protected]>
Tested-by: Naresh Kamboju <[email protected]>
---
arch/arm64/include/asm/ftrace.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
index caa955f10e19..a710f79db442 100644
--- a/arch/arm64/include/asm/ftrace.h
+++ b/arch/arm64/include/asm/ftrace.h
@@ -56,6 +56,15 @@ static inline bool
arch_trace_is_compat_syscall(struct pt_regs *regs)
{
return is_compat_task();
}
+
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+
+static inline bool arch_syscall_match_sym_name(const char *sym,
+ const char *name)
+{
+ /* Since all syscall functions have __arm64_ prefix, we must skip it */
+ return !strcmp(sym + 8, name);
+}
#endif /* ifndef __ASSEMBLY__ */
#endif /* __ASM_FTRACE_H */
>
> Thank you,
>
> 2018年11月28日(水) 0:22 Naresh Kamboju <[email protected]>:
> >
> > While debugging the selftests/bpf: get_cgroup_id_user test failure on arm64
> > where the test is expecting trace file
> > /sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id
> > but this path not enabled after enabling required kernel configuration also.
> > CONFIG_FTRACE_SYSCALLS=y
> >
> > strace output:
> > open(\"/sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id\",
> > O_RDONLY) = -1 ENOENT (No such file or directory)
> >
> > This problem noticed on Linux mainline kernel version 4.20.0-rc3.
> >
> > Best regards
> > Naresh Kamboju
>
>
>
> --
> Masami Hiramatsu
Hi Masami,
On Wed, Nov 28, 2018 at 08:55:55AM +0900, Masami Hiramatsu wrote:
> On Tue, 27 Nov 2018 13:18:59 -0500
> Steven Rostedt <[email protected]> wrote:
>
> > On Tue, 27 Nov 2018 16:58:49 +0000
> > Will Deacon <[email protected]> wrote:
> >
> > > This looks fine to me, but I'm curious about whether this is supposed to
> > > work with compat syscalls as well, where the prefix is "__arm64_compat_".
> > >
> > > If we broadly follow the x86 lead, we'd have:
> > >
> > > return (!strncmp(sym, "__arm64_", 8) && !strcmp(sym + 8, name)) ||
> > > (!strncmp(sym, "__arm64_compat_", 15) && !strcmp(sym + 15, name));
> > >
> > > Do we need to handle compat (i.e. 32-bit) tasks here?
> >
> > Only if you want to trace compat syscalls as well ;-)
>
> Actually I thought about that, but I found below comment in
> arch/arm64/include/asm/ftrace.h
>
> * Because AArch32 mode does not share the same syscall table with AArch64,
> * tracing compat syscalls may result in reporting bogus syscalls or even
> * hang-up, so just do not trace them.
>
> That's why I dropped compat syscall support.
Ok! Then please add a comment to arch_syscall_match_sym_name() along those
lines, and you can add my ack:
Acked-by: Will Deacon <[email protected]>
Thanks,
Will
On Wed, 28 Nov 2018 12:05:02 +0000
Will Deacon <[email protected]> wrote:
> Ok! Then please add a comment to arch_syscall_match_sym_name() along those
> lines, and you can add my ack:
>
> Acked-by: Will Deacon <[email protected]>
Shouldn't this go through your tree?
-- Steve
On Wed, Nov 28, 2018 at 09:22:23AM -0500, Steven Rostedt wrote:
> On Wed, 28 Nov 2018 12:05:02 +0000
> Will Deacon <[email protected]> wrote:
>
> > Ok! Then please add a comment to arch_syscall_match_sym_name() along those
> > lines, and you can add my ack:
> >
> > Acked-by: Will Deacon <[email protected]>
>
> Shouldn't this go through your tree?
Yup; I'm hoping Catalin will pick it up as a fix for 4.20 (we take it in
turns, so I'm looking at stuff for 4.21 atm).
Will
On Wed, 28 Nov 2018 19:59:22 +0000
Will Deacon <[email protected]> wrote:
> On Wed, Nov 28, 2018 at 09:22:23AM -0500, Steven Rostedt wrote:
> > On Wed, 28 Nov 2018 12:05:02 +0000
> > Will Deacon <[email protected]> wrote:
> >
> > > Ok! Then please add a comment to arch_syscall_match_sym_name() along those
> > > lines, and you can add my ack:
> > >
> > > Acked-by: Will Deacon <[email protected]>
> >
> > Shouldn't this go through your tree?
>
> Yup; I'm hoping Catalin will pick it up as a fix for 4.20 (we take it in
> turns, so I'm looking at stuff for 4.21 atm).
OK, I'll add a comment about compat syscalls. BTW, this should be applied
to 4.19 too, since without this, no one can use syscall events on arm64.
Thank you,
--
Masami Hiramatsu <[email protected]>
Since commit 4378a7d4be30 ("arm64: implement syscall wrappers")
introduced "__arm64_" prefix to all syscall wrapper symbols in
sys_call_table, syscall tracer can not find corresponding
metadata from syscall name. In the result, we have no syscall
ftrace events on arm64 kernel, and some bpf testcases are failed
on arm64.
To fix this issue, this introduces custom
arch_syscall_match_sym_name() which skips first 8 bytes when
comparing the syscall and symbol names.
Fixes: 4378a7d4be30 ("arm64: implement syscall wrappers")
Reported-by: Naresh Kamboju <[email protected]>
Signed-off-by: Masami Hiramatsu <[email protected]>
Acked-by: Will Deacon <[email protected]>
Tested-by: Naresh Kamboju <[email protected]>
Cc: [email protected]
---
arch/arm64/include/asm/ftrace.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
index caa955f10e19..fac54fb050d0 100644
--- a/arch/arm64/include/asm/ftrace.h
+++ b/arch/arm64/include/asm/ftrace.h
@@ -56,6 +56,19 @@ static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
{
return is_compat_task();
}
+
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+
+static inline bool arch_syscall_match_sym_name(const char *sym,
+ const char *name)
+{
+ /*
+ * Since all syscall functions have __arm64_ prefix, we must skip it.
+ * However, as we described above, we decided to ignore compat
+ * syscalls, so we don't care about __arm64_compat_ prefix here.
+ */
+ return !strcmp(sym + 8, name);
+}
#endif /* ifndef __ASSEMBLY__ */
#endif /* __ASM_FTRACE_H */
On Thu, Nov 29, 2018 at 02:39:33PM +0900, Masami Hiramatsu wrote:
> Since commit 4378a7d4be30 ("arm64: implement syscall wrappers")
> introduced "__arm64_" prefix to all syscall wrapper symbols in
> sys_call_table, syscall tracer can not find corresponding
> metadata from syscall name. In the result, we have no syscall
> ftrace events on arm64 kernel, and some bpf testcases are failed
> on arm64.
>
> To fix this issue, this introduces custom
> arch_syscall_match_sym_name() which skips first 8 bytes when
> comparing the syscall and symbol names.
>
> Fixes: 4378a7d4be30 ("arm64: implement syscall wrappers")
> Reported-by: Naresh Kamboju <[email protected]>
> Signed-off-by: Masami Hiramatsu <[email protected]>
> Acked-by: Will Deacon <[email protected]>
> Tested-by: Naresh Kamboju <[email protected]>
> Cc: [email protected]
Queued for 4.20. Thanks.
--
Catalin
On Thu, 29 Nov 2018 16:53:30 +0000
Catalin Marinas <[email protected]> wrote:
> On Thu, Nov 29, 2018 at 02:39:33PM +0900, Masami Hiramatsu wrote:
> > Since commit 4378a7d4be30 ("arm64: implement syscall wrappers")
> > introduced "__arm64_" prefix to all syscall wrapper symbols in
> > sys_call_table, syscall tracer can not find corresponding
> > metadata from syscall name. In the result, we have no syscall
> > ftrace events on arm64 kernel, and some bpf testcases are failed
> > on arm64.
> >
> > To fix this issue, this introduces custom
> > arch_syscall_match_sym_name() which skips first 8 bytes when
> > comparing the syscall and symbol names.
> >
> > Fixes: 4378a7d4be30 ("arm64: implement syscall wrappers")
> > Reported-by: Naresh Kamboju <[email protected]>
> > Signed-off-by: Masami Hiramatsu <[email protected]>
> > Acked-by: Will Deacon <[email protected]>
> > Tested-by: Naresh Kamboju <[email protected]>
> > Cc: [email protected]
>
> Queued for 4.20. Thanks.
Thank you Catalin!
>
> --
> Catalin
--
Masami Hiramatsu <[email protected]>