From patchwork Fri Sep 16 10:58:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avik Sil X-Patchwork-Id: 4121 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C958823EF7 for ; Fri, 16 Sep 2011 10:58:17 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id B9DDFA18A1B for ; Fri, 16 Sep 2011 10:58:17 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 23so2176515fxe.11 for ; Fri, 16 Sep 2011 03:58:17 -0700 (PDT) Received: by 10.223.5.76 with SMTP id 12mr1422952fau.103.1316170697618; Fri, 16 Sep 2011 03:58:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs124234lab; Fri, 16 Sep 2011 03:58:17 -0700 (PDT) Received: by 10.68.34.42 with SMTP id w10mr3210730pbi.313.1316170695668; Fri, 16 Sep 2011 03:58:15 -0700 (PDT) Received: from mail-pz0-f45.google.com (mail-pz0-f45.google.com [209.85.210.45]) by mx.google.com with ESMTPS id t7si1547324pbe.160.2011.09.16.03.58.14 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Sep 2011 03:58:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.45 is neither permitted nor denied by best guess record for domain of avik.sil@linaro.org) client-ip=209.85.210.45; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.45 is neither permitted nor denied by best guess record for domain of avik.sil@linaro.org) smtp.mail=avik.sil@linaro.org Received: by pzk33 with SMTP id 33so1738198pzk.4 for ; Fri, 16 Sep 2011 03:58:14 -0700 (PDT) Received: by 10.68.66.226 with SMTP id i2mr1449171pbt.473.1316170694277; Fri, 16 Sep 2011 03:58:14 -0700 (PDT) Received: from localhost.localdomain ([117.192.86.150]) by mx.google.com with ESMTPS id 4sm32080336pbk.5.2011.09.16.03.58.11 (version=SSLv3 cipher=OTHER); Fri, 16 Sep 2011 03:58:13 -0700 (PDT) From: Avik Sil To: ltt-dev@lists.casi.polymtl.ca Cc: dave.martin@linaro.org, jon.medhurst@linaro.org, patches@linaro.org Subject: [PATCH] ARM: Set bit 0 for thumb mode in kallsyms_lookup_name returned address Date: Fri, 16 Sep 2011 16:28:04 +0530 Message-Id: <1316170684-1914-1-git-send-email-avik.sil@linaro.org> X-Mailer: git-send-email 1.7.0.4 This patch fixes the undefined instruction oops due to execution of thumb-2 code in ARM mode. The zero bit in the symbol address returned by kallsyms_lookup_name is not set, leading to switching to ARM mode that generates oops while executing thumb-2 code. For detailed discussion, see [1]. [1] http://lists.casi.polymtl.ca/pipermail/ltt-dev/2011-September/005176.html Signed-off-by: Avik Sil --- lttng-context-prio.c | 11 ++++++++++- wrapper/ftrace.h | 28 ++++++++++++++++++++++------ wrapper/splice.c | 14 ++++++++++++-- wrapper/vmalloc.h | 14 +++++++++++--- 4 files changed, 55 insertions(+), 12 deletions(-) diff --git a/lttng-context-prio.c b/lttng-context-prio.c index ad1c42f..5e8c0d2 100644 --- a/lttng-context-prio.c +++ b/lttng-context-prio.c @@ -20,7 +20,16 @@ int (*wrapper_task_prio_sym)(struct task_struct *t); int wrapper_task_prio_init(void) { - wrapper_task_prio_sym = (void *) kallsyms_lookup_name("task_prio"); + unsigned long addr; + + addr = kallsyms_lookup_name("task_prio"); +#ifdef CONFIG_ARM +#ifdef CONFIG_THUMB2_KERNEL + if (addr) + addr |= 1; /* set bit 0 in address for thumb mode */ +#endif +#endif + wrapper_task_prio_sym = (void *) addr; if (!wrapper_task_prio_sym) { printk(KERN_WARNING "LTTng: task_prio symbol lookup failed.\n"); return -EINVAL; diff --git a/wrapper/ftrace.h b/wrapper/ftrace.h index 9c18cc5..d79aa5e 100644 --- a/wrapper/ftrace.h +++ b/wrapper/ftrace.h @@ -21,10 +21,18 @@ static inline int wrapper_register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, void *data) { - int (*register_ftrace_function_probe_sym)(char *glob, - struct ftrace_probe_ops *ops, void *data); + unsigned long addr; + int (*register_ftrace_function_probe_sym)(char *glob, + struct ftrace_probe_ops *ops, void *data); - register_ftrace_function_probe_sym = (void *) kallsyms_lookup_name("register_ftrace_function_probe"); + addr = kallsyms_lookup_name("register_ftrace_function_probe"); +#ifdef CONFIG_ARM +#ifdef CONFIG_THUMB2_KERNEL + if (addr) + addr |= 1; /* set bit 0 in address for thumb mode */ +#endif +#endif + register_ftrace_function_probe_sym = (void *) addr; if (register_ftrace_function_probe_sym) { return register_ftrace_function_probe_sym(glob, ops, data); } else { @@ -37,10 +45,18 @@ static inline void wrapper_unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, void *data) { - void (*unregister_ftrace_function_probe_sym)(char *glob, - struct ftrace_probe_ops *ops, void *data); + unsigned long addr; + void (*unregister_ftrace_function_probe_sym)(char *glob, + struct ftrace_probe_ops *ops, void *data); - unregister_ftrace_function_probe_sym = (void *) kallsyms_lookup_name("unregister_ftrace_function_probe"); + addr = kallsyms_lookup_name("unregister_ftrace_function_probe"); +#ifdef CONFIG_ARM +#ifdef CONFIG_THUMB2_KERNEL + if (addr) + addr |= 1; /* set bit 0 in address for thumb mode */ +#endif +#endif + unregister_ftrace_function_probe_sym = (void *) addr; if (unregister_ftrace_function_probe_sym) { unregister_ftrace_function_probe_sym(glob, ops, data); } else { diff --git a/wrapper/splice.c b/wrapper/splice.c index edc499c..c2c275b 100644 --- a/wrapper/splice.c +++ b/wrapper/splice.c @@ -21,8 +21,18 @@ ssize_t (*splice_to_pipe_sym)(struct pipe_inode_info *pipe, ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe, struct splice_pipe_desc *spd) { - if (!splice_to_pipe_sym) - splice_to_pipe_sym = (void *) kallsyms_lookup_name("splice_to_pipe"); + unsigned long addr; + + if (!splice_to_pipe_sym) { + addr = kallsyms_lookup_name("splice_to_pipe"); +#ifdef CONFIG_ARM +#ifdef CONFIG_THUMB2_KERNEL + if (addr) + addr |= 1; /* set bit 0 in address for thumb mode */ +#endif +#endif + splice_to_pipe_sym = (void *) addr; + } if (splice_to_pipe_sym) { return splice_to_pipe_sym(pipe, spd); } else { diff --git a/wrapper/vmalloc.h b/wrapper/vmalloc.h index 7d87855..d512c89 100644 --- a/wrapper/vmalloc.h +++ b/wrapper/vmalloc.h @@ -18,9 +18,17 @@ static inline void wrapper_vmalloc_sync_all(void) { - void (*vmalloc_sync_all_sym)(void); - - vmalloc_sync_all_sym = (void *) kallsyms_lookup_name("vmalloc_sync_all"); + unsigned long addr; + void (*vmalloc_sync_all_sym)(void); + + addr = kallsyms_lookup_name("vmalloc_sync_all"); +#ifdef CONFIG_ARM +#ifdef CONFIG_THUMB2_KERNEL + if (addr) + addr |= 1; /* set bit 0 in address for thumb mode */ +#endif +#endif + vmalloc_sync_all_sym = (void *) addr; if (vmalloc_sync_all_sym) { vmalloc_sync_all_sym(); } else {