[openwrt/openwrt] realtek: take over boot command line patch into driver

LEDE Commits lede-commits at lists.infradead.org
Sat May 24 12:09:56 PDT 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/897abbfc4a340380ae902f59cbcc0240c55fd7ed

commit 897abbfc4a340380ae902f59cbcc0240c55fd7ed
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Tue May 20 11:11:24 2025 -0400

    realtek: take over boot command line patch into driver
    
    Make it easier to upgrade the kernel in the future. For this remove
    the 320-harden-fw_init_cmdline.patch and add the logic into the
    startup sequence at the right place.
    
    Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
    Link: https://github.com/openwrt/openwrt/pull/18853
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 .../realtek/files-6.6/arch/mips/rtl838x/prom.c     |  8 +++++
 .../patches-6.6/320-harden-fw_init_cmdline.patch   | 38 ----------------------
 2 files changed, 8 insertions(+), 38 deletions(-)

diff --git a/target/linux/realtek/files-6.6/arch/mips/rtl838x/prom.c b/target/linux/realtek/files-6.6/arch/mips/rtl838x/prom.c
index 73dac88b3c..03993ec01d 100644
--- a/target/linux/realtek/files-6.6/arch/mips/rtl838x/prom.c
+++ b/target/linux/realtek/files-6.6/arch/mips/rtl838x/prom.c
@@ -196,6 +196,14 @@ void __init prom_init(void)
 
 	pr_info("SoC Type: %s\n", get_system_type());
 
+	/*
+	 * fw_arg2 is be the pointer to the environment. Some devices (e.g. HP JG924A) hand
+	 * over other than expected kernel boot arguments. Something like 0xfffdffff looks
+	 * suspicous. Do extra cleanup for fw_init_cmdline() to avoid a hang during boot.
+	 */
+	if (fw_arg2 >= CKSEG2)
+		fw_arg2 = 0;
+
 	fw_init_cmdline();
 
 	mips_cpc_probe();
diff --git a/target/linux/realtek/patches-6.6/320-harden-fw_init_cmdline.patch b/target/linux/realtek/patches-6.6/320-harden-fw_init_cmdline.patch
deleted file mode 100644
index d45932b977..0000000000
--- a/target/linux/realtek/patches-6.6/320-harden-fw_init_cmdline.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From e813f48461b8011244b3e7dfe118cf94fd595f0d Mon Sep 17 00:00:00 2001
-From: Markus Stockhausen <markus.stockhausen at gmx.de>
-Date: Sun, 25 Aug 2024 13:09:48 -0400
-Subject: [PATCH] realtek: harden fw_init_cmdline()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Some devices (e.g. HP JG924A) hand over other than expected kernel boot
-arguments. Looking at these one can see:
-
-fw_init_cmdline: fw_arg0=00020000
-fw_init_cmdline: fw_arg1=00060000
-fw_init_cmdline: fw_arg2=fffdffff
-fw_init_cmdline: fw_arg3=0000416c
-
-Especially fw_arg2 should be the pointer to the environment and it looks
-very suspicous. It is not aligned and the address is outside KSEG0 and
-KSEG1. Booting the device will result in a hang. Do better at verifying
-the address.
-
-Signed-off-by: Bjørn Mork <bjorn at mork.no>
-Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
----
- arch/mips/fw/lib/cmdline.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/arch/mips/fw/lib/cmdline.c
-+++ b/arch/mips/fw/lib/cmdline.c
-@@ -31,7 +31,7 @@ void __init fw_init_cmdline(void)
- 	}
- 
- 	/* Validate environment pointer. */
--	if (fw_arg2 < CKSEG0)
-+	if (fw_arg2 < CKSEG0 || fw_arg2 >= CKSEG2)
- 		_fw_envp = NULL;
- 	else
- 		_fw_envp = (int *)fw_arg2;




More information about the lede-commits mailing list