• Youling Tang's avatar
    LoongArch: Add support for kernel address space layout randomization (KASLR) · e5f02b51
    Youling Tang authored
    This patch adds support for relocating the kernel to a random address.
    
    Entropy is derived from the banner, which will change every build and
    random_get_entropy() which should provide additional runtime entropy.
    
    The kernel is relocated by up to RANDOMIZE_BASE_MAX_OFFSET bytes from
    its link address. Because relocation happens so early during the kernel
    booting, the amount of physical memory has not yet been determined. This
    means the only way to limit relocation within the available memory is
    via Kconfig. So we limit the maximum value of RANDOMIZE_BASE_MAX_OFFSET
    to 256M (0x10000000) because our memory layout has many holes.
    Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
    Signed-off-by: Xi Ruoyao <xry111@xry111.site> # Fix compiler warnings
    Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
    e5f02b51
relocate.c 6.17 KB