[PATCH v2] of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify
Rob Herring
robh at kernel.org
Mon Oct 28 10:33:51 PDT 2024
On Mon, Oct 28, 2024 at 10:41 AM Will Deacon <will at kernel.org> wrote:
>
> On Wed, Oct 23, 2024 at 06:14:26PM +0100, Usama Arif wrote:
> > __pa() is only intended to be used for linear map addresses and using
> > it for initial_boot_params which is in fixmap for arm64 will give an
> > incorrect value. Hence save the physical address when it is known at
> > boot time when calling early_init_dt_scan for arm64 and use it at kexec
> > time instead of converting the virtual address using __pa().
> >
> > Reported-by: Breno Leitao <leitao at debian.org>
> > Suggested-by: Mark Rutland <mark.rutland at arm.com>
> > Signed-off-by: Usama Arif <usamaarif642 at gmail.com>
> > Fixes: ac10be5cdbfa ("arm64: Use common of_kexec_alloc_and_setup_fdt()")
> > ---
> > v1 -> 2:
> > - pass dt_phys in early_init_dt_scan instead of creating
> > anorther arch->dt function (Rob Herring)
> > ---
> > arch/arc/kernel/devtree.c | 2 +-
> > arch/arm/kernel/devtree.c | 2 +-
> > arch/arm64/kernel/setup.c | 6 +++++-
> > arch/csky/kernel/setup.c | 4 ++--
> > arch/loongarch/kernel/setup.c | 2 +-
> > arch/microblaze/kernel/prom.c | 2 +-
> > arch/mips/kernel/prom.c | 2 +-
> > arch/mips/kernel/relocate.c | 2 +-
> > arch/nios2/kernel/prom.c | 4 ++--
> > arch/openrisc/kernel/prom.c | 2 +-
> > arch/powerpc/kernel/dt_cpu_ftrs.c | 2 +-
> > arch/powerpc/kernel/prom.c | 2 +-
> > arch/powerpc/platforms/pseries/plpks.c | 2 +-
> > arch/riscv/kernel/setup.c | 2 +-
> > arch/sh/kernel/setup.c | 2 +-
> > arch/um/kernel/dtb.c | 2 +-
> > arch/x86/kernel/devicetree.c | 2 +-
> > arch/xtensa/kernel/setup.c | 2 +-
> > drivers/of/fdt.c | 14 ++++++++------
> > drivers/of/kexec.c | 2 +-
> > include/linux/of_fdt.h | 5 +++--
> > 21 files changed, 36 insertions(+), 29 deletions(-)
> >
> > diff --git a/arch/arc/kernel/devtree.c b/arch/arc/kernel/devtree.c
> > index 4c9e61457b2f..cc6ac7d128aa 100644
> > --- a/arch/arc/kernel/devtree.c
> > +++ b/arch/arc/kernel/devtree.c
> > @@ -62,7 +62,7 @@ const struct machine_desc * __init setup_machine_fdt(void *dt)
> > const struct machine_desc *mdesc;
> > unsigned long dt_root;
> >
> > - if (!early_init_dt_scan(dt))
> > + if (!early_init_dt_scan(dt, __pa(dt)))
> > return NULL;
> >
> > mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach);
> > diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
> > index fdb74e64206a..3b78966e750a 100644
> > --- a/arch/arm/kernel/devtree.c
> > +++ b/arch/arm/kernel/devtree.c
> > @@ -200,7 +200,7 @@ const struct machine_desc * __init setup_machine_fdt(void *dt_virt)
> >
> > mdesc_best = &__mach_desc_GENERIC_DT;
> >
> > - if (!dt_virt || !early_init_dt_verify(dt_virt))
> > + if (!dt_virt || !early_init_dt_verify(dt_virt, __pa(dt_virt)))
> > return NULL;
> >
> > mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach);
> > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> > index b22d28ec8028..177262739c49 100644
> > --- a/arch/arm64/kernel/setup.c
> > +++ b/arch/arm64/kernel/setup.c
> > @@ -175,7 +175,11 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
> > if (dt_virt)
> > memblock_reserve(dt_phys, size);
> >
> > - if (!dt_virt || !early_init_dt_scan(dt_virt)) {
> > + /*
> > + * dt_virt is a fixmap address, hence __pa(dt_virt) can't be used.
> > + * Pass dt_phys directly.
> > + */
> > + if (!dt_virt || !early_init_dt_scan(dt_virt, dt_phys)) {
>
> nit: It looks like early_init_dt_verify() will now return false if
> !dt_virt, so we can drop the additional check here.
That was true before, but I'll fix this up when applying.
Rob
More information about the linux-riscv
mailing list