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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2B2DC6FA99 for ; Sun, 12 Mar 2023 07:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbjCLHbw (ORCPT ); Sun, 12 Mar 2023 03:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbjCLHbu (ORCPT ); Sun, 12 Mar 2023 03:31:50 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BC0758C05 for ; Sat, 11 Mar 2023 23:31:49 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id s12so10233824qtq.11 for ; Sat, 11 Mar 2023 23:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1678606308; h=in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:from:to:cc:subject:date:message-id:reply-to; bh=4dS1lLmn7d6CrZjwyVYWK3YGHrlop5B1SpTiK36P6ic=; b=Hwjdej83Myyq18v4uoPpz7sB3EFe8GeC8gRSliPLRKkr++wSnW8dn4AmvllS9mRInG XpyhSTXNrwnSAJEEoeiTIX/0bB1cqyCrBgAd/73K4XN3sgsH+/bcoygugxzLs821x5hv 4mssPgOkOAnwKFRhKvvcF8w95OtZSXVx1cFLo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678606308; h=in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4dS1lLmn7d6CrZjwyVYWK3YGHrlop5B1SpTiK36P6ic=; b=xQr4572ssup1GPBaUOXITrRTv3mnsv2Y8iCQXfqBhqsQmY5hJJM9VRKKkMNiRdJsSn sIO1e3vP5WfWCvWO7J7df43JSDSSFslHhhKpYfByb0mqMs3hgW6kfmA9k3OuGBl/o5nP zE49hBV47dIN1TEvjJCccIjFO/T2ZpWubHxLSFyXhM6HseFbR+36sRZAsl75GZNfVtEb t4/PmVl/TF0lwxv+E6M2fu5O9w67YQJC7VOpsPUn+rG6M0LgIq182JqBrzttZVA+JWRZ Jfu7OOS/7ZokR8bu5CzbtePpP40IsnAJnftRmxW4PdAAl6P323NTzn8mZRpsE7ASDwhP ojJg== X-Gm-Message-State: AO0yUKUl1jgajUxFE/7bsgkbOGiPs4LJOIPkHWawYFG9165Jr4hn0QEr 30oCYbgwfZRzzrMYND/ZFZhVa/THBmun8YzQUpeQMGtr2HRWre41qCi4GbN+Upn3nnr+6g/77Ga iJgNhA9RTpJPnAON91/tlmpeIifH7FywPW7AuEIluWVIa2iy/wvqw8LfDI5jJh+T3Znh4bFJtGp HXLvGiQY5KsPfNKQ== X-Google-Smtp-Source: AK7set93ynytw5BXAg7ROxRt2gmuA5kBMj+h2OgFkIQSCLGSDPimdu0vqYrijN8ZWU/L3eHbaRb29A== X-Received: by 2002:ac8:7d86:0:b0:3bf:be7d:b3e5 with SMTP id c6-20020ac87d86000000b003bfbe7db3e5mr54748159qtd.41.1678606307839; Sat, 11 Mar 2023 23:31:47 -0800 (PST) Received: from bcacpedev-irv-3.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id s138-20020a374590000000b007436d0e9408sm3084168qka.127.2023.03.11.23.31.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Mar 2023 23:31:47 -0800 (PST) Subject: Re: [PATCH] mips: bmips: BCM6358: disable arch_sync_dma_for_cpu_all() To: Jonas Gorski , Florian Fainelli Cc: =?UTF-8?Q?=c3=81lvaro_Fern=c3=a1ndez_Rojas?= , bcm-kernel-feedback-list@broadcom.com, tsbogend@alpha.franken.de, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230310121306.4632-1-noltari@gmail.com> From: William Zhang Message-ID: <5b4d3eef-ff80-29e8-9be0-d487aee5e4e2@broadcom.com> Date: Sat, 11 Mar 2023 23:31:45 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="000000000000b95c1b05f6aefc22" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000b95c1b05f6aefc22 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit On 03/11/2023 11:44 AM, Jonas Gorski wrote: > On Sat, 11 Mar 2023 at 18:32, Florian Fainelli wrote: >> >> >> >> On 3/10/2023 4:13 AM, Álvaro Fernández Rojas wrote: >>> arch_sync_dma_for_cpu_all() causes kernel panics on BCM6358 with EHCI/OHCI: >>> [ 3.881739] usb 1-1: new high-speed USB device number 2 using ehci-platform >>> [ 3.895011] Reserved instruction in kernel code[#1]: >>> [ 3.900113] CPU: 0 PID: 1 Comm: init Not tainted 5.10.16 #0 >>> [ 3.905829] $ 0 : 00000000 10008700 00000000 77d94060 >>> [ 3.911238] $ 4 : 7fd1f088 00000000 81431cac 81431ca0 >>> [ 3.916641] $ 8 : 00000000 ffffefff 8075cd34 00000000 >>> [ 3.922043] $12 : 806f8d40 f3e812b7 00000000 000d9aaa >>> [ 3.927446] $16 : 7fd1f068 7fd1f080 7ff559b8 81428470 >>> [ 3.932848] $20 : 00000000 00000000 55590000 77d70000 >>> [ 3.938251] $24 : 00000018 00000010 >>> [ 3.943655] $28 : 81430000 81431e60 81431f28 800157fc >>> [ 3.949058] Hi : 00000000 >>> [ 3.952013] Lo : 00000000 >>> [ 3.955019] epc : 80015808 setup_sigcontext+0x54/0x24c >>> [ 3.960464] ra : 800157fc setup_sigcontext+0x48/0x24c >>> [ 3.965913] Status: 10008703 KERNEL EXL IE >>> [ 3.970216] Cause : 00800028 (ExcCode 0a) >>> [ 3.974340] PrId : 0002a010 (Broadcom BMIPS4350) >>> [ 3.979170] Modules linked in: ohci_platform ohci_hcd fsl_mph_dr_of ehci_platform ehci_fsl ehci_hcd gpio_button_hotplug usbcore nls_base usb_common >>> [ 3.992907] Process init (pid: 1, threadinfo=(ptrval), task=(ptrval), tls=77e22ec8) >>> [ 4.000776] Stack : 81431ef4 7fd1f080 81431f28 81428470 7fd1f068 81431edc 7ff559b8 81428470 >>> [ 4.009467] 81431f28 7fd1f080 55590000 77d70000 77d5498c 80015c70 806f0000 8063ae74 >>> [ 4.018149] 08100002 81431f28 0000000a 08100002 81431f28 0000000a 77d6b418 00000003 >>> [ 4.026831] ffffffff 80016414 80080734 81431ecc 81431ecc 00000001 00000000 04000000 >>> [ 4.035512] 77d54874 00000000 00000000 00000000 00000000 00000012 00000002 00000000 >>> [ 4.044196] ... >>> [ 4.046706] Call Trace: >>> [ 4.049238] [<80015808>] setup_sigcontext+0x54/0x24c >>> [ 4.054356] [<80015c70>] setup_frame+0xdc/0x124 >>> [ 4.059015] [<80016414>] do_notify_resume+0x1dc/0x288 >>> [ 4.064207] [<80011b50>] work_notifysig+0x10/0x18 >>> [ 4.069036] >>> [ 4.070538] Code: 8fc300b4 00001025 26240008 ac830004 3c048063 0c0228aa 24846a00 26240010 >>> [ 4.080686] >>> [ 4.082517] ---[ end trace 22a8edb41f5f983b ]--- >>> [ 4.087374] Kernel panic - not syncing: Fatal exception >>> [ 4.092753] Rebooting in 1 seconds.. >> >> Did you pinpoint which specific instruction within >> arch_sync_dma_for_cpu_all() is causing the reserved instruction exception? > > It's setup_sigcontext(), not arch_sync_dma_for_cpu_all() that's > causing the exception ;-) > > Hand decoding the Code gives me > > lw $1, 0xb4($fp) > or $v0, 0, 0 > addiu $a0, $s1, 8 > sw $v0, 0($a0) <- the code in brackets, so I guess EPC? > sw $v1, 4($a0) > > which I assume is this part: > > err |= __put_user(regs->cp0_epc, &sc->sc_pc); > > (0xb4 is the offset of cp0_epc, 0x8 the offset of sc_pc) > > One thing I see is that we do the RAC flush for BMIPS3300, 4350 and > 4380, but only initialize it for 3300 [1], but leave it at whatever > state the bootloader did for the other ones. Maybe it has some invalid > config in (that particuar?) 6358 that triggers issues later on after a > flush? E.g. the flush puts it in an error state, and the next time > something triggers a prefetch(write?) (by trying to access userspace) > it generates an error exception. > Depending on the bootloader but likely bootloader does not use RAC at all. So agree that RAC may not be properly initialized when the flush function is called and push the stale data to corrupt memory and cause problem later on the userspace. > Just spit balling though. > > [1] https://elixir.bootlin.com/linux/latest/source/arch/mips/kernel/smp-bmips.c#L587 > > Jonas > --000000000000b95c1b05f6aefc22 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQcAYJKoZIhvcNAQcCoIIQYTCCEF0CAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3HMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA vbCmXCcsbZ/a0fRIQMBxp4gJnnyeneFYpEtNydrZZ+GeKSMd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