From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (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 0FAE03749FA for ; Fri, 24 Jul 2026 03:03:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784862212; cv=none; b=IrFzL7uK1wdPnuaJ4p8b884a3DRNJ1FmnGMHipfN8wzQi07cNOWvlcAFO/hSIYx2LH7TJX49ai+BixiOhSjlJ9NqcQaG1BoTD7wwzgszfTXry+lQmOxhVkjGovQ7DUP9MiBmzwIEJSAEKzWOv9lm5bsotTyPBKahyKy6fDlAIFQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784862212; c=relaxed/simple; bh=gCtfnWPg+rPyq2XRQgPAbf/sWC72//bHQwAOPZ81tbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lVEXGaJdE+V8/trtj7Y8v2JxLf0Ko4zXyhClu4Ozwrqxf7esQ1mhZ4edMQuJlaSHO/Iq7lysGwXEPlVOOvoDgkBHBZnbh9QIpR/yDCqmfNw8P4A+uLnrAjTOus2z82Qwb3g3oRfIvlSNFZrhBJLqsLggio7FNVLk+2H7HdffN9A= 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=RfJHMV3W; arc=none smtp.client-ip=209.85.128.170 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="RfJHMV3W" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-80e2cfe6918so10120597b3.0 for ; Thu, 23 Jul 2026 20:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784862210; x=1785467010; 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=dPcCPVE6hByu3Jwn/37Fk8BMNH940blIrLxlZI+KWys=; b=RfJHMV3WcJiE9l5bpFmmHMKHsfZVtfik7GVdalnt1HFHVyU8QpVAEMv7fKuG4A5R2S FwpVaDxN42xV4+iApffqr+5aPWi0dPccj8X9k9r7dIpd5qb39fBJh+icmZQ2Fh98xNbn 0Gg3T0WOE7WjmI3V0xW+a0gfAvuCmKBfEo+nIChQbNs/5TwTCU9Uc3K1haAzBerJoC+C ViowpM7u4yNVqYRFV4vmzCCM23szNeH4OmTRlQFxuf8Julvy+l+tCX2La1eSmqPNE+38 +BjvNcHUqg63gjbe7d37fE7AdvWoHigBu/98K0F+SilUnOgpm6KFtHnGfAq9c2d+qi6/ Zg0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784862210; x=1785467010; 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=dPcCPVE6hByu3Jwn/37Fk8BMNH940blIrLxlZI+KWys=; b=IFIBCF9YCmt4eW3IlajpNCCeQWZ/GVVFqBjPf2q/iwONWUHn+661LCTbWiGSX0BEz9 21EwiusQtD30xxtSUuz7OnXvH2aXazhILqIYf6vKcecvDNsKNTRIS7lh3Sy1eI2aI60L lPhQlhAwD4mT7UbagPjvuYktSbuLOE1j6sBK4v3XAgaf6MFvTjQ0Z4jL2RiTkuYb3G/P Rm4HkqSmeTe6L6DBG1pN8GFzIlfiwH2zZ6Y986t4N1IoZTnoLBE/2SJGRMd5fz9Q6SFg WHVSy4927bGYTGR47N4qZZUyvUjGib7vdmbsH0CBPQCnJXo2+1IuxQ8gEUYaVQFlkH9W jIAA== X-Gm-Message-State: AOJu0YxpJhJIDeuxewuxPQ6GciOjUCUCDFpOrvoiiTgcYRl24TIYu9Ny RSrJgmkcOmklqQCOWH1qrdlV++2cKPXLYCfjqKsXQs2lVcG7IYix2ZqiCf/b X-Gm-Gg: AR+sD109nlYcyw4DbC9nNVvxoUsQyjofJ1KO2qm9L0tE7oxO9GU509/qPAS8gIeS10O 4YL0xJ9Ys5cYtGp40OwoB0vo7H1LjhH7bjtBAvDu4iVpXRSLwEgTOfUZr6TrKGu112tqvBivlTT ZYD19Mxs6E/K8krfqurve41GbXo3OEOwNXP3NI8XoBpJQ+b3TyvvE3C8Z4FJ+KhdxZtq6vbTZcq yGHB72+jOiXEQ0alKvwlvNJYgvP55SS3/5nvjGcDZMU5bzL1KTPlQaIoy8E5K07YT2eZFat0q4U 74m4LfQXQyb1fb7tmTQ3Z2IeR5uy14bZkhcHRya/iGGkBBdBd5s4QVgFiI5yyo9I3iywZiRaxnv r/Ae4w8/2R6hykw34Xk+WboVuVw049FoCmpUvhIWVpa7ugBW4LDwzQxt/Dwo= X-Received: by 2002:a05:690c:4d09:b0:814:5f5b:6378 with SMTP id 00721157ae682-81f4c22f8c7mr16030837b3.12.1784862210025; Thu, 23 Jul 2026 20:03:30 -0700 (PDT) Received: from citadel.lan ([2600:6c4a:4df0:2c10::1dba]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c397c9sm37379477b3.14.2026.07.23.20.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 20:03:29 -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 3/5] x86/boot: Remove hardcoded boot_param constants Date: Thu, 23 Jul 2026 23:02:54 -0400 Message-ID: <20260724030256.232690-4-brgerst@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260724030256.232690-1-brgerst@gmail.com> References: <20260724030256.232690-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..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); 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; } -- 2.55.0