linux/drivers/firmware/efi/libstub
WANG Rui 03d8273542 efi/loongarch: Randomize kernel preferred address for KASLR
Introduce efi_get_kimg_kaslr_address() helper to compute the preferred
kernel image load address dynamically when CONFIG_RANDOMIZE_BASE is
enabled. The function derives a random offset by using the EFI-provided
randomness combined with the timer tick 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.

Note: LoongArch can't KASLR for hibernation, so set efi_nokaslr to true
if "resume=<devname>" is explicitly specified in cmdline.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
History 2026-05-21 20:58:36 +08:00
..
alignedmem.c efi/libstub: Add one kernel-doc comment 2024-01-30 21:44:21 +01:00
arm32-stub.c efi: libstub: Move screen_info handling to common code 2022-11-09 12:42:02 +01:00
arm64-stub.c arm64/efistub: Clean up KASLR logic 2024-07-10 12:22:46 +02:00
arm64.c efistub/smbios: Simplify SMBIOS enumeration API 2024-07-02 00:42:04 +02:00
bitmap.c efi/libstub: Implement support for unaccepted memory 2023-06-06 16:58:23 +02:00
efi-stub-entry.c efi: Support EDID information 2025-12-16 14:40:51 +01:00
efi-stub-helper.c efi/loongarch: Randomize kernel preferred address for KASLR 2026-05-21 20:58:36 +08:00
efi-stub.c efi: Support EDID information 2025-12-16 14:40:51 +01:00
efistub.h efi/libstub: Move efi_relocate_kernel() into its only remaining user 2026-04-29 08:55:58 +02:00
fdt.c efi: libstub: fix type of fdt 32 and 64bit variables 2026-03-11 19:52:45 +01:00
file.c efi/libstub: Take command line overrides into account for loaded files 2024-11-17 08:54:01 +01:00
find.c efi/libstub: Implement support for unaccepted memory 2023-06-06 16:58:23 +02:00
gop.c efi/libstub: gop: Fix EDID support in mixed-mode 2025-12-24 21:32:31 +01:00
intrinsics.c efi/libstub: Avoid CopyMem/SetMem EFI services after ExitBootServices 2025-03-13 11:52:05 +01:00
kaslr.c efi/libstub: Use cleanup helpers for freeing copies of the memory map 2025-01-14 08:35:27 +01:00
loongarch-stub.c efi/libstub: Synchronize instruction cache after kernel relocation 2026-04-29 08:56:16 +02:00
loongarch-stub.h efi/loongarch: Directly position the loaded image file 2023-12-19 11:16:37 +01:00
loongarch.c efi/loongarch: Randomize kernel preferred address for KASLR 2026-05-21 20:58:36 +08:00
Makefile efi/libstub: Move efi_relocate_kernel() into its only remaining user 2026-04-29 08:55:58 +02:00
Makefile.zboot arm64: fix unnecessary rebuilding when CONFIG_DEBUG_EFI=y 2025-07-08 14:05:29 +01:00
mem.c efi/libstub: Move efi_relocate_kernel() into its only remaining user 2026-04-29 08:55:58 +02:00
pci.c efi/libstub: Simplify PCI I/O handle buffer traversal 2025-01-14 08:35:27 +01:00
primary_display.c efi: Support EDID information 2025-12-16 14:40:51 +01:00
printk.c efistub: Lower default log level 2025-07-15 03:32:53 +02:00
random.c efi: stub: use random seed from EFI variable 2022-12-01 09:51:21 +01:00
randomalloc.c efi/libstub: Avoid physical address 0x0 when doing random allocation 2025-03-14 12:21:29 +01:00
riscv-stub.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
riscv.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
secureboot.c efi: libstub: check Shim mode using MokSBStateRT 2022-09-22 10:15:44 +02:00
skip_spaces.c efi/libstub: Fix missing-prototype warning for skip_spaces() 2020-06-15 19:43:58 +02:00
smbios.c x86/efistub: Enable SMBIOS protocol handling for x86 2024-07-08 10:17:44 +02:00
string.c efi: libstub: Provide local implementations of strrchr() and memchr() 2022-11-09 12:42:02 +01:00
systable.c efi/libstub: move efi_system_table global var into separate object 2022-09-19 11:19:35 +02:00
tpm.c libstub,tpm: do not ignore failure case when reading final event log 2024-10-15 20:27:30 +02:00
unaccepted_memory.c mm: rework accept memory helpers 2024-09-01 20:26:07 -07:00
vsprintf.c isystem: ship and use stdarg.h 2021-08-19 09:02:55 +09:00
x86-5lvl.c efi/libstub: Fix page table access in 5-level to 4-level paging transition 2025-11-05 17:31:32 +01:00
x86-stub.c efi/libstub: x86: Store EDID in boot_params 2025-11-18 20:39:55 +01:00
x86-stub.h x86/efistub: Give up if memory attribute protocol returns an error 2024-01-26 16:58:19 +01:00
zboot-decompress-gzip.c efi/libstub: Avoid legacy decompressor zlib/zstd wrappers 2025-03-14 12:36:11 +01:00
zboot-decompress-zstd.c efi/libstub: Avoid legacy decompressor zlib/zstd wrappers 2025-03-14 12:36:11 +01:00
zboot-header.S include: pe.h: Fix PE definitions 2025-05-21 16:46:37 +02:00
zboot.c efi: Support EDID information 2025-12-16 14:40:51 +01:00
zboot.lds efi: Fix .data section size calculations when .sbat is present 2025-06-20 13:36:14 +02:00