From patchwork Thu Oct 8 10:01:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 54653 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 8EA9D22FF4 for ; Thu, 8 Oct 2015 10:03:26 +0000 (UTC) Received: by wicgi15 with SMTP id gi15sf638415wic.2 for ; Thu, 08 Oct 2015 03:03:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=GEvs6t+9jHD/fe5JgEEYGqWk6ezthIN52Cz/i2i5/yo=; b=VktET+l+dD4ivFCzO9HA4ybxSvcMcvts38s1EI44uTOh99Vdr36oXZ9knKUkZ0WNEC oBE/2xoAbvIGxavidsnmOG/tm24Dl1WDbaSEHOrW50I9j5AAcJ9oSN+ZNhzkpJlxf0cp zax5iFz6wsb2Jc4IQYZjVAYw4zPxdSnNGcZeCBLGFn3MmpoY0GvgeI7PQeKFslzvFqzB Uax393a0a4Huo3RnMcAJbxlrgQtA5nsc46YAEiLF9pMab/pYLJ/kLya4427N6+MDjEgZ z7/0KE2jI9y/IcL2M+qK2dmelf9CVCgAy+5wtiF1WM78IeZPG5dvLrlRrGwaIzeaXtZy Ux0w== X-Gm-Message-State: ALoCoQnm1WKNWAE0G0TuiTK6svlD6n3mdf+TRdz6LQJdp13F6XCuphnkSD4MusTD7ubHi/6s4pyU X-Received: by 10.180.105.98 with SMTP id gl2mr529076wib.0.1444298605916; Thu, 08 Oct 2015 03:03:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.205.7 with SMTP id d7ls171194lfg.82.gmail; Thu, 08 Oct 2015 03:03:25 -0700 (PDT) X-Received: by 10.25.85.202 with SMTP id j193mr2011453lfb.2.1444298605732; Thu, 08 Oct 2015 03:03:25 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id iz4si29051290lbc.36.2015.10.08.03.03.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Oct 2015 03:03:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbos8 with SMTP id s8so40624818lbo.0 for ; Thu, 08 Oct 2015 03:03:25 -0700 (PDT) X-Received: by 10.25.150.199 with SMTP id y190mr2111690lfd.35.1444298605605; Thu, 08 Oct 2015 03:03:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp482703lbq; Thu, 8 Oct 2015 03:03:24 -0700 (PDT) X-Received: by 10.107.136.203 with SMTP id s72mr7127864ioi.197.1444298604559; Thu, 08 Oct 2015 03:03:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k80si31034326ioi.214.2015.10.08.03.03.24; Thu, 08 Oct 2015 03:03:24 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755475AbbJHKDW (ORCPT + 30 others); Thu, 8 Oct 2015 06:03:22 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:33712 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752718AbbJHKDT (ORCPT ); Thu, 8 Oct 2015 06:03:19 -0400 Received: by pacex6 with SMTP id ex6so50898576pac.0 for ; Thu, 08 Oct 2015 03:03:18 -0700 (PDT) X-Received: by 10.68.168.226 with SMTP id zz2mr7233633pbb.8.1444298598645; Thu, 08 Oct 2015 03:03:18 -0700 (PDT) Received: from localhost.localdomain (61-205-1-208m5.grp1.mineo.jp. [61.205.1.208]) by smtp.googlemail.com with ESMTPSA id ya10sm44431428pbc.69.2015.10.08.03.03.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Oct 2015 03:03:17 -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 v3 2/7] arm64: ftrace: modify a stack frame in a safe way Date: Thu, 8 Oct 2015 19:01:39 +0900 Message-Id: <1444298504-10392-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444298504-10392-1-git-send-email-takahiro.akashi@linaro.org> References: <1444298504-10392-1-git-send-email-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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(-) 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