Skip to content

Commit e41ceed

Browse files
Jungseok Leectmarinas
authored andcommitted
arm64: Introduce VA_BITS and translation level options
This patch adds virtual address space size and a level of translation tables to kernel configuration. It facilicates introduction of different MMU options, such as 4KB + 4 levels, 16KB + 4 levels and 64KB + 3 levels, easily. The idea is based on the discussion with Catalin Marinas: http://www.spinics.net/linux/lists/arm-kernel/msg319552.html Signed-off-by: Jungseok Lee <jays.lee@samsung.com> Reviewed-by: Sungjinn Chung <sungjinn.chung@samsung.com> Acked-by: Kukjin Kim <kgene.kim@samsung.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Tested-by: Jungseok Lee <jungseoklee85@gmail.com>
1 parent 7edd88a commit e41ceed

7 files changed

Lines changed: 54 additions & 15 deletions

File tree

‎arch/arm64/Kconfig‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,57 @@ endmenu
157157

158158
menu "Kernel Features"
159159

160+
choice
161+
prompt "Page size"
162+
default ARM64_4K_PAGES
163+
help
164+
Page size (translation granule) configuration.
165+
166+
config ARM64_4K_PAGES
167+
bool "4KB"
168+
help
169+
This feature enables 4KB pages support.
170+
160171
config ARM64_64K_PAGES
161-
bool "Enable 64KB pages support"
172+
bool "64KB"
162173
help
163174
This feature enables 64KB pages support (4KB by default)
164175
allowing only two levels of page tables and faster TLB
165176
look-up. AArch32 emulation is not available when this feature
166177
is enabled.
167178

179+
endchoice
180+
181+
choice
182+
prompt "Virtual address space size"
183+
default ARM64_VA_BITS_39 if ARM64_4K_PAGES
184+
default ARM64_VA_BITS_42 if ARM64_64K_PAGES
185+
help
186+
Allows choosing one of multiple possible virtual address
187+
space sizes. The level of translation table is determined by
188+
a combination of page size and virtual address space size.
189+
190+
config ARM64_VA_BITS_39
191+
bool "39-bit"
192+
depends on ARM64_4K_PAGES
193+
194+
config ARM64_VA_BITS_42
195+
bool "42-bit"
196+
depends on ARM64_64K_PAGES
197+
198+
endchoice
199+
200+
config ARM64_VA_BITS
201+
int
202+
default 39 if ARM64_VA_BITS_39
203+
default 42 if ARM64_VA_BITS_42
204+
205+
config ARM64_2_LEVELS
206+
def_bool y if ARM64_64K_PAGES && ARM64_VA_BITS_42
207+
208+
config ARM64_3_LEVELS
209+
def_bool y if ARM64_4K_PAGES && ARM64_VA_BITS_39
210+
168211
config CPU_BIG_ENDIAN
169212
bool "Build big-endian kernel"
170213
help

‎arch/arm64/include/asm/memory.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@
4141
* The module space lives between the addresses given by TASK_SIZE
4242
* and PAGE_OFFSET - it must be within 128MB of the kernel text.
4343
*/
44-
#ifdef CONFIG_ARM64_64K_PAGES
45-
#define VA_BITS (42)
46-
#else
47-
#define VA_BITS (39)
48-
#endif
44+
#define VA_BITS (CONFIG_ARM64_VA_BITS)
4945
#define PAGE_OFFSET (UL(0xffffffffffffffff) << (VA_BITS - 1))
5046
#define MODULES_END (PAGE_OFFSET)
5147
#define MODULES_VADDR (MODULES_END - SZ_64M)

‎arch/arm64/include/asm/page.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#ifndef __ASSEMBLY__
4444

45-
#ifdef CONFIG_ARM64_64K_PAGES
45+
#ifdef CONFIG_ARM64_2_LEVELS
4646
#include <asm/pgtable-2level-types.h>
4747
#else
4848
#include <asm/pgtable-3level-types.h>

‎arch/arm64/include/asm/pgalloc.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#define check_pgt_cache() do { } while (0)
2828

29-
#ifndef CONFIG_ARM64_64K_PAGES
29+
#ifndef CONFIG_ARM64_2_LEVELS
3030

3131
static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
3232
{
@@ -44,7 +44,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
4444
set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
4545
}
4646

47-
#endif /* CONFIG_ARM64_64K_PAGES */
47+
#endif /* CONFIG_ARM64_2_LEVELS */
4848

4949
extern pgd_t *pgd_alloc(struct mm_struct *mm);
5050
extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);

‎arch/arm64/include/asm/pgtable-hwdef.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef __ASM_PGTABLE_HWDEF_H
1717
#define __ASM_PGTABLE_HWDEF_H
1818

19-
#ifdef CONFIG_ARM64_64K_PAGES
19+
#ifdef CONFIG_ARM64_2_LEVELS
2020
#include <asm/pgtable-2level-hwdef.h>
2121
#else
2222
#include <asm/pgtable-3level-hwdef.h>

‎arch/arm64/include/asm/pgtable.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extern void __pmd_error(const char *file, int line, unsigned long val);
4747
extern void __pgd_error(const char *file, int line, unsigned long val);
4848

4949
#define pte_ERROR(pte) __pte_error(__FILE__, __LINE__, pte_val(pte))
50-
#ifndef CONFIG_ARM64_64K_PAGES
50+
#ifndef CONFIG_ARM64_2_LEVELS
5151
#define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd_val(pmd))
5252
#endif
5353
#define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd))
@@ -323,7 +323,7 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
323323
*/
324324
#define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot)
325325

326-
#ifndef CONFIG_ARM64_64K_PAGES
326+
#ifndef CONFIG_ARM64_2_LEVELS
327327

328328
#define pud_none(pud) (!pud_val(pud))
329329
#define pud_bad(pud) (!(pud_val(pud) & 2))
@@ -345,7 +345,7 @@ static inline pmd_t *pud_page_vaddr(pud_t pud)
345345
return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
346346
}
347347

348-
#endif /* CONFIG_ARM64_64K_PAGES */
348+
#endif /* CONFIG_ARM64_2_LEVELS */
349349

350350
/* to find an entry in a page-table-directory */
351351
#define pgd_index(addr) (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
@@ -356,7 +356,7 @@ static inline pmd_t *pud_page_vaddr(pud_t pud)
356356
#define pgd_offset_k(addr) pgd_offset(&init_mm, addr)
357357

358358
/* Find an entry in the second-level page table.. */
359-
#ifndef CONFIG_ARM64_64K_PAGES
359+
#ifndef CONFIG_ARM64_2_LEVELS
360360
#define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
361361
static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
362362
{

‎arch/arm64/include/asm/tlb.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
9191
tlb_remove_page(tlb, pte);
9292
}
9393

94-
#ifndef CONFIG_ARM64_64K_PAGES
94+
#ifndef CONFIG_ARM64_2_LEVELS
9595
static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
9696
unsigned long addr)
9797
{

0 commit comments

Comments
 (0)