Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2152435pxb; Mon, 8 Mar 2021 16:04:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhzFCTIfNJBrO/g+oPwjM6qzdoP8UlKzJZ2y7GCMG3mz8yKxBIAJc6KM2BdfmuQb1SWO8u X-Received: by 2002:a17:906:d19b:: with SMTP id c27mr17012335ejz.304.1615248280615; Mon, 08 Mar 2021 16:04:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615248280; cv=none; d=google.com; s=arc-20160816; b=qxb08HWm2SKDQoK+OHGZOsDxErbBQD6oK2aLAN1ImU43lxqijpUJ+oFmMxc7h/YFeN xP9T9VCECA1L6FfhoAyZwdRWjbMwdgQkiHr3VPP8KnbyGIut1FfwC2x2bWSyKlw4vfQX onrQZ7h5DozRKEqH6kIZ0G53saApBpDWrPE2OP9v/i3pcclXAdiOdVwgTnU/t/Yk9iAU ZdJPBG9rDyJvNQ2nMbfPRpIwrNXkgvA0D4zsSf3Xje60oEJO8bv8FRavGYlpaiOQd7jo dkOISoCDpyJQ3rBJ/gY1CRos8wim3DHiqMiz+CAjIZZeTVhXGcut0eoPvJ3niaDnY2ZC OIig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=JdWHIzRGmOLt9F3snGySU/cGtM5upjIrGzPUlQLQgBU=; b=e+ZpDVp53GCO1VrBRgbMeCEkzjikJYCUtBPjk6qIzLGsD4lJDDw2b0llgxp1+7khwT YfrjRAWWXhdwhoHhbPld/rI1uu+77aUkeU7xYgIF89xoZedZITfL7pUcQk+jccxlb7hf OGvEqon4xndYkBO3t60ScCwWL6gjfHrI0hvdadG/OlslXenJeWOTdCqbJaogreiHMBQ/ Ri/m4gZmq6G0fFSvuIuuYGGqniUpu4IML16IUypOp3t142EWuLm79GApOWFOlbIgWis0 t0NCVPqlNN40HWPvuwbsk+WbGwCvIbDyl3aq8ZST9552/IEXUewOJQlJ3DWkWHeGw7ax nvkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=bLG5j++1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si3665560edd.479.2021.03.08.16.04.17; Mon, 08 Mar 2021 16:04:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=bLG5j++1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232058AbhCIADT (ORCPT + 99 others); Mon, 8 Mar 2021 19:03:19 -0500 Received: from rcdn-iport-4.cisco.com ([173.37.86.75]:14832 "EHLO rcdn-iport-4.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231986AbhCIAC4 (ORCPT ); Mon, 8 Mar 2021 19:02:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=5627; q=dns/txt; s=iport; t=1615248176; x=1616457776; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=djAQjtYwrMJu9fxe6w+8d3tJlP2NIiV3K6rQlAajVfs=; b=bLG5j++1IH2C3UsTkV6YLV0zJbM1bTf3vjl00xC+HIhVLKwJ0qKDRt9g FqO3n1TZn7YhVSBEPFxM41MF0g73Ln6EsbaYZq0WncceFZA7UBSKXrgSr 2nVhx6TwfLRZ1ZqMsVVTk/j+M13YSxsma/m5W7mHRFVW8rEfdbdd85sJq c=; X-IronPort-AV: E=Sophos;i="5.81,233,1610409600"; d="scan'208";a="846417787" Received: from alln-core-2.cisco.com ([173.36.13.135]) by rcdn-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 09 Mar 2021 00:02:55 +0000 Received: from zorba.cisco.com ([10.24.7.91]) by alln-core-2.cisco.com (8.15.2/8.15.2) with ESMTP id 12902mKe014497; Tue, 9 Mar 2021 00:02:54 GMT From: Daniel Walker To: Will Deacon , Christophe Leroy , Rob Herring , Daniel Gimpelevich , Andrew Morton , x86@kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, xe-linux-external@cisco.com, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Cc: Ruslan Ruslichenko , Ruslan Bilovol , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] CMDLINE: powerpc: convert to generic builtin command line Date: Mon, 8 Mar 2021 16:02:40 -0800 Message-Id: <20210309000247.2989531-5-danielwa@cisco.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Auto-Response-Suppress: DR, OOF, AutoReply X-Outbound-SMTP-Client: 10.24.7.91, [10.24.7.91] X-Outbound-Node: alln-core-2.cisco.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This updates the powerpc code to use the CONFIG_GENERIC_CMDLINE option. Cc: xe-linux-external@cisco.com Signed-off-by: Ruslan Ruslichenko Signed-off-by: Ruslan Bilovol Signed-off-by: Daniel Walker --- arch/powerpc/Kconfig | 37 +-------------------------------- arch/powerpc/kernel/prom.c | 1 + arch/powerpc/kernel/prom_init.c | 35 ++++++++++++++++++------------- 3 files changed, 23 insertions(+), 50 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 107bb4319e0e..276b06d5c961 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -167,6 +167,7 @@ config PPC select EDAC_SUPPORT select GENERIC_ATOMIC64 if PPC32 select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CMDLINE select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC @@ -906,42 +907,6 @@ config PPC_DENORMALISATION Add support for handling denormalisation of single precision values. Useful for bare metal only. If unsure say Y here. -config CMDLINE - string "Initial kernel command string" - default "" - help - On some platforms, there is currently no way for the boot loader to - pass arguments to the kernel. For these platforms, you can supply - some command-line options at build time by entering them here. In - most cases you will need to specify the root device here. - -choice - prompt "Kernel command line type" if CMDLINE != "" - default CMDLINE_FROM_BOOTLOADER - -config CMDLINE_FROM_BOOTLOADER - bool "Use bootloader kernel arguments if available" - help - Uses the command-line options passed by the boot loader. If - the boot loader doesn't provide any, the default kernel command - string provided in CMDLINE will be used. - -config CMDLINE_EXTEND - bool "Extend bootloader kernel arguments" - help - The command-line arguments provided by the boot loader will be - appended to the default kernel command string. - -config CMDLINE_FORCE - bool "Always use the default kernel command string" - help - Always use the default kernel command string, even if the boot - loader passes other arguments to the kernel. - This is useful if you cannot or don't want to change the - command-line options your boot loader passes to the kernel. - -endchoice - config EXTRA_TARGETS string "Additional default image types" help diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index ae3c41730367..96d0a01be1b4 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index e9d4eb6144e1..657241534d69 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -242,15 +243,6 @@ static int __init prom_strcmp(const char *cs, const char *ct) return 0; } -static char __init *prom_strcpy(char *dest, const char *src) -{ - char *tmp = dest; - - while ((*dest++ = *src++) != '\0') - /* nothing */; - return tmp; -} - static int __init prom_strncmp(const char *cs, const char *ct, size_t count) { unsigned char c1, c2; @@ -276,6 +268,20 @@ static size_t __init prom_strlen(const char *s) return sc - s; } +static size_t __init prom_strlcpy(char *dest, const char *src, size_t size) +{ + size_t ret = prom_strlen(src); + + if (size) { + size_t len = (ret >= size) ? size - 1 : ret; + + memcpy(dest, src, len); + dest[len] = '\0'; + } + return ret; +} + + static int __init prom_memcmp(const void *cs, const void *ct, size_t count) { const unsigned char *su1, *su2; @@ -304,6 +310,7 @@ static char __init *prom_strstr(const char *s1, const char *s2) return NULL; } +#ifdef GENERIC_CMDLINE_NEED_STRLCAT static size_t __init prom_strlcat(char *dest, const char *src, size_t count) { size_t dsize = prom_strlen(dest); @@ -323,6 +330,7 @@ static size_t __init prom_strlcat(char *dest, const char *src, size_t count) return res; } +#endif #ifdef CONFIG_PPC_PSERIES static int __init prom_strtobool(const char *s, bool *res) @@ -775,12 +783,11 @@ static void __init early_cmdline_parse(void) prom_cmd_line[0] = 0; p = prom_cmd_line; - if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && (long)prom.chosen > 0) + if ((long)prom.chosen > 0) l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1); - if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || l <= 0 || p[0] == '\0') - prom_strlcat(prom_cmd_line, " " CONFIG_CMDLINE, - sizeof(prom_cmd_line)); + cmdline_add_builtin_custom(prom_cmd_line, (l > 0 ? p : NULL), sizeof(prom_cmd_line), + __prombss, prom_strlcpy, prom_strlcat); prom_printf("command line: %s\n", prom_cmd_line); @@ -2706,7 +2713,7 @@ static void __init flatten_device_tree(void) /* Add "phandle" in there, we'll need it */ namep = make_room(&mem_start, &mem_end, 16, 1); - prom_strcpy(namep, "phandle"); + prom_strlcpy(namep, "phandle", 8); mem_start = (unsigned long)namep + prom_strlen(namep) + 1; /* Build string array */ -- 2.25.1