From patchwork Wed Jun 10 16:10:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1307063 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=ti3Q3xgv; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49hsRX2KH2z9sRR for ; Thu, 11 Jun 2020 02:11:03 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TifzwJ4d+MWoUsxrOAg/eXnc7N/8bjwrrUK/TOIPq9U=; b=ti3Q3xgvLqFzsu 9E6+Bof3k0FRaAhnBXV3FogeMi68W1q/KMuGeXbugMSCZaxNEBgOvoqplVh/QAHysh22LGFMVURLz gwevtf1R4R7fKd8DAF2mt1wX3r40ozkCKcr920M5t5bhK4LxW18QCybzmSzbiAsNVL7prFf24ggid z+oMdU8BU24B/j032tMPh+HE8UdaD+NUsB+yBr2BMUJDOd7ASQrjc2Fa9WqqIVKzpXijExX8effdn 2yC4gNxDBl/cer+xHQb/z0wMrbPTAR97X4k44G8WCq8n5xkJ/u552jpZJM1wmjTarbKkk9y1ZV+LI PeFyCTLAlmLkTDXg6+Xw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jj3Jd-0004x1-Na; Wed, 10 Jun 2020 16:11:01 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jj3Ja-0004w6-L2 for openwrt-devel@lists.openwrt.org; Wed, 10 Jun 2020 16:11:00 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id EFB1D3C5D; Wed, 10 Jun 2020 18:10:54 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 7beda870; Wed, 10 Jun 2020 18:10:39 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Wed, 10 Jun 2020 18:10:40 +0200 Message-Id: <20200610161040.8903-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200610_091058_992017_50E2625E X-CRM114-Status: GOOD ( 10.32 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH] mvebu: fix bootloader kernel commandline mangling X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Currently I'm unable to boot initramfs image with `console=ttyS0,115200` kernel commandline as the bootloader mangling resets kernel commandline if there is no `root=` option provided, efectively clearing whatever I pass to the kernel, making the `root=` option mandatory. Signed-off-by: Petr Štetiar --- ...Mangle-bootloader-s-kernel-arguments.patch | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/target/linux/mvebu/patches-5.4/006-mvebu-Mangle-bootloader-s-kernel-arguments.patch b/target/linux/mvebu/patches-5.4/006-mvebu-Mangle-bootloader-s-kernel-arguments.patch index 2f942ea3af63..5969a10a865c 100644 --- a/target/linux/mvebu/patches-5.4/006-mvebu-Mangle-bootloader-s-kernel-arguments.patch +++ b/target/linux/mvebu/patches-5.4/006-mvebu-Mangle-bootloader-s-kernel-arguments.patch @@ -21,10 +21,10 @@ was found, resulting in blank cmdline and failure to boot. Signed-off-by: Michael Gray --- - arch/arm/Kconfig | 11 +++++ - arch/arm/boot/compressed/atags_to_fdt.c | 72 ++++++++++++++++++++++++++++++++- - init/main.c | 16 ++++++++ - 3 files changed, 98 insertions(+), 1 deletion(-) + arch/arm/Kconfig | 11 ++++ + arch/arm/boot/compressed/atags_to_fdt.c | 85 ++++++++++++++++++++++++- + init/main.c | 16 +++++ + 3 files changed, 111 insertions(+), 1 deletion(-) --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -57,7 +57,7 @@ Signed-off-by: Michael Gray #else #define do_extend_cmdline 0 #endif -@@ -67,6 +69,65 @@ static uint32_t get_cell_size(const void +@@ -67,6 +69,72 @@ static uint32_t get_cell_size(const void return cell_size; } @@ -78,7 +78,8 @@ Signed-off-by: Michael Gray + do { + ptr++; + ptr = strchr(ptr, 'r'); -+ if(!ptr) return dest; ++ if (!ptr) ++ goto no_append; + + } while (ptr != str && *(ptr-1) != ' '); + @@ -97,25 +98,31 @@ Signed-off-by: Michael Gray + + /* if append-rootblock property is set use it to append to command line */ + rootblock = getprop(fdt, "/chosen", "append-rootblock", &l); -+ if(rootblock != NULL) { -+ if(*dest != ' ') { -+ *dest = ' '; -+ dest++; -+ len++; -+ } -+ if (len + l + i <= COMMAND_LINE_SIZE) { -+ memcpy(dest, rootblock, l); -+ dest += l - 1; -+ memcpy(dest, ptr, i); -+ dest += i; -+ } -+ } else { -+ len = strlen(str); -+ if (len + 1 < COMMAND_LINE_SIZE) { -+ memcpy(dest, str, len); -+ dest += len; -+ } ++ if (rootblock == NULL) ++ goto no_append; ++ ++ if (*dest != ' ') { ++ *dest = ' '; ++ dest++; ++ len++; ++ } ++ ++ if (len + l + i <= COMMAND_LINE_SIZE) { ++ memcpy(dest, rootblock, l); ++ dest += l - 1; ++ memcpy(dest, ptr, i); ++ dest += i; + } ++ ++ return dest; ++ ++no_append: ++ len = strlen(str); ++ if (len + 1 < COMMAND_LINE_SIZE) { ++ memcpy(dest, str, len); ++ dest += len; ++ } ++ + return dest; +} +#endif @@ -123,7 +130,7 @@ Signed-off-by: Michael Gray static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) { char cmdline[COMMAND_LINE_SIZE]; -@@ -86,12 +147,21 @@ static void merge_fdt_bootargs(void *fdt +@@ -86,12 +154,21 @@ static void merge_fdt_bootargs(void *fdt /* and append the ATAG_CMDLINE */ if (fdt_cmdline) { @@ -145,7 +152,7 @@ Signed-off-by: Michael Gray } *ptr = '\0'; -@@ -166,7 +236,9 @@ int atags_to_fdt(void *atag_list, void * +@@ -166,7 +243,9 @@ int atags_to_fdt(void *atag_list, void * else setprop_string(fdt, "/chosen", "bootargs", atag->u.cmdline.cmdline); @@ -156,7 +163,7 @@ Signed-off-by: Michael Gray if (memcount >= sizeof(mem_reg_property)/4) continue; if (!atag->u.mem.size) -@@ -210,6 +282,10 @@ int atags_to_fdt(void *atag_list, void * +@@ -210,6 +289,10 @@ int atags_to_fdt(void *atag_list, void * setprop(fdt, "/memory", "reg", mem_reg_property, 4 * memcount * memsize); }