From nobody Mon Feb 9 16:47:07 2026 Received: from out28-97.mail.aliyun.com (out28-97.mail.aliyun.com [115.124.28.97]) (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 43EFF33ADB2 for ; Mon, 26 Jan 2026 13:36:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769434581; cv=none; b=BAGCquD0i7mjB/f6RNuFM6cMGlSUF7mywm2KxuSDcAVMdFum1LSYsvygq0TA2syJlIsD527EcNRrtNhWqMPE2pNvNTu5YGdOapZ0BUVae7Snf7pYj3Zfmwvq8ZLR3VAWeIMH2iV6KdTPJ9gHD5tEezEbeLC9blkh9JzqWB0UYxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769434581; c=relaxed/simple; bh=eitQmKmktSPddAH9FvI4GgY8d+k4Pzcc/yLI7Jl1LWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JPwowZkST7rubVMM6nj5Yxvj+XeVy3aTC+4cp0OPhVNYePKsfGCkUzXl70rL9WvEGORqKZBhf1eIAlg1IPsflfVu3uOwaFmnoWi85U9OsTlGrAytAAT0JBcXqfFVk9Ea/dGYZHhOL9fATZjjJ+NzXSAE8hMR7sEhGvc3MVX058c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=dNYdgYKx; arc=none smtp.client-ip=115.124.28.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="dNYdgYKx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1769434570; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=shvguEnBCnFDBN82Kkm3tKbFDhvQGxkda3Bv+csdOx0=; b=dNYdgYKxr1tKHVhn1lLEdocnTa6K5VfxFC/23mdn1Pei1RrFBm8jPnCHlGby9yybO3h2n7XkduDozKYtpuUxFrOcmsipQX73pyKWWemRckZ+ffUTgk+oxZTrNZibm6mrMj97u27EvCtMCKFGUWSt0E/6TJAub5OasXKlsDyMGXM= Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.gGBjWoK_1769434569 cluster:ay29) by smtp.aliyun-inc.com; Mon, 26 Jan 2026 21:36:09 +0800 From: Hou Wenlong To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Hou Wenlong , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Ard Biesheuvel , Nathan Chancellor , Masahiro Yamada , Vitaly Kuznetsov , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Brian Gerst Subject: [RFC PATCH 5/5] x86/boot: Use '.data.relocs' section for performing relocations during decompression Date: Mon, 26 Jan 2026 21:33:55 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: 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" When CONFIG_RELOCATABLE_UNCOMPRESSED_KERNEL is enabled, all the relocations are already in the '.data.relocs' section of the kernel binary, so there is no need to generate 'vmlinux.relocs' again. Use it directly for performing relocations during decompression. Signed-off-by: Hou Wenlong --- arch/x86/boot/compressed/Makefile | 6 ++++-- arch/x86/boot/compressed/misc.c | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/M= akefile index 68f9d7a1683b..ca629a9b9bce 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -12,7 +12,7 @@ # vmlinux.bin is: # vmlinux stripped of debugging and comments # vmlinux.bin.all is: -# vmlinux.bin + vmlinux.relocs +# vmlinux.bin + vmlinux.relocs (CONFIG_RELOCATABLE_UNCOMPRESSED_KERNEL=3Dn) # vmlinux.bin.(gz|bz2|lzma|...) is: # (see scripts/Makefile.lib size_append) # compressed vmlinux.bin.all + u32 size of vmlinux.bin.all @@ -76,7 +76,7 @@ LDFLAGS_vmlinux +=3D -T hostprogs :=3D mkpiggy HOST_EXTRACFLAGS +=3D -I$(srctree)/tools/include =20 -sed-voffset :=3D -e 's/^\([0-9a-fA-F]*\) [ABbCDGRSTtVW] \(_text\|__start_r= odata\|_sinittext\|__inittext_end\|__bss_start\|_end\)$$/\#define VO_\2 _AC= (0x\1,UL)/p' +sed-voffset :=3D -e 's/^\([0-9a-fA-F]*\) [ABbCDGRSTtVW] \(_text\|__start_r= odata\|_sinittext\|__inittext_end\|__bss_start\|_end\|__relocation_end\)$$/= \#define VO_\2 _AC(0x\1,UL)/p' =20 quiet_cmd_voffset =3D VOFFSET $@ cmd_voffset =3D $(NM) $< | sed -n $(sed-voffset) > $@ @@ -132,7 +132,9 @@ $(obj)/vmlinux.relocs: vmlinux.unstripped FORCE $(call if_changed,relocs) =20 vmlinux.bin.all-y :=3D $(obj)/vmlinux.bin +ifndef CONFIG_RELOCATABLE_UNCOMPRESSED_KERNEL vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) +=3D $(obj)/vmlinux.relocs +endif =20 $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE $(call if_changed,gzip) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/mis= c.c index 0f41ca0e52c0..d0f4e8302276 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -232,6 +232,14 @@ static void handle_relocations(void *output, unsigned = long output_len, } debug_putstr("Performing relocations... "); =20 +#ifdef CONFIG_RELOCATABLE_UNCOMPRESSED_KERNEL + /* + * If CONFIG_RELOCATABLE_UNCOMPRESSED_KERNEL is enabled, the relocations = is in + * '.data.reloc' section of kernel binary. + */ + output_len =3D VO___relocation_end - VO__text; +#endif + /* * Process relocations: 32 bit relocations first then 64 bit after. * Two sets of binary relocations are added to the end of the kernel --=20 2.31.1