mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Hou Wenlong <houwenlong.hwl@antgroup.com>, linux-kernel@vger.kernel.org
Cc: "Lai Jiangshan" <jiangshan.ljs@antgroup.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	x86@kernel.org, "Juergen Gross" <jgross@suse.com>,
	"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Vitaly Kuznetsov" <vkuznets@redhat.com>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Brian Gerst" <brgerst@gmail.com>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Alexander Graf" <graf@amazon.com>,
	"Joel Granados" <joel.granados@kernel.org>,
	"Thomas Huth" <thuth@redhat.com>,
	"Uros Bizjak" <ubizjak@gmail.com>,
	"Kiryl Shutsemau" <kas@kernel.org>,
	"Pawan Gupta" <pawan.kumar.gupta@linux.intel.com>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Xin Li (Intel)" <xin@zytor.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [RFC PATCH 0/5] x86/boot: Allow to perform randomization for uncompressed kernel image
Date: Mon, 26 Jan 2026 11:30:28 -0800	[thread overview]
Message-ID: <7716B334-004D-4CBB-9237-E8AE5CE696CE@zytor.com> (raw)
In-Reply-To: <cover.1769434279.git.houwenlong.hwl@antgroup.com>

On January 26, 2026 5:33:50 AM PST, Hou Wenlong <houwenlong.hwl@antgroup.com> wrote:
>Hi all,
>
>This RFC patch series introduces relocatable uncompressed kernel image,
>which is allowed to perform kerenl image virtual address randomization
>in 64-bit booting entry instead of decompression phase.
>
>- Background
>
>Currently, kernel image virtual address randomization is only performed
>during the decompression phase. However, in certain scenarios, such as
>secure container environments (e.g., Kata Containers), to speed up the
>boot process, the system may boot directly from an uncompressed kernel
>image. In such cases, virtual address randomization cannot be executed.
>Although the security enhancement provided by KASLR is limited, there is
>still a potential demand to allow uncompressed kernel images to perform
>virtual address randomization (for example, future support for x86 PIE).
>
>- Approaches
>
>Currently, the x86 kernel uses static compilation, but it retains
>relocation information through the '--emit-relocs' option, which is then
>simplified into a relocation table using 'relocs' tool. To enable
>virtual address randomization for uncompressed kernel images, relocation
>information is required, and there are several possible approaches:
>
>1) Who will perform the randomization:
>
>VMM: The VMM reads vmlinux.relocs after loading vmlinux to perform
>randomization. This would require additional modifications to the VMM,
>and vmlinux.relocs needs to be packaged when shipping.
>
>Kernel: The kernel performs randomization itself at the kernel
>entry point, requiring no modifications to the VMM.
>
>2) relocation information format:
>
>vmlinux.relocs: It only contains the necessary relocation entries and is
>simplified, making it small enough. However, it is a format defined
>within the kernel that was previously used only internally and is not
>part of the ABI.
>
>rela.* sections: It is the standard ELF ABI, but
>it contains RIP-relative relocation entries, which are more common in
>kernel, causing the kernel image to be larger.
>
>- Implementation
>
>The final implementation of this plan extends the 'relocs' tool to allow
>the insertion of relocation information into a reserved section of the
>kernel (referencing the MIPS implementation). This enables the reading
>of that information and subsequent execution of relocations when booting
>directly from an uncompressed kernel. Currently, this implementation is
>only available for 64-bit and has been tested with both PVH entry
>booting and standard 64-bit Linux entry. And the default reserve size is
>1MB for now, which is enough for defconfig.
>
>- TODO
>
>Clean up the decompression KASLR code to allow it to be shared with the
>booting phase.
>
>
>Thanks!
>
>Hou Wenlong (5):
>  x86/relocs: Cleanup cmdline options
>  x86/relocs: Insert relocations into input file
>  x86: Allow to build relocatable uncompressed kernel binary
>  x86/boot: Perform virtual address relocation in kernel entry
>  x86/boot: Use '.data.relocs' section for performing relocations during
>    decompression
>
> arch/x86/Kconfig                  |  20 ++++++
> arch/x86/Makefile.postlink        |  33 +++++++++
> arch/x86/boot/compressed/Makefile |   6 +-
> arch/x86/boot/compressed/misc.c   |   8 +++
> arch/x86/boot/startup/Makefile    |   1 +
> arch/x86/boot/startup/kaslr.c     | 116 ++++++++++++++++++++++++++++++
> arch/x86/include/asm/setup.h      |   1 +
> arch/x86/kernel/head_64.S         |   7 ++
> arch/x86/kernel/vmlinux.lds.S     |  20 ++++++
> arch/x86/lib/cmdline.c            |   6 ++
> arch/x86/lib/kaslr.c              |   5 ++
> arch/x86/platform/pvh/head.S      |  15 +++-
> arch/x86/tools/relocs.c           |  64 ++++++++++++++---
> arch/x86/tools/relocs.h           |  15 ++--
> arch/x86/tools/relocs_common.c    |  24 ++++---
> 15 files changed, 309 insertions(+), 32 deletions(-)
> create mode 100644 arch/x86/Makefile.postlink
> create mode 100644 arch/x86/boot/startup/kaslr.c
>
>--
>2.31.1
>

Hi!

At a very quick glance this seems like a very reasonable thing to me, but since the intent is reduced boot latency (a very worthwhile goal!) do you perhaps have any measurements to show how much improvement we are talking about? That would be really useful. 

Thanks! 

  parent reply	other threads:[~2026-01-26 19:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 13:33 Hou Wenlong
2026-01-26 13:33 ` [RFC PATCH 1/5] x86/relocs: Cleanup cmdline options Hou Wenlong
2026-01-26 13:33 ` [RFC PATCH 2/5] x86/relocs: Insert relocations into input file Hou Wenlong
2026-01-26 13:33 ` [RFC PATCH 3/5] x86: Allow to build relocatable uncompressed kernel binary Hou Wenlong
2026-01-26 13:33 ` [RFC PATCH 4/5] x86/boot: Perform virtual address relocation in kernel entry Hou Wenlong
2026-01-26 13:33 ` [RFC PATCH 5/5] x86/boot: Use '.data.relocs' section for performing relocations during decompression Hou Wenlong
2026-01-26 19:30 ` H. Peter Anvin [this message]
2026-01-27 12:03   ` [RFC PATCH 0/5] x86/boot: Allow to perform randomization for uncompressed kernel image Hou Wenlong
2026-01-27 15:43     ` H. Peter Anvin
2026-01-28  8:59       ` Hou Wenlong

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=7716B334-004D-4CBB-9237-E8AE5CE696CE@zytor.com \
    --to=hpa@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=graf@amazon.com \
    --cc=houwenlong.hwl@antgroup.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jgross@suse.com \
    --cc=jiangshan.ljs@antgroup.com \
    --cc=joel.granados@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=kas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=linux@weissschuh.net \
    --cc=masahiroy@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=tglx@kernel.org \
    --cc=thuth@redhat.com \
    --cc=ubizjak@gmail.com \
    --cc=vkuznets@redhat.com \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xin@zytor.com \
    /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

all inboxes | Powered by JetHome®