Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1263776pxb; Thu, 4 Mar 2021 07:19:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgDe+a+ix8dZ7bGD2LuSyI83eZXvAH6AZaZHm0bCN8BOmaP6g4gdMoUwleKYz8YAd29ems X-Received: by 2002:a50:f38f:: with SMTP id g15mr4862217edm.262.1614871173187; Thu, 04 Mar 2021 07:19:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614871173; cv=none; d=google.com; s=arc-20160816; b=BqtiP14hRPONeUBMRDi6YagOhsIwfb3lxwns1qadap+kxwd35mId6jKjXVDOwnJWHR evJ6hmGkcDvQsDZ8sXOMBIxK1fRyN9eStRXsJOyyNieS9DeZJaxNQX+n0ZUAQ6L0xpji mKb+/dD5TqMYy3QD2gCQJVORowjZJN6K/TY1xk9GpzwVmj+tOFo9/fZjHzY07GqNndUz MvOdiqu36mT56MjqHdk1Y5EinjWdHJDkW9cEP4ezgSrA0UiZzSN+XJk+0VXtW5NuWcRR e/Vor1puGK2FskJ3bSI1iXpQu7xux0wgMjIvBswTzBGIL5fOK9WISUMTkvZs3SJuci2l yopA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=OZSnRIwht8Z9ZYxf/AnUdmn9eqq5s1Zxw+vWBAYDcg8=; b=QqWGTqWulMRWOGt+7jScAe26lwpKv9O09ojrWEwOKGmGCX0geFk5lSePJfBQ9NKD4Y udG3+tMpU6FZWPUHa4nvUeFu2OKlyAm5vmPpPT4UGmZ6CsjT6uEcsI+rQ9Otpa/ETTff yjfoXqGBlmeG5PVP0t+pJOZtv+gg3Wy/JLwTXLLKu1inJ1BgVvzg9RTUqaEMJBQPw89k pQrsqojue1Npv11a183V/EBLi1tLUyZ8wzHb+wqoD0wDoahCUKOGCvzp6/4NdeIxdp8w YzB2DyDY2t/yuBjtxbu52QdXl7UcY/J3VRlqw0+l+pN3f7B7YCNU4WabNUh5196uI+MU lh9g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si17877998ejx.654.2021.03.04.07.19.10; Thu, 04 Mar 2021 07:19:33 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236294AbhCDHXK (ORCPT + 99 others); Thu, 4 Mar 2021 02:23:10 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:21764 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236296AbhCDHXG (ORCPT ); Thu, 4 Mar 2021 02:23:06 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4Drj4H0dHjz9v1DN; Thu, 4 Mar 2021 08:22:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 4-HQ5vnGd-Fz; Thu, 4 Mar 2021 08:22:23 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4Drj4G45TMz9v1DM; Thu, 4 Mar 2021 08:22:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DDE638B7F6; Thu, 4 Mar 2021 08:22:23 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id X-M_5o0sT4hk; Thu, 4 Mar 2021 08:22:23 +0100 (CET) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E4A288B773; Thu, 4 Mar 2021 08:22:22 +0100 (CET) Subject: Re: [PATCH 3/5] CMDLINE: powerpc: convert to generic builtin command line To: Daniel Walker , Will Deacon , ob Herring , Daniel Gimpelevich , Andrew Morton , x86@kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Cc: xe-linux-external@cisco.com, Ruslan Ruslichenko , Ruslan Bilovol , linux-kernel@vger.kernel.org References: <20210304044803.812204-3-danielwa@cisco.com> From: Christophe Leroy Message-ID: Date: Thu, 4 Mar 2021 08:22:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210304044803.812204-3-danielwa@cisco.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 04/03/2021 à 05:48, Daniel Walker a écrit : > This updates the powerpc code to use the CONFIG_GENERIC_CMDLINE > option. Should be split in two patches. The change of strcpy to strlcpy should go in a first patch. > > 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 | 31 +++++++++++++++------------ > 3 files changed, 20 insertions(+), 49 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..d752be688b62 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,19 @@ 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; > @@ -778,9 +783,9 @@ static void __init early_cmdline_parse(void) > if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && (long)prom.chosen > 0) You have removed CONFIG_CMDLINE_FORCE and the generic cmdline doesn't provide it. > 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)); > + if (l <= 0 || p[0] == '\0') /* dbl check */ So it means cmdline_add_builtin_custom() is only called when bootloader does not provide bootargs ? > + cmdline_add_builtin_custom(prom_cmd_line, NULL, sizeof(prom_cmd_line), > + __prombss, &prom_strlcpy, &prom_strlcat); > > prom_printf("command line: %s\n", prom_cmd_line); > > @@ -2706,7 +2711,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 */ >