]> git.baikalelectronics.ru Git - kernel.git/commit
riscv: Only extend kernel reservation if mapped read-only
authorGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 29 Apr 2021 15:05:00 +0000 (17:05 +0200)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Thu, 6 May 2021 16:40:12 +0000 (09:40 -0700)
commit2ec16517998cef83f32fca5a805678e2d33af0ff
tree4fc671a0bf9717eb421b2e053b7c8855190005ce
parent5750e37f07cf0d3e02960694a50cf5b8fc1d6ab8
riscv: Only extend kernel reservation if mapped read-only

When the kernel mapping was moved outside of the linear mapping, the
kernel memory reservation was increased, to take into account mapping
granularity.  However, this is done unconditionally, regardless of
whether the kernel memory is mapped read-only or not.

If this extension is not needed, up to 2 MiB may be lost, which has a
big impact on e.g. Canaan K210 (64-bit nommu) platforms with only 8 MiB
of RAM.

Reclaim the lost memory by only extending the reserved region when
needed, i.e. depending on a simplified version of the conditional logic
around the call to protect_kernel_linear_mapping_text_rodata().

Fixes: 7ab87eaa7eafd04d ("riscv: Move kernel mapping outside of linear mapping")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Alexandre Ghiti <alex@ghiti.fr>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
arch/riscv/mm/init.c