Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp917959pxb; Fri, 15 Oct 2021 20:09:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxctV3ad0UoCwNAoBQFEZNOM/pTkgLUtV7ZXBABi0X0xpnfn87tSRB6JkLlhQ77rmpzrB3p X-Received: by 2002:a63:f155:: with SMTP id o21mr11897147pgk.218.1634353760269; Fri, 15 Oct 2021 20:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634353760; cv=none; d=google.com; s=arc-20160816; b=qVLMcU87uWlT1y2tzhbpcSX2P2VxvR+T5G/bOuz01qlS7tA0wTlh+455YaAbj2DNpz R48gN4lmD1+KmXZ8YzMI6yG4qUSkOURLAbsg0q/4Q1mAJzEdGX/XpM9lwu+jv9Z9RTYw bSiZHY2ORvp44swYu5dh0ODLEZdkNRuI9U6bN+DSHkKoVkZH3dSjG1R3/l/eN+qNlzJX mIjzZl91D7AJlLlhohtDRSU0kCCJIdBNgcgkJW1Tg6MyOiST3qBkivybk7LgzwW0rzYp tCQS37on4vIuucm0Uzx2XlzUyw4Bedv6Xti8TM7kr/ILgkS2n4mqE1KiFO0LNzMXgx+S ElnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1JPjW/eWML94DGWLs4pv2IqyRmOJ/qjZsd7CKYW8TNo=; b=Mwy6GEbM43Nz1JAyWcl6JmMlOa4ok9peUjm9o2I0ConlLRTn0S7mUu14FxDJBSa+NJ 3Iw+DtCYDT6HO83ppWZ/nKE1VlfEM0oN0SYc7yQAT1t6uVGADRqPZyNuUleg1ul6TAsm EUxh1tASCouDDv9pYMja0ZgFZfzHgXJeaC+4FT1qFZ7wEe6VEu9CX3WrQKcdp2l9DAio 0F6GlM7vXh7+LYXST7VZMvKa8OGQZ+GEKkllqxXDxyOMQMbg8fxgOc50/qKXWk3VcVZh 0tzJxqjPErsyfFtS+fjzm9ZyTAhwS7rT8IINW+lHfuDsl3ksVSzT8/L01E25c8zfkKGJ 5SoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fkssxWyu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mu7si11508005pjb.146.2021.10.15.20.08.38; Fri, 15 Oct 2021 20:09:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fkssxWyu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239265AbhJOMyF (ORCPT + 99 others); Fri, 15 Oct 2021 08:54:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:53538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239268AbhJOMx5 (ORCPT ); Fri, 15 Oct 2021 08:53:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A9566101E; Fri, 15 Oct 2021 12:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634302310; bh=WqIiiFEaJiQvJq7Z5CrnA44AmFZAiLP70n+lEDL0ZZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fkssxWyurZ2i375lw8QBWz3d1mzUc+LIUjYF41fDOpx7aXA0+S8VGjaQrAXnAlerr fjjHanUxZA9YdkTFDJ6efqfUsxu2EbD0W8f8GVR5GL6n+GvT4sk+OZpsM7TJRL5G4C 9dOR2aE3Oe3IZrIyna6XFYQrxod+9/mRRvmKR4/lFuEo6vJFTgh3/GMp9A/3OSgusE GN5Pr+JOWAtwSAsgfR5XUy1Har1bt8OP0CF61T5fVXjTZnLcu+tKSuzU/VDAcyr8B5 y/G2hdSSw82z0y0mpqGN3Q4l8SkkkoC9fp4pmUOAYqup5jbfCCzxRP6cteQHjopp3h QPuaf+ZQXEqHw== From: Masami Hiramatsu To: Steven Rostedt Cc: "Naveen N . Rao" , Ananth N Mavinakayanahalli , Ingo Molnar , linux-kernel@vger.kernel.org, mhiramat@kernel.org, Sven Schnelle , Catalin Marinas , Will Deacon , Russell King , Nathan Chancellor , Nick Desaulniers , linux-arm-kernel@lists.infradead.org Subject: [PATCH 07/10] ARM: clang: Do not rely on lr register for stacktrace Date: Fri, 15 Oct 2021 21:51:46 +0900 Message-Id: <163430230603.459050.13271391202951929788.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163430224341.459050.2369208860773018092.stgit@devnote2> References: <163430224341.459050.2369208860773018092.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the stacktrace on clang compiled arm kernel uses the 'lr' register to find the first frame address from pt_regs. However, that is wrong after calling another function, because the 'lr' register is used by 'bl' instruction and never be recovered. As same as gcc arm kernel, directly use the frame pointer (r11) of the pt_regs to find the first frame address. Note that this fixes kretprobe stacktrace issue only with CONFIG_UNWINDER_FRAME_POINTER=y. For the CONFIG_UNWINDER_ARM, we need another fix. Signed-off-by: Masami Hiramatsu Reviewed-by: Nick Desaulniers --- Changes in v2: - Fix typos in changelog. --- arch/arm/kernel/stacktrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c index 76ea4178a55c..db798eac7431 100644 --- a/arch/arm/kernel/stacktrace.c +++ b/arch/arm/kernel/stacktrace.c @@ -54,8 +54,7 @@ int notrace unwind_frame(struct stackframe *frame) frame->sp = frame->fp; frame->fp = *(unsigned long *)(fp); - frame->pc = frame->lr; - frame->lr = *(unsigned long *)(fp + 4); + frame->pc = *(unsigned long *)(fp + 4); #else /* check current frame pointer is within bounds */ if (fp < low + 12 || fp > high - 4)