Patch "of: fdt: Honor CONFIG_CMDLINE* even without /chosen node, take 2" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    of: fdt: Honor CONFIG_CMDLINE* even without /chosen node, take 2

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     of-fdt-honor-config_cmdline-even-without-chosen-node.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 5eece547bd36776908d82ffb3ce1120ad84408d7
Author: Rob Herring <robh@xxxxxxxxxx>
Date:   Tue Jan 3 12:00:32 2023 -0600

    of: fdt: Honor CONFIG_CMDLINE* even without /chosen node, take 2
    
    [ Upstream commit 064e32dc5b03114d0767893fecdaf7b5dfd8c286 ]
    
    I do not read a strict requirement on /chosen node in either ePAPR or in
    Documentation/devicetree. Help text for CONFIG_CMDLINE and
    CONFIG_CMDLINE_EXTEND doesn't make their behavior explicitly dependent on
    the presence of /chosen or the presense of /chosen/bootargs.
    
    However the early check for /chosen and bailing out in
    early_init_dt_scan_chosen() skips CONFIG_CMDLINE handling which is not
    really related to /chosen node or the particular method of passing cmdline
    from bootloader.
    
    This leads to counterintuitive combinations (assuming
    CONFIG_CMDLINE_EXTEND=y):
    
    a) bootargs="foo", CONFIG_CMDLINE="bar" => cmdline=="foo bar"
    b) /chosen missing, CONFIG_CMDLINE="bar" => cmdline==""
    c) bootargs="", CONFIG_CMDLINE="bar" => cmdline==" bar"
    
    Rework early_init_dt_scan_chosen() so that the cmdline config options are
    always handled.
    
    [commit msg written by Alexander Sverdlin]
    
    Cc: Alexander Sverdlin <alexander.sverdlin@xxxxxxxxx>
    Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Cc: Arnd Bergmann <arnd@xxxxxxxx>
    Tested-by: Geoff Levand <geoff@xxxxxxxxxxxxx>
    Reviewed-by: Alexander Sverdlin <alexander.sverdlin@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20230103-dt-cmdline-fix-v1-2-7038e88b18b6@xxxxxxxxxx
    Signed-off-by: Rob Herring <robh@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 4f88e8bbdd27..f08b25195ae7 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1163,18 +1163,32 @@ int __init early_init_dt_scan_chosen(char *cmdline)
 	if (node < 0)
 		node = fdt_path_offset(fdt, "/chosen@0");
 	if (node < 0)
-		return -ENOENT;
+		/* Handle the cmdline config options even if no /chosen node */
+		goto handle_cmdline;
 
 	chosen_node_offset = node;
 
 	early_init_dt_check_for_initrd(node);
 	early_init_dt_check_for_elfcorehdr(node);
 
+	rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
+	if (rng_seed && l > 0) {
+		add_bootloader_randomness(rng_seed, l);
+
+		/* try to clear seed so it won't be found. */
+		fdt_nop_property(initial_boot_params, node, "rng-seed");
+
+		/* update CRC check value */
+		of_fdt_crc32 = crc32_be(~0, initial_boot_params,
+				fdt_totalsize(initial_boot_params));
+	}
+
 	/* Retrieve command line */
 	p = of_get_flat_dt_prop(node, "bootargs", &l);
 	if (p != NULL && l > 0)
 		strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
 
+handle_cmdline:
 	/*
 	 * CONFIG_CMDLINE is meant to be a default in case nothing else
 	 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
@@ -1195,18 +1209,6 @@ int __init early_init_dt_scan_chosen(char *cmdline)
 
 	pr_debug("Command line is: %s\n", (char *)cmdline);
 
-	rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
-	if (rng_seed && l > 0) {
-		add_bootloader_randomness(rng_seed, l);
-
-		/* try to clear seed so it won't be found. */
-		fdt_nop_property(initial_boot_params, node, "rng-seed");
-
-		/* update CRC check value */
-		of_fdt_crc32 = crc32_be(~0, initial_boot_params,
-				fdt_totalsize(initial_boot_params));
-	}
-
 	return 0;
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux