[PATCH] fdt_support.c: Allow late kernel cmdline modification

Tom Rini trini at konsulko.com
Wed Feb 24 14:51:06 CET 2021


On Tue, Feb 23, 2021 at 08:33:36AM +0200, Niko Mauno wrote:
> On 2/22/21 10:21 PM, Tom Rini wrote:
> > On Mon, Feb 22, 2021 at 07:18:51PM +0000, Niko Mauno wrote:
> > 
> > > By declaring board-specific board_fdt_chosen_bootargs() the kernel
> > > command line arguments can be adjusted before injecting to flat dt
> > > chosen node.
> > > 
> > > Signed-off-by: Niko Mauno <niko.mauno at vaisala.com>
> > > ---
> > >   common/fdt_support.c  | 12 +++++++++++-
> > >   include/fdt_support.h | 10 ++++++++++
> > >   2 files changed, 21 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/common/fdt_support.c b/common/fdt_support.c
> > > index 08d540bfc8..4379507e30 100644
> > > --- a/common/fdt_support.c
> > > +++ b/common/fdt_support.c
> > > @@ -269,6 +269,15 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end)
> > >   	return 0;
> > >   }
> > > +/**
> > > + * board_fdt_chosen_bootargs - boards may override this function to use
> > > + *                             alternative kernel command line arguments
> > > + */
> > > +__weak char *board_fdt_chosen_bootargs(void)
> > > +{
> > > +	return env_get("bootargs");
> > > +}
> > > +
> > >   int fdt_chosen(void *fdt)
> > >   {
> > >   	int   nodeoffset;
> > > @@ -286,7 +295,8 @@ int fdt_chosen(void *fdt)
> > >   	if (nodeoffset < 0)
> > >   		return nodeoffset;
> > > -	str = env_get("bootargs");
> > > +	str = board_fdt_chosen_bootargs();
> > > +
> > >   	if (str) {
> > >   		err = fdt_setprop(fdt, nodeoffset, "bootargs", str,
> > >   				  strlen(str) + 1);
> > 
> > What's this look like in practice?  I'm very wary about changing "set
> > bootargs to what you pass to the kernel" logic that's been there for
> > forever and a constant of every platform.  Thanks!
> > 
> Hi Tom,
> 
>    Effectively this change as such should introduce no changes to prevalent
> "bootargs" logic when an overriding board_fdt_chosen_bootargs() is not
> defined. Our motivation for proposing this change is that it provides us
> with a means to introduce an entry point where we can append rootfs specific
> dm-verity kernel command line metrics (such as described in
> https://www.kernel.org/doc/html/latest/admin-guide/device-mapper/verity.html)
> by reading a property from within a kernel tier FIT image header, in order
> to facilitate secure boot process all the way to root filesystem.

Right.  But what does that logic look like, and why must it be done in
C?  People have used dm-verity with U-Boot for ages, for example.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210224/63563ee3/attachment.sig>


More information about the U-Boot mailing list