From: Tom Lendacky <thomas.lendacky@amd.com>
To: Brian Gerst <brgerst@gmail.com>,
linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>, Ard Biesheuvel <ardb@kernel.org>,
Juergen Gross <jgross@suse.com>
Subject: Re: [PATCH 3/5] x86/boot: Remove hardcoded boot_param constants
Date: Fri, 24 Jul 2026 13:22:29 -0500 [thread overview]
Message-ID: <84c3aee9-d03f-4880-8974-99b2a8ee3841@amd.com> (raw)
In-Reply-To: <20260724030256.232690-4-brgerst@gmail.com>
On 7/23/26 22:02, Brian Gerst wrote:
> Use generated constants or sizeof() instead of hardcoded values.
>
> No functional change.
>
> Signed-off-by: Brian Gerst <brgerst@gmail.com>
> ---
> arch/x86/include/asm/setup.h | 3 ---
> arch/x86/kernel/asm-offsets.c | 2 ++
> arch/x86/kernel/head_32.S | 4 ++--
> drivers/firmware/efi/libstub/x86-stub.c | 6 +++---
> 4 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
> index 5534f4aaf73b..d23f4272d930 100644
> --- a/arch/x86/include/asm/setup.h
> +++ b/arch/x86/include/asm/setup.h
> @@ -21,11 +21,8 @@
>
> #endif /* __i386__ */
>
> -#define PARAM_SIZE 4096 /* sizeof(struct boot_params) */
> -
> #define OLD_CL_MAGIC 0xA33F
> #define OLD_CL_ADDRESS 0x020 /* Relative to real mode data */
> -#define NEW_CL_POINTER 0x228 /* Relative to real mode data */
>
> #ifndef __ASSEMBLER__
> #include <linux/cache.h>
> diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
> index 081816888f7a..0c49bb50188d 100644
> --- a/arch/x86/kernel/asm-offsets.c
> +++ b/arch/x86/kernel/asm-offsets.c
> @@ -105,6 +105,8 @@ static void __used common(void)
> OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
> OFFSET(BP_init_size, boot_params, hdr.init_size);
> OFFSET(BP_pref_address, boot_params, hdr.pref_address);
> + OFFSET(BP_cmd_line_ptr, boot_params, hdr.cmd_line_ptr);
> + DEFINE(SIZEOF_boot_params, sizeof(struct boot_params));
>
> BLANK();
> DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
> diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
> index 5171cb746444..1f66ccc36fe8 100644
> --- a/arch/x86/kernel/head_32.S
> +++ b/arch/x86/kernel/head_32.S
> @@ -96,10 +96,10 @@ SYM_CODE_START(startup_32)
> * page tables.
> */
> movl $pa(boot_params),%edi
> - movl $(PARAM_SIZE/4),%ecx
> + movl $(SIZEOF_boot_params/4),%ecx
> cld
> rep movsl
> - movl pa(boot_params) + NEW_CL_POINTER,%esi
> + movl pa(boot_params) + BP_cmd_line_ptr,%esi
> andl %esi,%esi
> jz 1f # No command line
> movl $pa(boot_command_line),%edi
> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> index cef32e2c82d8..c3522d417344 100644
> --- a/drivers/firmware/efi/libstub/x86-stub.c
> +++ b/drivers/firmware/efi/libstub/x86-stub.c
> @@ -520,11 +520,11 @@ static efi_status_t efi_allocate_bootparams(efi_handle_t handle,
> return status;
> }
>
> - status = efi_allocate_pages(PARAM_SIZE, &alloc, ULONG_MAX);
> + status = efi_allocate_pages(sizeof(struct boot_params), &alloc, ULONG_MAX);
Why not sizeof(*boot_params) here and each place below instead of
hardcoding the struct?
Thanks,
Tom
> if (status != EFI_SUCCESS)
> return status;
>
> - boot_params = memset((void *)alloc, 0x0, PARAM_SIZE);
> + boot_params = memset((void *)alloc, 0x0, sizeof(struct boot_params));
> hdr = &boot_params->hdr;
>
> /* Assign the setup_header fields that the kernel actually cares about */
> @@ -537,7 +537,7 @@ static efi_status_t efi_allocate_bootparams(efi_handle_t handle,
> /* Convert unicode cmdline to ascii */
> cmdline_ptr = efi_convert_cmdline(image);
> if (!cmdline_ptr) {
> - efi_free(PARAM_SIZE, alloc);
> + efi_free(sizeof(struct boot_params), alloc);
> return EFI_OUT_OF_RESOURCES;
> }
>
next prev parent reply other threads:[~2026-07-24 18:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 3:02 [PATCH 0/5] x86/boot: Early boot cleanups Brian Gerst
2026-07-24 3:02 ` [PATCH 1/5] x86/sme: Clear decrypted BSS separately Brian Gerst
2026-07-24 16:41 ` Tom Lendacky
2026-07-24 18:57 ` Brian Gerst
2026-07-24 19:56 ` Tom Lendacky
2026-07-24 21:06 ` Brian Gerst
2026-07-24 3:02 ` [PATCH 2/5] x86/boot/64: Clear BSS as early as possible Brian Gerst
2026-07-24 11:04 ` Nikolay Borisov
2026-07-24 11:34 ` Brian Gerst
2026-07-27 19:00 ` Brian Gerst
2026-07-24 3:02 ` [PATCH 3/5] x86/boot: Remove hardcoded boot_param constants Brian Gerst
2026-07-24 13:19 ` Nikolay Borisov
2026-07-24 18:22 ` Tom Lendacky [this message]
2026-07-24 19:03 ` Brian Gerst
2026-07-24 3:02 ` [PATCH 4/5] x86/boot/64: Remove copy_bootdata() call Brian Gerst
2026-07-24 3:02 ` [PATCH 5/5] x86/boot/64: Copy boot parameters and command line earlier Brian Gerst
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=84c3aee9-d03f-4880-8974-99b2a8ee3841@amd.com \
--to=thomas.lendacky@amd.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--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
Powered by JetHome