From: Borislav Petkov <bp@alien8.de>
To: Evgeniy Baskov <baskov@ispras.ru>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, x86@kernel.org,
Alexey Khoroshilov <khoroshilov@ispras.ru>
Subject: Re: [PATCH v8 2/5] x86: Add cmdline_prepare() helper
Date: Mon, 14 Nov 2022 15:28:55 +0100 [thread overview]
Message-ID: <Y3JQpxi6XDkPViBr@zn.tnic> (raw)
In-Reply-To: <b81fa524589ff21002a501f0b4cddf41b53f640f.1668082601.git.baskov@ispras.ru>
On Thu, Nov 10, 2022 at 04:09:30PM +0300, Evgeniy Baskov wrote:
> 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 <baskov@ispras.ru>
> ---
> arch/x86/include/asm/shared/cmdline.h | 35 +++++++++++++++++++++++++++
> 1 file changed, 35 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/shared/cmdline.h
> new file mode 100644
> index 000000000000..01736d66028d
> --- /dev/null
> +++ b/arch/x86/include/asm/shared/cmdline.h
> @@ -0,0 +1,35 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef _ASM_X86_SETUP_CMDLINE_H
> +#define _ASM_X86_SETUP_CMDLINE_H
> +
> +#define _SETUP
> +#include <asm/setup.h> /* For COMMAND_LINE_SIZE */
> +#undef _SETUP
> +
> +#include <linux/string.h>
> +
> +#ifdef CONFIG_CMDLINE_BOOL
> +#define BUILTIN_COMMAND_LINE CONFIG_CMDLINE
> +#else
> +#define BUILTIN_COMMAND_LINE ""
> +#endif
> +
> +static inline void cmdline_prepare(char *dst, const char *boot_command_line)
> +{
> + if (!IS_ENABLED(CONFIG_CMDLINE_BOOL)) {
> + strscpy(dst, boot_command_line, COMMAND_LINE_SIZE);
> + } else {
> + strscpy(dst, BUILTIN_COMMAND_LINE, COMMAND_LINE_SIZE);
> + /*
> + * Append boot loader cmdline to builtin, if it exists
> + * and should not be overriden.
> + */
> + if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE) && boot_command_line[0]) {
> + strlcat(dst, " ", COMMAND_LINE_SIZE);
> + strlcat(dst, boot_command_line, COMMAND_LINE_SIZE);
> + }
You keep changing what I'm suggesting and the next patch has a strscpy()
outside of the function.
When I say it should be all concentrated in one function, I really mean
it.
So now it is my turn: I'll do it how I think it should be done and you
can review it.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2022-11-14 14:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 13:09 [PATCH v8 0/5] Parse CONFIG_CMDLINE in compressed kernel Evgeniy Baskov
2022-11-10 13:09 ` [PATCH v8 1/5] x86/boot: Add strlcat() and strscpy() to " Evgeniy Baskov
2022-11-10 13:09 ` [PATCH v8 2/5] x86: Add cmdline_prepare() helper Evgeniy Baskov
2022-11-14 14:28 ` Borislav Petkov [this message]
2022-11-15 18:58 ` Borislav Petkov
2022-11-15 18:59 ` [PATCH 1/2] x86/boot: Add a function for kernel command line preparation Borislav Petkov
2022-11-15 19:00 ` [PATCH 2/2] x86/boot: Use cmdline_prepare() in the compressed stage Borislav Petkov
2022-11-16 10:48 ` Evgeniy Baskov
2022-11-10 13:09 ` [PATCH v8 3/5] x86/setup: Use cmdline_prepare() in setup.c Evgeniy Baskov
2022-11-10 13:09 ` [PATCH v8 4/5] x86/boot: Use cmdline_prapare() in compressed kernel Evgeniy Baskov
2022-11-10 13:09 ` [PATCH v8 5/5] x86/boot: Remove no longer needed includes Evgeniy Baskov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y3JQpxi6XDkPViBr@zn.tnic \
--to=bp@alien8.de \
--cc=baskov@ispras.ru \
--cc=dave.hansen@linux.intel.com \
--cc=khoroshilov@ispras.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox