From patchwork Tue Oct 20 08:00:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 55279 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id A4F3A22EA2 for ; Tue, 20 Oct 2015 08:01:59 +0000 (UTC) Received: by wiclg3 with SMTP id lg3sf6198131wic.3 for ; Tue, 20 Oct 2015 01:01:58 -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=wQ6880Ff/kBSz9sEV0m3BMedtbzd94YXjLg4IqxE090=; b=LFFG3sH/sYZvykwFDs/ToZy+uGOSV8NumzLFdSvA5CoJYPrCwMykwirnchf18FYRid HezkQLK2cnAFJ62rLXAOgnktpflp58qDAvcaK25D9bJsPnlBzBTCIEECJcR7KFa6MvcS YqOlvu31SNJiGF+3RC6HgyD9hS10Td3FTsVxT0Z9x+FqrFgsH8EAzWUQqwkmGJGh/3sS pe9NWJCimhe0kPeIAWTm6hzRwY5Dbve2LsNTKskfzTn2mTsp99Mjwf8LihUT4VXKIEVZ yM/6+ynxM4i2NjBAjrG/jfli0eGIQHC35qBo9oDJruWE2gH1wNBkPb39ZIfvysiGrVtU OH0g== X-Gm-Message-State: ALoCoQmqyAzjgkWWAvx3dzP89vdKnwEMemmwEjo7g/UAnKWRGnAP4E8jP2h9KUYZANlbIYcKfSpM X-Received: by 10.112.169.34 with SMTP id ab2mr330592lbc.23.1445328118730; Tue, 20 Oct 2015 01:01:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.85.82 with SMTP id j79ls39799lfb.81.gmail; Tue, 20 Oct 2015 01:01:58 -0700 (PDT) X-Received: by 10.112.235.229 with SMTP id up5mr920849lbc.96.1445328118565; Tue, 20 Oct 2015 01:01:58 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id g32si1330633lfi.87.2015.10.20.01.01.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 01:01:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbwb3 with SMTP id wb3so9028263lbb.1 for ; Tue, 20 Oct 2015 01:01:58 -0700 (PDT) X-Received: by 10.112.159.136 with SMTP id xc8mr781859lbb.76.1445328118439; Tue, 20 Oct 2015 01:01:58 -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 w3csp1921749lbq; Tue, 20 Oct 2015 01:01:57 -0700 (PDT) X-Received: by 10.107.14.14 with SMTP id 14mr2243727ioo.6.1445328117409; Tue, 20 Oct 2015 01:01:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j199si1807785ioe.58.2015.10.20.01.01.57; Tue, 20 Oct 2015 01:01:57 -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 S932147AbbJTIBq (ORCPT + 28 others); Tue, 20 Oct 2015 04:01:46 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:36468 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932105AbbJTIBm (ORCPT ); Tue, 20 Oct 2015 04:01:42 -0400 Received: by pacfv9 with SMTP id fv9so14473232pac.3 for ; Tue, 20 Oct 2015 01:01:42 -0700 (PDT) X-Received: by 10.66.121.195 with SMTP id lm3mr2458020pab.84.1445328102360; Tue, 20 Oct 2015 01:01:42 -0700 (PDT) Received: from localhost.localdomain (61-205-5-101m5.grp1.mineo.jp. [61.205.5.101]) by smtp.googlemail.com with ESMTPSA id zk3sm2135407pbb.41.2015.10.20.01.01.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Oct 2015 01:01:41 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Cc: jungseoklee85@gmail.com, james.morse@arm.com, mark.rutland@arm.com, broonie@kernel.org, david.griego@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v2 2/2] arm64: fix dump_backtrace() to show correct pt_regs at interrupt Date: Tue, 20 Oct 2015 17:00:19 +0900 Message-Id: <1445328019-23330-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445328019-23330-1-git-send-email-takahiro.akashi@linaro.org> References: <1445328019-23330-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.182 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: , Adding an extra dummy stack frame for interrupt has one side-effect that dump_backtrace() shows inccorect data of struct pt_regs at "Exception stack ..." because we are still on an interrupt stack when dump_backtrace() encounters an interrupt handler's frame. This patch reuses __in_irqentry_text() macro, which was added by commit 9a5ad7d0e3e1 ("arm64: Add __exception_irq_entry definition for function graph"), and allows dump_backtrace() to recognize an interrupt handler's frame and fetch a correct pointer (sp) to struct pt_regs on an process stack. One of drawbacks in this approach is that we will sometimes see __irqentry_text_start and gic_handle_irq interchangeably, especially, when "perf report --call-graph" shows stack traces because both symbols has the same address. (Please note that this can happen even without this patch if CONFIG_FUNCTION_GRAPH_TRACER is enabled.) Signed-off-by: AKASHI Takahiro --- arch/arm64/include/asm/exception.h | 7 +++---- arch/arm64/include/asm/traps.h | 7 ------- arch/arm64/kernel/traps.c | 9 +++++++-- arch/arm64/kernel/vmlinux.lds.S | 7 +++++++ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/exception.h b/arch/arm64/include/asm/exception.h index 6cb7e1a..8415005 100644 --- a/arch/arm64/include/asm/exception.h +++ b/arch/arm64/include/asm/exception.h @@ -21,10 +21,9 @@ #include #define __exception __attribute__((section(".exception.text"))) -#ifdef CONFIG_FUNCTION_GRAPH_TRACER +/* We always need this definition for dump_backtrace */ +#undef __irq_entry +#define __irq_entry __attribute__((__section__(".irqentry.text"))) #define __exception_irq_entry __irq_entry -#else -#define __exception_irq_entry __exception -#endif #endif /* __ASM_EXCEPTION_H */ diff --git a/arch/arm64/include/asm/traps.h b/arch/arm64/include/asm/traps.h index 0cc2f29..8f05d3b 100644 --- a/arch/arm64/include/asm/traps.h +++ b/arch/arm64/include/asm/traps.h @@ -34,7 +34,6 @@ struct undef_hook { void register_undef_hook(struct undef_hook *hook); void unregister_undef_hook(struct undef_hook *hook); -#ifdef CONFIG_FUNCTION_GRAPH_TRACER static inline int __in_irqentry_text(unsigned long ptr) { extern char __irqentry_text_start[]; @@ -43,12 +42,6 @@ static inline int __in_irqentry_text(unsigned long ptr) return ptr >= (unsigned long)&__irqentry_text_start && ptr < (unsigned long)&__irqentry_text_end; } -#else -static inline int __in_irqentry_text(unsigned long ptr) -{ - return 0; -} -#endif static inline int in_exception_text(unsigned long ptr) { diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index e9b9b53..8fc3d4b 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -179,10 +179,15 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) ret = unwind_frame(&frame); if (ret < 0) break; - stack = frame.sp; - if (in_exception_text(where)) + if (__in_irqentry_text(where)) { + stack = *(unsigned long *)(frame.fp + 0x18); + dump_mem("", "Interrupt stack", stack, + stack + sizeof(struct pt_regs), false); + } else if (in_exception_text(where)) { + stack = frame.sp; dump_mem("", "Exception stack", stack, stack + sizeof(struct pt_regs), false); + } } } diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 9807333..0d16d02 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -44,6 +44,13 @@ jiffies = jiffies_64; *(.idmap.text) \ VMLINUX_SYMBOL(__idmap_text_end) = .; +#undef IRQENTRY_TEXT +#define IRQENTRY_TEXT \ + ALIGN_FUNCTION(); \ + VMLINUX_SYMBOL(__irqentry_text_start) = .; \ + *(.irqentry.text) \ + VMLINUX_SYMBOL(__irqentry_text_end) = .; + /* * The size of the PE/COFF section that covers the kernel image, which * runs from stext to _edata, must be a round multiple of the PE/COFF