Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1424334rwd; Sat, 20 May 2023 21:04:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ54KV4Cht8+O/LR2X+962DC3KUCUQm3gtbEaDP+gw27tGkrtjq/aDskf0wPb/feyJl2O0Gb X-Received: by 2002:a17:90b:238f:b0:24d:f77c:71e7 with SMTP id mr15-20020a17090b238f00b0024df77c71e7mr6435295pjb.41.1684641894430; Sat, 20 May 2023 21:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684641894; cv=none; d=google.com; s=arc-20160816; b=WKyMASSo18ZMo7esugz/KW4lp5U8ryoazeiHHr1RzZ7mamXQ49oDxQA6aPCrRYzIjV z2ntT5AEF814bjMQEE+vRUJq3k50NkTd0UYU2f9mn1gq2ttqr4NYuWCYqVp35CB8Zuda ZhFrbXWzqE5He6tUI7o6N/n0LuSf4aHIB5Xdg1/9a7cZhmBPIK4x+0SH01AYrFAkHakI 3AVgl0sa1CIYKzlQSaWtLl7Pd0TMgQGm1lcqVzVgY1rpGciMoL2VhjQKjgz+T3Vw4RBN 6PwveUxyDsA23X/2nQHzSxiJBKTgL/HDu2xAabvU9LMZaer68mAoxKjtW6N7s4p99h0S mSIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:feedback-id:dkim-signature:dkim-signature; bh=5x449E8xOblw0cWhc2zaiCyBHOICHOXIWTje+n35wtI=; b=c9Oh+JaZARS24rC2iArL9PyJ/N3s+rOZNNyX3Qr2KrWOmBqgZM9wstVEeRoGQrcyxk U75EysfYyswN55ec2rhsethLxpw4KoLOAQZwWqwTuRI9BBHNSzWj2xj+EmAjEHeyyXkg 05aN7Y8hJuPFysepcpUEnfyKBoLo9T66r658N9YlpdNHef1X0K21wSHljPTXatEc2tUv lHIlroN/YqQLFwoZ05ER/sbd2l2Fzey6YF6LDZ3UPc454WG/ASogWqPRR0t5wcz5ZqU1 GX2Mgc0dAxYevlP5HOo5+Wr8O0Xz7sSOYJVuz3qJaBemx1+JTqmlWWN3Z/u3lxLve/+L mVBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=EjtTcWCh; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=G05n+Alt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a17090aea9300b002476173727fsi4581004pjz.26.2023.05.20.21.04.39; Sat, 20 May 2023 21:04:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=EjtTcWCh; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=G05n+Alt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbjEUDWr (ORCPT + 99 others); Sat, 20 May 2023 23:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbjEUDWl (ORCPT ); Sat, 20 May 2023 23:22:41 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 793F5119 for ; Sat, 20 May 2023 20:22:40 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E93155C0073; Sat, 20 May 2023 23:22:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 20 May 2023 23:22:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1684639357; x=1684725757; bh=5x449E8xOblw0cWhc2zaiCyBHOICHOXIWTj e+n35wtI=; b=EjtTcWCh+TATl0B1ppu+eEjmWT6bkd/Z1dLDzpA8brfCmq+zS2M MICMbj7XZ/IUEeRugfbjWi8l9hg/Eqj/m9q1BnyDpDiza4zMRZg2ebbQW6wmiaqk wSjmmpd/EV2tMI3DjxwUYdf0bhCQCI5TlV5wsrqWjBJM2Rmmm7bRg5PffH0JsAXQ Uez4r12kKLLhfQid8sMnXI36N9qRePhiCWc6+AFUUV3auvX6VRzCt8LeCzZd0zsI pRGb8tMF2lsgqRSDFT+vopNd8qDC1dWaJ3mxoaO8VpXauTIFNUBPBJ1hfv8ruwGG 5CMXEGCagyopfcW6fG5phHP94cr/m6t/fjA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1684639357; x=1684725757; bh=5x449E8xOblw0cWhc2zaiCyBHOICHOXIWTj e+n35wtI=; b=G05n+AltallEGNUVXYH17ypowjA8m+ND4dth3mdHO35rYgtI390 x95JOdFUmXj0Va/RthgNlqWBgZbEFDciRxK8omPhaebCusJZtefTljzL/Mn9oSDV emGolvlAZ1AeNRlsYG955vt0ql0CfUH1iQ26uncu5NQx4PaYduNtjd8NpDgXjNYW 91BsKGnH7urKNK7zvcHDtRileZT2FUPU/HyMetndXhw6rEMk5GvjptFVwpD7kPIj 4TVCaWYru1KfgWMz5fd9sPjs4VMyloGxp0nXIUcP2k0ess0dXKuc3ow7jjGEs+SE 5UoVJKOfYWYzwF2aTvJvdBmfEV3aZ83pRyw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeikedgieelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfvfevfhfhufgjtgfgsehtjeertddtfeejnecuhfhrohhmpefurghm uhgvlhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenuc ggtffrrghtthgvrhhnpeejgfffhfdujeeftdeuudeguedttefgieetffffheejuefguedv heejteeftdfftdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 20 May 2023 23:22:36 -0400 (EDT) Message-ID: <51339689-b92f-52fb-9202-2b91733f9180@sholland.org> Date: Sat, 20 May 2023 22:22:36 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux ppc64le; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Content-Language: en-US To: Drew Fustini Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Anup Patel , Alexandre Ghiti References: From: Samuel Holland Subject: Re: riscv: boot failure for 3335068f8721 ("riscv: Use PUD/P4D/PGD pages for the linear mapping") In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Drew, On 5/20/23 21:05, Drew Fustini wrote: > Hello, I tested 6.4-rc1 on an internal RISC-V SoC and observed a boot > failure on a Store/AMO access fault (exception code 7) in __memset(). > stval (e.g. badaddr) was set to 0xffffaf8000000000. This SoC is RV64GC > with Sv48 so it seems that address is the start of the "direct mapping > of all physical memory" [1]. > > The 6.3 release boots okay and the system is able to operate correctly > with an Ubuntu 23.04 rootfs on eMMC. Therefore, I decided to bisect and > I found the failure begins with 3335068f8721 ("riscv: Use PUD/P4D/PGD > pages for the linear mapping"). The system boots okay with the prior > commit 8589e346bbb6 ("riscv: Move the linear mapping creation in its > own function"). > > The boot log [2] shows that the fault happens right after buildroot's > init script [3] uses switch_root to execute init from the Ubuntu rootfs > on the eMMC. > > DWARF4 is enabled in .config [4] and the decoded stack trace [5] shows: > > epc : __memset (/eng/dfustini/gitlab/linux/arch/riscv/lib/memset.S:67) > > From memset.S: > > Line 67: REG_S a1, 0(t0) > > From the oops: > > epc : ffffffff81122d6c ra : ffffffff80218504 sp : ffffaf8002e47500 > gp : ffffffff82695010 tp : ffffaf8002e2ec00 t0 : ffffaf8000000000 > t1 : 0000000000000080 t2 : 0000000000000001 s0 : ffffaf8002e47550 > s1 : ffff8d8200000040 a0 : ffffaf8000000000 a1 : 0000000000000000 > > Thus I think it is trying to store 0x0 to 0xffffaf8000000000 which is > the start of the direct map. From the boot log [2], OpenSBI shows: > > Domain0 Region00 : 0x0000000002080000-0x00000000020bffff M: (I,R,W) S/U: () > Domain0 Region01 : 0x0000008000000000-0x000000800003ffff M: (R,W,X) S/U: () > Domain0 Region02 : 0x0000000002000000-0x000000000207ffff M: (I,R,W) S/U: () > Domain0 Region03 : 0x0000000000000000-0xffffffffffffffff M: (R,W,X) S/U: (R,W,X) > > The DDR memory on this SoC starts at 0x8000000000 with size 2GB. The > memory node from the device tree [6]: > > memory@8000000000 { > device_type = "memory"; > reg = <0x80 0 0x00000000 0x80000000>; > }; > > I think the direct map address 0xffffaf8000000000 would map to physical > address 0x8000000000. Thus I think the attempted store in S-mode to that > address would violate the PMP settings for Region01. > > I do not yet understand why this happens with 3335068f8721 ("riscv: Use > PUD/P4D/PGD pages for the linear mapping") but not for the prior commit > 8589e346bbb6 ("riscv: Move the linear mapping creation in its own > function"). Where does Linux's DTB come from? It should be the one that was modified by OpenSBI to add a reserved-memory node matching PMP Region01 (fdt_reserved_memory_fixup()). Before this commit, Linux ignored the first 2 MiB of physical RAM. So if OpenSBI was loaded in this region, you could get away with ignoring the firmware-provided DTB; now you actually need to use it, as intended. Regards, Samuel