Merge tag 'bpf-6.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
[linux-stable.git] / arch / arm64 / kernel / kaslr.c
blob1da3e25f9d9e5513ad37737ab1cb35a8799d3591
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2016 Linaro Ltd <ard.biesheuvel@linaro.org>
4 */
6 #include <linux/cache.h>
7 #include <linux/init.h>
8 #include <linux/printk.h>
10 #include <asm/cpufeature.h>
11 #include <asm/memory.h>
13 u16 __initdata memstart_offset_seed;
15 bool __ro_after_init __kaslr_is_enabled = false;
17 void __init kaslr_init(void)
19 if (kaslr_disabled_cmdline()) {
20 pr_info("KASLR disabled on command line\n");
21 return;
25 * The KASLR offset modulo MIN_KIMG_ALIGN is taken from the physical
26 * placement of the image rather than from the seed, so a displacement
27 * of less than MIN_KIMG_ALIGN means that no seed was provided.
29 if (kaslr_offset() < MIN_KIMG_ALIGN) {
30 pr_warn("KASLR disabled due to lack of seed\n");
31 return;
34 pr_info("KASLR enabled\n");
35 __kaslr_is_enabled = true;
38 static int __init parse_nokaslr(char *unused)
40 /* nokaslr param handling is done by early cpufeature code */
41 return 0;
43 early_param("nokaslr", parse_nokaslr);