From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 647CC606A31F for ; Sun, 6 Dec 2026 00:23:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.u-boot-project.org header.i=@lists.u-boot-project.org header.a=rsa-sha256 header.s=default header.b=EOHhkv1i; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=ziyao.cc header.i=@ziyao.cc header.a=rsa-sha256 header.s=zmail header.b=iSnDnoIv Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 926BF4072B; Sun, 6 Dec 2026 00:23:49 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id EiFjnzNbaXOR; Sun, 6 Dec 2026 00:23:48 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org 5011D40712 Authentication-Results: smtp4.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796516628; b=fJo/HWECBPPsV5Y2OQALDVvBVdcJSLqIPelhzaI4WQWCk1qKy+Br2iX9LKxHlxyB623y z+6RPb+b11C0xx0zB9j7zmepNwuttfsb8eK+AdiMtwkijou4OEuarcgB1g7vnvBJVmV7n S/JcjGPwfznUywehk16Jidy5oH+G0t1wLjGoFMM9OZGSiO6jAcj/omNcdnkVb0bIjacfr NVIVuj6Tv7KK5rpO73oAZxZGGq13BGCx3TxEezzrQ4N7U3Y+2V2zQ5v4F3y1tTfMWQJJ2 qHFiMUqwBGDAIMRs4WPeio7VDxZWhs6Lt9P6eDYnAsu4oY1XK7TWxz41TAzLqU46yfw== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796516628; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To:X-Zoho-Virus-Status: X-Zoho-AV-Stamp:X-ZohoMailClient:X-BeenThere:X-Mailman-Version: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:Errors-To; bh=g9QWy8dSoAslbv/MzQpKZ1sd2ScpbUsudagf5ivpABg=; b=BQcbpySzmLag1RWklof0ghOSKsYLrOZsPi7g66FQCRiwgicRqR8LHU3sdVnKgdghxGHd ElJk9On3e8APCUtDNfbE6ovjXVtHMr60LQ+T/3jjgw9IzcYlhG7PAMp6doHOl7dmnLDzf Lm8rU4dRmnjf+XgamDr8ACa2/2NC68FiavfIPHHKGS3orsJgvI5KbkeVSt4WEqxpQ1ags 2l3GA+8axe4NWCNE/7S2PyaD0Sq64IWU9vJtOFAubUGZWQUkWDvhTqdDfhg6pagtledka eYug+WdnOk1icxUx7Oy1TL9VIik9L325g+TU7aHivCK0IXksnYgdksHtlk2EFfvsDcQ== ARC-Authentication-Results: i=1; smtp4.osuosl.org; dmarc=pass header.from=ziyao.cc; dkim=pass header.d=ziyao.cc header.i=@ziyao.cc header.a=rsa-sha256 header.s=zmail header.b=iSnDnoIv; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=u-boot-bounces@lists.u-boot-project.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.u-boot-project.org; s=default; t=1796516628; bh=g9QWy8dSoAslbv/MzQpKZ1sd2ScpbUsudagf5ivpABg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EOHhkv1iDWxgJklc+FmMd/0v501GEOkk150v+sLsLEyaK228P2ZsdS6UrT3EqrZT9 SH5htWbv/IGwd3LlZ8gaIxItt7YaKlt/cI+eQbXgX6z3EmzGNV3rta93099SFDsKHG CgMTyvqwkwcZPL5609Onpe/VV5wSDzJNuYzpQN7SUSGoMSfxnFnKwe7cOEoekfbObw XF2ZZ9/ZkB3np6CH2SYQMd27mfICXsU27pjlp1Y6VAhiWX0T6WyHOenv8BGG0ifkU0 4YGDXKk2DTGXB7XPfWNDOEilrXrON3kYxp2jXo3NaZo7JaW9N4oGhTP+zlx999j2PU 1fEIxfSCLikRQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 5011D40712; Sun, 6 Dec 2026 00:23:48 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists1.osuosl.org (Postfix) with ESMTP id 721BD158 for ; Sun, 6 Dec 2026 00:23:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 632DB40712 for ; Sun, 6 Dec 2026 00:23:46 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id KVZubDa-mwfi for ; Sun, 6 Dec 2026 00:23:45 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org 2292A40705 Authentication-Results: smtp4.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.15 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=165.173.180.15; helo=sender6-op-o15.zoho.com; envelope-from=me@ziyao.cc; receiver= Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=ziyao.cc Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=ziyao.cc header.i=@ziyao.cc header.a=rsa-sha256 header.s=zmail header.b=iSnDnoIv Received: from sender6-op-o15.zoho.com (sender6-op-o15.zoho.com [165.173.180.15]) by smtp4.osuosl.org (Postfix) with ESMTPS id 2292A40705 for ; Sun, 6 Dec 2026 00:23:44 +0000 (UTC) DKIM-Signature: a=rsa-sha256; b=iSnDnoIv1LYI2xNLXEKA0ZM9bphrMTvh3x9aSyn+CkLcu957stxFY/yIP1ki0LDQlAxTpy55zKTrQPpmzDC02w/1j/2jvUV6NkNhQLPPRWqngmAYiuzmePxStNKUaFQQ2qonYGNLAieEghqQLUfR6yHl7GNo5GVVO3yD1tIvudk=; c=relaxed/relaxed; s=zmail; d=ziyao.cc; v=1; bh=g9QWy8dSoAslbv/MzQpKZ1sd2ScpbUsudagf5ivpABg=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 179651659549147.48682622623096; Sat, 5 Dec 2026 16:23:15 -0800 (PST) Date: Sun, 6 Dec 2026 00:23:04 +0000 From: Yao Zi To: E Shattow , Yao Zi , Anirudh Srinivasan Cc: u-boot@lists.u-boot-project.org, Tim Ouyang , Leo Liang , Tom Rini , Troy Mitchell Subject: Re: [PATCH v4] riscv: Mark M-IMSIC and M-APLIC nodes as reserved in DT passed to next stage in S mode Message-ID: References: <20261203-mimsic_maplic_fixup-v4-1-41acf30f9b68@oss.tenstorrent.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.28.1.5.5/296.511.11 X-ZohoMailClient: External X-BeenThere: u-boot@lists.u-boot-project.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: U-Boot discussion List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Sat, Dec 05, 2026 at 02:34:02PM -0800, E Shattow wrote: > On 12/5/26 13:54, Yao Zi wrote: > > On Sat, Dec 05, 2026 at 09:40:16AM -0800, E Shattow wrote: > >> Hi Anirudh, > >> > >> Thanks for your patience :) replying my questions. > >> > >> On 12/4/26 06:25, Anirudh Srinivasan wrote: > >>> Hi E, > >>> > >>> On Fri, Dec 4, 2026 at 5:10 AM E Shattow wrote: > >>>> > >>>> Hi Anirudh, > >>>> > >>>> On 12/3/26 08:56, Anirudh Srinivasan wrote: > >>>>> When U-Boot is running in S mode, the DT passed to the next S mode stage > >>>>> can either be the bundled in DT U-Boot and the previous M mode stage > >>>>> use, or be loaded by U-Boot from some boot media. In the former case, > >>>>> the M mode stage can fix up the DT to disable the M-IMSIC and M-APLIC > >>>>> nodes on an AIA system (for example, OpenSBI does this fixup). These > >>>>> controllers are to be managed by M-mode software, so this is done to > >>>>> prevent S mode software from trying to probe them. > >>>>> > >>>> > >>>> The way it reads now (in my point of view) is as: > >>>> > >>>> "M-IMSIC and M-APLIC controllers are to be managed by M-mode software, > >>>> and so enforce any M-mode M-IMSIC and M-APLIC nodes are effectively > >>>> status 'reserved' in S-mode U-Boot with a fixup to the received control > >>> > >>> This is what OpenSBI does. > >>> > >>>> Fdt from preceding M-Mode software (e.g. OpenSBI). Enforce again this > >>>> same fixup when entering the next S-mode kernel to prevent S-mode > >>>> software from trying to probe them. > >>> > >>> We're doing this again here cause we may possibly not use the DT > >>> passed by OpenSBI and use a fresh DT from boot media. > >>> > >>> Regards > >>> Anirudh srinivasan > >> > >> If we did not call out to an M-Mode SBI for the transition to S-Mode > >> then we would be managing these with a fix-up at M-Mode U-Boot SPL when > >> handing off to S-Mode U-Boot main app; I see the problem now, M-Mode > >> U-Boot SPL loads U-Boot main multi-fit image which begins code execution > >> with M-Mode SBI (e.g. OpenSBI or RustSBI, etc.) and we have no domain > >> over the Fdt control state as S-Mode U-Boot main app is loaded and > >> begins code execution because that is done by the 3rd party M-Mode SBI. > >> We again incur this problem exiting from S-Mode U-Boot Main app because > >> there are provisions for a user to again load data to the Fdt for > >> hand-off to the next boot phase. > >> > >> I think it would be appropriate to log a warning (or even log "info" > >> level) that this particular M-mode <=> S-Mode fix-up consistency > >> enforcement is being done, as for example: > >> > >> "Enforce reserved M-mode Fdt property status for handoff to S-Mode kernel: > >> * M-IMSIC okay => reserved > >> * M-APLIC okay => reserved" > >> > >> or when the fix-up is activated but no nodes are changed then as: > >> > >> "Enforce reserved M-mode Fdt property status for handoff to S-Mode > >> kernel: (n/a)" > > > > A message at warning or info level sounds too verbose. A message at > > debug level would indeed help debugging when problems occur. > > > >> Also for consistency we should enforce this twice, at both S-Mode U-Boot > >> main app initialization and at hand-off exiting S-Mode U-Boot main app. > > > > What do you mean by "enforce this twice"? Do you mean to fix up the FDT > > both on entry of the U-Boot proper and on hand-off to the OS? > > > > If my understanding is correct, this doesn't make sense. U-Boot makes no > > use of interrupts, thus imsic/aplic means nothing to it. > > > > Also running the fix-up at the entry of S-mode U-Boot Main app serves as > a user-facing warning when the Fdt is not consistent for the S-mode > operation. That is a hint that the SBI did not do its job. We don't know > all the possible things a user-defined SBI might do so just posture this > as input validation on both the entry to S-mode U-Boot and the hand-off > to exit from S-mode U-Boot. It's not relevant that U-Boot itself has no > interaction with interrupts or what the particular node is, only that it > is a fix-up that enforces M-mode <=> S-mode changeover. We couldn't validate every possible defect in the devicetree in a reasonable way, and I don't see anything different for the IMSIC/APLIC from other devicetree nodes. It's not U-Boot's job to take care of other components' issues. > >> I would like an explicit opt-in / opt-out strategy for the M-mode <=> > >> S-mode Fdt fix-up. A compile-time option is fine, here, and to make this > >> implicit for all RISC-V makes sense to me unless disabled explicitly > >> with "=n".... something so it appears in the .config but that it is a > >> sensible default so we don't require an opt-in. Presumably this is only > >> applicable to RISC-V platform? > > > > It makes sense to have a configurable option, but it should probably be > > off by default. At the time of writing, we don't have a lot of RISC-V > > SoCs implementing IMSIC/APLIC. AFAIK all in-tree RISC-V platforms except > > SpacemiT K3 don't require this fixup, so disabling it by default would > > avoid increase their binary size while keeping the code change minimal. > > > > I consider this as belonging to a group of M-mode <=> S-mode domain > specific Fdt properties that need to be input validated... not specific > to the peripherals or SoC features implemented by those. U-Boot is not even the consumer of this property, it's not U-Boot's job to do the validation. You probably want to add a check to the OS side instead. > >> I think this also would apply to U-Boot SPL, in terms of consistency > >> this fix-up should be instrumented so that you can require it to run > >> when exiting the SPL (but this would of course be disabled when there is > >> an SBI). This should not incur any code size overhead as a config option > >> it would simply not be compiled-in. This gives it an explicit > >> application at build time and be visible in the .config > > > > arch_fixup_fdt() is already invoked in SPL when transferring control to > > Linux. We should probably also do so when transferring control to > > OpenSBI, but this has nothing to do with this patch. Code included in > > this patch only gets executed in S-mode, in which case OpenSBI couldn't > > be invoked at all. > > > > Okay fine with me to keep the scope narrower, but I see nothing here > that restricts this to IMSIC/APLIC hardware features, or to "OpenSBI". > This is logically just input and output validation. See my previous replies, U-Boot isn't responsible for validating stuff about which it doesn't care. > >> With the above suggestions implemented, I think the commit message does > >> not require to mention "OpenSBI" at all. It simply becomes a matter of > >> informing the user and being a consistency enforcement SPL and Main app > >> boot phases. > > > > No, introducing this fixup to both SPL and U-Boot proper has nothing to > > do with the issue it solves. The original problem is that fixups > > performed by M-mode firmware are lost when loading a fresh devicetree, > > and it's good to describe the issue clearly in the commit message. I'm > > fine with this commit message. > > > > The issue IMO is not being addressed by this patch as it is; as-is this > is merely a workaround for a specific circumstance that depends on what > OpenSBI is or is not doing. Replacing devicetrees in the middle of the boot chain is always a dangerous operation, since you'll lose all changes that previous firmware commits. It's impossible to have a generic solution to this, because you couldn't infer the purpose of the changes without overfitting a specific implementation. However, supporting replacing devicetrees does matter, since it does a good job for debugging/development purposes, etc.. Without a generic solution, we could only play the whack-a-mole like this patch, which is probably okay as long as we only cover the common cases, considering that we already have fixups for reserved-memory, etc... > Look at it from the view of M-mode <=> > S-mode input validation and it's clear what to do, and the explanation > doesn't have to be so "what-about-..." explaining what OpenSBI does, > what U-Boot does, when and where. It is simply on every edge where > U-Boot goes M-mode <=> S-Mode we validate and enforce Fdt properties > that need to be adjusted for the new mode, no exceptions or inconsistencies. Generalizing the problem too much doesn't help others to understand what is happening, and this patch isn't going to validate properties. For the reason I've mentioned before, it's not U-Boot's job to validate things of which it doesn't make use. > -E -- Thanks, Yao Zi Meow-mrrp-mrow, I'm a cat.