From patchwork Tue Aug 4 07:44:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 51902 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 00107229FD for ; Tue, 4 Aug 2015 07:45:24 +0000 (UTC) Received: by lbbyj8 with SMTP id yj8sf717449lbb.3 for ; Tue, 04 Aug 2015 00:45:24 -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=OsrB8dKD9bFPyPUDCHM/EydOLWRLL7Kn9imtclQuOrc=; b=OMiOMpKx5P5zK7rPws//Mi6U/aPThJOPwlKZmEACan9tQvC3d13rTP5c7MNSke+jqr 8V4EETVWDXntlFcz6PZgMoGxdywVTyrl4nCnaXImP6BA2bEQOkEPFqERPrh+tN78usTi WW5PR49ikrf8leCkweUvAur2lwKa6apSZT5gFsld0v7ipSjScEpBgyJrUIfE6316Ot6T BMiyCUBU5o6TID3FTy/xf4i5KBwOBNAIySBQh2fqEX1CEDQLmpNlrYx0rkfA8zPQIBYL iDFWebjjAGRK1LksRoBMcYkJbM78R8be1DJJMe5yGR8e4d0gx5BSwWSz2/OCD8ZHIQoy ndeQ== X-Gm-Message-State: ALoCoQnBMTvxgJYLVe4f7npmdbJPVn62SNvZj6uqza94V0j9sud4/s30+J60GKwT9UXA6Qfws9ca X-Received: by 10.180.83.33 with SMTP id n1mr7133968wiy.4.1438674323606; Tue, 04 Aug 2015 00:45:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.1 with SMTP id h1ls8882lag.36.gmail; Tue, 04 Aug 2015 00:45:23 -0700 (PDT) X-Received: by 10.112.146.106 with SMTP id tb10mr1897960lbb.22.1438674323275; Tue, 04 Aug 2015 00:45:23 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id q10si120449lbp.109.2015.08.04.00.45.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2015 00:45:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by labow3 with SMTP id ow3so1395539lab.1 for ; Tue, 04 Aug 2015 00:45:23 -0700 (PDT) X-Received: by 10.112.145.169 with SMTP id sv9mr1878197lbb.73.1438674323170; Tue, 04 Aug 2015 00:45:23 -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.7.198 with SMTP id l6csp2266900lba; Tue, 4 Aug 2015 00:45:21 -0700 (PDT) X-Received: by 10.70.98.200 with SMTP id ek8mr4985988pdb.95.1438674321729; Tue, 04 Aug 2015 00:45:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si441229pdi.17.2015.08.04.00.45.20; Tue, 04 Aug 2015 00:45:21 -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 S1755323AbbHDHpM (ORCPT + 28 others); Tue, 4 Aug 2015 03:45:12 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:34819 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755220AbbHDHpF (ORCPT ); Tue, 4 Aug 2015 03:45:05 -0400 Received: by pasy3 with SMTP id y3so1976313pas.2 for ; Tue, 04 Aug 2015 00:45:05 -0700 (PDT) X-Received: by 10.68.200.225 with SMTP id jv1mr5007190pbc.63.1438674305303; Tue, 04 Aug 2015 00:45:05 -0700 (PDT) Received: from localhost.localdomain (61-205-6-81m5.grp1.mineo.jp. [61.205.6.81]) by smtp.googlemail.com with ESMTPSA id bd5sm287869pbb.85.2015.08.04.00.45.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Aug 2015 00:45:04 -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: [RFC v2 3/4] arm64: ftrace: fix a stack trace result under function graph tracer Date: Tue, 4 Aug 2015 16:44:08 +0900 Message-Id: <1438674249-3447-4-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438674249-3447-1-git-send-email-takahiro.akashi@linaro.org> References: <1438674249-3447-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.215.45 as permitted sender) smtp.mail=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 saved lr register on stack in order to hook a function return. This results in finding many bogus entries in a stack trace list. This patch replaces such entries with originals values stored in current->ret_stack[]. Signed-off-by: AKASHI Takahiro --- arch/arm64/kernel/stacktrace.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 496ab0f..d1790eb 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -100,6 +100,28 @@ static void notrace arm64_stack_index(struct stackframe *frame, /* should not go beyond this frame */ if (trace->index[x] == THREAD_SIZE) trace->index[x] = 0; + + if (trace->entries[x] == + ((unsigned long)return_to_handler + 0x8)) { + /* + * This is a case where return_to_handler() is calling + * ftrace_return_to_handler(). As we are already on + * an original function's stack, we have no way to fetch + * a correct pc value, just skip it. + */ + trace->entries[x] = 0x0; + } else if (trace->entries[x] == + (unsigned long)return_to_handler - AARCH64_INSN_SIZE) { + /* + * This is a case where function graph tracer has + * modified lr register on a stack to hook a function + * return. + * So replace it to original value. + */ + trace->entries[x] = + current->ret_stack[data->ret_stack_index--].ret + - AARCH64_INSN_SIZE; + } } #endif /* CONFIG_STACK_TRACER */