901-arm-add-cmdline-override.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --- a/arch/arm/Kconfig
  2. +++ b/arch/arm/Kconfig
  3. @@ -1730,6 +1730,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN
  4. endchoice
  5. +config CMDLINE_OVERRIDE
  6. + bool "Use alternative cmdline from device tree"
  7. + help
  8. + Some bootloaders may have uneditable bootargs. While CMDLINE_FORCE can
  9. + be used, this is not a good option for kernels that are shared across
  10. + devices. This setting enables using "chosen/cmdline-override" as the
  11. + cmdline if it exists in the device tree.
  12. +
  13. config CMDLINE
  14. string "Default kernel command string"
  15. default ""
  16. --- a/drivers/of/fdt.c
  17. +++ b/drivers/of/fdt.c
  18. @@ -1162,6 +1162,17 @@ int __init early_init_dt_scan_chosen(uns
  19. if (p != NULL && l > 0)
  20. strlcat(data, p, min_t(int, strlen(data) + (int)l, COMMAND_LINE_SIZE));
  21. + /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different
  22. + * device tree option of chosen/bootargs-override. This is
  23. + * helpful on boards where u-boot sets bootargs, and is unable
  24. + * to be modified.
  25. + */
  26. +#ifdef CONFIG_CMDLINE_OVERRIDE
  27. + p = of_get_flat_dt_prop(node, "bootargs-override", &l);
  28. + if (p != NULL && l > 0)
  29. + strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
  30. +#endif
  31. +
  32. /*
  33. * CONFIG_CMDLINE is meant to be a default in case nothing else
  34. * managed to set the command line, unless CONFIG_CMDLINE_FORCE
  35. --- a/arch/arm64/Kconfig
  36. +++ b/arch/arm64/Kconfig
  37. @@ -2057,6 +2057,14 @@ config CMDLINE_FORCE
  38. endchoice
  39. +config CMDLINE_OVERRIDE
  40. + bool "Use alternative cmdline from device tree"
  41. + help
  42. + Some bootloaders may have uneditable bootargs. While CMDLINE_FORCE can
  43. + be used, this is not a good option for kernels that are shared across
  44. + devices. This setting enables using "chosen/cmdline-override" as the
  45. + cmdline if it exists in the device tree.
  46. +
  47. config EFI_STUB
  48. bool