Received: by 10.213.65.68 with SMTP id h4csp1339522imn; Sat, 24 Mar 2018 09:59:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELs8AqR6NqmKN0F5JHgKVqga9bzyRyj0LaoESKj6913i3VsVKRWhV2omc3wyQa4ckVpdRjJ2 X-Received: by 10.98.174.23 with SMTP id q23mr24474593pff.103.1521910745876; Sat, 24 Mar 2018 09:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521910745; cv=none; d=google.com; s=arc-20160816; b=Mby8Z5ruM3q69O3AGNQ+Z0807LVc613xspnR/TkMShcJHvIp0FM0Hu9N7tRckBOL3/ 4tz5ehVCnDgVNTd31L52TJF8O6pefmCA1CfsSxfUVivV/2kyebdzuxCKjORgW9NgnvkY qoV2MXoDz+Vj366QXvzBcu9g/T3pggihMQV5+DISjaUIyyjYuOAEbh3KmqTIrIBp2zdk XtDneHgjYitusj0Pq3AqbDHzcWhLfoc8kUGNcD/dNapiM5d0lqJJDZejXA4Q0UCsku+J py2c/a94UBfNYu/5ugkhByR7QfasWSubVbj7D+DvjfZbROYxvqe98K4nvGbEEhNdEJQm Qe1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2G+UFiGSvFR/o4wil0R7qbdyA0+kh0/zurfD7xMcndw=; b=QD3JP6Q1MTXqRdIv7YWrq/nnaFXsI+ZiWCyxRao8gE/+jLWu42+NYmwo/tMQ9iU7RU w+nKlzJtXpwCvltKk1f0VC/dKdinCHsQBgZ990spSXaf5hgkxRYNvp6tf6ZttQkqYl68 N+WJ+vbI9j6k6OOFe6Tgwu2nGLV8b1iSosf6AxQ7Kp1ty3e/mII4MxKtv8CX7PWlz8jc bGTb+HFlkLOWIJuD8ytT8wdo6U1iZOyeRL6Mhnk9kRXD+fTjuQ75FtEbyoLxJ+WYLHrJ xVPLmNGQt3Y2ZrjQKQGVir/RdtAUgZnM3sEj/BLcZIiYex8auwnaofmQ2Wm66irjsf+y BAjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si8514497pfh.200.2018.03.24.09.58.50; Sat, 24 Mar 2018 09:59:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752548AbeCXQ55 (ORCPT + 99 others); Sat, 24 Mar 2018 12:57:57 -0400 Received: from orthanc.universe-factory.net ([104.238.176.138]:54052 "EHLO orthanc.universe-factory.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752400AbeCXQ54 (ORCPT ); Sat, 24 Mar 2018 12:57:56 -0400 Received: from localhost.localdomain (unknown [IPv6:2001:19f0:6c01:100::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by orthanc.universe-factory.net (Postfix) with ESMTPSA id E324D1F516; Sat, 24 Mar 2018 17:57:54 +0100 (CET) From: Matthias Schiffer To: ralf@linux-mips.org, rostedt@goodmis.org, mingo@redhat.com Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, mschiffer@universe-factory.net Subject: [PATCH] mips: ftrace: fix static function graph tracing Date: Sat, 24 Mar 2018 17:57:49 +0100 Message-Id: <7dc2bb7f712c1e3cfeaafaefe3a3f97668dee549.1521909650.git.mschiffer@universe-factory.net> X-Mailer: git-send-email 2.16.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ftrace_graph_caller was never run after calling ftrace_trace_function, breaking the function graph tracer. Fix this, bringing it in line with the x86 implementation. While we're at it, also streamline the control flow of _mcount a bit to reduce the number of branches. This issue was reported before: https://www.linux-mips.org/archives/linux-mips/2014-11/msg00295.html Signed-off-by: Matthias Schiffer --- Caveats: I've only tested this on 32bit; it would be great if someone with MIPS64 hardware or a working emulator setup could give it a spin. My test device runs on kernel 4.9.y, but I don't expect any problems applying the fix to newer kernels, given that this code is basically unchanged since 2014. I'm not sure what the correct Fixes: line would be. I did not bother to bisect the issue and could not find the commit introducing it by inspecting the log (assuming the tracer worked at some point). arch/mips/kernel/mcount.S | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S index f2ee7e1e3342..cff52b283e03 100644 --- a/arch/mips/kernel/mcount.S +++ b/arch/mips/kernel/mcount.S @@ -119,10 +119,20 @@ NESTED(_mcount, PT_SIZE, ra) EXPORT_SYMBOL(_mcount) PTR_LA t1, ftrace_stub PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */ - bne t1, t2, static_trace + beq t1, t2, fgraph_trace nop + MCOUNT_SAVE_REGS + + move a0, ra /* arg1: self return address */ + jalr t2 /* (1) call *ftrace_trace_function */ + move a1, AT /* arg2: parent's return address */ + + MCOUNT_RESTORE_REGS + +fgraph_trace: #ifdef CONFIG_FUNCTION_GRAPH_TRACER + PTR_LA t1, ftrace_stub PTR_L t3, ftrace_graph_return bne t1, t3, ftrace_graph_caller nop @@ -131,24 +141,11 @@ EXPORT_SYMBOL(_mcount) bne t1, t3, ftrace_graph_caller nop #endif - b ftrace_stub -#ifdef CONFIG_32BIT - addiu sp, sp, 8 -#else - nop -#endif -static_trace: - MCOUNT_SAVE_REGS - - move a0, ra /* arg1: self return address */ - jalr t2 /* (1) call *ftrace_trace_function */ - move a1, AT /* arg2: parent's return address */ - - MCOUNT_RESTORE_REGS #ifdef CONFIG_32BIT addiu sp, sp, 8 #endif + .globl ftrace_stub ftrace_stub: RETURN_BACK -- 2.16.2