Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS64: Support of at least 48 bits of SEGBITS

SEGBITS is 40 bits or more, depending on CPU type. Introduces optional
support for 48 bits of application virtual address space. Only 16K and
64K pages are supported.

Enabling will result in a memory overhead of a small number of pages for
small applications. For 64K pages a 3rd level of page tables is required
which has some impact during software TLB refill.

[ralf@linux-mips.org: Fixed things raised in the review of the version
posted and changed kconfig to be a bit more userfriendly.]

Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Cc: aleksey.makarov@auriga.com
Cc: james.hogan@imgtec.com
Cc: paul.burton@imgtec.com
Cc: david.daney@cavium.com
Cc: peterz@infradead.org
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Cc: davidlohr@hp.com
Cc: kirill@shutemov.name
Cc: akpm@linux-foundation.org
Cc: mingo@kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/10051/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Leonid Yegoshin and committed by
Ralf Baechle
1e321fa9 7939469d

+29 -8
+13
arch/mips/Kconfig
··· 2076 2076 emulation when determining guest CPU Frequency. Instead, the guest's 2077 2077 timer frequency is specified directly. 2078 2078 2079 + config MIPS_VA_BITS_48 2080 + bool "48 bits virtual memory" 2081 + depends on 64BIT 2082 + help 2083 + Support a maximum at least 48 bits of application virtual memory. 2084 + Default is 40 bits or less, depending on the CPU. 2085 + This option result in a small memory overhead for page tables. 2086 + This option is only supported with 16k and 64k page sizes. 2087 + If unsure, say N. 2088 + 2079 2089 choice 2080 2090 prompt "Kernel page size" 2081 2091 default PAGE_SIZE_4KB ··· 2093 2083 config PAGE_SIZE_4KB 2094 2084 bool "4kB" 2095 2085 depends on !CPU_LOONGSON2 && !CPU_LOONGSON3 2086 + depends on !MIPS_VA_BITS_48 2096 2087 help 2097 2088 This option select the standard 4kB Linux page size. On some 2098 2089 R3000-family processors this is the only available page size. Using ··· 2103 2092 config PAGE_SIZE_8KB 2104 2093 bool "8kB" 2105 2094 depends on CPU_R8000 || CPU_CAVIUM_OCTEON 2095 + depends on !MIPS_VA_BITS_48 2106 2096 help 2107 2097 Using 8kB page size will result in higher performance kernel at 2108 2098 the price of higher memory consumption. This option is available ··· 2122 2110 config PAGE_SIZE_32KB 2123 2111 bool "32kB" 2124 2112 depends on CPU_CAVIUM_OCTEON 2113 + depends on !MIPS_VA_BITS_48 2125 2114 help 2126 2115 Using 32kB page size will result in higher performance kernel at 2127 2116 the price of higher memory consumption. This option is available
+11 -7
arch/mips/include/asm/pgtable-64.h
··· 17 17 #include <asm/cachectl.h> 18 18 #include <asm/fixmap.h> 19 19 20 - #ifdef CONFIG_PAGE_SIZE_64KB 20 + #if defined(CONFIG_PAGE_SIZE_64KB) && !defined(CONFIG_MIPS_VA_BITS_48) 21 21 #include <asm-generic/pgtable-nopmd.h> 22 22 #else 23 23 #include <asm-generic/pgtable-nopud.h> ··· 90 90 #define PTE_ORDER 0 91 91 #endif 92 92 #ifdef CONFIG_PAGE_SIZE_16KB 93 - #define PGD_ORDER 0 93 + #ifdef CONFIG_MIPS_VA_BITS_48 94 + #define PGD_ORDER 1 95 + #else 96 + #define PGD_ORDER 0 97 + #endif 94 98 #define PUD_ORDER aieeee_attempt_to_allocate_pud 95 99 #define PMD_ORDER 0 96 100 #define PTE_ORDER 0 ··· 108 104 #ifdef CONFIG_PAGE_SIZE_64KB 109 105 #define PGD_ORDER 0 110 106 #define PUD_ORDER aieeee_attempt_to_allocate_pud 107 + #ifdef CONFIG_MIPS_VA_BITS_48 108 + #define PMD_ORDER 0 109 + #else 111 110 #define PMD_ORDER aieeee_attempt_to_allocate_pmd 111 + #endif 112 112 #define PTE_ORDER 0 113 113 #endif 114 114 ··· 122 114 #endif 123 115 #define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t)) 124 116 125 - #if PGDIR_SIZE >= TASK_SIZE64 126 - #define USER_PTRS_PER_PGD (1) 127 - #else 128 - #define USER_PTRS_PER_PGD (TASK_SIZE64 / PGDIR_SIZE) 129 - #endif 117 + #define USER_PTRS_PER_PGD ((TASK_SIZE64 / PGDIR_SIZE)?(TASK_SIZE64 / PGDIR_SIZE):1) 130 118 #define FIRST_USER_ADDRESS 0UL 131 119 132 120 /*
+5 -1
arch/mips/include/asm/processor.h
··· 63 63 * 8192EB ... 64 64 */ 65 65 #define TASK_SIZE32 0x7fff8000UL 66 - #define TASK_SIZE64 0x10000000000UL 66 + #ifdef CONFIG_MIPS_VA_BITS_48 67 + #define TASK_SIZE64 (0x1UL << ((cpu_data[0].vmbits>48)?48:cpu_data[0].vmbits)) 68 + #else 69 + #define TASK_SIZE64 0x10000000000UL 70 + #endif 67 71 #define TASK_SIZE (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64) 68 72 #define STACK_TOP_MAX TASK_SIZE64 69 73