From patchwork Fri Nov 6 06:44:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 56089 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp829669lbr; Thu, 5 Nov 2015 22:45:30 -0800 (PST) X-Received: by 10.66.172.144 with SMTP id bc16mr15181226pac.114.1446792330842; Thu, 05 Nov 2015 22:45:30 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wy2si15564895pab.104.2015.11.05.22.45.30; Thu, 05 Nov 2015 22:45:30 -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; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032087AbbKFGp2 (ORCPT + 28 others); Fri, 6 Nov 2015 01:45:28 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34573 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031989AbbKFGpZ (ORCPT ); Fri, 6 Nov 2015 01:45:25 -0500 Received: by padhx2 with SMTP id hx2so105028950pad.1 for ; Thu, 05 Nov 2015 22:45:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cmpaItrUi//sSEmY/EXKvhbY7FpsucF5B4XIrvJdDRY=; b=1y8JqRK5cxXtRYMCt/6kHpubDboTmJtH6BIaeYVfsITdmQ+bxoSBwctz8Wa8KULP/8 NmwxNjc1VaXT0CI0/Psr3nw5aCpezVvSDAszC7A9/ZsYrb4JlS4ykTSsxwdYuRjAgtV3 T3hbPjMH87zJTEUugDR8B7PF0EDxgap5qrclIdJr4M/j4nmSJu4XDZgwR1A4N+bYFlCE 7SBAFcAffV1DpPVQil/0oTcBsfntipVts6JAHAcLSFrLhOFTfWkjGLvu32cY/MOtsFtu XnwSmWgukh5wapG4ZxDjF0Zp/AsY+jGyq9mRJYHzj22NF4SrrHyYIKaGIJM8KiPSVPwY +SUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cmpaItrUi//sSEmY/EXKvhbY7FpsucF5B4XIrvJdDRY=; b=EtM+ebvWy/YZ0p7567mwgk7dLxheDYYe0fFEcHUSVEo0WUc3Ee+HC0KIzdwx/ApU7c 2khK805qoW5rTVi+C7L9yVu8LRWKktyR1X8IOkQGm+IJ/AUfImyxPTygRqLCvdWZrEf2 6qEdoWiKM8GfETbttz/4rH/Nlh8F0x5J/cVJWFajFKko7G17AWXJFV1v0EiOYgS64KmL V8wKHkif8PRL1rzvSK6cYyGf7SdJJxEGlYXVhIHXhLiTP092F55hM7eVQagW/JZfYz1c WmDuSrK0AhQPUhl33FWtRyA2/3yx46GyTHd8wiI0iY7/Q9w1+YdaDNRMJX19BEU6es1A a2Jg== X-Gm-Message-State: ALoCoQkKCWaen8i/WiqfboSgp4yquVH3tWNx4meQCli4uYx1dmwmMETYZazwLALn57zIO3kgwj50 X-Received: by 10.68.68.201 with SMTP id y9mr15459620pbt.10.1446792325437; Thu, 05 Nov 2015 22:45:25 -0800 (PST) Received: from localhost.localdomain (61-205-2-204m5.grp1.mineo.jp. [61.205.2.204]) by smtp.googlemail.com with ESMTPSA id zi1sm11732096pbc.10.2015.11.05.22.45.20 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Nov 2015 22:45:23 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, rostedt@goodmis.org Cc: jungseoklee85@gmail.com, broonie@kernel.org, david.griego@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v5 1/6] arm64: ftrace: modify a stack frame in a safe way Date: Fri, 6 Nov 2015 15:44:40 +0900 Message-Id: <1446792285-1154-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446792285-1154-1-git-send-email-takahiro.akashi@linaro.org> References: <1446792285-1154-1-git-send-email-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function graph tracer modifies a return address (LR) in a stack frame by calling ftrace_prepare_return() in a traced function's function prologue. The current code does this modification before preserving an original address at ftrace_push_return_trace() and there is always a small window of inconsistency when an interrupt occurs. This doesn't matter, as far as an interrupt stack is introduced, because stack tracer won't be invoked in an interrupt context. But it would be better to proactively minimize such a window by moving the LR modification after ftrace_push_return_trace(). Signed-off-by: AKASHI Takahiro --- arch/arm64/kernel/ftrace.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index c851be7..314f82d 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -125,23 +125,20 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, * on other archs. It's unlikely on AArch64. */ old = *parent; - *parent = return_hooker; trace.func = self_addr; trace.depth = current->curr_ret_stack + 1; /* Only trace if the calling function expects to */ - if (!ftrace_graph_entry(&trace)) { - *parent = old; + if (!ftrace_graph_entry(&trace)) return; - } err = ftrace_push_return_trace(old, self_addr, &trace.depth, frame_pointer); - if (err == -EBUSY) { - *parent = old; + if (err == -EBUSY) return; - } + else + *parent = return_hooker; } #ifdef CONFIG_DYNAMIC_FTRACE