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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA247C433EF for ; Mon, 11 Jul 2022 13:20:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 743CD84012; Mon, 11 Jul 2022 15:20:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="nJxcqWPc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2343084013; Mon, 11 Jul 2022 15:20:38 +0200 (CEST) Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3E6848400C for ; Mon, 11 Jul 2022 15:20:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qk1-x72f.google.com with SMTP id b2so1187549qkk.3 for ; Mon, 11 Jul 2022 06:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=d0MdZ5nv25MVnDlVHkneYaVq4HjSNKnnYiwkN9Tb4YA=; b=nJxcqWPce8LiHFlU37oJbAFcZjQuZdwaoxXd6tkr6+eJM+5bh5fONOY2qPq4LhiI55 1aTQSpxvV80PUU9M6eK60uujn5aAcOfCHZV/zYhOMspuL3M0Ot7H9AtJUqBCN/qBm6D7 4ZaZW2fnNhu0TN3/sDVlO0mUXEyknzTw1W9RY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=d0MdZ5nv25MVnDlVHkneYaVq4HjSNKnnYiwkN9Tb4YA=; b=Mkke8O4lvstLQIEScFY8j0DqrEAAbZa9oXNMwX2RQi7+p7wFwlcsKfLhYQ3YsygULh 4qjzamNKZNdlREljAk13PRVnP6r3jEes6ij9D2zIXYhRTUSTIHk7tViCPGGrpvlLKH7i dvCNxUZyeW8YgKXg7m34jmRsz1L15X9WnVAMRfG7wRuv+Qz+dAJ7AzcoPyHXskGSoOG1 RmkdRrug4LMm67/u67AGCB6FnjnMLM2LeZTcwfVGyHoRGGInkbd2yZCGd4hnCkn711jv ffEP13oBHd9LMtnN0o64tMM/xelBI/3J+oJaYtUsivrthfq8tWUaMb8C2UyKQU7omPbR SNcQ== X-Gm-Message-State: AJIora9Q0QGUIR5q/4tRV+2dfCazrxpBs+TLlFLUNjRrdxCS+Tk4SzE9 4RfssDStWja9KpCUNuLaD8B+aw== X-Google-Smtp-Source: AGRyM1v73lYxbUDqjeooFfkLjvcXYyXZIo6nPlJuhMfXwWrahWbLecrgqKsh8LfqpqQhZqtODR6Vlg== X-Received: by 2002:a37:6712:0:b0:6b5:8541:78f7 with SMTP id b18-20020a376712000000b006b5854178f7mr3576036qkc.90.1657545632607; Mon, 11 Jul 2022 06:20:32 -0700 (PDT) Received: from bill-the-cat (cpe-65-184-195-139.ec.res.rr.com. [65.184.195.139]) by smtp.gmail.com with ESMTPSA id q27-20020a37f71b000000b006b249cc505fsm6250968qkj.82.2022.07.11.06.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 06:20:31 -0700 (PDT) Date: Mon, 11 Jul 2022 09:20:29 -0400 From: Tom Rini To: Heinrich Schuchardt Cc: U-Boot Mailing List , Simon Glass Subject: Re: [PATCH 3/3] doc: environment: Further expand on Image locations and provide example Message-ID: <20220711132029.GS1146598@bill-the-cat> References: <20220620143129.1772880-1-trini@konsulko.com> <20220620143129.1772880-3-trini@konsulko.com> <20220710161733.GM1146598@bill-the-cat> <847a24ba-845c-1a4e-f2b7-c4611a27f7bd@gmx.de> <20220711124112.GQ1146598@bill-the-cat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+va490ct0l13Tq8S" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean --+va490ct0l13Tq8S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 11, 2022 at 03:10:36PM +0200, Heinrich Schuchardt wrote: > On 7/11/22 14:41, Tom Rini wrote: > > On Mon, Jul 11, 2022 at 08:42:08AM +0200, Heinrich Schuchardt wrote: > > > On 7/10/22 18:17, Tom Rini wrote: > > > > On Sun, Jul 10, 2022 at 02:26:04PM +0200, Heinrich Schuchardt wrote: > > > > > On 6/30/22 12:06, Simon Glass wrote: > > > > > > On Mon, 20 Jun 2022 at 08:32, Tom Rini wro= te: > > > > > > >=20 > > > > > > > Start by elaborating on what some of our constraints tend to = be with > > > > > > > image location values, and document where these external cons= traints > > > > > > > come from. Provide a new subsection, an example based on the= TI ARMv7 > > > > > > > OMAP2PLUS families of chips, that gives sample values and exp= lains why > > > > > > > we use these particular values. This is based on what is in > > > > > > > include/configs/ti_armv7_common.h as of fb3ad9bd923d ("TI: Ad= d, use a > > > > > > > DEFAULT_LINUX_BOOT_ENV environment string") as this contains = just the > > > > > > > values referenced in this document now and not some of the fu= rther > > > > > > > additions that are less generic. > > > > > > >=20 > > > > > > > Signed-off-by: Tom Rini > > > > > > > --- > > > > > > > doc/usage/environment.rst | 39 ++++++++++++++++++++++++++= +++++++++++++ > > > > > > > 1 file changed, 39 insertions(+) > > > > > >=20 > > > > > > Reviewed-by: Simon Glass > > > > >=20 > > > > > Below you want a change? > > > >=20 > > > > Yes, often Simon does that (and it's fine) to both offer a tag but = if > > > > another iteration is needed to make a minor adjustment to some word= ing > > > > or another, or to make when applying. Which is fine with me. > > > >=20 > > > > > > > diff --git a/doc/usage/environment.rst b/doc/usage/environmen= t.rst > > > > > > > index a9a4702632d2..f70ccd6a58ee 100644 > > > > > > > --- a/doc/usage/environment.rst > > > > > > > +++ b/doc/usage/environment.rst > > > > > > > @@ -404,6 +404,42 @@ device tree blob fdtfile fdt_add= r_r fdt_addr > > > > > > > ramdisk ramdiskfile ramdisk_addr_r ramdisk= _addr > > > > > > > =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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > > > >=20 > > > > > > > +When setting the RAM addresses for `kernel_addr_r`, `fdt_add= r_r` and > > > > > > > +`ramdisk_addr_r` there are several constraints to keep in mi= nd. When booting > > > > > > > +Linux, the `Booting ARM Linux`_ and `Booting AArch64 Linux`_= documents lay out > > > > > > > +the requirements for booting all ARM platforms, including bo= th alignment and > > > > > > > +where within memory various things must be. These guideline= s tend to also be > > > > > > > +correct for other OSes and unless specifically contradicted = by documentation > > > > >=20 > > > > > What makes you think that BSD or Haiku have the same constraints = as Linux? > > > >=20 > > > > Because of what I said, and experience? Now, one may be a subset of > > > > another, but that still means it will work for both. This is inten= ded > > > > to be general best practices. If you follow this then it's likely > > > > anything else will work too. The danger comes from trying to optim= ize > > > > the sizes to be as small as possible, rather than as large/flexible= as > > > > will likely work anywhere. I will try and expand on that idea in t= he > > > > next iteration. > > > >=20 > > > > > > > +specific to another architecture, are good rules to follow f= or other > > > > > > > +architectures as well. > > > > >=20 > > > > > No. RISC-V does not have the same requirements as ARM. E.g. the i= nitrd > > > > > can be located anywhere in memory. > > > >=20 > > > > Please point to documentation that confirms that, and some otherwis= e bad > > > > examples that actually work. > > >=20 > > > [PATCH 1/1] RISC-V: load initrd wherever it fits into memory > > > https://lore.kernel.org/all/20210629134018.62859-1-xypron.glpk@gmx.de/ > >=20 > > Looks like someone ran in to the first common case of "oops, overwrote > > the ramdisk with the kernel bss" or something along those lines. >=20 > Not at all. The ramdisk was relocated by U-Boot unnecessarily to above > 256 MiB after start of RAM and the EFI stub before the patch did not > accept this address for no reason. Then bootm_size / bootm_low should have been set appropriately in U-Boot. > > Which is why I'm asking for more architectures to add good examples of > > where to load each payload in to memory, with explanations of why and > > how big of a gap to have. I _think_ in Linux RISC-V (and hopefully for > > 32bit and 64bit) used the arm64 Image format and so BSS size is > > available in the header and so we can safely check for that overlap and > > relocate rather than fail to boot. Checking for, and avoiding to start > > with, these types of problems is why I want to add the examples. >=20 > I am not aware of any restrictions for the placement of kernel, initrd, > fdt for RISC-V. Therefore there is no need to relocate anything after > loading (without overlap). >=20 > The bootefi command will never relocate a kernel or an fdt on any > architecture. You just pass the original load addresses. Which is all the more reason we need to ensure that the fdt and initrd are placed in appropriately aligned and non-overlapping locations. Because if you put the initrd too close to where the kernel ends up, the BSS will eat your ramdisk before it can go "oh, there's a ramdisk there". That's a practical, not architectural, problem. Same with the device tree. > > > Please, have a look at efi_get_max_initrd_addr() in these files: > > >=20 > > > arch/arm/include/asm/efi.h:73 > > > arch/arm64/include/asm/efi.h:77 > > > arch/loongarch/include/asm/efi.h:36 > > > arch/riscv/include/asm/efi.h:31 > > >=20 > > > MAX_UNCOMP_KERNEL_SIZE =3D 32 MiB is only enforced in > > > drivers/firmware/efi/libstub/arm32-stub.c. > >=20 > > This isn't an EFI thing however. The max uncompressed Linux kernel > > image for arm32 is something along the lines of 96MiB I recall rmk > > telling me when I asked about it at the time. The base+32MiB in the > > example here is for optimal (but not REQUIRED) decompressor location. >=20 > The decompressor is what follows the EFI stub in the image? I'm not talking about EFI at all in this example, as it's 32bit ARM, not 64bit ARM or RISC-V. > > > > > > > +Example Image locations > > > > > > > +^^^^^^^^^^^^^^^^^^^^^^^ > > > > >=20 > > > > > You seem not to refer to a file 'Image'. > > > > >=20 > > > > > %s/Image/image/ > > > >=20 > > > > OK. > > > >=20 > > > > > > > + > > > > > > > +If we take the Texas Instruments OMAP2PLUS family of ARMv7 p= rocessors as an > > > > > > > +example for the above listed variables, we would do:: > > > > >=20 > > > > > %s/we would do/we chose/ ? > > > >=20 > > > > Either? I don't see it mattering either way. > > > >=20 > > > > > > > + > > > > > > > + loadaddr=3D0x82000000 > > > > > > > + kernel_addr_r=3D${loadaddr} > > > > > > > + fdt_addr_r=3D0x88000000 > > > > > > > + ramdisk_addr_r=3D0x88080000 > > > > > > > + bootm_size=3D0x10000000 > > > > > > > + > > > > > > > +To explain this, we start by noting that DRAM starts at 0x80= 000000. A 32MiB > > > > > >=20 > > > > > > Should it say 'We use a 32MiB' ? > > > > >=20 > > > > > Please, mention that MAX_UNCOMP_KERNEL_SIZE =3D 32 MiB is ARMv7 s= pecific. > > > >=20 > > > > Sorry? As I understood it last, the maximum size was something like > > > > 96MiB before you have to employ some funky tricks. > > >=20 > > > Look at the use of MAX_UNCOMP_KERNEL_SIZE in handle_kernel_image() of > > > the EFI stub (drivers/firmware/efi/libstub/arm32-stub.c). > > >=20 > > > >=20 > > > > > > > +buffer from the start of memory as our default load address,= and so where the > > > > > > > +kernel would also be loaded to. This will hopefully allow f= or us to have the > > > > >=20 > > > > > %s/allow for us/allow/ > > > > >=20 > > > > > > > +whole of the compressed kernel image exist in memory above w= here the whole of > > > > > > > +the decompressed kernel image will be, and allow for a quick= er boot. Next, we > > > >=20 > > > > We use 32MiB for the reason I said here. Which is only a slight > > > > rewording of the arm32 Linux booting document, and the section star= ts > > > > out by saying this is an example for ARMv7 platforms. > > >=20 > > > You ask all other architectures to follow this example? > >=20 > > I could have sworn that somewhere within the comments of this series I > > asked for more examples to be added, yes. And I know I intended to > > (since we _need_ them, and I think I've expressed me desire to have them > > before) and I am asking now. > >=20 > > > > > Please, mention that decompressor code otherwise will have to rel= ocate > > > > > the compressed kernel. > > > >=20 > > > > I'm not sure. Perhaps it would be good to also link to some of the > > > > articles expanding upon how Linux on ARM32 boots, as part of more > > > > general documentation, rather than a specific example here. > > >=20 > > > Just look at the comment above the definition of MAX_UNCOMP_KERNEL_SI= ZE > > > in arch/arm/include/asm/efi.h. > >=20 > > Keep in mind this is only vaguely EFI-related. Given how long ago edkII > > for beagleboard was done, it doesn't quite predate EFI on ARM, but this > > example has been in long use for the common non-EFI case on 32bit ARM. >=20 > The EFI stub is using the value due to (assumed) restrictions in the > decompressor and main kernel. OK, but EFI is largely irrelevant to the 32bit ARM case, which is what this example is for. --=20 Tom --+va490ct0l13Tq8S Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmLMI50ACgkQFHw5/5Y0 tyy42wv5AVpUJ/PzHjxOBqtY1veBwYVukxIPwLG/69k/qa/vGPrw+u+4nrRmAGjj 57wzbgaPlF4R349Jm645zvvuSVtWBTjkeNKXJ9Y7CK6toAmNNGhWyJXwJkiYeoWA KsoaWRjM/kV2iMVZ0InQJCsY0ZsY+Mog5+GssK/xwmLdbYfzouWaSbkVGPyRP4WQ CEg7T8BOMnnoJ5YXG3YDmZ241PWKi6pKCUjn6vAsRB74tUOV3ntZoQa3vq4tWKLu 3WvgMspg/jfiqBf9B3qdXkLu/Pmd7IHE3mu0jX9+SFQx7Dl5BEXOhjezsq6TYGlN XI5dwWMA84OkTHIAbB4RjoLhrrQnKJkBcK4H0yf/n4aNZ2uE59EbWQN43f3vzwhp nXNMWMedU0C8Wnwy53N7UPtY5oOA7zNFZvPtw1S9bjUbN4+FiCk/1wiJI/6j4HPG Q5U2PrIsRnQgJKsw5GUJ2wnSTL5izDHM/bX+/S9n3UYrRr/XBfQCaZvCflw5RiHU PddODMSY =Uf90 -----END PGP SIGNATURE----- --+va490ct0l13Tq8S--