Skip to content

Commit 1db780b

Browse files
ardbiesheuvelwilldeacon
authored andcommitted
arm64/mm: Remove randomization of the linear map
Since commit 97d6786 ("arm64: mm: account for hotplug memory when randomizing the linear region") the decision whether or not to randomize the placement of the system's DRAM inside the linear map is based on the capabilities of the CPU rather than how much memory is present at boot time. This change was necessary because memory hotplug may result in DRAM appearing in places that are not covered by the linear region at all (and therefore unusable) if the decision is solely based on the memory map at boot. In the Android GKI kernel, which requires support for memory hotplug, and is built with a reduced virtual address space of only 39 bits wide, randomization of the linear map never happens in practice as a result. And even on arm64 kernels built with support for 48 bit virtual addressing, the wider PArange of recent CPUs means that linear map randomization is slowly becoming a feature that only works on systems that will soon be obsolete. So let's just remove this feature. We can always bring it back in an improved form if there is a real need for it. Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Kees Cook <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 0af2f6b commit 1db780b

File tree

4 files changed

+0
-27
lines changed

4 files changed

+0
-27
lines changed

arch/arm64/kernel/image-vars.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ PROVIDE(__pi_cavium_erratum_27456_cpus = cavium_erratum_27456_cpus);
5252
PROVIDE(__pi_is_midr_in_range_list = is_midr_in_range_list);
5353
#endif
5454
PROVIDE(__pi__ctype = _ctype);
55-
PROVIDE(__pi_memstart_offset_seed = memstart_offset_seed);
5655

5756
PROVIDE(__pi_init_idmap_pg_dir = init_idmap_pg_dir);
5857
PROVIDE(__pi_init_idmap_pg_end = init_idmap_pg_end);

arch/arm64/kernel/kaslr.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include <asm/cpufeature.h>
1111
#include <asm/memory.h>
1212

13-
u16 __initdata memstart_offset_seed;
14-
1513
bool __ro_after_init __kaslr_is_enabled = false;
1614

1715
void __init kaslr_init(void)

arch/arm64/kernel/pi/kaslr_early.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
#include "pi.h"
2020

21-
extern u16 memstart_offset_seed;
22-
2321
static u64 __init get_kaslr_seed(void *fdt, int node)
2422
{
2523
static char const seed_str[] __initconst = "kaslr-seed";
@@ -53,8 +51,6 @@ u64 __init kaslr_early_init(void *fdt, int chosen)
5351
return 0;
5452
}
5553

56-
memstart_offset_seed = seed & U16_MAX;
57-
5854
/*
5955
* OK, so we are proceeding with KASLR enabled. Calculate a suitable
6056
* kernel image offset from the seed. Let's place the kernel in the

arch/arm64/mm/init.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -275,26 +275,6 @@ void __init arm64_memblock_init(void)
275275
}
276276
}
277277

278-
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
279-
extern u16 memstart_offset_seed;
280-
u64 mmfr0 = read_cpuid(ID_AA64MMFR0_EL1);
281-
int parange = cpuid_feature_extract_unsigned_field(
282-
mmfr0, ID_AA64MMFR0_EL1_PARANGE_SHIFT);
283-
s64 range = linear_region_size -
284-
BIT(id_aa64mmfr0_parange_to_phys_shift(parange));
285-
286-
/*
287-
* If the size of the linear region exceeds, by a sufficient
288-
* margin, the size of the region that the physical memory can
289-
* span, randomize the linear region as well.
290-
*/
291-
if (memstart_offset_seed > 0 && range >= (s64)ARM64_MEMSTART_ALIGN) {
292-
range /= ARM64_MEMSTART_ALIGN;
293-
memstart_addr -= ARM64_MEMSTART_ALIGN *
294-
((range * memstart_offset_seed) >> 16);
295-
}
296-
}
297-
298278
/*
299279
* Register the kernel text, kernel data, initrd, and initial
300280
* pagetables with memblock.

0 commit comments

Comments
 (0)