aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2014-07-15 10:37:21 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2014-07-23 10:27:46 -0400
commitabe669d7e1a8f9163eb7e8e153e7257d38c1ba3e (patch)
tree58632fadf3e08f37407fb14193c00085e247dab8 /arch
parentc79b954bf6c006f2d3dd9d01f231abeead13a410 (diff)
arm64: Convert bool ARM64_x_LEVELS to int ARM64_PGTABLE_LEVELS
Rather than having several Kconfig options, define int ARM64_PGTABLE_LEVELS which will be also useful in converting some of the pgtable macros. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Tested-by: Jungseok Lee <jungseoklee85@gmail.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm64/Kconfig13
-rw-r--r--arch/arm64/include/asm/page.h6
-rw-r--r--arch/arm64/include/asm/pgalloc.h8
-rw-r--r--arch/arm64/include/asm/pgtable-hwdef.h4
-rw-r--r--arch/arm64/include/asm/pgtable.h18
-rw-r--r--arch/arm64/include/asm/tlb.h4
-rw-r--r--arch/arm64/kernel/head.S2
-rw-r--r--arch/arm64/mm/ioremap.c4
8 files changed, 28 insertions, 31 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index cf07cc7295bb..8cdb7f36bfc8 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -207,14 +207,11 @@ config ARM64_VA_BITS
207 default 42 if ARM64_VA_BITS_42 207 default 42 if ARM64_VA_BITS_42
208 default 48 if ARM64_VA_BITS_48 208 default 48 if ARM64_VA_BITS_48
209 209
210config ARM64_2_LEVELS 210config ARM64_PGTABLE_LEVELS
211 def_bool y if ARM64_64K_PAGES && ARM64_VA_BITS_42 211 int
212 212 default 2 if ARM64_64K_PAGES && ARM64_VA_BITS_42
213config ARM64_3_LEVELS 213 default 3 if ARM64_4K_PAGES && ARM64_VA_BITS_39
214 def_bool y if ARM64_4K_PAGES && ARM64_VA_BITS_39 214 default 4 if ARM64_4K_PAGES && ARM64_VA_BITS_48
215
216config ARM64_4_LEVELS
217 def_bool y if ARM64_4K_PAGES && ARM64_VA_BITS_48
218 215
219config CPU_BIG_ENDIAN 216config CPU_BIG_ENDIAN
220 bool "Build big-endian kernel" 217 bool "Build big-endian kernel"
diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h
index cf9afa0366b6..a998ff478777 100644
--- a/arch/arm64/include/asm/page.h
+++ b/arch/arm64/include/asm/page.h
@@ -37,7 +37,7 @@
37 * map the kernel. The swapper also maps the FDT (see __create_page_tables for 37 * map the kernel. The swapper also maps the FDT (see __create_page_tables for
38 * more information). 38 * more information).
39 */ 39 */
40#ifdef CONFIG_ARM64_4_LEVELS 40#if CONFIG_ARM64_PGTABLE_LEVELS == 4
41#define SWAPPER_DIR_SIZE (3 * PAGE_SIZE) 41#define SWAPPER_DIR_SIZE (3 * PAGE_SIZE)
42#define IDMAP_DIR_SIZE (3 * PAGE_SIZE) 42#define IDMAP_DIR_SIZE (3 * PAGE_SIZE)
43#else 43#else
@@ -47,9 +47,9 @@
47 47
48#ifndef __ASSEMBLY__ 48#ifndef __ASSEMBLY__
49 49
50#ifdef CONFIG_ARM64_2_LEVELS 50#if CONFIG_ARM64_PGTABLE_LEVELS == 2
51#include <asm/pgtable-2level-types.h> 51#include <asm/pgtable-2level-types.h>
52#elif defined(CONFIG_ARM64_3_LEVELS) 52#elif CONFIG_ARM64_PGTABLE_LEVELS == 3
53#include <asm/pgtable-3level-types.h> 53#include <asm/pgtable-3level-types.h>
54#else 54#else
55#include <asm/pgtable-4level-types.h> 55#include <asm/pgtable-4level-types.h>
diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
index 7deb5750a945..d5bed02073d6 100644
--- a/arch/arm64/include/asm/pgalloc.h
+++ b/arch/arm64/include/asm/pgalloc.h
@@ -26,7 +26,7 @@
26 26
27#define check_pgt_cache() do { } while (0) 27#define check_pgt_cache() do { } while (0)
28 28
29#ifndef CONFIG_ARM64_2_LEVELS 29#if CONFIG_ARM64_PGTABLE_LEVELS > 2
30 30
31static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) 31static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
32{ 32{
@@ -44,9 +44,9 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
44 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE)); 44 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
45} 45}
46 46
47#endif /* CONFIG_ARM64_2_LEVELS */ 47#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 2 */
48 48
49#ifdef CONFIG_ARM64_4_LEVELS 49#if CONFIG_ARM64_PGTABLE_LEVELS > 3
50 50
51static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) 51static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
52{ 52{
@@ -64,7 +64,7 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
64 set_pgd(pgd, __pgd(__pa(pud) | PUD_TYPE_TABLE)); 64 set_pgd(pgd, __pgd(__pa(pud) | PUD_TYPE_TABLE));
65} 65}
66 66
67#endif /* CONFIG_ARM64_4_LEVELS */ 67#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 3 */
68 68
69extern pgd_t *pgd_alloc(struct mm_struct *mm); 69extern pgd_t *pgd_alloc(struct mm_struct *mm);
70extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); 70extern 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 fddcc3efa569..d453e8bfef06 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -16,9 +16,9 @@
16#ifndef __ASM_PGTABLE_HWDEF_H 16#ifndef __ASM_PGTABLE_HWDEF_H
17#define __ASM_PGTABLE_HWDEF_H 17#define __ASM_PGTABLE_HWDEF_H
18 18
19#ifdef CONFIG_ARM64_2_LEVELS 19#if CONFIG_ARM64_PGTABLE_LEVELS == 2
20#include <asm/pgtable-2level-hwdef.h> 20#include <asm/pgtable-2level-hwdef.h>
21#elif defined(CONFIG_ARM64_3_LEVELS) 21#elif CONFIG_ARM64_PGTABLE_LEVELS == 3
22#include <asm/pgtable-3level-hwdef.h> 22#include <asm/pgtable-3level-hwdef.h>
23#else 23#else
24#include <asm/pgtable-4level-hwdef.h> 24#include <asm/pgtable-4level-hwdef.h>
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index d9b23efdaded..9f862e6e9286 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -35,7 +35,7 @@
35 * VMALLOC and SPARSEMEM_VMEMMAP ranges. 35 * VMALLOC and SPARSEMEM_VMEMMAP ranges.
36 */ 36 */
37#define VMALLOC_START (UL(0xffffffffffffffff) << VA_BITS) 37#define VMALLOC_START (UL(0xffffffffffffffff) << VA_BITS)
38#ifndef CONFIG_ARM64_4_LEVELS 38#if CONFIG_ARM64_PGTABLE_LEVELS != 4
39#define VMALLOC_END (PAGE_OFFSET - UL(0x400000000) - SZ_64K) 39#define VMALLOC_END (PAGE_OFFSET - UL(0x400000000) - SZ_64K)
40#else 40#else
41#define VMALLOC_END (PAGE_OFFSET - UL(0x40000000000) - SZ_64K) 41#define VMALLOC_END (PAGE_OFFSET - UL(0x40000000000) - SZ_64K)
@@ -52,10 +52,10 @@ extern void __pud_error(const char *file, int line, unsigned long val);
52extern void __pgd_error(const char *file, int line, unsigned long val); 52extern void __pgd_error(const char *file, int line, unsigned long val);
53 53
54#define pte_ERROR(pte) __pte_error(__FILE__, __LINE__, pte_val(pte)) 54#define pte_ERROR(pte) __pte_error(__FILE__, __LINE__, pte_val(pte))
55#ifndef CONFIG_ARM64_2_LEVELS 55#if CONFIG_ARM64_PGTABLE_LEVELS > 2
56#define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd_val(pmd)) 56#define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd_val(pmd))
57#endif 57#endif
58#ifdef CONFIG_ARM64_4_LEVELS 58#if CONFIG_ARM64_PGTABLE_LEVELS > 3
59#define pud_ERROR(pud) __pud_error(__FILE__, __LINE__, pud_val(pud)) 59#define pud_ERROR(pud) __pud_error(__FILE__, __LINE__, pud_val(pud))
60#endif 60#endif
61#define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd)) 61#define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd))
@@ -331,7 +331,7 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
331 */ 331 */
332#define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot) 332#define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot)
333 333
334#ifndef CONFIG_ARM64_2_LEVELS 334#if CONFIG_ARM64_PGTABLE_LEVELS > 2
335 335
336#define pud_none(pud) (!pud_val(pud)) 336#define pud_none(pud) (!pud_val(pud))
337#define pud_bad(pud) (!(pud_val(pud) & 2)) 337#define pud_bad(pud) (!(pud_val(pud) & 2))
@@ -353,9 +353,9 @@ static inline pmd_t *pud_page_vaddr(pud_t pud)
353 return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK); 353 return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
354} 354}
355 355
356#endif /* CONFIG_ARM64_2_LEVELS */ 356#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 2 */
357 357
358#ifdef CONFIG_ARM64_4_LEVELS 358#if CONFIG_ARM64_PGTABLE_LEVELS > 3
359 359
360#define pgd_none(pgd) (!pgd_val(pgd)) 360#define pgd_none(pgd) (!pgd_val(pgd))
361#define pgd_bad(pgd) (!(pgd_val(pgd) & 2)) 361#define pgd_bad(pgd) (!(pgd_val(pgd) & 2))
@@ -377,7 +377,7 @@ static inline pud_t *pgd_page_vaddr(pgd_t pgd)
377 return __va(pgd_val(pgd) & PHYS_MASK & (s32)PAGE_MASK); 377 return __va(pgd_val(pgd) & PHYS_MASK & (s32)PAGE_MASK);
378} 378}
379 379
380#endif /* CONFIG_ARM64_4_LEVELS */ 380#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 3 */
381 381
382/* to find an entry in a page-table-directory */ 382/* to find an entry in a page-table-directory */
383#define pgd_index(addr) (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) 383#define pgd_index(addr) (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
@@ -387,7 +387,7 @@ static inline pud_t *pgd_page_vaddr(pgd_t pgd)
387/* to find an entry in a kernel page-table-directory */ 387/* to find an entry in a kernel page-table-directory */
388#define pgd_offset_k(addr) pgd_offset(&init_mm, addr) 388#define pgd_offset_k(addr) pgd_offset(&init_mm, addr)
389 389
390#ifdef CONFIG_ARM64_4_LEVELS 390#if CONFIG_ARM64_PGTABLE_LEVELS > 3
391#define pud_index(addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)) 391#define pud_index(addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
392static inline pud_t *pud_offset(pgd_t *pgd, unsigned long addr) 392static inline pud_t *pud_offset(pgd_t *pgd, unsigned long addr)
393{ 393{
@@ -396,7 +396,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long addr)
396#endif 396#endif
397 397
398/* Find an entry in the second-level page table.. */ 398/* Find an entry in the second-level page table.. */
399#ifndef CONFIG_ARM64_2_LEVELS 399#if CONFIG_ARM64_PGTABLE_LEVELS > 2
400#define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)) 400#define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
401static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) 401static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
402{ 402{
diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
index 49dc8f03362f..62731ef9749a 100644
--- a/arch/arm64/include/asm/tlb.h
+++ b/arch/arm64/include/asm/tlb.h
@@ -91,7 +91,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
91 tlb_remove_page(tlb, pte); 91 tlb_remove_page(tlb, pte);
92} 92}
93 93
94#ifndef CONFIG_ARM64_2_LEVELS 94#if CONFIG_ARM64_PGTABLE_LEVELS > 2
95static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, 95static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
96 unsigned long addr) 96 unsigned long addr)
97{ 97{
@@ -100,7 +100,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
100} 100}
101#endif 101#endif
102 102
103#ifdef CONFIG_ARM64_4_LEVELS 103#if CONFIG_ARM64_PGTABLE_LEVELS > 3
104static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp, 104static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp,
105 unsigned long addr) 105 unsigned long addr)
106{ 106{
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 847b99daad79..019f81d9f1d5 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -484,7 +484,7 @@ ENDPROC(__calc_phys_offset)
484 * Returns: pud 484 * Returns: pud
485 */ 485 */
486 .macro create_pud_entry, pgd, tbl, virt, pud, tmp1, tmp2 486 .macro create_pud_entry, pgd, tbl, virt, pud, tmp1, tmp2
487#ifdef CONFIG_ARM64_4_LEVELS 487#if CONFIG_ARM64_PGTABLE_LEVELS == 4
488 add \tbl, \tbl, #PAGE_SIZE // bump tbl 1 page up. 488 add \tbl, \tbl, #PAGE_SIZE // bump tbl 1 page up.
489 // to make room for pud 489 // to make room for pud
490 add \pud, \pgd, #PAGE_SIZE // pgd points to pud which 490 add \pud, \pgd, #PAGE_SIZE // pgd points to pud which
diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c
index d5e969e7b576..fa324bd5a5c4 100644
--- a/arch/arm64/mm/ioremap.c
+++ b/arch/arm64/mm/ioremap.c
@@ -104,10 +104,10 @@ void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size)
104EXPORT_SYMBOL(ioremap_cache); 104EXPORT_SYMBOL(ioremap_cache);
105 105
106static pte_t bm_pte[PTRS_PER_PTE] __page_aligned_bss; 106static pte_t bm_pte[PTRS_PER_PTE] __page_aligned_bss;
107#ifndef CONFIG_ARM64_2_LEVELS 107#if CONFIG_ARM64_PGTABLE_LEVELS > 2
108static pte_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss; 108static pte_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss;
109#endif 109#endif
110#ifdef CONFIG_ARM64_4_LEVELS 110#if CONFIG_ARM64_PGTABLE_LEVELS > 3
111static pte_t bm_pud[PTRS_PER_PUD] __page_aligned_bss; 111static pte_t bm_pud[PTRS_PER_PUD] __page_aligned_bss;
112#endif 112#endif
113 113