From patchwork Wed Nov 18 06:43:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 56910 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2382545lbb; Tue, 17 Nov 2015 22:46:11 -0800 (PST) X-Received: by 10.68.229.39 with SMTP id sn7mr69935040pbc.164.1447829171048; Tue, 17 Nov 2015 22:46:11 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id nh10si2291920pbc.109.2015.11.17.22.46.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2015 22:46:11 -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.20150623.gappssmtp.com 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 1ZywTw-000338-8O; Wed, 18 Nov 2015 06:44:40 +0000 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZywTs-0002wU-MV for linux-arm-kernel@lists.infradead.org; Wed, 18 Nov 2015 06:44:37 +0000 Received: by pacdm15 with SMTP id dm15so35025829pac.3 for ; Tue, 17 Nov 2015 22:44:15 -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=cWzCJJDdUL1n7kp4p4z7Wn0MQRuaErrvMVH9ZCs4oOqOobrGNxyHvITBc5UD10qxCC x2AaloEOss8rc1VI2EtE9wI6uHX9aDwfd6k87N2q90/fGW+qIDty1vF+cj22TAjwyOA/ lIytmkCtz/KD82uxIdOVaWDnKcVQk2Kd7htd4stuq6FrKZXfDmT3oNDt2Daj8V4EW9Ib SqdnXwp3I47J/t+caPMntfPhJGwuHI0Xtqx6Cq731dgyJQalsxxa6Wg/Cucoir9ybq+W iZf+gSoZGayzr06UVhdVCsk20Scxu9D6TvscaIcC/lVTDpozG88ftp2xkYJjc23Rq3ZM tpUA== 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=N7j6952iy/mC4QwsEGz6hgKGODhjneshlZiSZilUpsRY4GwrlK5m3CA56yMfsl736s 0BZHQYh6hL8cCbxdxnp5E8TyJBVYdUnEtv1vcbZzRNk9vWAu5eSHAcQMud4Z0NK6HmO1 SRKZtl5F4G3cYnyurhoPJiBZ3LDLJ9Xuwlx0vkzxEClzfCeVWe+qbpf7zw/tA19jyonG HLoEZhjVlJ0KuYYtPs5Mll4Ibdx+bPIsFlIJa+KtCxcyGetrSNyi5YkXorqyJhNXcv+X ejQYj/fB2pXGxfhEOhlZ60mbyCxlwVZEaBKRCxtKbhFJcENxDXQKKI8Yc+MCayrqSg/X cBsw== X-Gm-Message-State: ALoCoQlakeus/qgduwNzsTahMWMSWrXl2o95FcUJgAuyKRVoWkzSNRtiPusOGjAjGB25AgXCcBEh X-Received: by 10.66.156.106 with SMTP id wd10mr68275419pab.150.1447829055689; Tue, 17 Nov 2015 22:44:15 -0800 (PST) Received: from localhost.localdomain (61-205-7-47m5.grp1.mineo.jp. [61.205.7.47]) by smtp.googlemail.com with ESMTPSA id xr8sm1685523pab.26.2015.11.17.22.44.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Nov 2015 22:44:14 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, rostedt@goodmis.org Subject: [PATCH v6 1/6] arm64: ftrace: modify a stack frame in a safe way Date: Wed, 18 Nov 2015 15:43:04 +0900 Message-Id: <1447828989-4980-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447828989-4980-1-git-send-email-takahiro.akashi@linaro.org> References: <1447828989-4980-1-git-send-email-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151117_224436_791594_C5613D67 X-CRM114-Status: GOOD ( 14.73 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:234 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 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