• Geert Uytterhoeven's avatar
    riscv: Only extend kernel reservation if mapped read-only · 8db6f937
    Geert Uytterhoeven authored
    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: 2bfc6cd8 ("riscv: Move kernel mapping outside of linear mapping")
    Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
    Tested-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
    Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
    8db6f937
init.c 25.1 KB