{"id":1449485,"url":"http://patchwork.ozlabs.org/api/patches/1449485/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210309000247.2989531-5-danielwa@cisco.com/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<20210309000247.2989531-5-danielwa@cisco.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20210309000247.2989531-5-danielwa@cisco.com/","date":"2021-03-09T00:02:40","name":"[v2,4/7] CMDLINE: powerpc: convert to generic builtin command line","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"1d8df3c92f3972f94c3cbbe4d9b16cea7b3b3aec","submitter":{"id":67374,"url":"http://patchwork.ozlabs.org/api/people/67374/?format=json","name":"Daniel Walker (danielwa)","email":"danielwa@cisco.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210309000247.2989531-5-danielwa@cisco.com/mbox/","series":[{"id":232859,"url":"http://patchwork.ozlabs.org/api/series/232859/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=232859","date":"2021-03-09T00:02:37","name":"[v2,1/7] CMDLINE: add generic builtin command line","version":2,"mbox":"http://patchwork.ozlabs.org/series/232859/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/1449485/comments/","check":"fail","checks":"http://patchwork.ozlabs.org/api/patches/1449485/checks/","tags":{},"related":[{"id":1460185,"url":"http://patchwork.ozlabs.org/api/patches/1460185/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/e51a16e369f6a7dfae948c6de76061f3a061a375.1617126961.git.danielwa@cisco.com/","msgid":"<e51a16e369f6a7dfae948c6de76061f3a061a375.1617126961.git.danielwa@cisco.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/e51a16e369f6a7dfae948c6de76061f3a061a375.1617126961.git.danielwa@cisco.com/","date":"2021-03-30T17:56:59","name":"[4/8] CMDLINE: powerpc: convert to generic builtin command line","mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/e51a16e369f6a7dfae948c6de76061f3a061a375.1617126961.git.danielwa@cisco.com/mbox/"}],"headers":{"Return-Path":"\n <linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Authentication-Results":["ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=112.213.38.117; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org;\n receiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=cisco.com header.i=@cisco.com header.a=rsa-sha256\n header.s=iport header.b=jKVjU3wa;\n\tdkim-atps=neutral","lists.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=cisco.com header.i=@cisco.com header.a=rsa-sha256\n header.s=iport header.b=jKVjU3wa;\n\tdkim-atps=neutral","lists.ozlabs.org; spf=pass (sender SPF authorized)\n smtp.mailfrom=cisco.com (client-ip=173.37.86.75; helo=rcdn-iport-4.cisco.com;\n envelope-from=danielwa@cisco.com; receiver=<UNKNOWN>)","lists.ozlabs.org; dkim=pass (1024-bit key;\n unprotected) header.d=cisco.com header.i=@cisco.com header.a=rsa-sha256\n header.s=iport header.b=jKVjU3wa; dkim-atps=neutral"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4Dvb7H1kRFz9s1l\n\tfor <patchwork-incoming@ozlabs.org>; Tue,  9 Mar 2021 11:04:59 +1100 (AEDT)","from boromir.ozlabs.org (localhost [IPv6:::1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4Dvb7H0j0sz3ddW\n\tfor <patchwork-incoming@ozlabs.org>; Tue,  9 Mar 2021 11:04:59 +1100 (AEDT)","from rcdn-iport-4.cisco.com (rcdn-iport-4.cisco.com [173.37.86.75])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n bits)) (No client certificate requested)\n by lists.ozlabs.org (Postfix) with ESMTPS id 4Dvb4y73yxz3cbV\n for <linuxppc-dev@lists.ozlabs.org>; Tue,  9 Mar 2021 11:02:58 +1100 (AEDT)","from alln-core-2.cisco.com ([173.36.13.135])\n by rcdn-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA;\n 09 Mar 2021 00:02:55 +0000","from zorba.cisco.com ([10.24.7.91])\n by alln-core-2.cisco.com (8.15.2/8.15.2) with ESMTP id 12902mKe014497;\n Tue, 9 Mar 2021 00:02:54 GMT"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n d=cisco.com; i=@cisco.com; l=5627; q=dns/txt; s=iport;\n t=1615248179; x=1616457779;\n h=from:to:cc:subject:date:message-id:mime-version:\n content-transfer-encoding;\n bh=djAQjtYwrMJu9fxe6w+8d3tJlP2NIiV3K6rQlAajVfs=;\n b=jKVjU3waLnOefUqZgW+xTV5VEWIOF+zRMVj9mvJQRb186qwh1bNrtncA\n oYAXOZ0I4cd5BazMfGJmOiv6ovmn3Cqc7LzAwCsYSV4EvghmOc2twmXMz\n Y/GGhMASeVh74vsFGWJURTjhMnACsN6nlrJZdJ9JlWouLjyZ4BY4XTrSo U=;","X-IronPort-AV":"E=Sophos;i=\"5.81,233,1610409600\"; d=\"scan'208\";a=\"846417787\"","From":"Daniel Walker <danielwa@cisco.com>","To":"Will Deacon <will@kernel.org>,\n Christophe Leroy <christophe.leroy@csgroup.eu>,\n Rob Herring <robh@kernel.org>,\n Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>,\n Andrew Morton <akpm@linux-foundation.org>, x86@kernel.org,\n linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,\n xe-linux-external@cisco.com, Michael Ellerman <mpe@ellerman.id.au>,\n Benjamin Herrenschmidt <benh@kernel.crashing.org>,\n Paul Mackerras <paulus@samba.org>","Subject":"[PATCH v2 4/7] CMDLINE: powerpc: convert to generic builtin command\n 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","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List <linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n <mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n <mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Ruslan Ruslichenko <rruslich@cisco.com>,\n Ruslan Bilovol <rbilovol@cisco.com>, linux-kernel@vger.kernel.org","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n <linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"},"content":"This updates the powerpc code to use the CONFIG_GENERIC_CMDLINE\noption.\n\nCc: xe-linux-external@cisco.com\nSigned-off-by: Ruslan Ruslichenko <rruslich@cisco.com>\nSigned-off-by: Ruslan Bilovol <rbilovol@cisco.com>\nSigned-off-by: Daniel Walker <danielwa@cisco.com>\n---\n arch/powerpc/Kconfig            | 37 +--------------------------------\n arch/powerpc/kernel/prom.c      |  1 +\n arch/powerpc/kernel/prom_init.c | 35 ++++++++++++++++++-------------\n 3 files changed, 23 insertions(+), 50 deletions(-)","diff":"diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig\nindex 107bb4319e0e..276b06d5c961 100644\n--- a/arch/powerpc/Kconfig\n+++ b/arch/powerpc/Kconfig\n@@ -167,6 +167,7 @@ config PPC\n \tselect EDAC_SUPPORT\n \tselect GENERIC_ATOMIC64\t\t\tif PPC32\n \tselect GENERIC_CLOCKEVENTS_BROADCAST\tif SMP\n+\tselect GENERIC_CMDLINE\n \tselect GENERIC_CMOS_UPDATE\n \tselect GENERIC_CPU_AUTOPROBE\n \tselect GENERIC_CPU_VULNERABILITIES\tif PPC_BARRIER_NOSPEC\n@@ -906,42 +907,6 @@ config PPC_DENORMALISATION\n \t  Add support for handling denormalisation of single precision\n \t  values.  Useful for bare metal only.  If unsure say Y here.\n \n-config CMDLINE\n-\tstring \"Initial kernel command string\"\n-\tdefault \"\"\n-\thelp\n-\t  On some platforms, there is currently no way for the boot loader to\n-\t  pass arguments to the kernel. For these platforms, you can supply\n-\t  some command-line options at build time by entering them here.  In\n-\t  most cases you will need to specify the root device here.\n-\n-choice\n-\tprompt \"Kernel command line type\" if CMDLINE != \"\"\n-\tdefault CMDLINE_FROM_BOOTLOADER\n-\n-config CMDLINE_FROM_BOOTLOADER\n-\tbool \"Use bootloader kernel arguments if available\"\n-\thelp\n-\t  Uses the command-line options passed by the boot loader. If\n-\t  the boot loader doesn't provide any, the default kernel command\n-\t  string provided in CMDLINE will be used.\n-\n-config CMDLINE_EXTEND\n-\tbool \"Extend bootloader kernel arguments\"\n-\thelp\n-\t  The command-line arguments provided by the boot loader will be\n-\t  appended to the default kernel command string.\n-\n-config CMDLINE_FORCE\n-\tbool \"Always use the default kernel command string\"\n-\thelp\n-\t  Always use the default kernel command string, even if the boot\n-\t  loader passes other arguments to the kernel.\n-\t  This is useful if you cannot or don't want to change the\n-\t  command-line options your boot loader passes to the kernel.\n-\n-endchoice\n-\n config EXTRA_TARGETS\n \tstring \"Additional default image types\"\n \thelp\ndiff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c\nindex ae3c41730367..96d0a01be1b4 100644\n--- a/arch/powerpc/kernel/prom.c\n+++ b/arch/powerpc/kernel/prom.c\n@@ -27,6 +27,7 @@\n #include <linux/irq.h>\n #include <linux/memblock.h>\n #include <linux/of.h>\n+#include <linux/cmdline.h>\n #include <linux/of_fdt.h>\n #include <linux/libfdt.h>\n #include <linux/cpu.h>\ndiff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c\nindex e9d4eb6144e1..657241534d69 100644\n--- a/arch/powerpc/kernel/prom_init.c\n+++ b/arch/powerpc/kernel/prom_init.c\n@@ -27,6 +27,7 @@\n #include <linux/initrd.h>\n #include <linux/bitops.h>\n #include <linux/pgtable.h>\n+#include <linux/cmdline.h>\n #include <asm/prom.h>\n #include <asm/rtas.h>\n #include <asm/page.h>\n@@ -242,15 +243,6 @@ static int __init prom_strcmp(const char *cs, const char *ct)\n \treturn 0;\n }\n \n-static char __init *prom_strcpy(char *dest, const char *src)\n-{\n-\tchar *tmp = dest;\n-\n-\twhile ((*dest++ = *src++) != '\\0')\n-\t\t/* nothing */;\n-\treturn tmp;\n-}\n-\n static int __init prom_strncmp(const char *cs, const char *ct, size_t count)\n {\n \tunsigned char c1, c2;\n@@ -276,6 +268,20 @@ static size_t __init prom_strlen(const char *s)\n \treturn sc - s;\n }\n \n+static size_t __init prom_strlcpy(char *dest, const char *src, size_t size)\n+{\n+\tsize_t ret = prom_strlen(src);\n+\n+\tif (size) {\n+\t\tsize_t len = (ret >= size) ? size - 1 : ret;\n+\n+\t\tmemcpy(dest, src, len);\n+\t\tdest[len] = '\\0';\n+\t}\n+\treturn ret;\n+}\n+\n+\n static int __init prom_memcmp(const void *cs, const void *ct, size_t count)\n {\n \tconst unsigned char *su1, *su2;\n@@ -304,6 +310,7 @@ static char __init *prom_strstr(const char *s1, const char *s2)\n \treturn NULL;\n }\n \n+#ifdef GENERIC_CMDLINE_NEED_STRLCAT\n static size_t __init prom_strlcat(char *dest, const char *src, size_t count)\n {\n \tsize_t dsize = prom_strlen(dest);\n@@ -323,6 +330,7 @@ static size_t __init prom_strlcat(char *dest, const char *src, size_t count)\n \treturn res;\n \n }\n+#endif\n \n #ifdef CONFIG_PPC_PSERIES\n static int __init prom_strtobool(const char *s, bool *res)\n@@ -775,12 +783,11 @@ static void __init early_cmdline_parse(void)\n \tprom_cmd_line[0] = 0;\n \tp = prom_cmd_line;\n \n-\tif (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && (long)prom.chosen > 0)\n+\tif ((long)prom.chosen > 0)\n \t\tl = prom_getprop(prom.chosen, \"bootargs\", p, COMMAND_LINE_SIZE-1);\n \n-\tif (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || l <= 0 || p[0] == '\\0')\n-\t\tprom_strlcat(prom_cmd_line, \" \" CONFIG_CMDLINE,\n-\t\t\t     sizeof(prom_cmd_line));\n+\tcmdline_add_builtin_custom(prom_cmd_line, (l > 0 ? p : NULL), sizeof(prom_cmd_line),\n+\t\t\t\t\t__prombss, prom_strlcpy, prom_strlcat);\n \n \tprom_printf(\"command line: %s\\n\", prom_cmd_line);\n \n@@ -2706,7 +2713,7 @@ static void __init flatten_device_tree(void)\n \n \t/* Add \"phandle\" in there, we'll need it */\n \tnamep = make_room(&mem_start, &mem_end, 16, 1);\n-\tprom_strcpy(namep, \"phandle\");\n+\tprom_strlcpy(namep, \"phandle\", 8);\n \tmem_start = (unsigned long)namep + prom_strlen(namep) + 1;\n \n \t/* Build string array */\n","prefixes":["v2","4/7"]}