]> git.baikalelectronics.ru Git - kernel.git/commit
riscv: Move kernel mapping outside of linear mapping
authorAlexandre Ghiti <alex@ghiti.fr>
Sun, 11 Apr 2021 16:41:44 +0000 (12:41 -0400)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Mon, 26 Apr 2021 15:25:04 +0000 (08:25 -0700)
commit38ecc1bf092d7cd3db267b97d15b2c522d00aafe
treec06ff6ac90cb7735bb0871aa357c5d2b8049a6dc
parented419a3df544ed727d7203e97916ea03440af3ce
riscv: Move kernel mapping outside of linear mapping

This is a preparatory patch for relocatable kernel and sv48 support.

The kernel used to be linked at PAGE_OFFSET address therefore we could use
the linear mapping for the kernel mapping. But the relocated kernel base
address will be different from PAGE_OFFSET and since in the linear mapping,
two different virtual addresses cannot point to the same physical address,
the kernel mapping needs to lie outside the linear mapping so that we don't
have to copy it at the same physical offset.

The kernel mapping is moved to the last 2GB of the address space, BPF
is now always after the kernel and modules use the 2GB memory range right
before the kernel, so BPF and modules regions do not overlap. KASLR
implementation will simply have to move the kernel in the last 2GB range
and just take care of leaving enough space for BPF.

In addition, by moving the kernel to the end of the address space, both
sv39 and sv48 kernels will be exactly the same without needing to be
relocated at runtime.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
[Palmer: Squash the STRICT_RWX fix, and a !MMU fix]
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
12 files changed:
arch/riscv/boot/loader.lds.S
arch/riscv/include/asm/page.h
arch/riscv/include/asm/pgtable.h
arch/riscv/include/asm/set_memory.h
arch/riscv/kernel/head.S
arch/riscv/kernel/module.c
arch/riscv/kernel/setup.c
arch/riscv/kernel/vmlinux.lds.S
arch/riscv/mm/fault.c
arch/riscv/mm/init.c
arch/riscv/mm/kasan_init.c
arch/riscv/mm/physaddr.c