From: "Ard Biesheuvel" <ardb@kernel.org>
To: "WANG Rui" <r@hev.cc>
Cc: "Huacai Chen" <chenhuacai@kernel.org>,
"WANG Xuerui" <kernel@xen0n.name>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Haiyong Sun" <sunhaiyong@loongson.cn>,
"Lisa Robinson" <lisa@bytefly.space>,
loongarch@lists.linux.dev, linux-efi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/3] efi/loongarch: Randomize kernel preferred address for KASLR
Date: Wed, 29 Apr 2026 11:15:16 +0200 [thread overview]
Message-ID: <08229417-cc68-4cfc-9896-4dd82ada1b56@app.fastmail.com> (raw)
In-Reply-To: <CAHirt9hCLMmfhyYisWGB+84OauMx1_w1maEpEZhx34dPX6xiyA@mail.gmail.com>
On Wed, 29 Apr 2026, at 11:04, WANG Rui wrote:
> Hi Ard,
>
> On Wed, Apr 29, 2026 at 4:55 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>>
>>
>>
>> On Wed, 29 Apr 2026, at 07:13, WANG Rui wrote:
>> > Introduce efi_get_kimg_kaslr_address() to compute the preferred
>> > kernel image address dynamically when CONFIG_RANDOMIZE_BASE is
>> > enabled. The function derives a random offset using EFI-provided
>> > randomness combined with the timer value, and constrains it within
>> > CONFIG_RANDOMIZE_BASE_MAX_OFFSET.
>> >
>> > Update EFI_KIMG_PREFERRED_ADDRESS to call this helper so that the
>> > EFI stub can select a randomized load address when KASLR is active,
>> > while preserving the original base address behavior when KASLR is
>> > disabled or nokaslr is specified.
>> >
>> > Signed-off-by: WANG Rui <r@hev.cc>
>> > ---
>> > arch/loongarch/include/asm/efi.h | 4 +++-
>> > drivers/firmware/efi/libstub/loongarch.c | 16 ++++++++++++++++
>> > 2 files changed, 19 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/arch/loongarch/include/asm/efi.h b/arch/loongarch/include/asm/efi.h
>> > index eddc8e79b3fa..f831320efd41 100644
>> > --- a/arch/loongarch/include/asm/efi.h
>> > +++ b/arch/loongarch/include/asm/efi.h
>> > @@ -30,6 +30,8 @@ static inline unsigned long efi_get_kimg_min_align(void)
>> > return SZ_2M;
>> > }
>> >
>> > -#define EFI_KIMG_PREFERRED_ADDRESS PHYSADDR(VMLINUX_LOAD_ADDRESS)
>> > +unsigned long efi_get_kimg_kaslr_address(void);
>> > +
>>
>> Where is the call to this function being added?
>>
>> > +#define EFI_KIMG_PREFERRED_ADDRESS efi_get_kimg_kaslr_address()
>
> 1. drivers/firmware/efi/libstub/loongarch-stub.c
>
> efi_status_t handle_kernel_image(...)
> {
> ...
> status = efi_relocate_kernel(&kernel_addr, kernel_fsize, kernel_asize,
> EFI_KIMG_PREFERRED_ADDRESS, efi_get_kimg_min_align(), 0x0);
> ...
> }
>
> 2. drivers/firmware/efi/libstub/zboot.c
>
> static unsigned long alloc_preferred_address(...)
> {
> #ifdef EFI_KIMG_PREFERRED_ADDRESS
> efi_physical_addr_t efi_addr = EFI_KIMG_PREFERRED_ADDRESS;
>
> if (efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
> alloc_size / EFI_PAGE_SIZE, &efi_addr) == EFI_SUCCESS)
> return efi_addr;
> #endif
> return ULONG_MAX;
> }
>
Ah apologies - I misread the patch.
next prev parent reply other threads:[~2026-04-29 9:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 5:13 [PATCH v3 0/3] LoongArch: Move KASLR to EFI stub to avoid initrd overlap WANG Rui
2026-04-29 5:13 ` [PATCH v3 1/3] efi/loongarch: Randomize kernel preferred address for KASLR WANG Rui
2026-04-29 7:51 ` Huacai Chen
2026-04-29 8:55 ` Ard Biesheuvel
2026-04-29 9:04 ` WANG Rui
2026-04-29 9:15 ` Ard Biesheuvel [this message]
2026-04-29 5:13 ` [PATCH v3 2/3] LoongArch: Skip relocation-time KASLR if it has already been applied WANG Rui
2026-04-29 5:13 ` [PATCH v3 3/3] LoongArch: Avoid initrd overlap during kernel relocation WANG Rui
2026-04-29 7:39 ` Huacai Chen
2026-04-29 9:16 ` [PATCH v3 0/3] LoongArch: Move KASLR to EFI stub to avoid initrd overlap Ard Biesheuvel
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=08229417-cc68-4cfc-9896-4dd82ada1b56@app.fastmail.com \
--to=ardb@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=kernel@xen0n.name \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lisa@bytefly.space \
--cc=loongarch@lists.linux.dev \
--cc=r@hev.cc \
--cc=sunhaiyong@loongson.cn \
/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