[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL_JsqJ2x7zbyP3fAacdfHOWjCVjg6XhraV2YkoBJdZ2jXAMEA@mail.gmail.com>
Date: Tue, 15 Jun 2021 08:01:35 -0600
From: Rob Herring <robh@...nel.org>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Lakshmi Ramasubramanian <nramas@...ux.microsoft.com>,
Mimi Zohar <zohar@...ux.ibm.com>,
Thiago Jung Bauermann <bauerman@...ux.ibm.com>,
AKASHI Takahiro <takahiro.akashi@...aro.org>,
Greg KH <gregkh@...uxfoundation.org>,
Will Deacon <will@...nel.org>, Joe Perches <joe@...ches.com>,
Catalin Marinas <catalin.marinas@....com>,
Michael Ellerman <mpe@...erman.id.au>,
Stephen Rothwell <sfr@...b.auug.org.au>,
James Morse <james.morse@....com>,
Sasha Levin <sashal@...nel.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Frank Rowand <frowand.list@...il.com>,
Vincenzo Frascino <vincenzo.frascino@....com>,
Mark Rutland <mark.rutland@....com>, dmitry.kasatkin@...il.com,
James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
Pavel Tatashin <pasha.tatashin@...een.com>,
Allison Randal <allison@...utok.net>,
Masahiro Yamada <masahiroy@...nel.org>,
Matthias Brugger <mbrugger@...e.com>,
Hsin-Yi Wang <hsinyi@...omium.org>, tao.li@...o.com,
Christophe Leroy <christophe.leroy@....fr>,
Prakhar Srivastava <prsriva@...ux.microsoft.com>,
balajib@...ux.microsoft.com,
linux-integrity <linux-integrity@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@...r.kernel.org>,
linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>
Subject: Re: [PATCH v19 05/13] of: Add a common kexec FDT setup function
On Tue, Jun 15, 2021 at 6:18 AM Geert Uytterhoeven <geert@...ux-m68k.org> wrote:
>
> Hi Lakshmi and Rob,
>
> On Sun, Feb 21, 2021 at 6:52 PM Lakshmi Ramasubramanian
> <nramas@...ux.microsoft.com> wrote:
> > From: Rob Herring <robh@...nel.org>
> >
> > Both arm64 and powerpc do essentially the same FDT /chosen setup for
> > kexec. The differences are either omissions that arm64 should have
> > or additional properties that will be ignored. The setup code can be
> > combined and shared by both powerpc and arm64.
> >
> > The differences relative to the arm64 version:
> > - If /chosen doesn't exist, it will be created (should never happen).
> > - Any old dtb and initrd reserved memory will be released.
> > - The new initrd and elfcorehdr are marked reserved.
> > - "linux,booted-from-kexec" is set.
> >
> > The differences relative to the powerpc version:
> > - "kaslr-seed" and "rng-seed" may be set.
> > - "linux,elfcorehdr" is set.
> > - Any existing "linux,usable-memory-range" is removed.
> >
> > Combine the code for setting up the /chosen node in the FDT and updating
> > the memory reservation for kexec, for powerpc and arm64, in
> > of_kexec_alloc_and_setup_fdt() and move it to "drivers/of/kexec.c".
> >
> > Signed-off-by: Rob Herring <robh@...nel.org>
> > Signed-off-by: Lakshmi Ramasubramanian <nramas@...ux.microsoft.com>
>
> > --- /dev/null
> > +++ b/drivers/of/kexec.c
>
> > +/*
> > + * of_kexec_alloc_and_setup_fdt - Alloc and setup a new Flattened Device Tree
> > + *
> > + * @image: kexec image being loaded.
> > + * @initrd_load_addr: Address where the next initrd will be loaded.
> > + * @initrd_len: Size of the next initrd, or 0 if there will be none.
> > + * @cmdline: Command line for the next kernel, or NULL if there will
> > + * be none.
> > + * @extra_fdt_size: Additional size for the new FDT buffer.
> > + *
> > + * Return: fdt on success, or NULL errno on error.
> > + */
> > +void *of_kexec_alloc_and_setup_fdt(const struct kimage *image,
> > + unsigned long initrd_load_addr,
> > + unsigned long initrd_len,
> > + const char *cmdline, size_t extra_fdt_size)
> > +{
>
> > + /* Did we boot using an initrd? */
> > + prop = fdt_getprop(fdt, chosen_node, "linux,initrd-start", NULL);
> > + if (prop) {
> > + u64 tmp_start, tmp_end, tmp_size;
> > +
> > + tmp_start = fdt64_to_cpu(*((const fdt64_t *) prop));
> > +
> > + prop = fdt_getprop(fdt, chosen_node, "linux,initrd-end", NULL);
> > + if (!prop) {
> > + ret = -EINVAL;
> > + goto out;
> > + }
> > +
> > + tmp_end = fdt64_to_cpu(*((const fdt64_t *) prop));
>
> Some kernel code assumes "linux,initrd-{start,end}" are 64-bit,
> other code assumes 32-bit.
It can be either. The above code was a merge of arm64 and powerpc both
of which use 64-bit and still only runs on those arches. It looks like
some powerpc platforms may use 32-bit, but this would have been broken
before.
The code in drivers/of/fdt.c handles either case. We should probably
refactor early_init_dt_check_for_initrd() and this function to use a
common routine.
> linux/Documentation/arm/uefi.rst says 64-bit,
> dt-schema/schemas/chosen.yaml says 32-bit.
We should fix that.
Rob
Powered by blists - more mailing lists