Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8126966imu; Tue, 4 Dec 2018 03:28:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/W+73JnPs6j3qXlaq2Ha2gs+m0P1IklSXmQiHDZyQYin/XavPSk/FkDcV6deZ+cy0gzYW/9 X-Received: by 2002:a63:f959:: with SMTP id q25mr16618337pgk.315.1543922904798; Tue, 04 Dec 2018 03:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543922904; cv=none; d=google.com; s=arc-20160816; b=vvZyLlHTWmPbLk8Jy/ZpUtmC7RxIsdVESEkNuB+z/KYz4lmyVDgoFyDktsIkMb9aOF KzVYa7L2dhBNhbII7vEGOlOCqGla1yikit+stl3cSNiiM6ayLQUWgPdGJ4jzzFsYZpEH XLHXjwT1+Qf4dHzA4yxBdB9JN9am6Z9c0TBdmVU2t4ZbhBbEm0EpQM5qZF6wNFAJUHjz dy6e4lSg+AZaUvADGD0f2LYDHZoeY+lgkZ6ND1g5NyaMk3c8+yB7vZ+THRjmowQeHqQp yXdwQ/LEEuHHGV3aD/cwRLCBKWmMa6hMcvUvKoM+9er9dUb9rRYf10V5c01Do45PvsVf h+DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rqDwQL+M5zVOYR2e2vJZ4J199o/MZpp3MaKFAjtj+zs=; b=y7mAcDbHP4W0SCZpxNx9Hh9zE49XT0srTFBWp91TrfMejy1fYbisiW5H3dS1rNA0Y9 AAWmdeHRIsX4DrErfE4n1Vr3lSUJb0oJNSyeJH6TtKLvk0hrZNJH7tOS7P4B0pgSkD/C 8LDObQAkl/WJpqJJBrrupR3oO3jCn2oTCN6fVKiL4/cRW14+bKjE/gRUXKcCT/6aTQU7 ZdXOfY6QLDDIz6222apI963EnS7VYGPDRl7ah/F1Z4Oj56yg0dcnkbQq8yq4Dg1Qe6wW ZJzn/AIsb3mJweFWuh4z/bjSTo1O7Wi7FhQvMNYb8JBqvxYQQbkLUml7KuzbVN4HA1L8 Y9tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HHKuavhB; 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 u23si17045700pfi.175.2018.12.04.03.28.09; Tue, 04 Dec 2018 03:28:24 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=HHKuavhB; 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 S1727085AbeLDK7K (ORCPT + 99 others); Tue, 4 Dec 2018 05:59:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:43740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbeLDK7G (ORCPT ); Tue, 4 Dec 2018 05:59:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4DA9420878; Tue, 4 Dec 2018 10:59:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921145; bh=Otkclb+QcbCvkVUa9dq/BC19nECr3Efghy3FUhMYg0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HHKuavhBhRi04XOVO7waYQZT8k5kUXqC0kTjzgzFrYHcyRAsLPNAGMet8roYSuiPk ZooofTVWtWYiDVuO7s1CutNGcRxXiuSJdMZ9IGYUfZSIvqHx1brFdTPTUlPdHpMYUk fkACySy/gqfsVBx2Xj3WJNkR0gjHOYzZLxfz0ZWI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Masami Hiramatsu , "Steven Rostedt (VMware)" Subject: [PATCH 4.19 098/139] function_graph: Create function_graph_enter() to consolidate architecture code Date: Tue, 4 Dec 2018 11:49:39 +0100 Message-Id: <20181204103654.446058411@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt (VMware) commit 8114865ff82e200b383e46821c25cb0625b842b5 upstream. Currently all the architectures do basically the same thing in preparing the function graph tracer on entry to a function. This code can be pulled into a generic location and then this will allow the function graph tracer to be fixed, as well as extended. Create a new function graph helper function_graph_enter() that will call the hook function (ftrace_graph_entry) and the shadow stack operation (ftrace_push_return_trace), and remove the need of the architecture code to manage the shadow stack. This is needed to prepare for a fix of a design bug on how the curr_ret_stack is used. Cc: stable@kernel.org Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback") Reviewed-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- include/linux/ftrace.h | 3 +++ kernel/trace/trace_functions_graph.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -779,6 +779,9 @@ extern void return_to_handler(void); extern int ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth, unsigned long frame_pointer, unsigned long *retp); +extern int +function_graph_enter(unsigned long ret, unsigned long func, + unsigned long frame_pointer, unsigned long *retp); unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx, unsigned long ret, unsigned long *retp); --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c @@ -182,6 +182,22 @@ ftrace_push_return_trace(unsigned long r return 0; } +int function_graph_enter(unsigned long ret, unsigned long func, + unsigned long frame_pointer, unsigned long *retp) +{ + struct ftrace_graph_ent trace; + + trace.func = func; + trace.depth = current->curr_ret_stack + 1; + + /* Only trace if the calling function expects to */ + if (!ftrace_graph_entry(&trace)) + return -EBUSY; + + return ftrace_push_return_trace(ret, func, &trace.depth, + frame_pointer, retp); +} + /* Retrieve a function return address to the trace stack on thread info.*/ static void ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret,