From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FE1BC433EF for ; Thu, 30 Sep 2021 08:42:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 540CE6187A for ; Thu, 30 Sep 2021 08:42:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348745AbhI3Iof (ORCPT ); Thu, 30 Sep 2021 04:44:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:48484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348518AbhI3Ioe (ORCPT ); Thu, 30 Sep 2021 04:44:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 040AA61439; Thu, 30 Sep 2021 08:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632991372; bh=YAnA2FtNx+qKH+DUhXFTr035RylLWdDdVr26z3gny3o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XNN48DDrtgswcaru3LHGl7NIqrLp1HEB8JubJ12b7gm+02FO64euY3Zcf/N2xrsKi h8SSwH3omgH/zN8rTqniJGQR4YlBnqLvUGoB0Fhe3aKUyd7SsTQSyQM/xkshI1M7F1 gLQC0+1k304iTXeIZh/JbxZSTuQ6ip+8lpgsd5AuGuELW/LHcI/1ScXmQXsADUVKEx YfWiwKzTvHVRBNQbYyoKI1IpHwZZhcGtdZ3b2CdTndusVE1vvJnj/YiPERRTx3nB/k gN47SY1pjtHs0weXfAe6o0y/9DRGIcDT/FZmNk9Hnynp0FNdoNDQkz9EgyWyH0sJ9N i2XobeaZh7JdA== Date: Thu, 30 Sep 2021 09:42:47 +0100 From: Will Deacon To: Chen Lin Cc: catalin.marinas@arm.com, mark.rutland@arm.com, joey.gouly@arm.com, maz@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Chen Lin Subject: Re: [PATCH] arm64: traps: add dump instr before BUG in kernel Message-ID: <20210930084247.GC23389@willie-the-truck> References: <1632922186-3116-1-git-send-email-chen45464546@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1632922186-3116-1-git-send-email-chen45464546@163.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021 at 09:29:46PM +0800, Chen Lin wrote: > From: Chen Lin > > we should dump the real instructions before BUG in kernel mode, and > compare this to the instructions from objdump. > > Signed-off-by: Chen Lin > --- > arch/arm64/kernel/traps.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > index b03e383..621a9dd 100644 > --- a/arch/arm64/kernel/traps.c > +++ b/arch/arm64/kernel/traps.c > @@ -495,7 +495,12 @@ void do_undefinstr(struct pt_regs *regs) > if (call_undef_hook(regs) == 0) > return; > > - BUG_ON(!user_mode(regs)); > + if (!user_mode(regs)) { > + pr_emerg("Undef instruction in kernel, dump instr:"); > + dump_kernel_instr(KERN_EMERG, regs); > + BUG(); > + } Hmm, I'm not completely convinced about this as the instruction in the i-cache could be completely different. I think the PC value (for addr2line) is a lot more useful, and we should be printing that already. Maybe you can elaborate on a situation where this information was helpful? Thanks, Will From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2293DC433EF for ; Thu, 30 Sep 2021 08:44:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D9E3B61439 for ; Thu, 30 Sep 2021 08:44:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D9E3B61439 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0lbtUCj5se2ybt2toeGSpbdxSTWQyG9W3w9XSoXIwCY=; b=p1NeD6KwS6mnQl tb/lIh3zx0QkztK9dh7M0tDQRQNnrTO6yLy+5tZr6H2wtNYLHn8A4ZiCN7YJczL+IDMylIV0Xdsde VDqDtUE9FJfIAc8H+Jil/JuIs0na/SYlLOHjdaTdREs6YiJ6PEABFuS26UYY5f8hx9LTxMbjA0Uht 7DmbGb/CZfITkCWLRnHiaPv9PRevuerE9zezgqDqcnSpHJusmLPLxaTla3d8FogE3HlxbPH0SbVEE EMyzAoj4wSzi8WOtsEY3h+pYgUVKhzwvlypRY2SYLBklcDdvRtLrjLdYkO/c8v2NtuliAzZvZ7EVE 1dcSnhEjg2doy0s5csTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVrea-00DSFG-5O; Thu, 30 Sep 2021 08:42:56 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVreW-00DSEs-PZ for linux-arm-kernel@lists.infradead.org; Thu, 30 Sep 2021 08:42:54 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 040AA61439; Thu, 30 Sep 2021 08:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632991372; bh=YAnA2FtNx+qKH+DUhXFTr035RylLWdDdVr26z3gny3o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XNN48DDrtgswcaru3LHGl7NIqrLp1HEB8JubJ12b7gm+02FO64euY3Zcf/N2xrsKi h8SSwH3omgH/zN8rTqniJGQR4YlBnqLvUGoB0Fhe3aKUyd7SsTQSyQM/xkshI1M7F1 gLQC0+1k304iTXeIZh/JbxZSTuQ6ip+8lpgsd5AuGuELW/LHcI/1ScXmQXsADUVKEx YfWiwKzTvHVRBNQbYyoKI1IpHwZZhcGtdZ3b2CdTndusVE1vvJnj/YiPERRTx3nB/k gN47SY1pjtHs0weXfAe6o0y/9DRGIcDT/FZmNk9Hnynp0FNdoNDQkz9EgyWyH0sJ9N i2XobeaZh7JdA== Date: Thu, 30 Sep 2021 09:42:47 +0100 From: Will Deacon To: Chen Lin Cc: catalin.marinas@arm.com, mark.rutland@arm.com, joey.gouly@arm.com, maz@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Chen Lin Subject: Re: [PATCH] arm64: traps: add dump instr before BUG in kernel Message-ID: <20210930084247.GC23389@willie-the-truck> References: <1632922186-3116-1-git-send-email-chen45464546@163.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1632922186-3116-1-git-send-email-chen45464546@163.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210930_014252_876072_1B8A1D66 X-CRM114-Status: GOOD ( 17.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Sep 29, 2021 at 09:29:46PM +0800, Chen Lin wrote: > From: Chen Lin > > we should dump the real instructions before BUG in kernel mode, and > compare this to the instructions from objdump. > > Signed-off-by: Chen Lin > --- > arch/arm64/kernel/traps.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > index b03e383..621a9dd 100644 > --- a/arch/arm64/kernel/traps.c > +++ b/arch/arm64/kernel/traps.c > @@ -495,7 +495,12 @@ void do_undefinstr(struct pt_regs *regs) > if (call_undef_hook(regs) == 0) > return; > > - BUG_ON(!user_mode(regs)); > + if (!user_mode(regs)) { > + pr_emerg("Undef instruction in kernel, dump instr:"); > + dump_kernel_instr(KERN_EMERG, regs); > + BUG(); > + } Hmm, I'm not completely convinced about this as the instruction in the i-cache could be completely different. I think the PC value (for addr2line) is a lot more useful, and we should be printing that already. Maybe you can elaborate on a situation where this information was helpful? Thanks, Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel