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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D78CFC433EF for ; Wed, 9 Mar 2022 19:38:11 +0000 (UTC) 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=tU4K12Idl4C61LravUl6R6UYUVXb4Gx4R3f0Y9/jhPg=; b=X9npzQ2EM1wBec 1s80sKBTfl8VC3UMeDbfWCCDA+VQodiXv3QFuQPgSDSIb0XbUb66JSwzIEcrOgm9pyl5Z731g7Mh0 Ld70xdfCeZvKKbpPZuDxhdrpLLvO0TIlrhMpeHSIEhrF/ttWmSMOAhJthtAY5xxvaQ6d/xgwZT7o9 K13IMyZqyKWiESkisb34ZGIDdkUdKt91mxvF2/XiFx9ZmE9fu8BkD1QZzP9Y9k9txSaP/o4ej0vcD 3JgzZ+T1HgweX06jlOwiNoYSj14mhB6Ei8KAMKuLvRxqwTnn+nMKh9KTzbaM09iiRwS0+DFkKkjOD 0W0gS8t51PSkYG46ztYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS27C-00AImu-EX; Wed, 09 Mar 2022 19:36:54 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS278-00AIll-6T for linux-arm-kernel@lists.infradead.org; Wed, 09 Mar 2022 19:36:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KbNjVleHzXmiuPoSqakRW+gnUx6PldItakYIGnlJGzM=; b=pLDg+9RL+WDjMvY7+mptTatP+q SlgUqA3mrISRsnfRsmP1RD3HbwEtUak+3gZdYWPcrZMCW1D29npvVSr4cwa/aJWzzkCRXHCRk0ozp 3ZagA54NNjE9P7UyMCLBMhRnropGKsn/3sQEtVh8LLBmJU+Sp6fUNIwMBwwZU7BN7EZ6xKHLOxpX8 VbCEK9/hMULRQRyrrMYQa9mMPpoJIA+0m/BBJ1nONhr/2CY4kQE/iRJboF4dgJL2vTgljw02WUQLZ Yyoht0Bh3WP7v3BpFLB5onIrVkNssSSXzJxHEk5xVCvyAU0i7obYjXEGGLR25SIaHZR4e9PCF56nI RhwD827w==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:57756) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nS270-0000Gm-FA; Wed, 09 Mar 2022 19:36:42 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nS26y-0008Do-85; Wed, 09 Mar 2022 19:36:40 +0000 Date: Wed, 9 Mar 2022 19:36:40 +0000 From: "Russell King (Oracle)" To: Ard Biesheuvel Cc: Naresh Kamboju , open list , Linux-Next Mailing List , Linux ARM , Linus Walleij , Arnd Bergmann , Corentin Labbe , Stephen Rothwell Subject: Re: [next] arm: Internal error: Oops: 5 PC is at __read_once_word_nocheck Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220309_113650_416748_BBACC90A X-CRM114-Status: GOOD ( 46.04 ) 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, Mar 09, 2022 at 08:14:30PM +0100, Ard Biesheuvel wrote: > On Wed, 9 Mar 2022 at 19:48, Russell King (Oracle) > wrote: > > > > On Wed, Mar 09, 2022 at 06:43:42PM +0100, Ard Biesheuvel wrote: > > > On Wed, 9 Mar 2022 at 18:11, Russell King (Oracle) > > > wrote: > > > > > > > > On Wed, Mar 09, 2022 at 10:08:25PM +0530, Naresh Kamboju wrote: > > > > > Hi Russell, > > > > > > > > > > On Wed, 9 Mar 2022 at 20:37, Russell King (Oracle) > > > > > wrote: > > > > > > > > > > > > On Wed, Mar 09, 2022 at 03:57:32PM +0100, Ard Biesheuvel wrote: > > > > > > > On Wed, 9 Mar 2022 at 15:44, Naresh Kamboju wrote: > > > > > > > > > > > > > > > > > > > Well, we unwound until: > > > > > > > > > > > > __irq_svc from migrate_disable+0x0/0x70 > > > > > > > > > > > > and then crashed - and the key thing there is that we're at the start > > > > > > of migrate_disable() when we took an interrupt. > > > > > > > > > > > > For some reason, this triggers an access to address 0x10, which faults. > > > > > > We then try unwinding again, and successfully unwind all the way back > > > > > > to the same point (the line above) which then causes the unwinder to > > > > > > again access address 0x10, and the cycle repeats with the stack > > > > > > growing bigger and bigger. > > > > > > > > > > > > I'd suggest also testing without the revert but with my patch. > > > > > > > > > > I have tested your patch on top of linux next-20220309 and still see kernel > > > > > crash as below [1]. build link [2]. > > > > > > > > > > [ 26.812060] 8<--- cut here --- > > > > > [ 26.813459] Unhandled fault: page domain fault (0x01b) at 0xb6a3ab70 > > > > > [ 26.816139] [b6a3ab70] *pgd=fb28a835 > > > > > [ 26.817770] Internal error: : 1b [#1] SMP ARM > > > > > [ 26.819636] Modules linked in: > > > > > [ 26.820956] CPU: 0 PID: 211 Comm: haveged Not tainted > > > > > 5.17.0-rc7-next-20220309 #1 > > > > > [ 26.824519] Hardware name: Generic DT based system > > > > > [ 26.827148] PC is at __read_once_word_nocheck+0x0/0x8 > > > > > [ 26.829856] LR is at unwind_frame+0x7dc/0xab4 > > > > > > > > > > - Naresh > > > > > > > > > > [1] https://lkft.validation.linaro.org/scheduler/job/4688599#L596 > > > > > [2] https://builds.tuxbuild.com/269gYLGuAdmltuLhIUDAjS2fg1Q/ > > > > > > > > I think the problem has just moved: > > > > > > > > [ 27.113085] __irq_svc from __copy_to_user_std+0x24/0x378 > > > > > > > > The code at the start of __copy_to_user_std is: > > > > > > > > 0: e3a034bf mov r3, #-1090519040 ; 0xbf000000 > > > > 4: e243c001 sub ip, r3, #1 > > > > 8: e05cc000 subs ip, ip, r0 > > > > c: 228cc001 addcs ip, ip, #1 > > > > 10: 205cc002 subscs ip, ip, r2 > > > > 14: 33a00000 movcc r0, #0 > > > > 18: e320f014 csdb > > > > 1c: e3a03000 mov r3, #0 > > > > 20: e92d481d push {r0, r2, r3, r4, fp, lr} > > > > 24: e1a0b00d mov fp, sp > > > > > > > > and the unwind information will be: > > > > > > > > 0xc056f14c : @0xc0b89b84 > > > > Compact model index: 1 > > > > 0x9b vsp = r11 > > > > 0xb1 0x0d pop {r0, r2, r3} > > > > 0x84 0x81 pop {r4, r11, r14} > > > > 0xb0 finish > > > > > > > > The problem is that the unwind information says "starting at offset > > > > 0x1c, to unwind do the following operations". The first of which is > > > > to move r11 (fp) to the stack pointer. However, r11 isn't setup > > > > until function offset 0x24. You've hit that instruction, which hasn't > > > > executed yet, but the stack has been modified by pushing r0, r2-r4, > > > > fp and lr onto it. > > > > > > > > Given this, there is no way that the unwinder (as it currently stands) > > > > can do its job properly between 0x1c and 0x24. > > > > > > > > I don't think this is specifically caused by Ard's patches, but by > > > > the addition of KASAN, which has the effect of calling the unwinder > > > > at random points in the kernel (when an interrupt happens) and it's > > > > clear from the above that there are windows in the code where, if > > > > we attempt to unwind using the unwind information, we faill fail > > > > because the program state is not consistent with the unwind > > > > information. > > > > > > > > Ard's patch that changes: > > > > > > > > ctrl->vrs[reg] = READ_ONCE_NOCHECK(*(*vsp)); > > > > > > > > to use get_kernel_nofault() should have the effect of protecting > > > > against the oops, but the side effect is that it is fundamentally not > > > > possible with the way these things are to unwind at these points - > > > > which means its not possible to get a stacktrace there. > > > > > > > > So, I don't think this is a "new" problem, but a weakness of using > > > > the unwinder to get a backtrace for KASAN. > > > > > > > > > > It essentially means that we cannot unwind through asynchronous > > > exceptions, and so we should probably make the svc_entry macro > > > .nounwind, instead of pretending that we can reliably unwind through > > > it. > > > > Doesn't that impact the ability to debug the kernel over things like > > oopses and the like? > > > > The backtrace dumped by __die() uses the pt_regs from the exception > context as the starting point, so the exception entry code that deals > with the condition that triggered the oops is omitted, and does not > have to be unwound. That is true, but that's not really the case I was thinking about. I was thinking more about cases such as RCU stalls, soft lockups, etc. For example: https://www.linuxquestions.org/questions/linux-kernel-70/kenel-v4-4-60-panic-in-igmp6_send-and-and-__neigh_create-4175704721/ In that stack trace, the interesting bits are not the beginning of the stack trace down to __irq_svc, but everything beyond __irq_svc, since the lockup is probably caused by being stuck in _raw_write_lock_bh(). It's these situations that we will totally destroy debuggability for, and the only way around that would be to force frame pointers and ARM builds (not Thumb-2 as that requires the unwinder... which means a Thumb-2 kernel soft lockup would be undebuggable. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel