Skip to content

Commit c09dc9e

Browse files
AlexGhitipalmer-dabbelt
authored andcommitted
riscv: Fix memory_limit for 64-bit kernel
As described in Documentation/riscv/vm-layout.rst, the end of the virtual address space for 64-bit kernel is occupied by the modules/BPF/ kernel mappings so this actually reduces the amount of memory we are able to map and then use in the linear mapping. So make sure this limit is correctly set. Signed-off-by: Alexandre Ghiti <[email protected]> Fixes: 2bfc6cd ("riscv: Move kernel mapping outside of linear mapping") Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent c79e89e commit c09dc9e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

arch/riscv/mm/init.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,17 @@ void __init mem_init(void)
127127
}
128128

129129
/*
130-
* The default maximal physical memory size is -PAGE_OFFSET,
131-
* limit the memory size via mem.
130+
* The default maximal physical memory size is -PAGE_OFFSET for 32-bit kernel,
131+
* whereas for 64-bit kernel, the end of the virtual address space is occupied
132+
* by the modules/BPF/kernel mappings which reduces the available size of the
133+
* linear mapping.
134+
* Limit the memory size via mem.
132135
*/
136+
#ifdef CONFIG_64BIT
137+
static phys_addr_t memory_limit = -PAGE_OFFSET - SZ_4G;
138+
#else
133139
static phys_addr_t memory_limit = -PAGE_OFFSET;
140+
#endif
134141

135142
static int __init early_mem(char *p)
136143
{

0 commit comments

Comments
 (0)