From nobody Fri Dec 19 00:51:56 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15E131C3F2C for ; Fri, 6 Dec 2024 10:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733481056; cv=none; b=FtqOVwarm6v3Rrr7vdCRSYhBbSmzhuN3Ia2wC0GeaChRC7hCIJ2l1rlqxbwVcLGrXL8Uyo1Dh3uZps8as1txIidqOxvRFvO5lgeVqxH+g1OZo/1+kkXHgMtlFkLjJvZ+nJByg2UIYgk6jmuoKJhSywm55CjgE4MZv8kLCjEqne0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733481056; c=relaxed/simple; bh=9queEJvu5d9ge2refCPUa6FSP1BvRTqPK/DYIcHJkeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vgx8QeozG6A/kQxV8u2PPu3dCjj5/PS/SkRKlgC1LlYA/lFZIoFKperXSa49wsOkF9IN7kJUn6kDS7+Od5JAJ7koTO7kTMdnOJWbV+CnXQlfXQVM0L3ruY7FizSy7ZAfy6+s1WI81vSIuKbE/TtgGvgq+fRGVNSWQwba3ExNu6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RfTb0AuX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RfTb0AuX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AA17C4CEDD; Fri, 6 Dec 2024 10:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733481055; bh=9queEJvu5d9ge2refCPUa6FSP1BvRTqPK/DYIcHJkeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RfTb0AuXA33OVGJI1pyHYa8q1GDfWkk03SmRZBpzCyhQn+hiXDv4gJRh7swwaxoyS VgiATS8yrilhuD1cmPIZzkqMflYyh78s5WuMKFqYHdQy9C/GQsNsYuvaNewHjwcQEo mdJpXz+Znl+LVT/9d/k2gDm4+/W+cc2tQvv1oxMM8aFxbl8YWsPkccKkZkGX2OZe2Z WmPpbRwkFBqkOHg0a2dZd1agyZwTlK5mEUnhgB/jAjUjApB3LRlc+ZhvNM7b2MzqZL 0Rq8srGJ0QLziAnQ7aytSfbuHCK3JLEpDmKpTTqRAnLfre+sJ0d5FHkKJAve6fUYmC wOiHClFGr+sCA== From: Mike Rapoport To: x86@kernel.org Cc: Andy Lutomirski , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Mike Rapoport , Ning Sun , Peter Zijlstra , Thomas Gleixner , linux-kernel@vger.kernel.org, tboot-devel@lists.sourceforge.net Subject: [PATCH v2 3/4] x86/boot: split parsing of boot_params into a helper function Date: Fri, 6 Dec 2024 12:30:30 +0200 Message-ID: <20241206103031.737458-4-rppt@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206103031.737458-1-rppt@kernel.org> References: <20241206103031.737458-1-rppt@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Mike Rapoport (Microsoft)" Makes setup_arch a bit easier to comprehend. No functional changes. Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/kernel/setup.c | 72 +++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index c34316a12897..d4e44f50f350 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -426,6 +426,46 @@ static void __init parse_setup_data(void) } } =20 +/* + * Translate the fields of 'struct boot_param' into global variables + * representing these parameters. + */ +static void __init parse_boot_params(void) +{ + ROOT_DEV =3D old_decode_dev(boot_params.hdr.root_dev); + screen_info =3D boot_params.screen_info; + edid_info =3D boot_params.edid_info; +#ifdef CONFIG_X86_32 + apm_info.bios =3D boot_params.apm_bios_info; + ist_info =3D boot_params.ist_info; +#endif + saved_video_mode =3D boot_params.hdr.vid_mode; + bootloader_type =3D boot_params.hdr.type_of_loader; + if ((bootloader_type >> 4) =3D=3D 0xe) { + bootloader_type &=3D 0xf; + bootloader_type |=3D (boot_params.hdr.ext_loader_type+0x10) << 4; + } + bootloader_version =3D bootloader_type & 0xf; + bootloader_version |=3D boot_params.hdr.ext_loader_ver << 4; + +#ifdef CONFIG_BLK_DEV_RAM + rd_image_start =3D boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK; +#endif +#ifdef CONFIG_EFI + if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, + EFI32_LOADER_SIGNATURE, 4)) { + set_bit(EFI_BOOT, &efi.flags); + } else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, + EFI64_LOADER_SIGNATURE, 4)) { + set_bit(EFI_BOOT, &efi.flags); + set_bit(EFI_64BIT, &efi.flags); + } +#endif + + if (!boot_params.hdr.root_flags) + root_mountflags &=3D ~MS_RDONLY; +} + static void __init memblock_x86_reserve_range_setup_data(void) { struct setup_indirect *indirect; @@ -803,35 +843,7 @@ void __init setup_arch(char **cmdline_p) =20 setup_olpc_ofw_pgd(); =20 - ROOT_DEV =3D old_decode_dev(boot_params.hdr.root_dev); - screen_info =3D boot_params.screen_info; - edid_info =3D boot_params.edid_info; -#ifdef CONFIG_X86_32 - apm_info.bios =3D boot_params.apm_bios_info; - ist_info =3D boot_params.ist_info; -#endif - saved_video_mode =3D boot_params.hdr.vid_mode; - bootloader_type =3D boot_params.hdr.type_of_loader; - if ((bootloader_type >> 4) =3D=3D 0xe) { - bootloader_type &=3D 0xf; - bootloader_type |=3D (boot_params.hdr.ext_loader_type+0x10) << 4; - } - bootloader_version =3D bootloader_type & 0xf; - bootloader_version |=3D boot_params.hdr.ext_loader_ver << 4; - -#ifdef CONFIG_BLK_DEV_RAM - rd_image_start =3D boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK; -#endif -#ifdef CONFIG_EFI - if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, - EFI32_LOADER_SIGNATURE, 4)) { - set_bit(EFI_BOOT, &efi.flags); - } else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, - EFI64_LOADER_SIGNATURE, 4)) { - set_bit(EFI_BOOT, &efi.flags); - set_bit(EFI_64BIT, &efi.flags); - } -#endif + parse_boot_params(); =20 x86_init.oem.arch_setup(); =20 @@ -855,8 +867,6 @@ void __init setup_arch(char **cmdline_p) =20 copy_edd(); =20 - if (!boot_params.hdr.root_flags) - root_mountflags &=3D ~MS_RDONLY; setup_initial_init_mm(_text, _etext, _edata, (void *)_brk_end); =20 /* --=20 2.45.2