Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
riscv: Fix memory_limit for 64-bit kernel
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
AlexGhiti authored and palmer-dabbelt committed Jul 23, 2021
1 parent c79e89e commit c09dc9e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions arch/riscv/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,17 @@ void __init mem_init(void)
}

/*
* The default maximal physical memory size is -PAGE_OFFSET,
* limit the memory size via mem.
* The default maximal physical memory size is -PAGE_OFFSET for 32-bit kernel,
* whereas for 64-bit kernel, the end of the virtual address space is occupied
* by the modules/BPF/kernel mappings which reduces the available size of the
* linear mapping.
* Limit the memory size via mem.
*/
#ifdef CONFIG_64BIT
static phys_addr_t memory_limit = -PAGE_OFFSET - SZ_4G;
#else
static phys_addr_t memory_limit = -PAGE_OFFSET;
#endif

static int __init early_mem(char *p)
{
Expand Down

0 comments on commit c09dc9e

Please sign in to comment.