From patchwork Sat Oct 24 18:56:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 55732 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9OIuiux005723 for ; Sat, 24 Oct 2009 18:56:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752028AbZJXS4P (ORCPT ); Sat, 24 Oct 2009 14:56:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752024AbZJXS4M (ORCPT ); Sat, 24 Oct 2009 14:56:12 -0400 Received: from 124x34x33x190.ap124.ftth.ucom.ne.jp ([124.34.33.190]:43295 "EHLO master.linux-sh.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751844AbZJXS4J (ORCPT ); Sat, 24 Oct 2009 14:56:09 -0400 Received: from localhost (unknown [127.0.0.1]) by master.linux-sh.org (Postfix) with ESMTP id CDF3810289C; Sat, 24 Oct 2009 18:56:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at linux-sh.org Received: from master.linux-sh.org ([127.0.0.1]) by localhost (master.linux-sh.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M7EJO0tuY56j; Sun, 25 Oct 2009 03:56:10 +0900 (JST) Received: from localhost (82-38-64-26.cable.ubr06.brad.blueyonder.co.uk [82.38.64.26]) by master.linux-sh.org (Postfix) with ESMTP id E4116102897; Sun, 25 Oct 2009 03:56:09 +0900 (JST) From: Matt Fleming To: Paul Mundt Cc: linux-sh@vger.kernel.org, Steven Rostedt , Frederic Weisbecker Subject: [PATCH] sh: Check for return_to_handler when unwinding the stack Date: Sat, 24 Oct 2009 19:56:57 +0100 Message-Id: <1256410617-16860-1-git-send-email-matt@console-pimps.org> X-Mailer: git-send-email 1.6.4.rc0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org diff --git a/arch/sh/kernel/dwarf.c b/arch/sh/kernel/dwarf.c index 4d8c7bd..6c9d0c1 100644 --- a/arch/sh/kernel/dwarf.c +++ b/arch/sh/kernel/dwarf.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -569,6 +570,27 @@ struct dwarf_frame * dwarf_unwind_stack(unsigned long pc, if (!pc && !prev) pc = (unsigned long)current_text_addr(); +#ifdef CONFIG_FUNCTION_GRAPH_TRACER + /* + * If our stack has been patched by the function graph tracer + * then we might see the address of return_to_handler() where we + * expected to find the real return address. + */ + if (pc == (unsigned long)&return_to_handler) { + int index = current->curr_ret_stack; + + /* + * We currently have no way of tracking how many + * return_to_handler()'s we've seen. If there is more + * than one patched return address on our stack, + * complain loudly. + */ + WARN_ON(index > 0); + + pc = current->ret_stack[index].ret; + } +#endif + frame = mempool_alloc(dwarf_frame_pool, GFP_ATOMIC); if (!frame) { printk(KERN_ERR "Unable to allocate a dwarf frame\n");