mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
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>
38 lines
914 B
C
38 lines
914 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited
|
|
*/
|
|
#ifndef _ASM_LOONGARCH_EFI_H
|
|
#define _ASM_LOONGARCH_EFI_H
|
|
|
|
#include <linux/efi.h>
|
|
|
|
void __init efi_init(void);
|
|
void __init efi_runtime_init(void);
|
|
void __init *efi_fdt_pointer(void);
|
|
void efifb_setup_from_dmi(struct screen_info *si, const char *opt);
|
|
|
|
#define ARCH_EFI_IRQ_FLAGS_MASK 0x00000004 /* Bit 2: CSR.CRMD.IE */
|
|
|
|
#define arch_efi_call_virt_setup()
|
|
#define arch_efi_call_virt_teardown()
|
|
|
|
#define EFI_ALLOC_ALIGN SZ_64K
|
|
#define EFI_RT_VIRTUAL_OFFSET CSR_DMW0_BASE
|
|
|
|
static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
|
|
{
|
|
return ULONG_MAX;
|
|
}
|
|
|
|
static inline unsigned long efi_get_kimg_min_align(void)
|
|
{
|
|
return SZ_2M;
|
|
}
|
|
|
|
unsigned long efi_get_kimg_kaslr_address(void);
|
|
|
|
#define EFI_KIMG_PREFERRED_ADDRESS efi_get_kimg_kaslr_address()
|
|
|
|
#endif /* _ASM_LOONGARCH_EFI_H */
|