Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2983149imm; Sun, 1 Jul 2018 09:40:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfqm6SD6+/VyNmeRQuHZriAFK5imaRH7Vh9Akz9P60LEXDl4OmU2qcB9lI3s2JCWnihVnIo X-Received: by 2002:a17:902:8347:: with SMTP id z7-v6mr16623424pln.290.1530463224355; Sun, 01 Jul 2018 09:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530463224; cv=none; d=google.com; s=arc-20160816; b=NiZJx4NkzDEkHljJArgY0Ac3YnTw3VaIFH7QJhi0Q1SqrdeGWSbMHRGCRMS8XBUu4K 6S61t4ftoG9bTgLw10sOtA1y50u2uaE4Z9Apub8C87vkf7UWLjWwSuUE+e83ddf56ENV X5zhYn6Op4oXBcQXaZGfCMKM9wtBK5uFf26FjNy4kBxJJGXRkAorO2Q3RDsgBKHWXMqa 0WCzsCQg1iK8v11dbn7EXBxoDdxK2C/f+vn8MDLruoONYCtbmZ5S0lYqUBuRecWkbbM4 Q1pU5GQg6oqH7I0u0tDOV3oRbGNrLfugnHgrDSfImhB/QkcjJmjwpQh+euJYOUH/uViK 9L4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7kFAiMXIO214eskI+3H1S7zTDugL3uBREwi5fcVdAkk=; b=xULwJLc/a0ytWXq8MpJdjiRWieX9jm7h13tgpaDxtUZghkRooL7tAOcVZijNx8l24t xA6Q0c2PbtJPmKCyP58O0omI+PEcjsd3fJbPD/hHkEkMHGkpyyFp8BJlEd7Z1x8Ho0ig LYARvrQdqd7ofcIJvqrA5rA0oZZ4vraLTf8C1eh4vuIUQXzQ5jxnHJVfIPMuQ0XZ7eH6 VF8tOsIqzQowr+xxPmMsNe887klTVoEwyhEqKniZu/1HOOuTgvO4FSihaufxKFEBMXyc l407N0Nxg1WOhK8UATg24XnEoW3DpMe1mDM6nnCSxfbqwMFxh9KTv2+EbSSESi1m8eoU Nx7Q== 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 k1-v6si14591479pld.40.2018.07.01.09.40.10; Sun, 01 Jul 2018 09:40:24 -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 S1031665AbeGAQi4 (ORCPT + 99 others); Sun, 1 Jul 2018 12:38:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36790 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031375AbeGAQiv (ORCPT ); Sun, 1 Jul 2018 12:38:51 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3449992B; Sun, 1 Jul 2018 16:38:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthias Schiffer , Matt Redfearn , Paul Burton Subject: [PATCH 4.17 035/220] mips: ftrace: fix static function graph tracing Date: Sun, 1 Jul 2018 18:20:59 +0200 Message-Id: <20180701160909.797865281@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Matthias Schiffer commit 6fb8656646f996d1eef42e6d56203c4915cb9e08 upstream. 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 Tested-by: Matt Redfearn Patchwork: https://patchwork.linux-mips.org/patch/18929/ Signed-off-by: Paul Burton Cc: stable@vger.kernel.org # v3.17+ Signed-off-by: Greg Kroah-Hartman --- arch/mips/kernel/mcount.S | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) --- 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