Received: by 10.223.148.5 with SMTP id 5csp7698683wrq; Thu, 18 Jan 2018 08:29:48 -0800 (PST) X-Google-Smtp-Source: ACJfBoucEkKTwVSHXBpCfqcLsVQ5wvEWDIsKopzpQGaN307CZU8ZZAuF3q7GktoUR/bVkx1r4pUX X-Received: by 2002:a17:902:b2cb:: with SMTP id x11-v6mr48606plw.298.1516292988732; Thu, 18 Jan 2018 08:29:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516292988; cv=none; d=google.com; s=arc-20160816; b=kw7iQCUWDOLYCFpoScxE9l7WrRtYapxBsC6xBkqL/bqJHfo5DpHGk2ri1WWV2cH0TP wheyvpp2hUF5uR8e1wzIQy7t/xwlXkGk4RscBceR+fBSkD4cYu2bX5OmrueQDabXyIPd JQzLS2LYeQaii9qu615Z0SVNQXhCZNmas9D5c+hEK0AOiGg4uhSvXC1e2hbsM9QffqBi P/2ufk7QQYFCZoyptky/lNv/imYl7LrTQEkdbddjOqpNfbvtGivO/jANmvPK754hOa32 lfmMSnyODNar8tQxImM+OGuLunzsUhzzR2C7+ox9YqR1xKmgxTHyD9+qL2RXQOIuZ3Ca rxPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=VFB8vCrnvYOCgPw50Yb+dKFSiTn06ROpaPwHOZK1DN0=; b=QC07h/794DeUK3YEMreEUNi8SeM/aqhwVNhFb/lgylv21jXYa0p0S0SUD2psEGYYgM MrKDjrwnBH80dvea4v2HuLiEbtsA5O7BISKmaHlnMOdjgHZ6zg1shzFgEh7hpgqYQk6Y a59ni9yfnZR7qMUvPHE2wWFyhNrP6sDMZZTckxjBGajUokChwgiQse7bLF5AJlf6NkjH hrn11zp49As6rdUokundxBlZule2Wmrd0LC7lsYD7vlpduJrkhO8fmxhhliZ3j2w4H3+ 5O0dS9t49kEYoGZlxcAxJvUZ+Q9cOD6Z0rtEECfLfmqIlFX+d129axqtSWV0IlxcQL+O NlpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lYjoT6o4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si6343456pge.749.2018.01.18.08.29.34; Thu, 18 Jan 2018 08:29:48 -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=@gmail.com header.s=20161025 header.b=lYjoT6o4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932996AbeARPyY (ORCPT + 99 others); Thu, 18 Jan 2018 10:54:24 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36935 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932970AbeARPx7 (ORCPT ); Thu, 18 Jan 2018 10:53:59 -0500 Received: by mail-pf0-f193.google.com with SMTP id p1so14906696pfh.4 for ; Thu, 18 Jan 2018 07:53:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VFB8vCrnvYOCgPw50Yb+dKFSiTn06ROpaPwHOZK1DN0=; b=lYjoT6o4tTtx48CFsqMX1RSUqhxd1/Zmx4ApGhKGTzp0vDyMdggxwuLSEO5iSJx24T dVIXwUIiytgbVTPyEs4AxmFiODG2miPReGHuc85nJPsMYQ+fMZO4Il6Ii19rn4FNafeR WtSSy8/xUiQA6V1mJcn+pnOdjP3Y/mQSgZNiyK+yqapoxMbQZrmlT98AKJSC8LLrEJit udZKhBTa/bdLQN0AE0VIe8dik1xHyiIj4SVdC1giHanJ8ZOFidaf6Y4CpUXvRvskOO8X 4rE97dHUtTLcJz0ll/BEAs/htn99B7lloZYUwoxX8lcYPJGu4HPNgdae3IOXsIZcwU6j SAgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VFB8vCrnvYOCgPw50Yb+dKFSiTn06ROpaPwHOZK1DN0=; b=gGu6cAnQF2AGlfTwwCE0ioE5ghzhtKA2UaADkxnyaPjw2xK0ZO75mdW+yhmIC+X/b0 pu8efoAMQEE38+zjot8+dZ74J7OXD75fcGcSlE2MsiFGZqm9Jc3KIQ7GPSUwBXkQbpVR DaA3znYsMQys3DZY3Rt7xTuYJeZ/HJh8NCLhS8LrgsaJpriHb2sdyq/dv6beO4Uj0FzV s/cBEKEl5W+qFbS1X+O+cs298qGRX2ulchlTVJLr4YTia5T80XAfK64GJesxkLazM5Ea W1uVjOZIgcU5d97xoBOKdFXtuSYbOzyGIKdylyWjn2qeig2xvHzPtXBfdcFoIbn/fgJ7 3sWg== X-Gm-Message-State: AKGB3mJOZSIBn3xmp8ECeV9DYyCcmnoI0qtYcsTmpR/qDB/ehttFM6eJ FDeLkcjLEl61xxdt/BuL4XY= X-Received: by 10.98.97.3 with SMTP id v3mr43148661pfb.124.1516290382598; Thu, 18 Jan 2018 07:46:22 -0800 (PST) Received: from localhost.localdomain (114-37-171-238.dynamic-ip.hinet.net. [114.37.171.238]) by smtp.gmail.com with ESMTPSA id f188sm14571465pfc.22.2018.01.18.07.46.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 07:46:21 -0800 (PST) From: Alan Kao X-Google-Original-From: Alan Kao To: Palmer Dabbelt , Albert Ou , Steven Rostedt , Ingo Molnar , Masahiro Yamada , Kamil Rytarowski , Andrew Morton , patches@groups.riscv.org, linux-kernel@vger.kernel.org, Stefan O'Rear Cc: Alan Kao , Greentime Hu Subject: [PATCH v3 6/6] riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support Date: Thu, 18 Jan 2018 23:45:45 +0800 Message-Id: <20180118154545.17987-7-alankao@andestech.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180118154545.17987-1-alankao@andestech.com> References: <20180118154545.17987-1-alankao@andestech.com> 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/include/asm/ftrace.h | 1 + arch/riscv/kernel/ftrace.c | 2 +- arch/riscv/kernel/stacktrace.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h index 429a6a156645..6e4b4c96b63e 100644 --- a/arch/riscv/include/asm/ftrace.h +++ b/arch/riscv/include/asm/ftrace.h @@ -8,6 +8,7 @@ #if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_FRAME_POINTER) #define HAVE_FUNCTION_GRAPH_FP_TEST #endif +#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR #define ARCH_SUPPORTS_FTRACE_OPS 1 #ifndef __ASSEMBLY__ diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c index 3922b29c107b..ded8ab25f4ad 100644 --- a/arch/riscv/kernel/ftrace.c +++ b/arch/riscv/kernel/ftrace.c @@ -150,7 +150,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