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 73511606A31F for ; Sat, 5 Dec 2026 22:34:39 +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=HDLGURhv; dkim=pass (2048-bit key, unprotected) header.d=freeshell.de header.i=@freeshell.de header.a=rsa-sha256 header.s=s2025 header.b=NBpVIHlJ Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4076B4059C; Sat, 5 Dec 2026 22:34:39 +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 HJZrq-muZzEX; Sat, 5 Dec 2026 22:34:38 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org C1826405B8 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=1796510077; b=SAK+LRUKB7FJZLSGEC4r0a4oCcxGHT3aB3abbNISmOqKa3jgLxtMwMp5afO7boHGOYyR p0lkoU1qIJnKNZqZgNXunkJeJ+bXlkd72dvl37sn8t4n8t1jh+hF7bCWDOo7tG3mRW0/I X9LYAD0u2SCsPhko/qStobe7otUhEJulYZRXzWtzRmkrGGSwHP2IowqrpYsWEpLlGb3Lk Xm0qnWld+K6ceqViIdBSc9pQz2MxH76dpljxVujgGxkvqZQT1EHzbMIl2tdoMjsa5MNdf FS1aBBVbuN023ABfAZuH0tt1MN6DaLOuyPAo9UEnFAsl8YfgnREjn3NwIXuJm4fHRPw== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796510077; 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:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-BeenThere:X-Mailman-Version: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:Errors-To; bh=1gdhOu6IIgZvOiRRBO3WktJju3f5/65pCCmjazcjmm8=; b=T0ftmT1g+huNCBgIAd0h4QETSTz906ISjgMietX7SaHJdalIWbA7ighb7IZLo/ikjxs7 UiUrHqdctbSZ4iKGa+/pFQSxCcMBLvGffahpnzebkBtPZJs2KAVCNB3d+mYHkB85GVJP2 dBKB0MSrP2I5HgiuGZT4skKaiHnnPVm7FqNfBcKtuOqPw5+sb0JOq3hpqDHCosJPZIExe ZMaATFZk/ahuW9jKhiX6Rm66H0yFi3jH0qhA2CJmeNIO5viL2vqMRTdBc9HfVKY9ciFxg 6aLxZK4tKF8EnsWD5SGcBUYhkFH2qw7PHqGnVRed0MdIZJX23hsuFCOtDoXvrS04sDw== ARC-Authentication-Results: i=1; smtp4.osuosl.org; 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=1796510077; bh=1gdhOu6IIgZvOiRRBO3WktJju3f5/65pCCmjazcjmm8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=HDLGURhvqytKUySSHJaeK/Hk2tZzC1Sdzoy3KcNsSJoM+xQS9m+sgp0Tb8IVPDso9 GyDOwN15Xtb/6Jsgk97tpTyXMvDmaPdG3mpBfVoBOi92iKPVlklfwFELl1NV7O0LAG 2BN+h0mPbM7Va+WtS057cWfP3nolFy+enp/dL4sKlv/LcvU3L7uboka1BycAldDdWW We6Bs6OqKGr1yazIPnZvarsBP1u9bglFiGLDlH3/TyccGK7PrefLa9epVwLUgNWfe/ i3beK6fo2Ld5GZOdS5MaxN48DXOGrMeEStxKr2GBgQOWk3jXIPlfonts+fUgsRtnNX 097113yi5QkZQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id C1826405B8; Sat, 5 Dec 2026 22:34:37 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists1.osuosl.org (Postfix) with ESMTP id CF823325 for ; Sat, 5 Dec 2026 22:34:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B41E840052 for ; Sat, 5 Dec 2026 22:34:36 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id sS_KqE-kSSLG for ; Sat, 5 Dec 2026 22:34:35 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp2.osuosl.org 5D22040050 Authentication-Results: smtp2.osuosl.org; arc=none smtp.remote-ip=116.202.128.144 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=116.202.128.144; helo=freeshell.de; envelope-from=e@freeshell.de; receiver= Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=reject dis=none) header.from=freeshell.de Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=freeshell.de header.i=@freeshell.de header.a=rsa-sha256 header.s=s2025 header.b=NBpVIHlJ Received: from freeshell.de (freeshell.de [116.202.128.144]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5D22040050 for ; Sat, 5 Dec 2026 22:34:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freeshell.de; s=s2025; t=1796510048; bh=1gdhOu6IIgZvOiRRBO3WktJju3f5/65pCCmjazcjmm8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NBpVIHlJbFpcKr0tUqBINE3lO4dMddOOLRmUlR8vw9UGYm1Ao/F+FSNQpVvIkcE9V XGbttuKEiYJDzq2NnrS0p9CVhtHtrdiiR1yJES+nxOLijlJN5Le+w2vt0I04MYZVZo evu5I5vMeTdcfDZeKZewauX/r9//alfthrjNUUY5tp245jzn8klwTkU9RvGNPtrHwg 6kexT9RSbmUcvt+fBMs+RX/RvbziOdkbiG5sV6s0vuW93vMhSdn37C3eUlKc0TGW+m /qlt+JZsXzR1j4E16WcP8GbtYFIn4vbqIduPECYM6cFwMl4HzCDl/pYiroyXMSAeac 1Sn49tbWyWmZg== Received: from [IPV6:2605:59ca:364f:d400:1b91:6b30:22c2:fffc] (unknown [IPv6:2605:59ca:364f:d400:1b91:6b30:22c2:fffc]) (Authenticated sender: e) by freeshell.de (Postfix) with ESMTPSA id AD748B2215B4; Sat, 5 Dec 2026 23:34:06 +0100 (CET) Message-ID: Date: Sat, 5 Dec 2026 14:34:02 -0800 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4] riscv: Mark M-IMSIC and M-APLIC nodes as reserved in DT passed to next stage in S mode To: Yao Zi , Anirudh Srinivasan Cc: u-boot@lists.u-boot-project.org, Tim Ouyang , Leo Liang , Tom Rini , Troy Mitchell References: <20261203-mimsic_maplic_fixup-v4-1-41acf30f9b68@oss.tenstorrent.com> Content-Language: en-US From: E Shattow In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=-7.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,USER_AGENT_SANE_1 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 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. >> 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. >> 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. >> 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. 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. -E