From patchwork Tue Dec 15 08:33: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: 58381 Delivered-To: patch@linaro.org Received: by 10.112.129.4 with SMTP id ns4csp56990lbb; Tue, 15 Dec 2015 00:36:17 -0800 (PST) X-Received: by 10.66.251.193 with SMTP id zm1mr51894913pac.154.1450168577691; Tue, 15 Dec 2015 00:36:17 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ih10si421273pad.145.2015.12.15.00.36.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Dec 2015 00:36:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a8l4X-0007wA-Js; Tue, 15 Dec 2015 08:35:01 +0000 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a8l4T-0007ht-Gc for linux-arm-kernel@lists.infradead.org; Tue, 15 Dec 2015 08:34:58 +0000 Received: by mail-pf0-x22f.google.com with SMTP id 63so1129358pff.2 for ; Tue, 15 Dec 2015 00:34:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cmpaItrUi//sSEmY/EXKvhbY7FpsucF5B4XIrvJdDRY=; b=KL4NCZIaA/5KNGjfWIlNZRcn+Vc3VcQzsBWn4zCHxDROifnxHi6TI6uc2oVyHqyZxB c3IxSbAvfHw1ZCbLXmZW0BT2hDAHC7px2eO53mvejIlnoh6EHkGnqX7XQq8hGAaVpKtu v6CejjW2+9dja9uJ/pwYxZgFSlrK5odc/Hfhw= 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=QUkRH1+pw3dHOCtC6dzyteEyjTBj3TQetm0YExznWAYIlGNFwM344UgtAnsp/EYt9J fjTRnF7WQ5LDghYxzSJY1x19GPWiS21e/Ykcz6IyQEZ3hJrdMB9wCGs3IS1Whltt++GY 3oL5IpRcB4zopmvVc7A7SmMMna8d5sCxhamsBhvHVe8nPcZ0NKIBBloiXrEKAa83X3HA qzsnQoqeawmnUhhZj2HdSCeZS2Ovfc/5NNqB4D5XOfUPIa+L1kD5K5hoJ9WzLGMYS4Y1 /SDHtFx2PIamWcPyYvlsJcTLbpM0aqFk5+LqEkGVs+KI3tuwK0k2KbK6nY/Z0RmOKReg +DHg== X-Gm-Message-State: ALoCoQmeXi8onkQ5FCoRBGk18sLfbNX/Stklm84v9t1lEp47SR39aiND1hcaRqe6/ocKQZLtswEc6STZQVZja6QXIVoKGbKa7g== X-Received: by 10.98.72.26 with SMTP id v26mr19146045pfa.109.1450168476998; Tue, 15 Dec 2015 00:34:36 -0800 (PST) Received: from localhost.localdomain (61-205-82-105m5.grp2.mineo.jp. [61.205.82.105]) by smtp.googlemail.com with ESMTPSA id f5sm586757pas.8.2015.12.15.00.34.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 Dec 2015 00:34:35 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, rostedt@goodmis.org Subject: [PATCH v7 1/6] arm64: ftrace: modify a stack frame in a safe way Date: Tue, 15 Dec 2015 17:33:39 +0900 Message-Id: <1450168424-10010-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450168424-10010-1-git-send-email-takahiro.akashi@linaro.org> References: <1450168424-10010-1-git-send-email-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151215_003457_688061_805B5B69 X-CRM114-Status: GOOD ( 13.67 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c00:0:0:0:22f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jungseoklee85@gmail.com, AKASHI Takahiro , broonie@kernel.org, yalin.wang2010@gmail.com, david.griego@linaro.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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