Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4178262rwo; Tue, 25 Jul 2023 01:42:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlHxyJVdlk572lVXPjYh80lUOfR9+mTMO0cOE37N9PS5Do2O1c1tx1XGdPbQAt+0+hVKo7mP X-Received: by 2002:a2e:880a:0:b0:2b7:bb73:b6e5 with SMTP id x10-20020a2e880a000000b002b7bb73b6e5mr8173187ljh.27.1690274528572; Tue, 25 Jul 2023 01:42:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690274528; cv=none; d=google.com; s=arc-20160816; b=W6yeHWj9wPHYHMwOPoKwQy5GR/EE6rURCZGeCMKI7KWPOoNaeC/oTRLFpSL/rzsR4I awHjMmx5hhaaN6QkCMuGmEJHxHYZX/dNCz5g+r4szhDvo2RSlB5Vc9ZK9LOhodmPnKwh /HPHfvXpeE2aBS1u7tgusLLH6fA2Ji1rPRbarEo4IbluKazy41EWRLzB3yekTSp6nbKj RQCILnCw+OaIaHXBehcTbZthWnYfYUbBIvmg2tNdNIkGJwR8SfyrbkftRl/KFM4LUD9q ky83qE+rGNy4bdoTWgLj25L7GUu4ciTFgbk2Tz8ZpiTEr01uIJj9n0SB813swAj/qZ21 dKyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Qy1+b1K519FpXkmyThSnFmRzN6pFlVKnNg610BuI7MA=; fh=hYpHNoyvJqmlnKD0CnSRRKHihzNQ3cOJFA1QnTSt+rU=; b=PghS4vNQsn7qGRyzh0OS1ueDdCKfhrnJlW8/E9FyIJ4rhI/3o9Tqm73KhFATBc6VJm z2eQtRll3g9hSF8ncxj+Jx5q0eHlw8x9Lq1TmNJKlZxqM7sIwY0vjIQAHXlIsSYnl6yN Xnchy37pbIdV7p/ZRqjgOjnYBzEWmUJOpAqAJEdSzROmWgckGZH7lUWnp+H98BSPcJ2+ qxyKatvOmelciflNkOJHCzpdL4iUFtQLPvYmJ9ob6xl7EXkZy3eSBhHf8yw2U4AHGNmB X1XWzi7lpivp6bT/DYapcuwynjoBYvhh3esKA+d8JU5Z0TDgWDJsXg5FvhG7emQpb07C Vr9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Y1Y741t+; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a1709060e5200b00988479dc7f1si7277065eji.764.2023.07.25.01.41.43; Tue, 25 Jul 2023 01:42:08 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Y1Y741t+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232327AbjGYHh0 (ORCPT + 99 others); Tue, 25 Jul 2023 03:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232317AbjGYHhM (ORCPT ); Tue, 25 Jul 2023 03:37:12 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 543041BE1 for ; Tue, 25 Jul 2023 00:35:23 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31759e6a4a1so1719378f8f.3 for ; Tue, 25 Jul 2023 00:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1690270515; x=1690875315; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Qy1+b1K519FpXkmyThSnFmRzN6pFlVKnNg610BuI7MA=; b=Y1Y741t+P9RDREXrYmfmRP7Im2iZvT/2t5X35M4FEgebyODy107yyHKGzzduzu7oVs 7i7TfIq5srzIjlwZKmlX3jZroJNfrnIQ1x68Be5+BvAhpQdR4Lt22LovPXgMPbV9CvK2 MHMegHGW8CQq5bNmZmYHk41U8oYO5rmNDaJmqnbL1jYGv4UPPQch0g8RH5W0u8LP9JPF I1P5aCQNGqjfe/Ucg4/kCJP2NiPByg0tB4y96td55gv7I751Dg+TsoK2I117gid6PH94 VCx5HJ/z/ewrUd2Qjq0BOpLjjqMuwTAJgjyAoTZvxaNdqhXFaJOYXH/276CJxZzmv3MQ lE7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690270515; x=1690875315; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qy1+b1K519FpXkmyThSnFmRzN6pFlVKnNg610BuI7MA=; b=eo+lttYTT/N4cKwp5wqgHK8wW+cMNRhuyTlrmI8VtBKACrVqbkaOaq17aO4XtVaT+y 1FDYix5EV3b8Pa6IjGkm2IqkjCfpn+X1XBeTOXHO5Qvfvf2extuRBZ2rUBgilI1z7BDQ 02SYj+TzA01R9xktYehkwIM+5yjT8q+YWFcAgecZfwgfNXfraXwUFuaFZrjjpoQqtfnY 9+wiS5s7PaQ3cPmD/is3ZX3kJ98tTfxuR5AjpEbay1EKPwANBgAxGHtCGr/oj04p16RF yPITtFLsj9uPLufz4Z7lFWOhhQmm08aCYRJrXY22CGoW+u/P31L6y5ebFTruZPc19Bem qxeg== X-Gm-Message-State: ABy/qLak41A4CVRM6U6Bt7KXtKIumZ3FJZo1Pgo9djKd6FHAyxrJFNMA vAamPL3LH/h6p+gY2rXNJ3NnzY7gBuJqlNzXFuPxFg== X-Received: by 2002:a5d:4e12:0:b0:317:69d2:35c2 with SMTP id p18-20020a5d4e12000000b0031769d235c2mr1018661wrt.2.1690270514987; Tue, 25 Jul 2023 00:35:14 -0700 (PDT) MIME-Version: 1.0 References: <20230722113445.630714-1-alexghiti@rivosinc.com> <20230722113445.630714-2-alexghiti@rivosinc.com> In-Reply-To: From: Alexandre Ghiti Date: Tue, 25 Jul 2023 09:35:04 +0200 Message-ID: Subject: Re: [PATCH v5 2/3] Documentation: riscv: Add early boot document To: Randy Dunlap Cc: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Andrew Jones , Conor Dooley , Sunil V L , Song Shuai , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Atish Patra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 Randy, On Sat, Jul 22, 2023 at 10:19=E2=80=AFPM Randy Dunlap wrote: > > Hi, > > On 7/22/23 04:34, Alexandre Ghiti wrote: > > This document describes the constraints and requirements of the early > > boot process in a RISC-V kernel. > > > > Signed-off-by: Alexandre Ghiti > > Reviewed-by: Bj=C3=B6rn T=C3=B6pel > > Reviewed-by: Conor Dooley > > Reviewed-by: Sunil V L > > Reviewed-by: Andrew Jones > > Reviewed-by: Palmer Dabbelt > > Reviewed-by: Atish Patra > > Reviewed-by: Song Shuai > > Acked-by: Palmer Dabbelt > > --- > > - Changes in v5: > > * Rebase on top of docs-next > > > > Documentation/riscv/boot-image-header.rst | 3 - > > Documentation/riscv/boot.rst | 169 ++++++++++++++++++++++ > > Documentation/riscv/index.rst | 1 + > > 3 files changed, 170 insertions(+), 3 deletions(-) > > create mode 100644 Documentation/riscv/boot.rst > > > > > diff --git a/Documentation/riscv/boot.rst b/Documentation/riscv/boot.rs= t > > new file mode 100644 > > index 000000000000..f890ac442c91 > > --- /dev/null > > +++ b/Documentation/riscv/boot.rst > > @@ -0,0 +1,169 @@ > > +.. SPDX-License-Identifier: GPL-2.0 > > + > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > +RISC-V Kernel Boot Requirements and Constraints > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > +:Author: Alexandre Ghiti > > +:Date: 23 May 2023 > > + > > +This document describes what the RISC-V kernel expects from bootloader= s and > > +firmware, but also the constraints that any developer must have in min= d when > > I would s/but/and/. Ok I change that, thanks. > > > +touching the early boot process. For the purposes of this document, th= e > > +``early boot process`` refers to any code that runs before the final v= irtual > > +mapping is set up. > > + > > +Pre-kernel Requirements and Constraints > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > +The RISC-V kernel expects the following of bootloaders and platform fi= rmware: > > + > > +Register state > > +-------------- > > + > > +The RISC-V kernel expects: > > + > > + * ``$a0`` to contain the hartid of the current core. > > + * ``$a1`` to contain the address of the devicetree in memory. > > + > > +CSR state > > +--------- > > + > > +The RISC-V kernel expects: > > + > > + * ``$satp =3D 0``: the MMU, if present, must be disabled. > > + > > +Reserved memory for resident firmware > > +------------------------------------- > > + > > +The RISC-V kernel must not map any resident memory, or memory protecte= d with > > +PMPs, in the direct mapping, so the firmware must correctly mark those= regions > > +as per the devicetree specification and/or the UEFI specification. > > + > > +Kernel location > > +--------------- > > + > > +The RISC-V kernel expects to be placed at a PMD boundary (2MB aligned = for rv64 > > +and 4MB aligned for rv32). Note that the EFI stub will physically relo= cate the > > +kernel if that's not the case. > > + > > +Hardware description > > +-------------------- > > + > > +The firmware can pass either a devicetree or ACPI tables to the RISC-V= kernel. > > + > > +The devicetree is either passed directly to the kernel from the previo= us stage > > +using the ``$a1`` register, or when booting with UEFI, it can be passe= d using the > > +EFI configuration table. > > + > > +The ACPI tables are passed to the kernel using the EFI configuration t= able. In > > +this case, a tiny devicetree is still created by the EFI stub. Please = refer to > > +"EFI stub and devicetree" section below for details about this devicet= ree. > > + > > +Kernel entrance > > +--------------- > > How about "entry" instead of "entrance"? I have to admit that I don't have the nuance between both words, if 'entry' is more appropriate, I'll change it. > > > + > > +On SMP systems, there are 2 methods to enter the kernel: > > + > > +- ``RISCV_BOOT_SPINWAIT``: the firmware releases all harts in the kern= el, one hart > > + wins a lottery and executes the early boot code while the other hart= s are > > + parked waiting for the initialization to finish. This method is most= ly used to > > + support older firmwares without SBI HSM extension and M-mode RISC-V = kernel. > > +- ``Ordered booting``: the firmware releases only one hart that will e= xecute the > > + initialization phase and then will start all other harts using the S= BI HSM > > + extension. The ordered booting method is the preferred booting metho= d for > > + booting the RISC-V kernel because it can support cpu hotplug and kex= ec. > > preferably s/cpu/CPU/ Done! > > > + > > +UEFI > > +---- > > [snip] > > I can't say how correct the documentation is, but it is well-written > and has no issues with punctuation, grammar, or spelling AFAICT, so > you can take this if you want it: > > Reviewed-by: Randy Dunlap Thanks for the nice comments, @Conor Dooley (and others) really helped! I'll respin a new version today, Alex > > thanks. > -- > ~Randy