Skip to content

Commit 383c279

Browse files
committed
arm64: Add support for 48-bit VA space with 64KB page configuration
This patch allows support for 3 levels of page tables with 64KB page configuration allowing 48-bit VA space. The pgd is no longer a full PAGE_SIZE (PTRS_PER_PGD is 64) and (swapper|idmap)_pg_dir are not fully populated (pgd_alloc falls back to kzalloc). Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Tested-by: Jungseok Lee <jungseoklee85@gmail.com>
1 parent 7078db4 commit 383c279

4 files changed

Lines changed: 22 additions & 9 deletions

File tree

‎Documentation/arm64/memory.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ Start End Size Use
4545
fffffc0000000000 ffffffffffffffff 4TB kernel
4646

4747

48+
AArch64 Linux memory layout with 64KB pages + 3 levels:
49+
50+
Start End Size Use
51+
-----------------------------------------------------------------------
52+
0000000000000000 0000ffffffffffff 256TB user
53+
ffff000000000000 ffffffffffffffff 256TB kernel
54+
55+
4856
For details of the virtual kernel memory layout please see the kernel
4957
booting log.
5058

‎arch/arm64/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ config ARM64_VA_BITS
210210
config ARM64_PGTABLE_LEVELS
211211
int
212212
default 2 if ARM64_64K_PAGES && ARM64_VA_BITS_42
213+
default 3 if ARM64_64K_PAGES && ARM64_VA_BITS_48
213214
default 3 if ARM64_4K_PAGES && ARM64_VA_BITS_39
214215
default 4 if ARM64_4K_PAGES && ARM64_VA_BITS_48
215216

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,19 @@
3434
/*
3535
* The idmap and swapper page tables need some space reserved in the kernel
3636
* image. Both require pgd, pud (4 levels only) and pmd tables to (section)
37-
* map the kernel. The swapper also maps the FDT (see __create_page_tables for
38-
* more information).
37+
* map the kernel. With the 64K page configuration, swapper and idmap need to
38+
* map to pte level. The swapper also maps the FDT (see __create_page_tables
39+
* for more information).
3940
*/
40-
#if CONFIG_ARM64_PGTABLE_LEVELS == 4
41-
#define SWAPPER_DIR_SIZE (3 * PAGE_SIZE)
42-
#define IDMAP_DIR_SIZE (3 * PAGE_SIZE)
41+
#ifdef CONFIG_ARM64_64K_PAGES
42+
#define SWAPPER_PGTABLE_LEVELS (CONFIG_ARM64_PGTABLE_LEVELS)
4343
#else
44-
#define SWAPPER_DIR_SIZE (2 * PAGE_SIZE)
45-
#define IDMAP_DIR_SIZE (2 * PAGE_SIZE)
44+
#define SWAPPER_PGTABLE_LEVELS (CONFIG_ARM64_PGTABLE_LEVELS - 1)
4645
#endif
4746

47+
#define SWAPPER_DIR_SIZE (SWAPPER_PGTABLE_LEVELS * PAGE_SIZE)
48+
#define IDMAP_DIR_SIZE (SWAPPER_DIR_SIZE)
49+
4850
#ifndef __ASSEMBLY__
4951

5052
#include <asm/pgtable-types.h>

‎arch/arm64/kernel/head.S‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@
5555
#ifdef CONFIG_ARM64_64K_PAGES
5656
#define BLOCK_SHIFT PAGE_SHIFT
5757
#define BLOCK_SIZE PAGE_SIZE
58+
#define TABLE_SHIFT PMD_SHIFT
5859
#else
5960
#define BLOCK_SHIFT SECTION_SHIFT
6061
#define BLOCK_SIZE SECTION_SIZE
62+
#define TABLE_SHIFT PUD_SHIFT
6163
#endif
6264

6365
#define KERNEL_START KERNEL_RAM_VADDR
@@ -505,8 +507,8 @@ ENDPROC(__calc_phys_offset)
505507
*/
506508
.macro create_pgd_entry, tbl, virt, tmp1, tmp2
507509
create_table_entry \tbl, \virt, PGDIR_SHIFT, PTRS_PER_PGD, \tmp1, \tmp2
508-
#if CONFIG_ARM64_PGTABLE_LEVELS == 4
509-
create_table_entry \tbl, \virt, PUD_SHIFT, PTRS_PER_PUD, \tmp1, \tmp2
510+
#if SWAPPER_PGTABLE_LEVELS == 3
511+
create_table_entry \tbl, \virt, TABLE_SHIFT, PTRS_PER_PTE, \tmp1, \tmp2
510512
#endif
511513
.endm
512514

0 commit comments

Comments
 (0)