Thread (19 messages) 19 messages, 4 authors, 2021-02-08

Re: [PATCH v16 11/12] powerpc: Use OF alloc and free for FDT

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2021-02-08 04:14:10
Also in: linux-devicetree, linux-integrity, linuxppc-dev, lkml

Rob Herring [off-list ref] writes:
On Thu, Feb 4, 2021 at 10:42 AM Lakshmi Ramasubramanian
[off-list ref] wrote:
...
quoted
diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c
index d0e459bb2f05..51d2d8eb6c1b 100644
--- a/arch/powerpc/kexec/elf_64.c
+++ b/arch/powerpc/kexec/elf_64.c
@@ -19,6 +19,7 @@
 #include <linux/kexec.h>
 #include <linux/libfdt.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/of_fdt.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -32,7 +33,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
        unsigned int fdt_size;
        unsigned long kernel_load_addr;
        unsigned long initrd_load_addr = 0, fdt_load_addr;
-       void *fdt;
+       void *fdt = NULL;
        const void *slave_code;
        struct elfhdr ehdr;
        char *modified_cmdline = NULL;
@@ -103,18 +104,12 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
        }

        fdt_size = fdt_totalsize(initial_boot_params) * 2;
-       fdt = kmalloc(fdt_size, GFP_KERNEL);
+       fdt = of_alloc_and_init_fdt(fdt_size);
        if (!fdt) {
                pr_err("Not enough memory for the device tree.\n");
                ret = -ENOMEM;
                goto out;
        }
-       ret = fdt_open_into(initial_boot_params, fdt, fdt_size);
-       if (ret < 0) {
-               pr_err("Error setting up the new device tree.\n");
-               ret = -EINVAL;
-               goto out;
-       }

        ret = setup_new_fdt_ppc64(image, fdt, initrd_load_addr,
The first thing this function does is call setup_new_fdt() which first
calls of_kexec_setup_new_fdt(). (Note, I really don't understand the
PPC code split. It looks like there's a 32-bit and 64-bit split, but
32-bit looks broken to me. Nothing ever calls setup_new_fdt() except
setup_new_fdt_ppc64()).
I think that's because 32-bit doesn't support kexec_file_load().

cheers

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help