From patchwork Fri Oct 30 05:25:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 55816 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp965643lbr; Thu, 29 Oct 2015 22:27:30 -0700 (PDT) X-Received: by 10.50.60.104 with SMTP id g8mr997960igr.89.1446182850507; Thu, 29 Oct 2015 22:27:30 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b19si972414igr.56.2015.10.29.22.27.30; Thu, 29 Oct 2015 22:27:30 -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; 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 S1758478AbbJ3F12 (ORCPT + 28 others); Fri, 30 Oct 2015 01:27:28 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:36428 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752445AbbJ3F10 (ORCPT ); Fri, 30 Oct 2015 01:27:26 -0400 Received: by pacfv9 with SMTP id fv9so65561812pac.3 for ; Thu, 29 Oct 2015 22:27:26 -0700 (PDT) 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=YrHipKpovJkWvJ/9DKR52Ii0AjAMhpPUFQA8EruKbwQ2u9BsNGmyJ/pAJ6qLp7LYtn 9SPm+okxRZoEkC43QxQ4ZVE5ecWYQvB61PQpR5XVs62JvQrW067/HnmZCwhyoVTrSINx OJSQcyi3An+wZlw/ZaB7M0Bwp9ehxiViJBpQ/TKa5iwFDXutoZW+Hx1e2FI2SgNQbtbg ep33flXh5NLN79qZGaDSyTv44UShwVZVNbGmJ8ROa6Wyt30Tj9o1skvw3jbXLxENhBiZ azMTqRLnyQUqbz/lED9cE0smxWeE8OLjvEXIDvZ8gvhjKlWeKpnpBfkFrYa/gYNbTmx7 +AOw== 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=CI3SVR1PFwdEPwtHuMIbSnBDw67OtWf9ykPb/hxex4e2z+Lkovi9CT3PpY65sdVDUn TZPjeDQpB7zkl23rSBIxs+MfSt1fqiMmhllKzBs/j3dp/gwQFiYChxZAu4/YYTkkIuUR dQ1cR3ziBryUff4RTdfAj72JWiURkqZYM44W1/VpQsd7BRNVR0lDLzYuhhY0ah/qqolt 9iZyQxoYNjgEYOq1q/f4aMj1phlc58hGp0zCLesvb00TdbHqm2+XVFmKghzId8xy91Fw mb5Ae8RhvScLIbimbWiqNyACci3gMppvQC5WxirZ3ChSiFwHe8bXKLGjvc5yggSyg4w3 dyRw== X-Gm-Message-State: ALoCoQlg+jzgTnajpJJ6Inl434ynAe1EF9hZumBF2ct5vjBaozYzRmBzDTRifxGLacAYvoFLMPpU X-Received: by 10.66.252.131 with SMTP id zs3mr6521215pac.69.1446182846548; Thu, 29 Oct 2015 22:27:26 -0700 (PDT) Received: from localhost.localdomain (61-205-6-54m5.grp1.mineo.jp. [61.205.6.54]) by smtp.googlemail.com with ESMTPSA id ho3sm5571377pbb.18.2015.10.29.22.27.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Oct 2015 22:27:25 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, rostedt@goodmis.org Cc: jungseoklee85@gmail.com, olof@lixom.net, broonie@kernel.org, david.griego@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v4 2/6] arm64: ftrace: modify a stack frame in a safe way Date: Fri, 30 Oct 2015 14:25:37 +0900 Message-Id: <1446182741-31019-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446182741-31019-1-git-send-email-takahiro.akashi@linaro.org> References: <1446182741-31019-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