summaryrefslogtreecommitdiff
path: root/arch/arm64/kernel/kaslr.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2016-01-29 11:59:03 +0100
committerCatalin Marinas <catalin.marinas@arm.com>2016-02-24 14:57:27 +0000
commitc031a4213c11a5db475f528c182f7b3858df11db (patch)
tree194b08753fc4dc09977fed71eccfcee48e66f412 /arch/arm64/kernel/kaslr.c
parentf80fb3a3d50843a401dac4b566b3b131da8077a2 (diff)
arm64: kaslr: randomize the linear region
When KASLR is enabled (CONFIG_RANDOMIZE_BASE=y), and entropy has been provided by the bootloader, randomize the placement of RAM inside the linear region if sufficient space is available. For instance, on a 4KB granule/3 levels kernel, the linear region is 256 GB in size, and we can choose any 1 GB aligned offset that is far enough from the top of the address space to fit the distance between the start of the lowest memblock and the top of the highest memblock. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/kernel/kaslr.c')
-rw-r--r--arch/arm64/kernel/kaslr.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c
index 8b32a1f8f09f..582983920054 100644
--- a/arch/arm64/kernel/kaslr.c
+++ b/arch/arm64/kernel/kaslr.c
@@ -21,6 +21,7 @@
#include <asm/sections.h>
u64 __read_mostly module_alloc_base;
+u16 __initdata memstart_offset_seed;
static __init u64 get_kaslr_seed(void *fdt)
{
@@ -123,6 +124,9 @@ u64 __init kaslr_early_init(u64 dt_phys)
mask = ((1UL << (VA_BITS - 2)) - 1) & ~(SZ_2M - 1);
offset = seed & mask;
+ /* use the top 16 bits to randomize the linear region */
+ memstart_offset_seed = seed >> 48;
+
/*
* The kernel Image should not extend across a 1GB/32MB/512MB alignment
* boundary (for 4KB/16KB/64KB granule kernels, respectively). If this