From patchwork Thu Jul 30 20:51:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 11693661 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14AD21392 for ; Thu, 30 Jul 2020 20:51:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD3C420829 for ; Thu, 30 Jul 2020 20:51:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yBWDvkfc"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="ViS1JlQV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD3C420829 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZTkOpbctfv91xG35owlhW/waDOqgx/TNI0G3b5zO2SE=; b=yBWDvkfcjQRD6myM8KFSCKrMm Ow3Vb+cGdcW+pqs4NHtjGHbTfUmylb+5RTtUPoeUzQZFrFqlRJd9FFoaIEB0UgxTIA6lPn0CnwwbL z1BZiC07uBrSi6E5Tq2zTI3uaGDi4stJEU/uedx37EFvzb0uh4QGN8//ls8nePTaCfftNT5mqf9Rh BdCVcqlj0A85/5Mj+Jk1qbzX0bDrYjOsMsfBgsllftIoXYJMi/cyZYl10IC+vgwQyv+CkiR9juJTr 7BFXs8mReqRc20tlcMerGGu22A5t6b30dozvfzC8OLhpuoOvIZGkfKgsOtPj9Afa7g2Ua1Hx4B/og QqcbNNlDg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWd-0004iH-BS; Thu, 30 Jul 2020 20:51:39 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWU-0004dx-KM for linux-mediatek@lists.infradead.org; Thu, 30 Jul 2020 20:51:31 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id a127so35451857ybb.14 for ; Thu, 30 Jul 2020 13:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=G95KKuekTz1iA7Zr8ZdyT9EdDFTvRs8dYtvTVOv4Dfc=; b=ViS1JlQVeIZx1+sasiczEhUQiJqT9BJ3+cGlNfVvdmsU9R2mLheJZdbOTUgKPav/+p 5pdrAapxvRSoKlz+chL0Gy18OCbJssl+aqaycS4dtpZekMdniwmfHSE28+u/htN+H2l+ lzAV54E++V9VAVcItllAAJIR59b/yWJz3F+UzYTyFBu/N5BqHonoSRohu96fk/lK3LEL 0FlD+6rYx6p5mrUR2jhCMNL3Mk/QYxpV5o//SYtwl8PLWXae6OWyWZcWxICKQUEdXgj8 g1z85D6nN1NBUXBVWo8pSEl6use+HV+VDaOcghe11TQpqrFnYk0mdJa+xoPyhRvpSBPa 46FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=G95KKuekTz1iA7Zr8ZdyT9EdDFTvRs8dYtvTVOv4Dfc=; b=m9iM2jzW5xCryksMeZTPOGTBscDlTL25Tp16t1bMtHfmZm+o8/HEG3cIHVpl3gqKM0 NsyL2yjGgbxZ5CfPOxOqNVQLgSuU4YYGIX5k3Hg9rDD5UTDkMD/pvPx+iuPmlTO2mfie Fj+mRJyfyOSU1gY0JHX9n5jWZteUlFodVFcvfQ4Gm5mVooAKTfjV6HySYqB2tJV3Sp60 27NQg6iy7YxBvLD+Z85ujm70g8UD7lr5EXi09OpRHveqPkMN/YpNpVLxc56lk//UQImm edGcMtQR5Ud24/t9GX5QbjFJ6x1i5vf8pDa+eQqGvCP3Vz9OX9Jvc+uHXhKvxr6S4uyU ezKw== X-Gm-Message-State: AOAM533wT1qh844WBbGeMInUcNKoKevndQEf47xY7M72Buo038juuRk+ VJRzREeb/Hitnn0B+/qAGaMjs9OR+q8XSnYjFjo= X-Google-Smtp-Source: ABdhPJx9IM+NZ+Dy+UO1H89OWuA1mQwu+ABN06cb8h6aN7Xpr4/KTHo0SHpRsO8t4uShHvxZa2ijHx26yaXliUNcOww= X-Received: by 2002:a25:40cb:: with SMTP id n194mr1171359yba.380.1596142286622; Thu, 30 Jul 2020 13:51:26 -0700 (PDT) Date: Thu, 30 Jul 2020 13:51:09 -0700 In-Reply-To: <20200730205112.2099429-1-ndesaulniers@google.com> Message-Id: <20200730205112.2099429-2-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200730205112.2099429-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [PATCH 1/4] ARM: backtrace-clang: check for NULL lr From: Nick Desaulniers To: Nathan Huckleberry , Russell King X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_165130_697454_0436FD9E X-CRM114-Status: GOOD ( 12.43 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:b4a listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Desaulniers , Chunyan Zhang , Dmitry Safonov <0x7f454c46@gmail.com>, linux-kernel@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com, Miles Chen , linux-mediatek@lists.infradead.org, Matthias Brugger , Andrew Morton , Lvqiang Huang , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org If the link register was zeroed out, do not attempt to use it for address calculations for which there are currently no fixup handlers, which can lead to a panic during unwind. Since panicking triggers another unwind, this can lead to an infinite loop. If this occurs during start_kernel(), this can prevent a kernel from booting. commit 59b6359dd92d ("ARM: 8702/1: head-common.S: Clear lr before jumping to start_kernel()") intentionally zeros out the link register in __mmap_switched which tail calls into start kernel. Test for this condition so that we can stop unwinding when initiated within start_kernel() correctly. Cc: stable@vger.kernel.org Fixes: commit 6dc5fd93b2f1 ("ARM: 8900/1: UNWINDER_FRAME_POINTER implementation for Clang") Reported-by: Miles Chen Signed-off-by: Nick Desaulniers Reviewed-by: Nathan Huckleberry --- arch/arm/lib/backtrace-clang.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/lib/backtrace-clang.S b/arch/arm/lib/backtrace-clang.S index 6174c45f53a5..5388ac664c12 100644 --- a/arch/arm/lib/backtrace-clang.S +++ b/arch/arm/lib/backtrace-clang.S @@ -144,6 +144,8 @@ for_each_frame: tst frame, mask @ Check for address exceptions */ 1003: ldr sv_lr, [sv_fp, #4] @ get saved lr from next frame + tst sv_lr, #0 @ If there's no previous lr, + beq finished_setup @ we're done. ldr r0, [sv_lr, #-4] @ get call instruction ldr r3, .Lopcode+4 and r2, r3, r0 @ is this a bl call From patchwork Thu Jul 30 20:51:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 11693663 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58BD71392 for ; Thu, 30 Jul 2020 20:51:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3108D20829 for ; Thu, 30 Jul 2020 20:51:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="1drvkcon"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="bS33mlwd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3108D20829 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vTdqIhI+DwkIhPUlMgK+1VNVtbcfGIrlH1ZirhuzHHs=; b=1drvkconasBLWABbcG6LW2pyy 0bkn3HeuAMBt3eohYTGXBeFTD5Mr1H2B7hWCAnBifBvUjlf/fLY5nCVwVIH21RfGU4WE6Ee4xFjKF yGions5yH0TPxs1khSWELcz4rABTTNhl5u74Uy4fA5jjkdDHFWeCUsTJT1JpGgw2eLYqsJ5j2aC2y H9d8ATJ9++54GV8en3fWkxgUjnPUJoQfN+KinM/0lFNRzUstougSUR0LebcSTr/psJapDjEYHcCd3 Acx+Azwnfh6UwCTCrMV1coUVWhr5ohl9TCV1vHrZ/9lblxcFsJiM6glBpteIRhzwsKjQ+ng6AmDJG vuaEH7oFA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWl-0004kv-8N; Thu, 30 Jul 2020 20:51:47 +0000 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWX-0004fM-S8 for linux-mediatek@lists.infradead.org; Thu, 30 Jul 2020 20:51:35 +0000 Received: by mail-pj1-x1049.google.com with SMTP id t3so6704552pjo.2 for ; Thu, 30 Jul 2020 13:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=U0OUPTDRNGhh0ydoN6VkhJdiruQZ6OtwNxR4N39C4f8=; b=bS33mlwdf/DJIQD28epPbEI7pJZXa1xHzvIjvbrwJsYvNRprRL04EmCMO8BY7c7vyR ofLXj+EecJitrlsOgIRSeYox7Ze/fCWlAwsLoJGJXNxJhm1Jzit1E25lLOIc4Zq4SNtH vDVgxSSFKjr6Dev1jNeB+/y6/4/TPRX9evR1RJBCof4kAi7IzZUb1z4wOFHcPt1MDXS1 UMmiVxWsDAo7fDiJWj5rZyAePJEpkaW+/xc4T//YX/DRcxFqZMlHsEZewHwkWf3ZE5Bn pEZzlVLo2QFc9P0WbNbGGnsimIfk/QgsbAfVHpxvfHt3Lp7csq8m7P0gUJ1850oZa06/ oWcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=U0OUPTDRNGhh0ydoN6VkhJdiruQZ6OtwNxR4N39C4f8=; b=JEExlZGZv3Ke6q6U9XXB0zwG+tU1E8+iqrLoMiBnbHwmjXRUzLTavR2iyuqYVAOdv4 bCou4klI9Oj95WdyjlAQ5mWVuaaig5fMFsPcw8XXZ3AapBjVYk0US/TWqdaEV7rd4M10 xwdM9XLw2r2Xpcu79iPR2hrnUCvKUJiD71OtrsJpskjW7cKfZhOtkgELUZ+NSa9FtLrD eg7M3DVfssUtJnHpnrBv1cF/rpOVw/5yqPpW3avcc6STSgtRQbCmPLKii0K6eDZcxKul n45OGn1Sold9JM7eMTr5IrYXJ0pdnA1vtcf8GJtuVqY3LYYTkbyZNXsNcA9kXlGiw0wb hKPg== X-Gm-Message-State: AOAM5301SnIuk9gnRCA/4SYjm5SkHi1kOsIKjoutJ0j6qu01cZAUOxHo jiI2oeMHv99io5pqeBIVsEP92hF5pgFoq7UlkWI= X-Google-Smtp-Source: ABdhPJwCEyx+wmqrFUv640p8yJy8eY2sYOEIDXEj/DD5NDhOwWleNVqKa5yzVDKQryUe9mvaALl+3zlHBVcQT43pRDg= X-Received: by 2002:a17:90b:4d0b:: with SMTP id mw11mr923395pjb.4.1596142290243; Thu, 30 Jul 2020 13:51:30 -0700 (PDT) Date: Thu, 30 Jul 2020 13:51:10 -0700 In-Reply-To: <20200730205112.2099429-1-ndesaulniers@google.com> Message-Id: <20200730205112.2099429-3-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200730205112.2099429-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [PATCH 2/4] ARM: backtrace-clang: add fixup for lr dereference From: Nick Desaulniers To: Nathan Huckleberry , Russell King X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_165133_989234_6470B41C X-CRM114-Status: GOOD ( 13.34 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1049 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Desaulniers , Chunyan Zhang , Dmitry Safonov <0x7f454c46@gmail.com>, linux-kernel@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com, Miles Chen , linux-mediatek@lists.infradead.org, Matthias Brugger , Andrew Morton , Lvqiang Huang , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org If the value of the link register is not correct (tail call from asm that didn't set it, stack corruption, memory no longer mapped), then using it for an address calculation may trigger an exception. Without a fixup handler, this will lead to a panic, which will unwind, which will trigger the fault repeatedly in an infinite loop. We don't observe such failures currently, but we have. Just to be safe, add a fixup handler here so that at least we don't have an infinite loop. Cc: stable@vger.kernel.org Fixes: commit 6dc5fd93b2f1 ("ARM: 8900/1: UNWINDER_FRAME_POINTER implementation for Clang") Reported-by: Miles Chen Signed-off-by: Nick Desaulniers --- arch/arm/lib/backtrace-clang.S | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm/lib/backtrace-clang.S b/arch/arm/lib/backtrace-clang.S index 5388ac664c12..40eb2215eaf4 100644 --- a/arch/arm/lib/backtrace-clang.S +++ b/arch/arm/lib/backtrace-clang.S @@ -146,7 +146,7 @@ for_each_frame: tst frame, mask @ Check for address exceptions tst sv_lr, #0 @ If there's no previous lr, beq finished_setup @ we're done. - ldr r0, [sv_lr, #-4] @ get call instruction +prev_call: ldr r0, [sv_lr, #-4] @ get call instruction ldr r3, .Lopcode+4 and r2, r3, r0 @ is this a bl call teq r2, r3 @@ -206,6 +206,13 @@ finished_setup: mov r2, frame bl printk no_frame: ldmfd sp!, {r4 - r9, fp, pc} +/* + * Accessing the address pointed to by the link register triggered an + * exception, don't try to unwind through it. + */ +bad_lr: mov sv_fp, #0 + mov sv_lr, #0 + b finished_setup ENDPROC(c_backtrace) .pushsection __ex_table,"a" .align 3 @@ -214,6 +221,7 @@ ENDPROC(c_backtrace) .long 1003b, 1006b .long 1004b, 1006b .long 1005b, 1006b + .long prev_call, bad_lr .popsection .Lbad: .asciz "%sBacktrace aborted due to bad frame pointer <%p>\n" From patchwork Thu Jul 30 20:51:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 11693665 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2DC21746 for ; Thu, 30 Jul 2020 20:51:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C42E2084D for ; Thu, 30 Jul 2020 20:51:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bcPmN7PR"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="h7wTTnVr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C42E2084D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BZArP4QZiYBEj1bfvmI2qIysiC5MwRn63KKG178jOps=; b=bcPmN7PRB6+YO8LlDFf5yIgFf 3qw/bB9uc0EsdE2QSsxyovDpB+XZ1piKianbaJH1mB688loM0rhNKEsp6ymxF/RgwcFrxRvohDwaP 1eQ2wLx2FPgQx6D6kqAYN+gBmbjOHm/m6koYeNDI2XKkiSAHsN2u7DzM3hViKrxQaMrItOvQf78h8 tmLbXpH+54VLy8DKRabiqiLJxgAvjBMjIUQDolMcVXg2pmIPs++3I+GqgYQFY7umfjJw4xUGJXvd5 BD2phn4Jf6FyVC79PmBIQv53JLp/smFUAjEFy7YvC1wXl6UDY9cZXg2QndH95O8aW9C1CquUeo6S0 pMTXt4few==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWl-0004lD-T4; Thu, 30 Jul 2020 20:51:47 +0000 Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWb-0004gt-VM for linux-mediatek@lists.infradead.org; Thu, 30 Jul 2020 20:51:39 +0000 Received: by mail-qt1-x84a.google.com with SMTP id b1so11992677qto.17 for ; Thu, 30 Jul 2020 13:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ydEFx7nL1QHetJ3IzZOqahIDDjnqGsyqZ8n++t96BPs=; b=h7wTTnVreiKdJy+S3fm1G5Q+3oIaI3sFumAyVhgRi/n9ezm7wRwkGq12SeApvBf77Z yX7kGgMRDPif/nTYK3URgcmC1Hxjt9vaylvzFShL86Y577Y6AIKwncRD7f+EY3NuLIgC p7gZGl2vcGUf1bULilSS8BokmMppT1Dk6tDPMc2loxDlz/Sj0BwExazMghpSO2ttTSYm QZT41EGqN8BUowWyiJBATS4vAbv+FJCk9y9IxDLnYkcJddcQ3rn2W7WaH/CaXUGuKrou Q/E6wrfVPA3s3Q8HvtnjIGhotWF6O53G/C61bFtcN5o/TijH9HAU744EsMUgY5wpo+GY jLwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ydEFx7nL1QHetJ3IzZOqahIDDjnqGsyqZ8n++t96BPs=; b=lcGxE7fhzFqGIpaCvcZunAyONjsdDYIIWOp518OOheSMd0CmEyczoWKeJHndihVc0e nL3htdA5MTQ1p25AUF85qVRNqOUWhXqZckBOEqz/FOWOhaGNOy+cbb0aulbAIfCN86/H giVVWslb46RMynEB+iG0jW3McMVpw02fIdlDEXXyTueNcRx4SX32cavpSfMN/vTPlvRW DgHmP9N8DSpc2mfHJZO9LduhtrBcoUhP0LL09JEdtjdLJHgtjOWT/CMz7oRx/4VrYx5Z zcByo9/azggeN2BrtjNkHV7Yb086Kbqt1uM5yQ8J0tWsPmV/dgRtYDBcpx82i1enMPIr OsZA== X-Gm-Message-State: AOAM532m3mLb66fzu+dLd87EZKP96eeLBU0A1GxQl2up3m4ZF43Qcwb4 Gxg6ExacZev/Q6gWvGHjMQwssp6aZX7ge828Iio= X-Google-Smtp-Source: ABdhPJypnfQMkIkUmhttCt6JJcEy5+kESjzSY6DmkgV227v2mbIs9Wfta5Fz6VMfPMaMbwf8XRvCb9EMykZZanPJTgU= X-Received: by 2002:a0c:b891:: with SMTP id y17mr1039225qvf.2.1596142294513; Thu, 30 Jul 2020 13:51:34 -0700 (PDT) Date: Thu, 30 Jul 2020 13:51:11 -0700 In-Reply-To: <20200730205112.2099429-1-ndesaulniers@google.com> Message-Id: <20200730205112.2099429-4-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200730205112.2099429-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [PATCH 3/4] ARM: backtrace-clang: give labels more descriptive names From: Nick Desaulniers To: Nathan Huckleberry , Russell King X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_165138_084137_AF869AF3 X-CRM114-Status: GOOD ( 11.50 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:84a listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Desaulniers , Chunyan Zhang , Dmitry Safonov <0x7f454c46@gmail.com>, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Miles Chen , linux-mediatek@lists.infradead.org, Matthias Brugger , Andrew Morton , Lvqiang Huang , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Removes the 1004 label; it was neither a control flow target, nor an instruction we expect to produce a fault. Gives the labels slightly more readable names. The `b` suffixes are handy to disambiguate between labels of the same identifier when there's more than one. Since these labels are unique, let's just give them names. Signed-off-by: Nick Desaulniers --- arch/arm/lib/backtrace-clang.S | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/arch/arm/lib/backtrace-clang.S b/arch/arm/lib/backtrace-clang.S index 40eb2215eaf4..7dad2a6843a5 100644 --- a/arch/arm/lib/backtrace-clang.S +++ b/arch/arm/lib/backtrace-clang.S @@ -121,8 +121,8 @@ for_each_frame: tst frame, mask @ Check for address exceptions * start. This value gets updated to be the function start later if it is * possible. */ -1001: ldr sv_pc, [frame, #4] @ get saved 'pc' -1002: ldr sv_fp, [frame, #0] @ get saved fp +load_pc: ldr sv_pc, [frame, #4] @ get saved 'pc' +load_fp: ldr sv_fp, [frame, #0] @ get saved fp teq sv_fp, mask @ make sure next frame exists beq no_frame @@ -142,7 +142,7 @@ for_each_frame: tst frame, mask @ Check for address exceptions * registers for the current function, but the stacktrace is still printed * properly. */ -1003: ldr sv_lr, [sv_fp, #4] @ get saved lr from next frame +load_lr: ldr sv_lr, [sv_fp, #4] @ get saved lr from next frame tst sv_lr, #0 @ If there's no previous lr, beq finished_setup @ we're done. @@ -166,8 +166,7 @@ finished_setup: /* * Print the function (sv_pc) and where it was called from (sv_lr). */ -1004: mov r0, sv_pc - + mov r0, sv_pc mov r1, sv_lr mov r2, frame bic r1, r1, mask @ mask PC/LR for the mode @@ -182,7 +181,7 @@ finished_setup: * pointer the comparison will fail and no registers will print. Unwinding will * continue as if there had been no registers stored in this frame. */ -1005: ldr r1, [sv_pc, #0] @ if stmfd sp!, {..., fp, lr} +load_stmfd: ldr r1, [sv_pc, #0] @ if stmfd sp!, {..., fp, lr} ldr r3, .Lopcode @ instruction exists, teq r3, r1, lsr #11 ldr r0, [frame] @ locals are stored in @@ -201,7 +200,7 @@ finished_setup: mov frame, sv_fp @ above the current frame bhi for_each_frame -1006: adr r0, .Lbad +bad_frame: adr r0, .Lbad mov r1, loglvl mov r2, frame bl printk @@ -216,11 +215,10 @@ bad_lr: mov sv_fp, #0 ENDPROC(c_backtrace) .pushsection __ex_table,"a" .align 3 - .long 1001b, 1006b - .long 1002b, 1006b - .long 1003b, 1006b - .long 1004b, 1006b - .long 1005b, 1006b + .long load_pc, bad_frame + .long load_fp, bad_frame + .long load_lr, bad_frame + .long load_stmfd, bad_frame .long prev_call, bad_lr .popsection From patchwork Thu Jul 30 20:51:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 11693669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0C961392 for ; Thu, 30 Jul 2020 20:52:02 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A136E20829 for ; Thu, 30 Jul 2020 20:52:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XBBOb81N"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="KNXCOzxZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A136E20829 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SwxrHr0KPxLVUWRLPmIqpfMf5zNx2R529UVPSburKEw=; b=XBBOb81Nm9uzNJV4/khXFrTNA XI6rCZX3LnBitzhaJMUZGrOymLS0Q5f3UQ347by2hhk9SpHZZrmdSNCU92ZfN9+Y+URPsMYvs/4hl VdLZ71/Gumt4lWmoUtNMaMYne7pB9ZkDEDEqcjU5KpYd3Asgtkt0iltgoojarsks2P+wn+CYpINVO 4uLCVIPY4bEkOnpM838iVmFg9H2OV9d3+P/tAiNpKpX58/Vt/qJSeVz2uZmqsAOPasjUkywqiHjeI iMIXTkB7dFrJSK8FuwoAE+InvHS0FkduBs8jwzxXicS4T0sZu+08Yyn2xMlShMPqNdjzPmTMJN9HY tLVg2B3zw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWx-0004pK-RW; Thu, 30 Jul 2020 20:51:59 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWf-0004iA-Fg for linux-mediatek@lists.infradead.org; Thu, 30 Jul 2020 20:51:42 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id e196so30895229ybh.6 for ; Thu, 30 Jul 2020 13:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QONIUax01BTjdO9Ra0WL2SaVjevDM7EFtQflcDkiZpw=; b=KNXCOzxZ5pBdanQWFcSr/OXE5B2/MHBDkzE0HeXydXqmchbCVf1W+UZq4r4Psxg/Wk 1DEQowbCu9uiGpRhB/dKS68WmrNs9kpD8hFn8AFd9ehaQ+aESTZaHw/5spbgKV2A8+hh gPvh6rRe3QytXFvyoUDWs9xZdj9sIJaHtZ1y1PJbwcXaIx9mdZ/Y3Xjw9DwXmEjNWo4/ 2UHVOrmwIJ0roULI0LVnH1Rym+desYivmDF40KeGKX9Tl0bEe2Awjztl/Vxjw3CZlc67 sNbngbmuxGMjWzDi+NpTTHb8LppYudA+15WmYdcxDCVNRvEZpo0kOAEryTzieodpJD6r Ikpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QONIUax01BTjdO9Ra0WL2SaVjevDM7EFtQflcDkiZpw=; b=e9GabvgxGIByjfKpW5/ABt+DpOTpi0ROnkLIF6uiw9gRsVX0dq7dn2gMp4D99aKtgN 2AUej0Lo7djPTkh7KZSmRawHOmXGKTfeLzPnd6gi3RR2BVuZC9ATwEFVZWjFQklK7C8Z ET//8yAWfe3hqlvzcW+xb5OR6v898d+P7yBs6Fim/OS18no7VGobVJh0q8iBxNR7Rflz AOXzAmw0RJJlFn7vJrrUdGYf/ZNN4tS2620aodh6eo+bwXDs8mMx2vsL9++SO7uHleFy jpSYGEt0LKZJIfQA4l97bT1Y7OZIgHkkRGk3wEZxR1+MlkdtYuEiaobOdKSxHHX4SHXe VDFA== X-Gm-Message-State: AOAM53326TN6qwYhjqyhrCmqtH6OTpgFUIw0Ez9GFnz0+nC/31DWSEsQ F/BlwF5hAd0iI1HY+guH6ik4rXh6feJIUnfoq3A= X-Google-Smtp-Source: ABdhPJxNBCENw+3kJpkaLmevqSScT/aVOmfpWZ+6QdeX2ScuiXo2KHy5MFNiKfuHDYstF0PZx795gbSwSo9qT61KX4Q= X-Received: by 2002:a25:aba2:: with SMTP id v31mr1236236ybi.138.1596142298407; Thu, 30 Jul 2020 13:51:38 -0700 (PDT) Date: Thu, 30 Jul 2020 13:51:12 -0700 In-Reply-To: <20200730205112.2099429-1-ndesaulniers@google.com> Message-Id: <20200730205112.2099429-5-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200730205112.2099429-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [PATCH 4/4] ARM: backtrace: use more descriptive labels From: Nick Desaulniers To: Nathan Huckleberry , Russell King X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_165141_616153_2B88214D X-CRM114-Status: GOOD ( 10.30 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:b4a listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Desaulniers , Chunyan Zhang , Dmitry Safonov <0x7f454c46@gmail.com>, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Miles Chen , linux-mediatek@lists.infradead.org, Matthias Brugger , Andrew Morton , Lvqiang Huang , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org We don't necessarily need the `b` suffixes used to disambiguate between non-unique local labels. Give these labels more descriptive names. Signed-off-by: Nick Desaulniers --- arch/arm/lib/backtrace.S | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm/lib/backtrace.S b/arch/arm/lib/backtrace.S index 872f658638d9..138e961ff033 100644 --- a/arch/arm/lib/backtrace.S +++ b/arch/arm/lib/backtrace.S @@ -37,9 +37,9 @@ ENDPROC(c_backtrace) THUMB( orreq mask, #0x03 ) movne mask, #0 @ mask for 32-bit -1: stmfd sp!, {pc} @ calculate offset of PC stored +store_pc: stmfd sp!, {pc} @ calculate offset of PC stored ldr r0, [sp], #4 @ by stmfd for this CPU - adr r1, 1b + adr r1, store_pc sub offset, r0, r1 /* @@ -60,14 +60,14 @@ ENDPROC(c_backtrace) for_each_frame: tst frame, mask @ Check for address exceptions bne no_frame -1001: ldr sv_pc, [frame, #0] @ get saved pc -1002: ldr sv_fp, [frame, #-12] @ get saved fp +load_pc: ldr sv_pc, [frame, #0] @ get saved pc +load_fp: ldr sv_fp, [frame, #-12] @ get saved fp sub sv_pc, sv_pc, offset @ Correct PC for prefetching bic sv_pc, sv_pc, mask @ mask PC/LR for the mode -1003: ldr r2, [sv_pc, #-4] @ if stmfd sp!, {args} exists, - ldr r3, .Ldsi+4 @ adjust saved 'pc' back one +load_stmfd: ldr r2, [sv_pc, #-4] @ if stmfd sp!, {args} exists, + ldr r3, .Lopcode + 4 @ adjust saved 'pc' back one teq r3, r2, lsr #11 @ instruction subne r0, sv_pc, #4 @ allow for mov subeq r0, sv_pc, #8 @ allow for mov + stmia @@ -79,15 +79,15 @@ for_each_frame: tst frame, mask @ Check for address exceptions bl dump_backtrace_entry ldr r1, [sv_pc, #-4] @ if stmfd sp!, {args} exists, - ldr r3, .Ldsi+4 + ldr r3, .Lopcode + 4 teq r3, r1, lsr #11 ldreq r0, [frame, #-8] @ get sp subeq r0, r0, #4 @ point at the last arg mov r2, loglvl bleq dump_backtrace_stm @ dump saved registers -1004: ldr r1, [sv_pc, #0] @ if stmfd sp!, {..., fp, ip, lr, pc} - ldr r3, .Ldsi @ instruction exists, +reload_stmfd: ldr r1, [sv_pc, #0] @ if stmfd sp!, {..., fp, ip, lr, pc} + ldr r3, .Lopcode @ instruction exists, teq r3, r1, lsr #11 subeq r0, frame, #16 mov r2, loglvl @@ -100,7 +100,7 @@ for_each_frame: tst frame, mask @ Check for address exceptions mov frame, sv_fp @ above the current frame bhi for_each_frame -1006: adr r0, .Lbad +bad_frame: adr r0, .Lbad mov r1, loglvl mov r2, frame bl printk @@ -109,15 +109,15 @@ ENDPROC(c_backtrace) .pushsection __ex_table,"a" .align 3 - .long 1001b, 1006b - .long 1002b, 1006b - .long 1003b, 1006b - .long 1004b, 1006b + .long load_pc, bad_frame + .long load_fp, bad_frame + .long load_stmfd, bad_frame + .long reload_stmfd, bad_frame .popsection .Lbad: .asciz "%sBacktrace aborted due to bad frame pointer <%p>\n" .align -.Ldsi: .word 0xe92dd800 >> 11 @ stmfd sp!, {... fp, ip, lr, pc} +.Lopcode: .word 0xe92dd800 >> 11 @ stmfd sp!, {... fp, ip, lr, pc} .word 0xe92d0000 >> 11 @ stmfd sp!, {} #endif