[BUG] Set device tree bootargs failed when DTB does not contain a chosen node.

Vicente Bergas vicencb at gmail.com
Sat Oct 27 03:26:17 PDT 2018


On Sat, Oct 27, 2018 at 12:55 AM Bhupesh Sharma <bhsharma at redhat.com> wrote:
>
> Hi Vicenç,
>
> On Fri, Oct 26, 2018 at 6:42 PM Vicente Bergas <vicencb at gmail.com> wrote:
> >
> > Hello,
> > when executing
> >   kexec -d --dtb dtb_without_chosen_node.dtb --append 'cmdline' --load Image
> > it reports
> >   dtb_set_property: fdt_add_subnode failed: <valid offset/length>
> >   kexec: Set device tree bootargs failed.
> >
> > It has been tested on the arm64 architecture with version v2.0.17 and
> > v2.0.18-rc1
>
> Can you share some details on the underlying platform and kernel
> version you are using?
>
> Looking at the logs, I am assuming you are running 'kexec' on a arm64
> platform (as it depends on creating a dtb to be passed to the 2nd
> kernel).
>
> My general advice is to avoid the --dtb option as it is known to cause
> issues with kexec in the past (see [0] for details)
> Ideally, if you don't use the --dtb option, then kexec will read the existing
> kernel's dtb from /proc/device-tree, and that device tree will include
> all the changes that the boot loader has done, including adding details
> of the available memory in the system.
>
> [0]. https://www.spinics.net/lists/arm-kernel/msg618236.html
>
> Hope this helps.
>
> Regards,
> Bhupesh

Hi Bhupesh, thanks for answering and yes, this helps!

As you say, when not using the --dtb option it works fine. But this
way is not applicable in my use case.

I am trying to use Linux as a bootloader. This bootloader will reside
in a difficult-to-write memory (SPI-NOR Flash) and, because of that,
will rarely be updated.
Over time, new kernel versions will provide updated DTB files, so,
the DT from both kernels will diverge over time.
This is the reason to use the --dtb option.

Thanks for the information you provided, now I see a bug and also a
missing feature.


Focusing on the bug, I have traced it down to here:
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/tree/kexec/dt-ops.c#n87
the result is tested for non-zero as error condition, but, as seen here
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/tree/kexec/libfdt/fdt_rw.c#n345
it looks like positive values are not errors.


Now, focusing on the missing feature.
kexec-tools already has the (buggy) ability to add the "/chosen/bootargs" node.
I assume that it also adds or updates the "/chosen/linux,initrd-start"
and "/chosen/linux,initrd-end" nodes because it has the --initrd option.
Again, I assume it also adds/updates all "/memreserve" nodes with
the location where the DTB and initrd reside in memory.

So, just adding the "/memory" node will make it feature complete.
This node can be populated with data provided from the command line as
parameters or with data extracted from /proc/device-tree.

Adding "/ethernetX/local-mac-address" would be a bonus.


As a side node, can I suggest updating libfdt with latest upstream?
from:
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/tree/kexec/libfdt
to:
https://git.kernel.org/pub/scm/utils/dtc/dtc.git/tree/libfdt

Regards,
  Vicenç



More information about the kexec mailing list