riscv: Allow to dynamically define VA_BITS
With 4-level page table folding at runtime, we don't know at compile time the size of the virtual address space so we must set VA_BITS dynamically so that sparsemem reserves the right amount of memory for struct pages. Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
This commit is contained in:
Родитель
840125a97a
Коммит
3270bfdb9e
|
@ -146,16 +146,6 @@ config MMU
|
||||||
Select if you want MMU-based virtualised addressing space
|
Select if you want MMU-based virtualised addressing space
|
||||||
support by paged memory management. If unsure, say 'Y'.
|
support by paged memory management. If unsure, say 'Y'.
|
||||||
|
|
||||||
config VA_BITS
|
|
||||||
int
|
|
||||||
default 32 if 32BIT
|
|
||||||
default 39 if 64BIT
|
|
||||||
|
|
||||||
config PA_BITS
|
|
||||||
int
|
|
||||||
default 34 if 32BIT
|
|
||||||
default 56 if 64BIT
|
|
||||||
|
|
||||||
config PAGE_OFFSET
|
config PAGE_OFFSET
|
||||||
hex
|
hex
|
||||||
default 0xC0000000 if 32BIT
|
default 0xC0000000 if 32BIT
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
*/
|
*/
|
||||||
#define KASAN_SHADOW_SCALE_SHIFT 3
|
#define KASAN_SHADOW_SCALE_SHIFT 3
|
||||||
|
|
||||||
#define KASAN_SHADOW_SIZE (UL(1) << ((CONFIG_VA_BITS - 1) - KASAN_SHADOW_SCALE_SHIFT))
|
#define KASAN_SHADOW_SIZE (UL(1) << ((VA_BITS - 1) - KASAN_SHADOW_SCALE_SHIFT))
|
||||||
#define KASAN_SHADOW_START (KASAN_SHADOW_END - KASAN_SHADOW_SIZE)
|
#define KASAN_SHADOW_START (KASAN_SHADOW_END - KASAN_SHADOW_SIZE)
|
||||||
#define KASAN_SHADOW_END MODULES_LOWEST_VADDR
|
#define KASAN_SHADOW_END MODULES_LOWEST_VADDR
|
||||||
#define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
|
#define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
|
||||||
|
|
|
@ -61,8 +61,14 @@
|
||||||
* struct pages to map half the virtual address space. Then
|
* struct pages to map half the virtual address space. Then
|
||||||
* position vmemmap directly below the VMALLOC region.
|
* position vmemmap directly below the VMALLOC region.
|
||||||
*/
|
*/
|
||||||
|
#ifdef CONFIG_64BIT
|
||||||
|
#define VA_BITS 39
|
||||||
|
#else
|
||||||
|
#define VA_BITS 32
|
||||||
|
#endif
|
||||||
|
|
||||||
#define VMEMMAP_SHIFT \
|
#define VMEMMAP_SHIFT \
|
||||||
(CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
|
(VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
|
||||||
#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
|
#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
|
||||||
#define VMEMMAP_END (VMALLOC_START - 1)
|
#define VMEMMAP_END (VMALLOC_START - 1)
|
||||||
#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
|
#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
|
||||||
|
@ -661,7 +667,7 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
|
||||||
* and give the kernel the other (upper) half.
|
* and give the kernel the other (upper) half.
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_64BIT
|
#ifdef CONFIG_64BIT
|
||||||
#define KERN_VIRT_START (-(BIT(CONFIG_VA_BITS)) + TASK_SIZE)
|
#define KERN_VIRT_START (-(BIT(VA_BITS)) + TASK_SIZE)
|
||||||
#else
|
#else
|
||||||
#define KERN_VIRT_START FIXADDR_START
|
#define KERN_VIRT_START FIXADDR_START
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,7 +4,11 @@
|
||||||
#define _ASM_RISCV_SPARSEMEM_H
|
#define _ASM_RISCV_SPARSEMEM_H
|
||||||
|
|
||||||
#ifdef CONFIG_SPARSEMEM
|
#ifdef CONFIG_SPARSEMEM
|
||||||
#define MAX_PHYSMEM_BITS CONFIG_PA_BITS
|
#ifdef CONFIG_64BIT
|
||||||
|
#define MAX_PHYSMEM_BITS 56
|
||||||
|
#else
|
||||||
|
#define MAX_PHYSMEM_BITS 34
|
||||||
|
#endif /* CONFIG_64BIT */
|
||||||
#define SECTION_SIZE_BITS 27
|
#define SECTION_SIZE_BITS 27
|
||||||
#endif /* CONFIG_SPARSEMEM */
|
#endif /* CONFIG_SPARSEMEM */
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче