From nobody Tue Apr 7 14:54:57 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FC2BECAAD4 for ; Sat, 27 Aug 2022 02:08:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345296AbiH0CIV (ORCPT ); Fri, 26 Aug 2022 22:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232013AbiH0CIO (ORCPT ); Fri, 26 Aug 2022 22:08:14 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45877C0B6C for ; Fri, 26 Aug 2022 19:08:13 -0700 (PDT) Received: from localhost.localdomain (unknown [80.240.223.29]) by mail.ispras.ru (Postfix) with ESMTPSA id 7DFD04076267; Sat, 27 Aug 2022 02:08:11 +0000 (UTC) From: Evgeniy Baskov To: Borislav Petkov Cc: Evgeniy Baskov , Dave Hansen , Ingo Molnar , Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org, Alexey Khoroshilov Subject: [PATCH v6 2/5] x86: Add cmdline_prepare() helper Date: Sat, 27 Aug 2022 05:08:07 +0300 Message-Id: X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Command line needs to be combined in both compressed and uncompressed kernel from built-in and boot command line strings, which requires non-trivial logic depending on CONFIG_CMDLINE_BOOL and CONFIG_CMDLINE_OVERRIDE. Add a helper function to avoid code duplication. Signed-off-by: Evgeniy Baskov --- arch/x86/include/asm/shared/cmdline.h | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 arch/x86/include/asm/shared/cmdline.h diff --git a/arch/x86/include/asm/shared/cmdline.h b/arch/x86/include/asm/s= hared/cmdline.h new file mode 100644 index 000000000000..a440d0bd6840 --- /dev/null +++ b/arch/x86/include/asm/shared/cmdline.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _ASM_X86_SETUP_CMDLINE_H +#define _ASM_X86_SETUP_CMDLINE_H + +#define _SETUP +#include /* For COMMAND_LINE_SIZE */ +#undef _SETUP + +#include + +#ifdef CONFIG_CMDLINE_BOOL +#define COMMAND_LINE_INIT CONFIG_CMDLINE +#else +#define COMMAND_LINE_INIT "" +#endif + +/* + * command_line and boot_command_line are expected to be at most + * COMMAND_LINE_SIZE length. command_line needs to be initialized + * with COMMAND_LINE_INIT. + */ +static inline void cmdline_prepare(char *command_line, + const char *boot_command_line) +{ +#ifdef CONFIG_CMDLINE_BOOL + if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) { + /* Append boot loader cmdline to builtin */ + strlcat(command_line, " ", COMMAND_LINE_SIZE); + strlcat(command_line, boot_command_line, COMMAND_LINE_SIZE); + } +#else + strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE); +#endif +} + +#endif /* _ASM_X86_SETUP_CMDLINE_H */ --=20 2.37.2