From patchwork Tue Aug 4 07:44:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 51903 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id 3E7D7229FD for ; Tue, 4 Aug 2015 07:45:30 +0000 (UTC) Received: by lbbnr7 with SMTP id nr7sf734450lbb.2 for ; Tue, 04 Aug 2015 00:45:29 -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=eHjKrhfhwKAFqAf1TE9kRIHSx8ywyXyF/iV3czTx9JI=; b=XcA1VOPz88UiLGPLk2TMklck80Bn4nIRrs9Vh7yOk6oKSIK+EYhVhdtANQ4RPTG1H1 FXhnU0XDLXmPjW0EJMVql9K1Vv1B0Lye/wYnYD78yhuOTMWPCJ/bwR4zkAd4nKwn7Xxm j/MpNV15CRTelg4bqF6ugUDorXfPsHEB3EFe8ojfrSjG14YasxnWem/vz6xKePpSlq59 sdFwBSlh63AddvT6epL0mE89N1tsZD2gfADgLTSyUXHeKtdnXD8IY1f22dsy93Pt1tXv DJ10SFdVR18qeBpyc1gkC8TPHS+l32jaAdkRQRJfs29kvs+DzbcYhUuqOhjeQDAFHy8D qUXA== X-Gm-Message-State: ALoCoQlm03JPVSv8+pdBjyQV792uGOWo7Z7hBMWJiouo6QuXERxxUPaEPIGOwFbZ5YhBOkkrZj6I X-Received: by 10.180.96.137 with SMTP id ds9mr7134546wib.2.1438674329182; Tue, 04 Aug 2015 00:45:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.165 with SMTP id p5ls7762lal.68.gmail; Tue, 04 Aug 2015 00:45:28 -0700 (PDT) X-Received: by 10.152.42.209 with SMTP id q17mr1320326lal.33.1438674328854; Tue, 04 Aug 2015 00:45:28 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id o1si142942lbc.8.2015.08.04.00.45.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2015 00:45:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by labgo9 with SMTP id go9so1365357lab.3 for ; Tue, 04 Aug 2015 00:45:28 -0700 (PDT) X-Received: by 10.152.9.66 with SMTP id x2mr1711256laa.76.1438674328740; Tue, 04 Aug 2015 00:45:28 -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 l6csp2266942lba; Tue, 4 Aug 2015 00:45:27 -0700 (PDT) X-Received: by 10.66.146.132 with SMTP id tc4mr5027571pab.124.1438674326547; Tue, 04 Aug 2015 00:45:26 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be10si453772pad.11.2015.08.04.00.45.25; Tue, 04 Aug 2015 00:45:26 -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 S1755349AbbHDHpV (ORCPT + 28 others); Tue, 4 Aug 2015 03:45:21 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33910 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755220AbbHDHpN (ORCPT ); Tue, 4 Aug 2015 03:45:13 -0400 Received: by pawu10 with SMTP id u10so2022180paw.1 for ; Tue, 04 Aug 2015 00:45:12 -0700 (PDT) X-Received: by 10.66.194.201 with SMTP id hy9mr5075345pac.140.1438674312633; Tue, 04 Aug 2015 00:45:12 -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.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Aug 2015 00:45:11 -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 4/4] arm64: ftrace: add a stack frame for exception handler Date: Tue, 4 Aug 2015 16:44:09 +0900 Message-Id: <1438674249-3447-5-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.47 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: , On arm64, an exception handler use the same stack as in non-exception contexts, but doesn't create a stack frame for elx_xx entry, only updating sp register. This behavior results in save_stace_trace() missing a function that is the one when an exception happens. This patch creates a stack frame for this case, and puts an additional entry for the function in a stack trace list. Signed-off-by: AKASHI Takahiro --- arch/arm64/kernel/entry.S | 4 ++++ arch/arm64/kernel/stacktrace.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index f860bfd..aacb6c6 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -107,6 +107,8 @@ str x21, [sp, #S_SYSCALLNO] .endif + /* create a stack frame for stack tracer */ + mov x29, sp /* * Registers that may be useful after this macro is invoked: * @@ -737,3 +739,5 @@ ENTRY(sys_rt_sigreturn_wrapper) mov x0, sp b sys_rt_sigreturn ENDPROC(sys_rt_sigreturn_wrapper) + +ENTRY(end_of_vectors) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index d1790eb..22ce7c9 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -25,6 +25,10 @@ #include #define S_FRAME_SIZE sizeof(struct pt_regs) /* asm-offsets.h */ +#define S_FP offsetof(struct pt_regs, regs[29]) +#define S_LR offsetof(struct pt_regs, regs[30]) + +extern unsigned int *vectors, *end_of_vectors; /* * AArch64 PCS assigns the frame pointer to x29. @@ -50,6 +54,19 @@ int notrace unwind_frame(struct stackframe *frame) if (fp < low || fp > high - 0x18 || fp & 0xf) return -EINVAL; + if ((frame->pc >= (unsigned long)&vectors) && + (frame->pc < (unsigned long)&end_of_vectors)) { + /* + * Expection handler does not use a normal format of + * stack frame, but allocates struct pt_regs. + */ + frame->sp = frame->sp + S_FRAME_SIZE; + frame->fp = *(unsigned long *)(fp + S_FP); + frame->pc = *(unsigned long *)(fp + S_LR); + + return 0; + } + frame->sp = fp + 0x10; frame->fp = *(unsigned long *)(fp); /*