Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1635506img; Tue, 19 Mar 2019 12:01:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLP0Ao3o0yz1bYGxQnPi63e59WERhLdOhikDDeIGNrRvBbaCq9wmqsmtI3LwjjfYcJYZ48 X-Received: by 2002:a63:f80f:: with SMTP id n15mr3666375pgh.283.1553022090203; Tue, 19 Mar 2019 12:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553022090; cv=none; d=google.com; s=arc-20160816; b=LlO1ZRyJh5fVTdGeroEf7MYEGODVARMWwaXv5V1F6+3SygnN9c1fcLasOzkpLHKg2b f9XO30+M8u/ojC23BoVZtUuH1uuHE/dfEDzTF7W8Vjn8+Vq4VaRvUte5PvUPnsYNsfgy djcIZsW5aHx6RKUz0Xa07Ee05X7svE38pDSoVCaxchfhjQepjk+KfXqLzGH84BPwAIQg iPwydJu5flBAHv9y6A4cmAeeoPw3Z3tjKmgbWH6mT3lTOPOEyCuTccluE0LWNaMIOYlJ kfXBUSDxTGrb3tLCsP6zQphRKGtedXPR9vz/ARDcYy8PGMGcRDLPB/QAN4u3wdIzyrXs bKrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5lUqc+Swh9o0CejkysxlY1LeLlKmcQ1HHKlsfPbnuxU=; b=UnZJFYVaeu8VFz2741j3cktLb+iAakQ61A9HwTcHE4yrf0z79RpjO0QakiqjbeAqaG 9f2t2QegbhsF7OynaStQQ0eVtis77ZYDe2ktheQo/FHaw9jSobrOj42nVSPJajLLGj4i nAGM7/KF4ziaXKu2Bql7qMBV8KLkI2+rnRmS9gUsovqrxx35Mn3O9umPqxUFRoNxhcEc I8q9TbaEdLp0hH6nyYO+EYuaBG8uj/qYVm9kEbeeDy53LbTdGThKJmyYQpFUr7cL4q2o 2T+ymkE+uTeyelrA+UlWGC9b1LRJIWv9Roh/t4OWONk/XQZdJr7vlBTbfElM+Qb43QeV 7haQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=BX3y2Ik9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 1si11688499plk.311.2019.03.19.12.01.13; Tue, 19 Mar 2019 12:01:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=BX3y2Ik9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727099AbfCSS66 (ORCPT + 99 others); Tue, 19 Mar 2019 14:58:58 -0400 Received: from rcdn-iport-4.cisco.com ([173.37.86.75]:26863 "EHLO rcdn-iport-4.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726753AbfCSS65 (ORCPT ); Tue, 19 Mar 2019 14:58:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=5762; q=dns/txt; s=iport; t=1553021937; x=1554231537; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=D0ic8t9YQG0FE69Ze9uqsg8+HQwii9+DcwRCgK6ja1s=; b=BX3y2Ik9jSCbjjD4yUIVRfsxrQoUIl2nwqWzSblyW49K34QweTuB1dNY vaPi+bUCqxXo55qRf36Rtmjp/HqhAS3M0U8pAIuBLwpGsaVPpTpeGejpS L0BVHRk79VpfjjDyOcwWSd/aMb+nxldJrPcZEvN7fBUv0iQQFVspjpt95 E=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AHAADCO5Fc/4gNJK1jGQEBAQEBAQE?= =?us-ascii?q?BAQEBAQcBAQEBAQGBUwIBAQEBAQsBghBoUDMnl1OCDY4/iXOBewsBASOERAM?= =?us-ascii?q?CAoRrIjYHDQEBAwEBCQEDAm0cDIVLAQUyAUYQCxIGCSUPLQ0OBoM2gXUPrAS?= =?us-ascii?q?KLxQOgQ0BizEXgUA/gRGDEoMeBBiHKAOKHIIahWaSTQmCS4USi0MlDIFwhXK?= =?us-ascii?q?LcIwjhGSNCAIEBgUCFYFNATGBVjMaCBsVO4JsCYINF4hfhV8fAzCNFCqCIwE?= =?us-ascii?q?B?= X-IronPort-AV: E=Sophos;i="5.60,245,1549929600"; d="scan'208";a="537168065" Received: from alln-core-3.cisco.com ([173.36.13.136]) by rcdn-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 19 Mar 2019 18:58:56 +0000 Received: from zorba ([10.41.50.85]) by alln-core-3.cisco.com (8.15.2/8.15.2) with ESMTPS id x2JIws9T032440 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 19 Mar 2019 18:58:56 GMT Date: Tue, 19 Mar 2019 11:58:56 -0700 From: Daniel Walker To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , xe-linux-external@cisco.com, linux-kernel@vger.kernel.org, Maksym Kokhan , Daniel Walker , Andrew Morton , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 2/3] powerpc: convert to generic builtin command line Message-ID: <20190319185856.zncq3f7naymoeobu@zorba> References: <1551469472-53043-3-git-send-email-danielwa@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) X-Auto-Response-Suppress: DR, OOF, AutoReply X-Outbound-SMTP-Client: 10.41.50.85, [10.41.50.85] X-Outbound-Node: alln-core-3.cisco.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 04, 2019 at 03:26:59PM +0100, Christophe Leroy wrote: > > > Le 01/03/2019 ? 20:44, Daniel Walker a ?crit?: > > This updates the powerpc code to use the CONFIG_GENERIC_CMDLINE > > option. > > Please explain more in details how each powerpc option is replaced by one of > the generic options. CMDLINE is replace by two options to either which allow static options to either be appended or prepended to the boot loader arguemnts. If you wanted a lateral changes you would only fill in CONFIG_CMDLINE_PREPEND. CONFIG_CMDLINE_OVERRIDE does the same as CMDLINE_FORCE, only with the append and prepend arguemnts merged without the boot loader arguments. > > --- a/arch/powerpc/kernel/prom.c > > +++ b/arch/powerpc/kernel/prom.c > > @@ -34,6 +34,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > @@ -716,6 +717,9 @@ void __init early_init_devtree(void *params) > > */ > > of_scan_flat_dt(early_init_dt_scan_chosen_ppc, boot_command_line); > > + /* append and prepend any arguments built into the kernel. */ > > + cmdline_add_builtin(boot_command_line, NULL, COMMAND_LINE_SIZE); > > + > > I don't think it is worth an implementation as complex as in the previous > patch just for the above line. > Could easily define the temporary buffer in this file directely, then just > locally do: > > strlcpy(temp_buff, CONFIG_CMDLINE_PREPEND, COMMAND_LINE_SIZE); > strlcat(temp_buff, boot_command_line, COMMAND_LINE_SIZE); > strlcat(temp_buff, CONFIG_CMDLINE_APPEND, COMMAND_LINE_SIZE); > strlcpy(boot_command_line, temp_buff, COMMAND_LINE_SIZE); The point of the code is to have an implementation that other architecture can use. If we open code it in powerpc we're no better off. > > > > /* Scan memory nodes and rebuild MEMBLOCKs */ > > of_scan_flat_dt(early_init_dt_scan_root, NULL); > > of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); > > diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c > > index f33ff4163a51..e8e9fca22470 100644 > > --- a/arch/powerpc/kernel/prom_init.c > > +++ b/arch/powerpc/kernel/prom_init.c > > @@ -30,6 +30,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -637,11 +638,10 @@ static void __init early_cmdline_parse(void) > > p = prom_cmd_line; > > if ((long)prom.chosen > 0) > > l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1); > > -#ifdef CONFIG_CMDLINE > > + > > if (l <= 0 || p[0] == '\0') /* dbl check */ > > - strlcpy(prom_cmd_line, > > - CONFIG_CMDLINE, sizeof(prom_cmd_line)); > > -#endif /* CONFIG_CMDLINE */ > > + cmdline_add_builtin_section(prom_cmd_line, NULL, sizeof(prom_cmd_line), __prombss); > > + > > You don't need something as complex as what your generic code does for that. > It could be done with the following simple line: > > strlcpy(prom_cmd_line, CONFIG_CMDLINE_PREPEND " " CONFIG_CMDLINE_APPEND, > sizeof(prom_cmd_line)); > > > prom_printf("command line: %s\n", prom_cmd_line); > > #ifdef CONFIG_PPC64 > > diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh > > index 667df97d2595..ab2acc8d8b5a 100644 > > --- a/arch/powerpc/kernel/prom_init_check.sh > > +++ b/arch/powerpc/kernel/prom_init_check.sh > > @@ -18,7 +18,7 @@ > > WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush > > _end enter_prom memcpy memset reloc_offset __secondary_hold > > -__secondary_hold_acknowledge __secondary_hold_spinloop __start > > +__secondary_hold_acknowledge __secondary_hold_spinloop __start strlcat > > The above is a big issue. In the scope of KASAN implementation, we are > getting rid of generic string functions from prom_init because they are > KASAN instrumented and that's far too early for prom_init. See series > https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=94949 and > especially patch [v9,03/11] powerpc/prom_init: don't use string functions > from lib/ You already re-implemented a number of string functions, seem easy enough to add another one. What your doing here is exactly what I'm trying to prevent in my implementation. Say there is a small, but horrific defect in one of the string functions. Some other architecture fixes it in lib/strings.c , woops , you just missed it and now prom_init.c is stuck with it unless powerpc maintainers are watching closely to keep up with the fixes to the string functions. You could move these functions into the include/linux/string.h as static inlines, then use them in lib/strings.c and in prom_init.c. Then you have a unified implementation. I assume you would regard that as ugly tho. Something else you would regard as ugly , your not adding an #ifdef on KASAN in prom_init.c for the string functions. If you have that then any buggy string functions which you may add (or forget to update) would only cause problems if you had KASAN enabled. That then isolates any problems you cause to only debug kernels with KASAN enabled, instead of unilaterally all platforms which use prom_init.c. That would also only increase the size if KASAN is enabled. Very desirable, but ugly. I think most of us kernel hackers will take the ugly. #ifdef CONFIG_KASAN ... #else #define prom_strcmp strcmp ... #endif /* !CONFIG_KASAN */ (you would have to change arch/powerpc/kernel/prom_init_check.sh , but that shouldn't be too hard) Daniel