Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753274AbcKNPkY (ORCPT ); Mon, 14 Nov 2016 10:40:24 -0500 Received: from smtprelay0077.hostedemail.com ([216.40.44.77]:52512 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751443AbcKNPkW (ORCPT ); Mon, 14 Nov 2016 10:40:22 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::,RULES_HIT:41:334:355:368:369:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1500:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2691:2693:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:4605:5007:6119:6261:6691:7576:7875:8660:10004:10394:10400:10450:10455:10848:10967:11026:11232:11473:11657:11658:11914:12043:12291:12296:12438:12555:12663:12740:12760:12986:13148:13161:13229:13230:13439:14096:14097:14181:14659:14721:14819:19904:19999:21080:21212:21451:30029:30030:30054:30089:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: worm03_17a7a473822b X-Filterd-Recvd-Size: 4061 Date: Mon, 14 Nov 2016 10:40:08 -0500 From: Steven Rostedt To: Russell King - ARM Linux Cc: Rabin Vincent , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Rabin Vincent Subject: Re: [PATCH] ARM: ftrace: fix syscall name matching Message-ID: <20161114104008.36e9c40d@gandalf.local.home> In-Reply-To: <20161114134017.GJ1041@n2100.armlinux.org.uk> References: <1479128625-20948-1-git-send-email-rabin.vincent@axis.com> <20161114134017.GJ1041@n2100.armlinux.org.uk> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2993 Lines: 95 On Mon, 14 Nov 2016 13:40:17 +0000 Russell King - ARM Linux wrote: > On Mon, Nov 14, 2016 at 02:03:45PM +0100, Rabin Vincent wrote: > > From: Rabin Vincent > > > > ARM has a few system calls (most notably mmap) for which the names of > > the functions which are referenced in the syscall table do not match the > > names of the syscall tracepoints. As a consequence of this, these > > tracepoints are not made available. Implement > > arch_syscall_match_sym_name to fix this and allow tracing even these > > system calls. > > > > Signed-off-by: Rabin Vincent > > --- > > arch/arm/include/asm/ftrace.h | 21 +++++++++++++++++++++ > > 1 file changed, 21 insertions(+) > > > > diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h > > index bfe2a2f..8467909 100644 > > --- a/arch/arm/include/asm/ftrace.h > > +++ b/arch/arm/include/asm/ftrace.h > > @@ -54,6 +54,27 @@ static inline void *return_address(unsigned int level) > > > > #define ftrace_return_address(n) return_address(n) > > > > +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME > > + > > +static inline bool arch_syscall_match_sym_name(const char *sym, > > + const char *name) > > +{ > > + /* Skip sys_ */ > > + sym += 4; > > + name += 4; > > Is this really safe? What guarantees that we can wind forward four > bytes here? If it's always safe, it needs a better comment than just > two words. I believe it is, but a comment would do well. The "sym" comes from kallsyms_lookup(syscall-address...) Which it becomes the syscall function. Mostly defined by: include/linux/syscalls.h: #define SYSCALL_DEFINEx(x, name) asmlinkage long sys_##name(...) But there are cases that archs can define their own system calls outside of this method. But then again, those system calls wont have tracepoints attached to them, and they wont be called with this function. The "name" part comes from the system call tracepoint. #define SYSCALL_METADATA(sname, ...) static struct syscall_metadata __syscall_meta_##sname = { .name = "sys"#sname, It too appends the "sys" to the name. Note, sname here is called with appending "_" to name, so the .name will start with "sys_" as well. I'm guessing that there's an issue if more than one function name is used for the same function, that is, the symbol maps to the same IP. Then kallsyms_lookup() can return different function names for the same function being called, and I'm guessing that's what this is trying to fix. -- Steve > > > + > > + if (!strcmp(sym, "mmap2")) > > + sym = "mmap_pgoff"; > > + else if (!strcmp(sym, "statfs64_wrapper")) > > + sym = "statfs64"; > > + else if (!strcmp(sym, "fstatfs64_wrapper")) > > + sym = "fstatfs64"; > > + else if (!strcmp(sym, "arm_fadvise64_64")) > > + sym = "fadvise64_64"; > > + > > + return !strcmp(sym, name); > > +} > > + > > #endif /* ifndef __ASSEMBLY__ */ > > > > #endif /* _ASM_ARM_FTRACE */ > > -- > > 2.1.4 > > >