Received: by 10.223.185.116 with SMTP id b49csp3142970wrg; Mon, 12 Feb 2018 21:44:49 -0800 (PST) X-Google-Smtp-Source: AH8x224bDaTAcGsieg1qBJy4rEQAgcyJ1US25PdB1s+ePVPBuRgtbOLqnHlVO6WbLiedxOGlIRag X-Received: by 10.99.61.75 with SMTP id k72mr79356pga.384.1518500689760; Mon, 12 Feb 2018 21:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518500689; cv=none; d=google.com; s=arc-20160816; b=kMHl7aOJbP8irRvxQ6dHuKP0zh282oow5L5BwrnX92gwtmut9QHBp+Uk0qwUw7A60s eqIcSN9uWQCUr7bYfOVGhIR8UijqlFSQ7HnfQZUINYJocZ/+B9qG431XTYZuMZQEqMX+ 0A8UyQhb3uWZzkNDtsZP7cARfQ78nrTwYI9CixgxGL5cWXZ9zgXrzYLfePR+mTYxa2fQ Ywc17gHVubzkmlCHG9xH8r5l1BBLT9M0InOaw4DY+BsIrbh0R6EDqS6KIStJDGvHxHs+ UPUNpM/PF/NDaoirNzEwX1NAR1m1/yrqZ61bu7ZRo3ncT1MrvB6Nd1kkqce1dv7c3Bch VkvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=ZyNLXf7nDehp3Ed1b9qW+YaXq+PEUlWKwQO+C0O0HDo=; b=CCI/32yhoLaZoH/wdxLWzjlIQD/SpsmVQe/R68xvX1vVxwQFYLQXuV4Y9WI2MLpCuk Ep4GiDWZtDJYDIiurSgKyAkjnTcB4NmdLR31kKUY/w8nhPhWR6gFRnbwcozaAihVuYHk YmVncJ5AaTywTGRn0mAoVuPw9uj3UGjtiziDmRwebS3wlT5S2Uj1fhlheI3qKL+HbEsc sAqyDlBvFs3jstIGPWPx+uqtLK1uIYf4Tb/gHYBQmIdollTeVhkmHoFPAHy3zfvmGgui rcV2wa5FlP39DoTdMpxVsWJ/YTn9tSlixl5s1skouWXdr/8rJLvi5F0Q1QOKwZQHQWEe S79w== 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 e23si780050pfl.195.2018.02.12.21.44.05; Mon, 12 Feb 2018 21:44:49 -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; 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 S933434AbeBMFma (ORCPT + 99 others); Tue, 13 Feb 2018 00:42:30 -0500 Received: from exmail.andestech.com ([59.124.169.137]:41160 "EHLO ATCSQR.andestech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754159AbeBMFm0 (ORCPT ); Tue, 13 Feb 2018 00:42:26 -0500 Received: from ATCSQR.andestech.com (localhost [127.0.0.2] (may be forged)) by ATCSQR.andestech.com with ESMTP id w1D5Gekp046309 for ; Tue, 13 Feb 2018 13:16:40 +0800 (GMT-8) (envelope-from alankao@andestech.com) Received: from mail.andestech.com (atcpcs16.andestech.com [10.0.1.222]) by ATCSQR.andestech.com with ESMTP id w1D5GQRV046280; Tue, 13 Feb 2018 13:16:26 +0800 (GMT-8) (envelope-from alankao@andestech.com) Received: from atcsqa06.andestech.com (10.0.1.85) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.123.3; Tue, 13 Feb 2018 13:17:36 +0800 From: Alan Kao To: Palmer Dabbelt , Albert Ou , "Steven Rostedt" , Ingo Molnar , , , CC: Alan Kao Subject: [PATCH v4 6/6] riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support Date: Tue, 13 Feb 2018 13:13:21 +0800 Message-ID: <1518498801-677-7-git-send-email-alankao@andestech.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518498801-677-1-git-send-email-alankao@andestech.com> References: <1518498801-677-1-git-send-email-alankao@andestech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.1.85] X-DNSRBL: X-MAIL: ATCSQR.andestech.com w1D5GQRV046280 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In walk_stackframe, the pc now receives the address from calling ftrace_graph_ret_addr instead of manual calculation. Note that the original calculation, pc = frame->ra - 4 is buggy when the instruction at the return address happened to be a compressed inst. But since it is not a critical part of ftrace, it is ignored for now to ease the review process. Cc: Greentime Hu Signed-off-by: Alan Kao --- arch/riscv/kernel/ftrace.c | 2 +- arch/riscv/kernel/stacktrace.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c index 48b5353691c3..1157b6b52d25 100644 --- a/arch/riscv/kernel/ftrace.c +++ b/arch/riscv/kernel/ftrace.c @@ -151,7 +151,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, return; err = ftrace_push_return_trace(old, self_addr, &trace.depth, - frame_pointer, NULL); + frame_pointer, parent); if (err == -EBUSY) return; *parent = return_hooker; diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c index 559aae781154..a4b1d94371a0 100644 --- a/arch/riscv/kernel/stacktrace.c +++ b/arch/riscv/kernel/stacktrace.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef CONFIG_FRAME_POINTER @@ -63,7 +64,12 @@ static void notrace walk_stackframe(struct task_struct *task, frame = (struct stackframe *)fp - 1; sp = fp; fp = frame->fp; +#ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR + pc = ftrace_graph_ret_addr(current, NULL, frame->ra, + (unsigned long *)(fp - 8)); +#else pc = frame->ra - 0x4; +#endif } } -- 2.15.1