Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp118578pxb; Wed, 20 Oct 2021 17:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb/Z5VXgJMHgiFuIVi3OEoZKi238X9g/KyurjBRG73yb+O9QEh7x0umeubgYwFU1TpN9dl X-Received: by 2002:a17:906:6592:: with SMTP id x18mr1146332ejn.307.1634777902715; Wed, 20 Oct 2021 17:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634777902; cv=none; d=google.com; s=arc-20160816; b=KtCwoz1/kFAyyAC5uhx45zUUqhkoAAWPudKeRndcDUD+BYjmHHmGGhiPnLBBAQoaGJ a6F791t9txm8SaG8OgaLzvPBy8mk8XefhOWYlzTsz2S+5iRzo9Es5eI8L8B8FUlHQ1tK WomwiMWVPF7oXw0J9oSJUH2hDL0R6wTvLpo3pWuT6lfVwxkp28+HXHV1Yq8JB5/98gzF OLSPkYxsEWHcZ/UZcUQXGCRM/fLjBOclvO0ge6lFQ87UJll3Wtbsvuf64Ezudu1PVkfN zlFL5fp5arMck+8I7Q/desBKRvIFi1yuZ6Qjuw1gMcpc/W3Fj/YaodoM6zUL3G1wnBdi a2GQ== 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=zz0HqR8JgX0QxDkqPFFMs8OGSb1QQDnxiYOwtOjhfS+NLvxwitg7bOAt4tHO4+Rzu5 Eq1rVvj/FU40fbxNzi0o/GTnwDiCM8ozM2qeavKEuiG2nFf4sTD6kbBCfiIro+7FYNeV NZ5+Zy69rP0lNLYz+62ogvr4Cjiu6O0zVeUTCqdcoJFkL9dq52wcdCERTSRiHKuXUVTB Twj/tPTGsMnmNnovYhnsxDOFGhk82FBgXlcZTPL6fzPSssEqGAGTxEbUwfBO+OrlIZlN Wlp9vFbSBmvDaOy3cOv9IupG/Wbn/JPeb5bdY0U3dZUQBxYoJGXCbC0kCHa29tOlaRAD pDaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Rrc3x0PQ; 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 z21si6291968edb.133.2021.10.20.17.57.59; Wed, 20 Oct 2021 17:58:22 -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=Rrc3x0PQ; 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 S231531AbhJUA5l (ORCPT + 99 others); Wed, 20 Oct 2021 20:57:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:51690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbhJUA5g (ORCPT ); Wed, 20 Oct 2021 20:57:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B052610A1; Thu, 21 Oct 2021 00:55:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634777720; bh=WqIiiFEaJiQvJq7Z5CrnA44AmFZAiLP70n+lEDL0ZZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rrc3x0PQtBl+jJxPYLxvEJa1gL8qJeSOIT/WdB1F9unisTMJ0qRNBU2b0lX9nS0NU FMdlhk1okPOs7djg+IcG1swg8hbe+zY20W64wUNz3bkkFu6P2kClPR2iIBJcQMYQQh O9tUMHRRn9YUhqTrXje//6rJZ+pGOfWkhHJZnh8k4puutQU12a7/dcrg7coDrchI6p hjS9GdYF3Ukaxn33B2uZLxJ/7o2xOG8ofx6ucqGEqtqDeVoZ7TVSNQrCV/6kwphEFI KpoWCmTVn4AYTPTjrZreELbMUWAfbdrMqcbpzo638QzVxMLCMsXwntoC+I31dxWzCv c7TP1t4aXZu2A== 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 v3 7/9] ARM: clang: Do not rely on lr register for stacktrace Date: Thu, 21 Oct 2021 09:55:17 +0900 Message-Id: <163477771763.264901.13199943018441108332.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163477765570.264901.3851692300287671122.stgit@devnote2> References: <163477765570.264901.3851692300287671122.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)