riscv: Map the kernel with correct permissions the first time
authorAlexandre Ghiti <alex@ghiti.fr>
Thu, 24 Jun 2021 12:00:41 +0000 (14:00 +0200)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Thu, 1 Jul 2021 04:18:58 +0000 (21:18 -0700)
commite5c35fa0401971701dcd7675f471b664698244dd
tree6f42965bac8ba06c33fa462472f852d92be187cd
parentc10bc260e7c030364b5150aac7ebf048ddfb9502
riscv: Map the kernel with correct permissions the first time

For 64-bit kernels, we map all the kernel with write and execute
permissions and afterwards remove writability from text and executability
from data.

For 32-bit kernels, the kernel mapping resides in the linear mapping, so we
map all the linear mapping as writable and executable and afterwards we
remove those properties for unused memory and kernel mapping as
described above.

Change this behavior to directly map the kernel with correct permissions
and avoid going through the whole mapping to fix the permissions.

At the same time, this fixes an issue introduced by commit 2bfc6cd81bd1
("riscv: Move kernel mapping outside of linear mapping") as reported
here https://github.com/starfive-tech/linux/issues/17.

Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
arch/riscv/include/asm/page.h
arch/riscv/include/asm/sections.h
arch/riscv/include/asm/set_memory.h
arch/riscv/kernel/setup.c
arch/riscv/mm/init.c