Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1374989pxf; Fri, 26 Mar 2021 06:49:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws7WgrkvzbwKNO3ZlMu+ftGbRZlgSVfCGMCBGqBep4rA30/KIVDdGzpvxA67gBrOUwmE4Y X-Received: by 2002:aa7:cc98:: with SMTP id p24mr15008488edt.187.1616766565020; Fri, 26 Mar 2021 06:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616766565; cv=none; d=google.com; s=arc-20160816; b=K5qlS5JXSwrcBiWIO/ddwwkhxG9qziH7LOui7irqPfBTMCZQJ895Zdnx7Mgll3lQZT NQEi5sXookiXi8nqDecnhEVTDhT6NnC0c0mnESQDw3SCUXA056j7UzEfsmU0+vQFxtLp rRdcXltvenjrEj1XCGXA4DWGh+ZUWb0Z0G0nLgY/bMRcKCncPl3udfvMxfRxbjLOL5d8 74oBw3xvDAfNVmR/KkWQ5picnezQei0dUJ9YdRovX6wF4dSR+CGU8HH7a9gdC1rLVQ88 Nba7Bl9FABpUD+t1k/ORaVkgjk4/uMnbmqZPD2c4Lg6MqSgl4Sb+pZGMGlRe48cEOV4/ GoWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:references:in-reply-to :message-id; bh=pYJW7evsGYkxSN5/Bh2uPGdi2PGkKJV5jKU8hTsjqz0=; b=0lZkGK0lIIue5BjpnacOxhCH72n6v2RPtu9fSW1lkq+JWlbeZCIxw4p4NqphQju3wl 6ahn7AJipOCHlzYfuzBoxWNJCmslckyopIi9sItfTJ1hGkmVDWi+Qgp3ja4d0b1uUmbl 9jIHbGf2BEutN+VaI3+SfxThxva1mUGpuuKWkrDmvRgM2+NwPqt/8tD9TXR8zBiW7OXP 3IaxvTSXu17iv/ZBa4nd1MtPqvXDq3cX9SH+40HBgms8XBV+9hMMGs3B1eO8G0KGmzRT bpdxCqWpSYOi7CdCa2BpD79IALxDct06rSrnZqwtmsxS9FBGNWYlidcc9zZQNf2QntKF eDhQ== 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 e12si7054798ejs.501.2021.03.26.06.49.01; Fri, 26 Mar 2021 06:49:25 -0700 (PDT) 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 S230282AbhCZNsD (ORCPT + 99 others); Fri, 26 Mar 2021 09:48:03 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:48322 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbhCZNph (ORCPT ); Fri, 26 Mar 2021 09:45:37 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4F6NWg6MzGz9v03T; Fri, 26 Mar 2021 14:45:03 +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 0qyljEPHuFJn; Fri, 26 Mar 2021 14:45:03 +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 4F6NWf6MZ6z9v03P; Fri, 26 Mar 2021 14:45:02 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id AFA6E8B8D1; Fri, 26 Mar 2021 14:45:03 +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 c6KWcbGdcZc0; Fri, 26 Mar 2021 14:45:03 +0100 (CET) Received: from po16121vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D72458B8C7; Fri, 26 Mar 2021 14:45:02 +0100 (CET) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 3BC2C67611; Fri, 26 Mar 2021 13:45:02 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v3 15/17] x86: Convert to GENERIC_CMDLINE To: will@kernel.org, danielwa@cisco.com, robh@kernel.org, daniel@gimpelevich.san-francisco.ca.us Cc: linux-arch@vger.kernel.org, devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, microblaze , linux-mips@vger.kernel.org, nios2 , openrisc@lists.librecores.org, linux-hexagon@vger.kernel.org, linux-riscv@lists.infradead.org, x86@kernel.org, linux-xtensa@linux-xtensa.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org Date: Fri, 26 Mar 2021 13:45:02 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This converts the architecture to GENERIC_CMDLINE. Signed-off-by: Christophe Leroy --- arch/x86/Kconfig | 45 ++----------------------- arch/x86/kernel/setup.c | 17 ++-------- drivers/firmware/efi/libstub/x86-stub.c | 26 +++++++------- 3 files changed, 18 insertions(+), 70 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 2792879d398e..66b384228ca3 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -104,6 +104,7 @@ config X86 select ARCH_USE_QUEUED_SPINLOCKS select ARCH_USE_SYM_ANNOTATIONS select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH + select ARCH_WANT_CMDLINE_PREPEND_BY_DEFAULT select ARCH_WANT_DEFAULT_BPF_JIT if X86_64 select ARCH_WANTS_DYNAMIC_TASK_STRUCT select ARCH_WANT_HUGE_PMD_SHARE @@ -118,6 +119,7 @@ config X86 select EDAC_SUPPORT select GENERIC_CLOCKEVENTS_BROADCAST if X86_64 || (X86_32 && X86_LOCAL_APIC) select GENERIC_CLOCKEVENTS_MIN_ADJUST + select GENERIC_CMDLINE select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES @@ -2358,49 +2360,6 @@ choice endchoice -config CMDLINE_BOOL - bool "Built-in kernel command line" - help - Allow for specifying boot arguments to the kernel at - build time. On some systems (e.g. embedded ones), it is - necessary or convenient to provide some or all of the - kernel boot arguments with the kernel itself (that is, - to not rely on the boot loader to provide them.) - - To compile command line arguments into the kernel, - set this option to 'Y', then fill in the - boot arguments in CONFIG_CMDLINE. - - Systems with fully functional boot loaders (i.e. non-embedded) - should leave this option set to 'N'. - -config CMDLINE - string "Built-in kernel command string" - depends on CMDLINE_BOOL - default "" - help - Enter arguments here that should be compiled into the kernel - image and used at boot time. If the boot loader provides a - command line at boot time, it is appended to this string to - form the full kernel command line, when the system boots. - - However, you can use the CONFIG_CMDLINE_OVERRIDE option to - change this behavior. - - In most cases, the command line (whether built-in or provided - by the boot loader) should specify the device for the root - file system. - -config CMDLINE_OVERRIDE - bool "Built-in command line overrides boot loader arguments" - depends on CMDLINE_BOOL && CMDLINE != "" - help - Set this option to 'Y' to have the kernel ignore the boot loader - command line, and use ONLY the built-in command line. - - This is used to work around broken boot loaders. This should - be set to 'N' under normal conditions. - config MODIFY_LDT_SYSCALL bool "Enable the LDT (local descriptor table)" if EXPERT default y diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index d883176ef2ce..93ac57ea3e64 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -5,6 +5,7 @@ * This file contains the setup_arch() code, which handles the architecture-dependent * parts of early kernel initialization. */ +#include #include #include #include @@ -161,9 +162,6 @@ unsigned long saved_video_mode; #define RAMDISK_LOAD_FLAG 0x4000 static char __initdata command_line[COMMAND_LINE_SIZE]; -#ifdef CONFIG_CMDLINE_BOOL -static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE; -#endif #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) struct edd edd; @@ -883,18 +881,7 @@ void __init setup_arch(char **cmdline_p) bss_resource.start = __pa_symbol(__bss_start); bss_resource.end = __pa_symbol(__bss_stop)-1; -#ifdef CONFIG_CMDLINE_BOOL -#ifdef CONFIG_CMDLINE_OVERRIDE - strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); -#else - if (builtin_cmdline[0]) { - /* append boot loader cmdline to builtin */ - strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE); - strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE); - strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); - } -#endif -#endif + cmdline_build(boot_command_line, boot_command_line, COMMAND_LINE_SIZE); strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); *cmdline_p = command_line; diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index f14c4ff5839f..5413aff010ec 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -6,6 +6,7 @@ * * ----------------------------------------------------------------------- */ +#include #include #include #include @@ -674,6 +675,7 @@ unsigned long efi_main(efi_handle_t handle, unsigned long buffer_start, buffer_end; struct setup_header *hdr = &boot_params->hdr; efi_status_t status; + char *cmdline; efi_system_table = sys_table_arg; @@ -735,22 +737,22 @@ unsigned long efi_main(efi_handle_t handle, image_offset = 0; } -#ifdef CONFIG_CMDLINE_BOOL - status = efi_parse_options(CONFIG_CMDLINE); + cmdline = kzalloc(COMMAND_LINE_SIZE, GFP_KERNEL); + if (cmdline) { + unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr | + ((u64)boot_params->ext_cmd_line_ptr << 32)); + + cmdline_build(cmdline, (char *)cmdline_paddr, COMMAND_LINE_SIZE); + status = efi_parse_options(cmdline); + kfree(cmdline); + } else { + efi_err("Failed to allocate memory\n"); + goto fail; + } if (status != EFI_SUCCESS) { efi_err("Failed to parse options\n"); goto fail; } -#endif - if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) { - unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr | - ((u64)boot_params->ext_cmd_line_ptr << 32)); - status = efi_parse_options((char *)cmdline_paddr); - if (status != EFI_SUCCESS) { - efi_err("Failed to parse options\n"); - goto fail; - } - } /* * At this point, an initrd may already have been loaded by the -- 2.25.0