From patchwork Fri Feb 14 19:35:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Johansson X-Patchwork-Id: 3653491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B49A39F334 for ; Fri, 14 Feb 2014 19:35:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E384B201CE for ; Fri, 14 Feb 2014 19:35:13 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 21B88200FF for ; Fri, 14 Feb 2014 19:35:09 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEOWw-0004LR-PK; Fri, 14 Feb 2014 19:34:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEOWu-0002wJ-G6; Fri, 14 Feb 2014 19:34:32 +0000 Received: from mail-pa0-f41.google.com ([209.85.220.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEOWr-0002vX-2F for linux-arm-kernel@lists.infradead.org; Fri, 14 Feb 2014 19:34:29 +0000 Received: by mail-pa0-f41.google.com with SMTP id fa1so12747219pad.0 for ; Fri, 14 Feb 2014 11:34:05 -0800 (PST) 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; bh=1b8HxsmEhfyLSWqNh4LUkRAs9fB5Zg3SgkgnpPNA/4Q=; b=Ggga4XFwgSR9i4woWoZBbk3WR+ybSaIyVdgTdjQoIL+1GeVimhVxVhpOo4DXtRBBOD oLirlmsoGeJe7f791GK5F2VgLcZPvSGHArXiOSOj53CJUbbhhBQoF3XKjLPKiyhQk3fj k4etlLVoRAy+/GQJiQv+sZthCOu1Mw6BeMqrMuiT4s/3cBfs1+BZZ/1XZZgC8H7fEOYW np8US+fYhHjpP4r9ONJJjwBzV+M+bF7Ikbd+J96HonZfggIC3/WfSQGQJFcSN7gkwhVY 5Ui0iSDDlO1ly63vrEVMcoFM4y16h/ShrEc+ehT8SKm+wE+ls2FFpuSsphdkuEAP8puj cnzA== X-Gm-Message-State: ALoCoQnl1LVlBIEaZZMN+Dym6L57MzjH69z0i5qVQFHg2V8S3EoGewNKfBCcpFGfvaRTq2FkZ+40 X-Received: by 10.68.197.66 with SMTP id is2mr11115734pbc.96.1392406445616; Fri, 14 Feb 2014 11:34:05 -0800 (PST) Received: from brutus.lixom.net (173-13-129-225-sfba.hfc.comcastbusiness.net. [173.13.129.225]) by mx.google.com with ESMTPSA id e6sm19921997pbg.4.2014.02.14.11.34.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Feb 2014 11:34:04 -0800 (PST) From: Olof Johansson To: Catalin Marinas , Will Deacon Subject: [PATCH] ARM64: unwind: Fix PC calculation Date: Fri, 14 Feb 2014 11:35:15 -0800 Message-Id: <1392406515-27835-1-git-send-email-olof@lixom.net> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140214_143429_177974_BE7D57E3 X-CRM114-Status: GOOD ( 12.27 ) X-Spam-Score: -2.6 (--) Cc: Olof Johansson , stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The frame PC value in the unwind code used to just take the saved LR value and use that. That's incorrect as a stack trace, since it shows the return path stack, not the call path stack. In particular, it shows faulty information in case the bl is done as the very last instruction of one label, since the return point will be in the next label. That can easily be seen with tail calls to panic(), which is marked __noreturn and thus doesn't have anything useful after it. Easiest here is to just correct the unwind code and do a -4, to get the actual call site for the backtrace instead of the return site. Signed-off-by: Olof Johansson Cc: stable@vger.kernel.org --- arch/arm64/kernel/stacktrace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index c3b6c63..463a757 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -48,7 +48,11 @@ int unwind_frame(struct stackframe *frame) frame->sp = fp + 0x10; frame->fp = *(unsigned long *)(fp); - frame->pc = *(unsigned long *)(fp + 8); + /* + * -4 here because we care about the PC at time of bl, + * not where the return will go. + */ + frame->pc = *(unsigned long *)(fp + 8) - 4; return 0; }