aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 19:49:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 19:49:17 -0400
commit1dcf58d6e6e6eb7ec10e9abc56887b040205b06f (patch)
treec03e7a25ef13eea62f1547914a76e5c68f3f4c28 /arch/arm64
parent80dcc31fbe55932ac9204daee5f2ebc0c49b6da3 (diff)
parente4b0db72be2487bae0e3251c22f82c104f7c1cfd (diff)
Merge branch 'akpm' (patches from Andrew)
Merge first patchbomb from Andrew Morton: - arch/sh updates - ocfs2 updates - kernel/watchdog feature - about half of mm/ * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (122 commits) Documentation: update arch list in the 'memtest' entry Kconfig: memtest: update number of test patterns up to 17 arm: add support for memtest arm64: add support for memtest memtest: use phys_addr_t for physical addresses mm: move memtest under mm mm, hugetlb: abort __get_user_pages if current has been oom killed mm, mempool: do not allow atomic resizing memcg: print cgroup information when system panics due to panic_on_oom mm: numa: remove migrate_ratelimited mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE mm: split ET_DYN ASLR from mmap ASLR s390: redefine randomize_et_dyn for ELF_ET_DYN_BASE mm: expose arch_mmap_rnd when available s390: standardize mmap_rnd() usage powerpc: standardize mmap_rnd() usage mips: extract logic for mmap_rnd() arm64: standardize mmap_rnd() usage x86: standardize mmap_rnd() usage arm: factor out mmap ASLR into mmap_rnd ...
Diffstat (limited to 'arch/arm64')
-rw-r--r--arch/arm64/Kconfig16
-rw-r--r--arch/arm64/include/asm/elf.h5
-rw-r--r--arch/arm64/include/asm/kvm_mmu.h4
-rw-r--r--arch/arm64/include/asm/page.h4
-rw-r--r--arch/arm64/include/asm/pgalloc.h8
-rw-r--r--arch/arm64/include/asm/pgtable-hwdef.h6
-rw-r--r--arch/arm64/include/asm/pgtable-types.h12
-rw-r--r--arch/arm64/include/asm/pgtable.h8
-rw-r--r--arch/arm64/include/asm/tlb.h4
-rw-r--r--arch/arm64/mm/init.c2
-rw-r--r--arch/arm64/mm/mmap.c20
-rw-r--r--arch/arm64/mm/mmu.c4
12 files changed, 47 insertions, 46 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1b8e97331ffb..34f487d5d84e 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,7 +1,7 @@
1config ARM64 1config ARM64
2 def_bool y 2 def_bool y
3 select ARCH_BINFMT_ELF_RANDOMIZE_PIE
4 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 3 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
4 select ARCH_HAS_ELF_RANDOMIZE
5 select ARCH_HAS_GCOV_PROFILE_ALL 5 select ARCH_HAS_GCOV_PROFILE_ALL
6 select ARCH_HAS_SG_CHAIN 6 select ARCH_HAS_SG_CHAIN
7 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST 7 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
@@ -143,6 +143,13 @@ config KERNEL_MODE_NEON
143config FIX_EARLYCON_MEM 143config FIX_EARLYCON_MEM
144 def_bool y 144 def_bool y
145 145
146config PGTABLE_LEVELS
147 int
148 default 2 if ARM64_64K_PAGES && ARM64_VA_BITS_42
149 default 3 if ARM64_64K_PAGES && ARM64_VA_BITS_48
150 default 3 if ARM64_4K_PAGES && ARM64_VA_BITS_39
151 default 4 if ARM64_4K_PAGES && ARM64_VA_BITS_48
152
146source "init/Kconfig" 153source "init/Kconfig"
147 154
148source "kernel/Kconfig.freezer" 155source "kernel/Kconfig.freezer"
@@ -413,13 +420,6 @@ config ARM64_VA_BITS
413 default 42 if ARM64_VA_BITS_42 420 default 42 if ARM64_VA_BITS_42
414 default 48 if ARM64_VA_BITS_48 421 default 48 if ARM64_VA_BITS_48
415 422
416config ARM64_PGTABLE_LEVELS
417 int
418 default 2 if ARM64_64K_PAGES && ARM64_VA_BITS_42
419 default 3 if ARM64_64K_PAGES && ARM64_VA_BITS_48
420 default 3 if ARM64_4K_PAGES && ARM64_VA_BITS_39
421 default 4 if ARM64_4K_PAGES && ARM64_VA_BITS_48
422
423config CPU_BIG_ENDIAN 423config CPU_BIG_ENDIAN
424 bool "Build big-endian kernel" 424 bool "Build big-endian kernel"
425 help 425 help
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 1f65be393139..faad6df49e5b 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -125,7 +125,6 @@ typedef struct user_fpsimd_state elf_fpregset_t;
125 * the loader. We need to make sure that it is out of the way of the program 125 * the loader. We need to make sure that it is out of the way of the program
126 * that it will "exec", and that there is sufficient room for the brk. 126 * that it will "exec", and that there is sufficient room for the brk.
127 */ 127 */
128extern unsigned long randomize_et_dyn(unsigned long base);
129#define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3) 128#define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3)
130 129
131/* 130/*
@@ -157,10 +156,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
157#define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12)) 156#define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12))
158#endif 157#endif
159 158
160struct mm_struct;
161extern unsigned long arch_randomize_brk(struct mm_struct *mm);
162#define arch_randomize_brk arch_randomize_brk
163
164#ifdef CONFIG_COMPAT 159#ifdef CONFIG_COMPAT
165 160
166#ifdef __AARCH64EB__ 161#ifdef __AARCH64EB__
diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h
index bbfb600fa822..36250705dc4c 100644
--- a/arch/arm64/include/asm/kvm_mmu.h
+++ b/arch/arm64/include/asm/kvm_mmu.h
@@ -163,12 +163,12 @@ static inline bool kvm_s2pmd_readonly(pmd_t *pmd)
163/* 163/*
164 * If we are concatenating first level stage-2 page tables, we would have less 164 * If we are concatenating first level stage-2 page tables, we would have less
165 * than or equal to 16 pointers in the fake PGD, because that's what the 165 * than or equal to 16 pointers in the fake PGD, because that's what the
166 * architecture allows. In this case, (4 - CONFIG_ARM64_PGTABLE_LEVELS) 166 * architecture allows. In this case, (4 - CONFIG_PGTABLE_LEVELS)
167 * represents the first level for the host, and we add 1 to go to the next 167 * represents the first level for the host, and we add 1 to go to the next
168 * level (which uses contatenation) for the stage-2 tables. 168 * level (which uses contatenation) for the stage-2 tables.
169 */ 169 */
170#if PTRS_PER_S2_PGD <= 16 170#if PTRS_PER_S2_PGD <= 16
171#define KVM_PREALLOC_LEVEL (4 - CONFIG_ARM64_PGTABLE_LEVELS + 1) 171#define KVM_PREALLOC_LEVEL (4 - CONFIG_PGTABLE_LEVELS + 1)
172#else 172#else
173#define KVM_PREALLOC_LEVEL (0) 173#define KVM_PREALLOC_LEVEL (0)
174#endif 174#endif
diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h
index 22b16232bd60..8fc8fa280e92 100644
--- a/arch/arm64/include/asm/page.h
+++ b/arch/arm64/include/asm/page.h
@@ -36,9 +36,9 @@
36 * for more information). 36 * for more information).
37 */ 37 */
38#ifdef CONFIG_ARM64_64K_PAGES 38#ifdef CONFIG_ARM64_64K_PAGES
39#define SWAPPER_PGTABLE_LEVELS (CONFIG_ARM64_PGTABLE_LEVELS) 39#define SWAPPER_PGTABLE_LEVELS (CONFIG_PGTABLE_LEVELS)
40#else 40#else
41#define SWAPPER_PGTABLE_LEVELS (CONFIG_ARM64_PGTABLE_LEVELS - 1) 41#define SWAPPER_PGTABLE_LEVELS (CONFIG_PGTABLE_LEVELS - 1)
42#endif 42#endif
43 43
44#define SWAPPER_DIR_SIZE (SWAPPER_PGTABLE_LEVELS * PAGE_SIZE) 44#define SWAPPER_DIR_SIZE (SWAPPER_PGTABLE_LEVELS * PAGE_SIZE)
diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
index e20df38a8ff3..76420568d66a 100644
--- a/arch/arm64/include/asm/pgalloc.h
+++ b/arch/arm64/include/asm/pgalloc.h
@@ -28,7 +28,7 @@
28 28
29#define PGALLOC_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO) 29#define PGALLOC_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO)
30 30
31#if CONFIG_ARM64_PGTABLE_LEVELS > 2 31#if CONFIG_PGTABLE_LEVELS > 2
32 32
33static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) 33static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
34{ 34{
@@ -46,9 +46,9 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
46 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE)); 46 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
47} 47}
48 48
49#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 2 */ 49#endif /* CONFIG_PGTABLE_LEVELS > 2 */
50 50
51#if CONFIG_ARM64_PGTABLE_LEVELS > 3 51#if CONFIG_PGTABLE_LEVELS > 3
52 52
53static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) 53static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
54{ 54{
@@ -66,7 +66,7 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
66 set_pgd(pgd, __pgd(__pa(pud) | PUD_TYPE_TABLE)); 66 set_pgd(pgd, __pgd(__pa(pud) | PUD_TYPE_TABLE));
67} 67}
68 68
69#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 3 */ 69#endif /* CONFIG_PGTABLE_LEVELS > 3 */
70 70
71extern pgd_t *pgd_alloc(struct mm_struct *mm); 71extern pgd_t *pgd_alloc(struct mm_struct *mm);
72extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); 72extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index 5f930cc9ea83..80f3d241cff8 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -21,7 +21,7 @@
21/* 21/*
22 * PMD_SHIFT determines the size a level 2 page table entry can map. 22 * PMD_SHIFT determines the size a level 2 page table entry can map.
23 */ 23 */
24#if CONFIG_ARM64_PGTABLE_LEVELS > 2 24#if CONFIG_PGTABLE_LEVELS > 2
25#define PMD_SHIFT ((PAGE_SHIFT - 3) * 2 + 3) 25#define PMD_SHIFT ((PAGE_SHIFT - 3) * 2 + 3)
26#define PMD_SIZE (_AC(1, UL) << PMD_SHIFT) 26#define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
27#define PMD_MASK (~(PMD_SIZE-1)) 27#define PMD_MASK (~(PMD_SIZE-1))
@@ -31,7 +31,7 @@
31/* 31/*
32 * PUD_SHIFT determines the size a level 1 page table entry can map. 32 * PUD_SHIFT determines the size a level 1 page table entry can map.
33 */ 33 */
34#if CONFIG_ARM64_PGTABLE_LEVELS > 3 34#if CONFIG_PGTABLE_LEVELS > 3
35#define PUD_SHIFT ((PAGE_SHIFT - 3) * 3 + 3) 35#define PUD_SHIFT ((PAGE_SHIFT - 3) * 3 + 3)
36#define PUD_SIZE (_AC(1, UL) << PUD_SHIFT) 36#define PUD_SIZE (_AC(1, UL) << PUD_SHIFT)
37#define PUD_MASK (~(PUD_SIZE-1)) 37#define PUD_MASK (~(PUD_SIZE-1))
@@ -42,7 +42,7 @@
42 * PGDIR_SHIFT determines the size a top-level page table entry can map 42 * PGDIR_SHIFT determines the size a top-level page table entry can map
43 * (depending on the configuration, this level can be 0, 1 or 2). 43 * (depending on the configuration, this level can be 0, 1 or 2).
44 */ 44 */
45#define PGDIR_SHIFT ((PAGE_SHIFT - 3) * CONFIG_ARM64_PGTABLE_LEVELS + 3) 45#define PGDIR_SHIFT ((PAGE_SHIFT - 3) * CONFIG_PGTABLE_LEVELS + 3)
46#define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT) 46#define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT)
47#define PGDIR_MASK (~(PGDIR_SIZE-1)) 47#define PGDIR_MASK (~(PGDIR_SIZE-1))
48#define PTRS_PER_PGD (1 << (VA_BITS - PGDIR_SHIFT)) 48#define PTRS_PER_PGD (1 << (VA_BITS - PGDIR_SHIFT))
diff --git a/arch/arm64/include/asm/pgtable-types.h b/arch/arm64/include/asm/pgtable-types.h
index ca9df80af896..2b1bd7e52c3b 100644
--- a/arch/arm64/include/asm/pgtable-types.h
+++ b/arch/arm64/include/asm/pgtable-types.h
@@ -38,13 +38,13 @@ typedef struct { pteval_t pte; } pte_t;
38#define pte_val(x) ((x).pte) 38#define pte_val(x) ((x).pte)
39#define __pte(x) ((pte_t) { (x) } ) 39#define __pte(x) ((pte_t) { (x) } )
40 40
41#if CONFIG_ARM64_PGTABLE_LEVELS > 2 41#if CONFIG_PGTABLE_LEVELS > 2
42typedef struct { pmdval_t pmd; } pmd_t; 42typedef struct { pmdval_t pmd; } pmd_t;
43#define pmd_val(x) ((x).pmd) 43#define pmd_val(x) ((x).pmd)
44#define __pmd(x) ((pmd_t) { (x) } ) 44#define __pmd(x) ((pmd_t) { (x) } )
45#endif 45#endif
46 46
47#if CONFIG_ARM64_PGTABLE_LEVELS > 3 47#if CONFIG_PGTABLE_LEVELS > 3
48typedef struct { pudval_t pud; } pud_t; 48typedef struct { pudval_t pud; } pud_t;
49#define pud_val(x) ((x).pud) 49#define pud_val(x) ((x).pud)
50#define __pud(x) ((pud_t) { (x) } ) 50#define __pud(x) ((pud_t) { (x) } )
@@ -64,13 +64,13 @@ typedef pteval_t pte_t;
64#define pte_val(x) (x) 64#define pte_val(x) (x)
65#define __pte(x) (x) 65#define __pte(x) (x)
66 66
67#if CONFIG_ARM64_PGTABLE_LEVELS > 2 67#if CONFIG_PGTABLE_LEVELS > 2
68typedef pmdval_t pmd_t; 68typedef pmdval_t pmd_t;
69#define pmd_val(x) (x) 69#define pmd_val(x) (x)
70#define __pmd(x) (x) 70#define __pmd(x) (x)
71#endif 71#endif
72 72
73#if CONFIG_ARM64_PGTABLE_LEVELS > 3 73#if CONFIG_PGTABLE_LEVELS > 3
74typedef pudval_t pud_t; 74typedef pudval_t pud_t;
75#define pud_val(x) (x) 75#define pud_val(x) (x)
76#define __pud(x) (x) 76#define __pud(x) (x)
@@ -86,9 +86,9 @@ typedef pteval_t pgprot_t;
86 86
87#endif /* STRICT_MM_TYPECHECKS */ 87#endif /* STRICT_MM_TYPECHECKS */
88 88
89#if CONFIG_ARM64_PGTABLE_LEVELS == 2 89#if CONFIG_PGTABLE_LEVELS == 2
90#include <asm-generic/pgtable-nopmd.h> 90#include <asm-generic/pgtable-nopmd.h>
91#elif CONFIG_ARM64_PGTABLE_LEVELS == 3 91#elif CONFIG_PGTABLE_LEVELS == 3
92#include <asm-generic/pgtable-nopud.h> 92#include <asm-generic/pgtable-nopud.h>
93#endif 93#endif
94 94
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 800ec0e87ed9..56283f8a675c 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -374,7 +374,7 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
374 */ 374 */
375#define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot) 375#define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot)
376 376
377#if CONFIG_ARM64_PGTABLE_LEVELS > 2 377#if CONFIG_PGTABLE_LEVELS > 2
378 378
379#define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd_val(pmd)) 379#define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd_val(pmd))
380 380
@@ -409,9 +409,9 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
409 409
410#define pud_page(pud) pfn_to_page(__phys_to_pfn(pud_val(pud) & PHYS_MASK)) 410#define pud_page(pud) pfn_to_page(__phys_to_pfn(pud_val(pud) & PHYS_MASK))
411 411
412#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 2 */ 412#endif /* CONFIG_PGTABLE_LEVELS > 2 */
413 413
414#if CONFIG_ARM64_PGTABLE_LEVELS > 3 414#if CONFIG_PGTABLE_LEVELS > 3
415 415
416#define pud_ERROR(pud) __pud_error(__FILE__, __LINE__, pud_val(pud)) 416#define pud_ERROR(pud) __pud_error(__FILE__, __LINE__, pud_val(pud))
417 417
@@ -445,7 +445,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long addr)
445 445
446#define pgd_page(pgd) pfn_to_page(__phys_to_pfn(pgd_val(pgd) & PHYS_MASK)) 446#define pgd_page(pgd) pfn_to_page(__phys_to_pfn(pgd_val(pgd) & PHYS_MASK))
447 447
448#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 3 */ 448#endif /* CONFIG_PGTABLE_LEVELS > 3 */
449 449
450#define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd)) 450#define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd))
451 451
diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
index 53d9c354219f..3a0242c7eb8d 100644
--- a/arch/arm64/include/asm/tlb.h
+++ b/arch/arm64/include/asm/tlb.h
@@ -53,7 +53,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
53 tlb_remove_entry(tlb, pte); 53 tlb_remove_entry(tlb, pte);
54} 54}
55 55
56#if CONFIG_ARM64_PGTABLE_LEVELS > 2 56#if CONFIG_PGTABLE_LEVELS > 2
57static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, 57static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
58 unsigned long addr) 58 unsigned long addr)
59{ 59{
@@ -62,7 +62,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
62} 62}
63#endif 63#endif
64 64
65#if CONFIG_ARM64_PGTABLE_LEVELS > 3 65#if CONFIG_PGTABLE_LEVELS > 3
66static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp, 66static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp,
67 unsigned long addr) 67 unsigned long addr)
68{ 68{
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index ae85da6307bb..597831bdddf3 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -190,6 +190,8 @@ void __init bootmem_init(void)
190 min = PFN_UP(memblock_start_of_DRAM()); 190 min = PFN_UP(memblock_start_of_DRAM());
191 max = PFN_DOWN(memblock_end_of_DRAM()); 191 max = PFN_DOWN(memblock_end_of_DRAM());
192 192
193 early_memtest(min << PAGE_SHIFT, max << PAGE_SHIFT);
194
193 /* 195 /*
194 * Sparsemem tries to allocate bootmem in memory_present(), so must be 196 * Sparsemem tries to allocate bootmem in memory_present(), so must be
195 * done after the fixed reservations. 197 * done after the fixed reservations.
diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c
index 54922d1275b8..ed177475dd8c 100644
--- a/arch/arm64/mm/mmap.c
+++ b/arch/arm64/mm/mmap.c
@@ -47,17 +47,16 @@ static int mmap_is_legacy(void)
47 return sysctl_legacy_va_layout; 47 return sysctl_legacy_va_layout;
48} 48}
49 49
50static unsigned long mmap_rnd(void) 50unsigned long arch_mmap_rnd(void)
51{ 51{
52 unsigned long rnd = 0; 52 unsigned long rnd;
53 53
54 if (current->flags & PF_RANDOMIZE) 54 rnd = (unsigned long)get_random_int() & STACK_RND_MASK;
55 rnd = (long)get_random_int() & STACK_RND_MASK;
56 55
57 return rnd << PAGE_SHIFT; 56 return rnd << PAGE_SHIFT;
58} 57}
59 58
60static unsigned long mmap_base(void) 59static unsigned long mmap_base(unsigned long rnd)
61{ 60{
62 unsigned long gap = rlimit(RLIMIT_STACK); 61 unsigned long gap = rlimit(RLIMIT_STACK);
63 62
@@ -66,7 +65,7 @@ static unsigned long mmap_base(void)
66 else if (gap > MAX_GAP) 65 else if (gap > MAX_GAP)
67 gap = MAX_GAP; 66 gap = MAX_GAP;
68 67
69 return PAGE_ALIGN(STACK_TOP - gap - mmap_rnd()); 68 return PAGE_ALIGN(STACK_TOP - gap - rnd);
70} 69}
71 70
72/* 71/*
@@ -75,15 +74,20 @@ static unsigned long mmap_base(void)
75 */ 74 */
76void arch_pick_mmap_layout(struct mm_struct *mm) 75void arch_pick_mmap_layout(struct mm_struct *mm)
77{ 76{
77 unsigned long random_factor = 0UL;
78
79 if (current->flags & PF_RANDOMIZE)
80 random_factor = arch_mmap_rnd();
81
78 /* 82 /*
79 * Fall back to the standard layout if the personality bit is set, or 83 * Fall back to the standard layout if the personality bit is set, or
80 * if the expected stack growth is unlimited: 84 * if the expected stack growth is unlimited:
81 */ 85 */
82 if (mmap_is_legacy()) { 86 if (mmap_is_legacy()) {
83 mm->mmap_base = TASK_UNMAPPED_BASE; 87 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
84 mm->get_unmapped_area = arch_get_unmapped_area; 88 mm->get_unmapped_area = arch_get_unmapped_area;
85 } else { 89 } else {
86 mm->mmap_base = mmap_base(); 90 mm->mmap_base = mmap_base(random_factor);
87 mm->get_unmapped_area = arch_get_unmapped_area_topdown; 91 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
88 } 92 }
89} 93}
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index c6daaf6c6f97..79e01163a981 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -550,10 +550,10 @@ void vmemmap_free(unsigned long start, unsigned long end)
550#endif /* CONFIG_SPARSEMEM_VMEMMAP */ 550#endif /* CONFIG_SPARSEMEM_VMEMMAP */
551 551
552static pte_t bm_pte[PTRS_PER_PTE] __page_aligned_bss; 552static pte_t bm_pte[PTRS_PER_PTE] __page_aligned_bss;
553#if CONFIG_ARM64_PGTABLE_LEVELS > 2 553#if CONFIG_PGTABLE_LEVELS > 2
554static pmd_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss; 554static pmd_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss;
555#endif 555#endif
556#if CONFIG_ARM64_PGTABLE_LEVELS > 3 556#if CONFIG_PGTABLE_LEVELS > 3
557static pud_t bm_pud[PTRS_PER_PUD] __page_aligned_bss; 557static pud_t bm_pud[PTRS_PER_PUD] __page_aligned_bss;
558#endif 558#endif
559 559