forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generic: move bootargs patch to generic
Different target (ipq806x, mpc85xx, mediatek, ramips) require the very same patch. Replace these patch with more upstream friendly patch and move to generic. Also drop the redundant config as we can directly check for the presence of the chosen property and the size increase is marginal. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
- Loading branch information
Showing
15 changed files
with
354 additions
and
270 deletions.
There are no files selected for viewing
21 changes: 0 additions & 21 deletions
21
target/linux/generic/hack-6.1/920-device_tree_cmdline.patch
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
target/linux/generic/hack-6.6/920-device_tree_cmdline.patch
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
target/linux/generic/pending-6.1/900-01-docs-dt-Document-new-bootargs-chosen-property.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
From a71b56fdb26ba0e942dda0b780e0c584ccb921d9 Mon Sep 17 00:00:00 2001 | ||
From: Christian Marangi <ansuelsmth@gmail.com> | ||
Date: Fri, 10 May 2024 17:49:42 +0200 | ||
Subject: [PATCH 1/4] docs: dt: Document new bootargs chosen property | ||
|
||
The bootargs property might be overridden by bootloaders on kernel load, | ||
in such scenario, bootargs-override might be used instead. With | ||
bootargs-override set, any value set in bootargs will be ignored. | ||
|
||
The bootargs-append can be used to append additional kernel arguments | ||
to the bootargs property. This can be useful in the context of a | ||
bootargs overridden by the bootloader that contains correct that but | ||
the kernel require additional one to be correctly setup. | ||
|
||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> | ||
--- | ||
Documentation/devicetree/usage-model.rst | 9 +++++++++ | ||
1 file changed, 9 insertions(+) | ||
|
||
diff --git a/Documentation/devicetree/usage-model.rst b/Documentation/devicetree/usage-model.rst | ||
index 0717426856b2..885be3e582fc 100644 | ||
--- a/Documentation/devicetree/usage-model.rst | ||
+++ b/Documentation/devicetree/usage-model.rst | ||
@@ -217,6 +217,15 @@ On ARM, the function setup_machine_fdt() is responsible for early | ||
scanning of the device tree after selecting the correct machine_desc | ||
that supports the board. | ||
|
||
+The bootargs property might be overridden by bootloaders on kernel load, | ||
+in such scenario, bootargs-override might be used instead. With | ||
+bootargs-override set, any value set in bootargs will be ignored. | ||
+ | ||
+The bootargs-append can be used to append additional kernel arguments | ||
+to the bootargs property. This can be useful in the context of a | ||
+bootargs overridden by the bootloader that contains correct that but | ||
+the kernel require additional one to be correctly setup. | ||
+ | ||
2.4 Device population | ||
--------------------- | ||
After the board has been identified, and after the early configuration data | ||
-- | ||
2.43.0 | ||
|
49 changes: 49 additions & 0 deletions
49
...nux/generic/pending-6.1/900-02-of-add-support-for-bootargs-override-chosen-property.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
From ca6be4504e4a2afed8de712d38486bf5f1d2e166 Mon Sep 17 00:00:00 2001 | ||
From: Christian Marangi <ansuelsmth@gmail.com> | ||
Date: Fri, 10 May 2024 17:29:47 +0200 | ||
Subject: [PATCH 2/4] of: add support for bootargs-override chosen property | ||
|
||
On some devices bootloader may hardcoded and overwrite the | ||
bootargs DT property passed in "/chosen" when the kernel is | ||
loaded resulting in the value dropped. | ||
|
||
While CMDLINE_FORCE can be used, this is not a good option for | ||
kernels that are shared across devices. | ||
|
||
This setting enables using "/chosen/bootargs-override" as the | ||
cmdline if it exists in the device tree. | ||
|
||
This broken behaviour was found in various devices from ipq806x Soc, | ||
to Mediatek and even PowerPC. | ||
|
||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> | ||
--- | ||
drivers/of/fdt.c | 12 ++++++++++-- | ||
1 file changed, 10 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c | ||
index a8a04f27915b..253315421591 100644 | ||
--- a/drivers/of/fdt.c | ||
+++ b/drivers/of/fdt.c | ||
@@ -1068,8 +1068,16 @@ int __init early_init_dt_scan_chosen(char *cmdline) | ||
fdt_totalsize(initial_boot_params)); | ||
} | ||
|
||
- /* Retrieve command line */ | ||
- p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
+ /* | ||
+ * Retrieve command line | ||
+ * bootargs might be hardcoded and overwrite by bootloader on | ||
+ * kernel load. | ||
+ * Check if alternative bootargs-override is present instead | ||
+ * first. | ||
+ */ | ||
+ p = of_get_flat_dt_prop(node, "bootargs-override", &l); | ||
+ if (p == NULL || l == 0) | ||
+ p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
if (p != NULL && l > 0) | ||
strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); | ||
|
||
-- | ||
2.43.0 | ||
|
34 changes: 34 additions & 0 deletions
34
...linux/generic/pending-6.1/900-03-of-add-support-for-bootargs-append-chosen-property.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
From 3f43c19d38251226a6b46e5d88690b220212962a Mon Sep 17 00:00:00 2001 | ||
From: Christian Marangi <ansuelsmth@gmail.com> | ||
Date: Fri, 10 May 2024 17:43:41 +0200 | ||
Subject: [PATCH 3/4] of: add support for bootargs-append chosen property | ||
|
||
Add support for bootargs-append chosen property. | ||
|
||
The bootargs-append can be used to append additional kernel arguments | ||
to the bootargs property. This can be useful in the context of a | ||
bootargs overridden by the bootloader that contains correct that but | ||
the kernel require additional one to be correctly setup. | ||
|
||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> | ||
--- | ||
drivers/of/fdt.c | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c | ||
index 253315421591..5d88f3fc2f35 100644 | ||
--- a/drivers/of/fdt.c | ||
+++ b/drivers/of/fdt.c | ||
@@ -1080,6 +1080,9 @@ int __init early_init_dt_scan_chosen(char *cmdline) | ||
p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
if (p != NULL && l > 0) | ||
strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); | ||
+ p = of_get_flat_dt_prop(node, "bootargs-append", &l); | ||
+ if (p != NULL && l > 0) | ||
+ strlcat(cmdline, p, min_t(int, strlen(cmdline) + l, COMMAND_LINE_SIZE)); | ||
|
||
handle_cmdline: | ||
/* | ||
-- | ||
2.43.0 | ||
|
52 changes: 52 additions & 0 deletions
52
target/linux/generic/pending-6.1/900-04-MIPS-add-bootargs-override-property.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
From 5a9f09e72b4fab4b6f4eeab64e636421a371ba8e Mon Sep 17 00:00:00 2001 | ||
From: David Bauer <mail@david-bauer.net> | ||
Date: Thu, 31 Dec 2020 18:49:12 +0100 | ||
Subject: [PATCH 4/4] MIPS: add bootargs-override property | ||
|
||
Add support for the bootargs-override and bootargs-append property | ||
to the chosen node similar to the one used on ipq806x or mpc85xx. | ||
|
||
This is necessary, as the U-Boot used on some boards, notably the | ||
Ubiquiti UniFi 6 Lite, overwrite the bootargs property of the chosen | ||
node leading to a kernel panic on kernel loading (hardcoded root path or | ||
other not compatible thing). | ||
|
||
Signed-off-by: David Bauer <mail@david-bauer.net> | ||
[ rework and simplify implementation, add support for bootargs-append ] | ||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> | ||
--- | ||
arch/mips/kernel/setup.c | 14 +++++++++++++- | ||
1 file changed, 13 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c | ||
index 12a1a4ffb602..3f87bf95c866 100644 | ||
--- a/arch/mips/kernel/setup.c | ||
+++ b/arch/mips/kernel/setup.c | ||
@@ -538,11 +538,23 @@ static int __init bootcmdline_scan_chosen(unsigned long node, const char *uname, | ||
(strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) | ||
return 0; | ||
|
||
- p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
+ /* | ||
+ * Retrieve command line | ||
+ * bootargs might be hardcoded and overwrite by bootloader on | ||
+ * kernel load. | ||
+ * Check if alternative bootargs-override is present instead | ||
+ * first. | ||
+ */ | ||
+ p = of_get_flat_dt_prop(node, "bootargs-override", &l); | ||
+ if (p == NULL || l == 0) | ||
+ p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
if (p != NULL && l > 0) { | ||
bootcmdline_append(p, min(l, COMMAND_LINE_SIZE)); | ||
*dt_bootargs = true; | ||
} | ||
+ p = of_get_flat_dt_prop(node, "bootargs-append", &l); | ||
+ if (p != NULL && l > 0) | ||
+ bootcmdline_append(p, min_t(int, strlen(boot_command_line) + l, COMMAND_LINE_SIZE)); | ||
|
||
return 1; | ||
} | ||
-- | ||
2.43.0 | ||
|
42 changes: 42 additions & 0 deletions
42
target/linux/generic/pending-6.6/900-01-docs-dt-Document-new-bootargs-chosen-property.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
From a71b56fdb26ba0e942dda0b780e0c584ccb921d9 Mon Sep 17 00:00:00 2001 | ||
From: Christian Marangi <ansuelsmth@gmail.com> | ||
Date: Fri, 10 May 2024 17:49:42 +0200 | ||
Subject: [PATCH 1/4] docs: dt: Document new bootargs chosen property | ||
|
||
The bootargs property might be overridden by bootloaders on kernel load, | ||
in such scenario, bootargs-override might be used instead. With | ||
bootargs-override set, any value set in bootargs will be ignored. | ||
|
||
The bootargs-append can be used to append additional kernel arguments | ||
to the bootargs property. This can be useful in the context of a | ||
bootargs overridden by the bootloader that contains correct that but | ||
the kernel require additional one to be correctly setup. | ||
|
||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> | ||
--- | ||
Documentation/devicetree/usage-model.rst | 9 +++++++++ | ||
1 file changed, 9 insertions(+) | ||
|
||
diff --git a/Documentation/devicetree/usage-model.rst b/Documentation/devicetree/usage-model.rst | ||
index 0717426856b2..885be3e582fc 100644 | ||
--- a/Documentation/devicetree/usage-model.rst | ||
+++ b/Documentation/devicetree/usage-model.rst | ||
@@ -217,6 +217,15 @@ On ARM, the function setup_machine_fdt() is responsible for early | ||
scanning of the device tree after selecting the correct machine_desc | ||
that supports the board. | ||
|
||
+The bootargs property might be overridden by bootloaders on kernel load, | ||
+in such scenario, bootargs-override might be used instead. With | ||
+bootargs-override set, any value set in bootargs will be ignored. | ||
+ | ||
+The bootargs-append can be used to append additional kernel arguments | ||
+to the bootargs property. This can be useful in the context of a | ||
+bootargs overridden by the bootloader that contains correct that but | ||
+the kernel require additional one to be correctly setup. | ||
+ | ||
2.4 Device population | ||
--------------------- | ||
After the board has been identified, and after the early configuration data | ||
-- | ||
2.43.0 | ||
|
49 changes: 49 additions & 0 deletions
49
...nux/generic/pending-6.6/900-02-of-add-support-for-bootargs-override-chosen-property.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
From ca6be4504e4a2afed8de712d38486bf5f1d2e166 Mon Sep 17 00:00:00 2001 | ||
From: Christian Marangi <ansuelsmth@gmail.com> | ||
Date: Fri, 10 May 2024 17:29:47 +0200 | ||
Subject: [PATCH 2/4] of: add support for bootargs-override chosen property | ||
|
||
On some devices bootloader may hardcoded and overwrite the | ||
bootargs DT property passed in "/chosen" when the kernel is | ||
loaded resulting in the value dropped. | ||
|
||
While CMDLINE_FORCE can be used, this is not a good option for | ||
kernels that are shared across devices. | ||
|
||
This setting enables using "/chosen/bootargs-override" as the | ||
cmdline if it exists in the device tree. | ||
|
||
This broken behaviour was found in various devices from ipq806x Soc, | ||
to Mediatek and even PowerPC. | ||
|
||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> | ||
--- | ||
drivers/of/fdt.c | 12 ++++++++++-- | ||
1 file changed, 10 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c | ||
index a8a04f27915b..253315421591 100644 | ||
--- a/drivers/of/fdt.c | ||
+++ b/drivers/of/fdt.c | ||
@@ -1068,8 +1068,16 @@ int __init early_init_dt_scan_chosen(char *cmdline) | ||
fdt_totalsize(initial_boot_params)); | ||
} | ||
|
||
- /* Retrieve command line */ | ||
- p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
+ /* | ||
+ * Retrieve command line | ||
+ * bootargs might be hardcoded and overwrite by bootloader on | ||
+ * kernel load. | ||
+ * Check if alternative bootargs-override is present instead | ||
+ * first. | ||
+ */ | ||
+ p = of_get_flat_dt_prop(node, "bootargs-override", &l); | ||
+ if (p == NULL || l == 0) | ||
+ p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
if (p != NULL && l > 0) | ||
strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); | ||
|
||
-- | ||
2.43.0 | ||
|
34 changes: 34 additions & 0 deletions
34
...linux/generic/pending-6.6/900-03-of-add-support-for-bootargs-append-chosen-property.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
From 3f43c19d38251226a6b46e5d88690b220212962a Mon Sep 17 00:00:00 2001 | ||
From: Christian Marangi <ansuelsmth@gmail.com> | ||
Date: Fri, 10 May 2024 17:43:41 +0200 | ||
Subject: [PATCH 3/4] of: add support for bootargs-append chosen property | ||
|
||
Add support for bootargs-append chosen property. | ||
|
||
The bootargs-append can be used to append additional kernel arguments | ||
to the bootargs property. This can be useful in the context of a | ||
bootargs overridden by the bootloader that contains correct that but | ||
the kernel require additional one to be correctly setup. | ||
|
||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> | ||
--- | ||
drivers/of/fdt.c | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c | ||
index 253315421591..5d88f3fc2f35 100644 | ||
--- a/drivers/of/fdt.c | ||
+++ b/drivers/of/fdt.c | ||
@@ -1080,6 +1080,9 @@ int __init early_init_dt_scan_chosen(char *cmdline) | ||
p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
if (p != NULL && l > 0) | ||
strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); | ||
+ p = of_get_flat_dt_prop(node, "bootargs-append", &l); | ||
+ if (p != NULL && l > 0) | ||
+ strlcat(cmdline, p, min_t(int, strlen(cmdline) + l, COMMAND_LINE_SIZE)); | ||
|
||
handle_cmdline: | ||
/* | ||
-- | ||
2.43.0 | ||
|
Oops, something went wrong.