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 68D70C43334 for ; Mon, 11 Jul 2022 13:10:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B0EE183B8B; Mon, 11 Jul 2022 15:10:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de 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; secure) header.d=gmx.net header.i=@gmx.net header.b="JsIby2no"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CF4A083E60; Mon, 11 Jul 2022 15:10:46 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 350F983965 for ; Mon, 11 Jul 2022 15:10:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657545041; bh=moKLzzqpt8w/UQwPC/bXz0lEkbqziM3wxXfkNC4r9RM=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=JsIby2noz1F/HVER+lJRIExaieFMFzR8oCkxDVgIyFRbeHJSjBTlJT9r80/cHTo5g wzfUXEpi9xwMEEeVvkUeyd2Q0VMlvfHmBmmaYgf6pQEZsXLsnLHYHloVr7p3ywEiqb cvu57mQ4/Z/zEOivwL/g+bMbbCjayJBkbX7lesJo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.67] ([62.143.94.109]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N63VY-1nVI1h09qy-016LMe; Mon, 11 Jul 2022 15:10:41 +0200 Message-ID: Date: Mon, 11 Jul 2022 15:10:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 3/3] doc: environment: Further expand on Image locations and provide example Content-Language: en-US To: Tom Rini Cc: U-Boot Mailing List , Simon Glass 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> From: Heinrich Schuchardt In-Reply-To: <20220711124112.GQ1146598@bill-the-cat> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:hD29uTrEA3Yy1BLizTQXmRDoK8lCvapwufwBYqqgzRduDcDHhpO CipzMzwg3fTOpcK+woAWdpeilLW97vjJkQXfJu9Di2GkbYAYyFg2MZypvU1tkxZZYfCJ1nj 8vhv4dpox7Lq7uRvcgT+s5g+YgrqPbeQxdRMsAGsEb02iXQqvrXA75QAJmDZTaSkxowi0AX tRBWQCbUdKyCkVNOm8yBg== X-UI-Out-Filterresults: notjunk:1;V03:K0:nAEaOw/i8dk=:8U//eV6aEGIRqCRzg5dzVE ZcRK8HuA2e+VoxmWhLCYib6qVuncqVSmamcqWWaBrA1snFW4+fDXLWU+52i6fNkY70j5b+fi4 WXQpXFOpb1+a9BnLeDzYw4citHx9FKFG2I8Qg9bd+2VfjcgymAECAAl7ocX6TDQmSAfNQ8jMv cBIVWukie1PqUrirySXK8hSG8RWD4bYHwk6KkGFa/uqraFgMn1euBMdPBcYCL500Cw57OlCgh lRIvaH1xYd/RSSrtpb8/cTOEVg3SI75zWiDVlMzhSrN7RZsI+un1m1n93o2k8qw5ttRMbMwfo //wM0K0XrRT7amIXf5HexNqOFQpYMXme3d1eOCxv288o2W4sfKJ9uZSZ8AXrDoRMHKElby1mY GWBR4jOhc7UGXSFynX7HsWA1iOAM958JC+uJqfAyQa3/sq822uSp26bq9K/tRBKUjzZq/08Eg OBGeMmiscYRWkJWNQV/rjTJbwqudAgCdqwUvxVUlb3YgclUX8YPWZTMpfRgKAcnEI09tXS1iR IXAIQ8eUQwj/HxYw0si3jKdstYuP4iNqTyzoi34LRdnv59cOqmBLUAjlHALrhZv56Pj6I5u0F oGxdZNyZ5lLydcdmT6tnMGSwyiLsB1ddiWgawDt9Y9OHaCBegAoXC+o/rhTA88uU8UDn8Hjw9 Oq7Rzz8YOfmKSybsG38w6j6fRWVjJ9Yj6/Ko+cFT0tZT3OQs247KNH4m96S/j6YnoJ6emSy8k wg0/fvfH7RoMFWR1kjCj1LInqUnmWvh7VgPJD5GSUIjdy8NemHXjEHPa1s/RNR+gSRynHBfk2 pKdbtAaj585IL0jOhsDyUx1AhMzlAzq6boL0PMwhc/J74HznrqdxwFfAuDJ85osE1j39Vb/zl e5AjOlj8rj5r4XLsw+xJfgE5Jd7RSv1+Kam5qp8pT1V0T5z1Z0x5uIPU67Vowj3dbowpDXdwj hOfeLpnbZVqPOM3x7yIhAbXI2QH0Jgx4hGFp/kKkoT8xiyzJD29N5a0sFpy2uN+vXgRtCc3Ih mQYnPhQeVE+TOaYHZ8TZzUbvE/UyOAG7dGxlYXlp0Qj79VKfTKyE8DeHVIM4vaUKWFQfArW2T PAG/UkwyUm0Sz2HgifVsMCVpB/JOli9ytYse3ZXdjD+0QTsc/XQRzW2wA== 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 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 wrote: >>>>>> >>>>>> Start by elaborating on what some of our constraints tend to be wit= h >>>>>> image location values, and document where these external constraint= s >>>>>> come from. Provide a new subsection, an example based on the TI AR= Mv7 >>>>>> OMAP2PLUS families of chips, that gives sample values and explains = why >>>>>> we use these particular values. This is based on what is in >>>>>> include/configs/ti_armv7_common.h as of fb3ad9bd923d ("TI: Add, use= a >>>>>> DEFAULT_LINUX_BOOT_ENV environment string") as this contains just t= he >>>>>> values referenced in this document now and not some of the further >>>>>> additions that are less generic. >>>>>> >>>>>> Signed-off-by: Tom Rini >>>>>> --- >>>>>> doc/usage/environment.rst | 39 ++++++++++++++++++++++++++++++++= +++++++ >>>>>> 1 file changed, 39 insertions(+) >>>>> >>>>> Reviewed-by: Simon Glass >>>> >>>> Below you want a change? >>> >>> 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 wording >>> or another, or to make when applying. Which is fine with me. >>> >>>>>> diff --git a/doc/usage/environment.rst b/doc/usage/environment.rst >>>>>> index a9a4702632d2..f70ccd6a58ee 100644 >>>>>> --- a/doc/usage/environment.rst >>>>>> +++ b/doc/usage/environment.rst >>>>>> @@ -404,6 +404,42 @@ device tree blob fdtfile fdt_addr_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 >>>>>> >>>>>> +When setting the RAM addresses for `kernel_addr_r`, `fdt_addr_r` a= nd >>>>>> +`ramdisk_addr_r` there are several constraints to keep in mind. Wh= en booting >>>>>> +Linux, the `Booting ARM Linux`_ and `Booting AArch64 Linux`_ docum= ents lay out >>>>>> +the requirements for booting all ARM platforms, including both ali= gnment and >>>>>> +where within memory various things must be. These guidelines tend= to also be >>>>>> +correct for other OSes and unless specifically contradicted by doc= umentation >>>> >>>> What makes you think that BSD or Haiku have the same constraints as L= inux? >>> >>> 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 intended >>> to be general best practices. If you follow this then it's likely >>> anything else will work too. The danger comes from trying to optimize >>> 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 the >>> next iteration. >>> >>>>>> +specific to another architecture, are good rules to follow for oth= er >>>>>> +architectures as well. >>>> >>>> No. RISC-V does not have the same requirements as ARM. E.g. the initr= d >>>> can be located anywhere in memory. >>> >>> Please point to documentation that confirms that, and some otherwise b= ad >>> examples that actually work. >> >> [PATCH 1/1] RISC-V: load initrd wherever it fits into memory >> https://lore.kernel.org/all/20210629134018.62859-1-xypron.glpk@gmx.de/ > > Looks like someone ran in to the first common case of "oops, overwrote > the ramdisk with the kernel bss" or something along those lines. 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. > > 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. 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). The bootefi command will never relocate a kernel or an fdt on any architecture. You just pass the original load addresses. > >> Please, have a look at efi_get_max_initrd_addr() in these files: >> >> 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 >> >> MAX_UNCOMP_KERNEL_SIZE =3D 32 MiB is only enforced in >> drivers/firmware/efi/libstub/arm32-stub.c. > > 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. The decompressor is what follows the EFI stub in the image? > >>>>>> +Example Image locations >>>>>> +^^^^^^^^^^^^^^^^^^^^^^^ >>>> >>>> You seem not to refer to a file 'Image'. >>>> >>>> %s/Image/image/ >>> >>> OK. >>> >>>>>> + >>>>>> +If we take the Texas Instruments OMAP2PLUS family of ARMv7 process= ors as an >>>>>> +example for the above listed variables, we would do:: >>>> >>>> %s/we would do/we chose/ ? >>> >>> Either? I don't see it mattering either way. >>> >>>>>> + >>>>>> + 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 0x80000000= . A 32MiB >>>>> >>>>> Should it say 'We use a 32MiB' ? >>>> >>>> Please, mention that MAX_UNCOMP_KERNEL_SIZE =3D 32 MiB is ARMv7 speci= fic. >>> >>> Sorry? As I understood it last, the maximum size was something like >>> 96MiB before you have to employ some funky tricks. >> >> Look at the use of MAX_UNCOMP_KERNEL_SIZE in handle_kernel_image() of >> the EFI stub (drivers/firmware/efi/libstub/arm32-stub.c). >> >>> >>>>>> +buffer from the start of memory as our default load address, and s= o where the >>>>>> +kernel would also be loaded to. This will hopefully allow for us = to have the >>>> >>>> %s/allow for us/allow/ >>>> >>>>>> +whole of the compressed kernel image exist in memory above where t= he whole of >>>>>> +the decompressed kernel image will be, and allow for a quicker boo= t. Next, we >>> >>> We use 32MiB for the reason I said here. Which is only a slight >>> rewording of the arm32 Linux booting document, and the section starts >>> out by saying this is an example for ARMv7 platforms. >> >> You ask all other architectures to follow this example? > > 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. > >>>> Please, mention that decompressor code otherwise will have to relocat= e >>>> the compressed kernel. >>> >>> 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. >> >> Just look at the comment above the definition of MAX_UNCOMP_KERNEL_SIZE >> in arch/arm/include/asm/efi.h. > > 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. The EFI stub is using the value due to (assumed) restrictions in the decompressor and main kernel. Best regards Heinrich > >>>>>> +say that the device tree will be placed at 128MiB offset from the = start of >>>> >>>> Please, mention that initrd must be >>>> >>>> * within 512 MiB (0x20000000) of the memory start on arm >>>> (which restricts initrd_high) >>>> * in a a 1 GB aligned region of size '1UL << (VA_BITS_MIN - 1)' that >>>> includes the kernel on arm64 >>> >>> No, because this is not intended to list every constraint on ARM32 (no= r >>> arm64, which would benefit from an example that's not TI, as TI arm64 >>> platforms share the same base address for memory). >> >> You ask above to follow the example of ARMv7 on all architectures. Henc= e >> it is necessary to point out the differences. > > No, I'm asking for more examples to be added for each architecture. >