From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f53.google.com (mail-yx1-f53.google.com [74.125.224.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0B3C3A9624 for ; Thu, 30 Jul 2026 19:59:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785441547; cv=none; b=kpv7rTq6UUb1OoMyuU0s422jzY3d8qn4nLFleqiz92tfOg/LxGYw7SabCQlo7QFPq74mjW7oGbhHANW03arwzekCGq3dZ2u71wzXjNaDqb2fxuMR+e+bNiTwGRgC4kje2n0RmBKCNtfdnkLzyGgcTzBA0Y66+JDWpFkiBSWKMpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785441547; c=relaxed/simple; bh=b5xV8kR5Ib7mo5arQYKY7XubjaxEYYx1Jlb5hnoae9Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O/AJEO7ymWAkOLzni+9QyQwWIXwtR834qyvdjuEfoGzF7Sv4c48HDLzRG/k9XNATWJ/cL2VlPbb2cmGF95z/JzwOk1hPaM0PmJzWSHDkUZyWaa7rBHJpD76rElJ29qUA+l0AO3dS1VOvneV2SSbsHL1WFEtuAQjevmcyHtGt1RQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DHEsxtRD; arc=none smtp.client-ip=74.125.224.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DHEsxtRD" Received: by mail-yx1-f53.google.com with SMTP id 956f58d0204a3-664b05d408bso103120d50.1 for ; Thu, 30 Jul 2026 12:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785441545; x=1786046345; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TL3CZCmFjHQe6dgjSpXUQD/AdymSVhww+Gx8EvJcIzk=; b=DHEsxtRDseVPsdoWUxWl/KrLaR81KLG6d/KJVu1MveaFdTKYz27/3sFRqn4uh1+KtG dFpV8bg1xd3TvIRQbsPcth07U+0VA9JIXg3hlcJcdbzcAZRM5qy54ks/Yhwk4Q1gvNS1 PsVmt2D1XkG8CC0SUGXNuizdVWhEwxpyrAMx4KBKRuO1LXp1Ems5sFHIqfS2ADxiarlb M/xi2yXe2nAFoXYpgvvk2tb3O4vgqrivxpyUzxhaD6dzIt5Ga5lbLGtDPmnLoMrFdkwo c1o27TXVBRogib9DxDr7H2iYKU/YBdQ3+fjx+6jEppkRzoKUGKB9JRj9QhbIbmwL9O+s jEnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785441545; x=1786046345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TL3CZCmFjHQe6dgjSpXUQD/AdymSVhww+Gx8EvJcIzk=; b=naGbK+yKSMhR9TefUif4v0m93bH4RqjeJxqGHiwWm1w1PagYCFWg8Wt5Fn8CSh/uiW K03cIUzDLocUneJMiBwF6p57IfiwpVRiLFUy3KiF5ipX27HA2X4O6GqUWsCyxRDFVmEN mC12YbKWMIUtHRk8+yo0Qwq9Dx+c6/VE0sN/sisNry9jtkFNd7bkRCVn3XdTfbG9EuuI H83KY9p27iwf7nh1U/+k9Rk7kalO1uRvcNQGgku2xE5nNtSajzDV9nS5fC8GyYtvhzhB 2PU1Jrqf2ALJ6gonGl3AQIDNY6YiNyebyGrvSD57BCZj1QShVQK1N5vnzGZCazwrB7m+ Vpqg== X-Gm-Message-State: AOJu0YxRYwV38EdsXMgCjolJRAZBUkO6ErRJ3A/E7H9FRPX15EINz+9F YDwurklMcYrLCYBU3YXwCtTooh51U+kdF2kVRi2cR+Mg9sY8YXx7NRI482JW X-Gm-Gg: AR+sD11FZ+hpOp94kFPUo9p9e4+/JaPWyb3YUvRievu5lkohvrk8jDzvH8EaeqeV9tQ M38+elEYCn4ZkXpXh/4NT7du+85V4RTB7oyhxuWPga212rE7ggN2B24rLCqGNR2sFyYfg9cpP5Z W8DWvpTqB5rgbqe2GnjayJgELwGEYvdSnCABBYgtxJeHAKP0DDgx7wMMyZYWoTHYu9MRmvkbkxE 8n4s/06Ieyv2bGK1o5EjRGyLXj+j4DICpWxnXVeFidxRIVJVGgwBEocl9+B4LIupwOYJbobm9EF 4BhHhWMlahEks7wfhs6M0gQi95W2e+6liBZCxgJdEGJDiP1C2NkVyx0aP1sAvhfnQONGAUWI3R5 t5T7V24ZiLS7B8Pe0SB45ugjWTcTeKkSBrhfT+OCTJRGsY2J34jGPHdZptN/HsUFGR7MD6Q8C1z 9LAmAKwuiBBK0CSimoWeEpOZff9aVneIhp1g+FOGT6qg== X-Received: by 2002:a05:690e:4184:b0:667:8b91:242e with SMTP id 956f58d0204a3-6692f827830mr2392134d50.93.1785441544609; Thu, 30 Jul 2026 12:59:04 -0700 (PDT) Received: from citadel.lan ([2600:6c4a:4df0:2c10::1dba]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6692c925a87sm1961623d50.15.2026.07.30.12.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 12:59:03 -0700 (PDT) From: Brian Gerst To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Borislav Petkov , Ard Biesheuvel , Juergen Gross , Tom Lendacky , Brian Gerst Subject: [PATCH v2 3/5] x86/boot: Remove hardcoded boot_param constants Date: Thu, 30 Jul 2026 15:58:52 -0400 Message-ID: <20260730195854.421115-4-brgerst@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730195854.421115-1-brgerst@gmail.com> References: <20260730195854.421115-1-brgerst@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use generated constants or sizeof() instead of hardcoded values. No functional change. Signed-off-by: Brian Gerst --- 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 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..9ec19e9a79ff 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(*boot_params), &alloc, ULONG_MAX); if (status != EFI_SUCCESS) return status; - boot_params = memset((void *)alloc, 0x0, PARAM_SIZE); + boot_params = memset((void *)alloc, 0x0, sizeof(*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(*boot_params), alloc); return EFI_OUT_OF_RESOURCES; } -- 2.55.0