linux/arch/riscv
Alexandre Ghiti 26e7aacb83
riscv: Allow to downgrade paging mode from the command line
Add 2 early command line parameters that allow to downgrade satp mode
(using the same naming as x86):
- "no5lvl": use a 4-level page table (down from sv57 to sv48)
- "no4lvl": use a 3-level page table (down from sv57/sv48 to sv39)

Note that going through the device tree to get the kernel command line
works with ACPI too since the efi stub creates a device tree anyway with
the command line.

In KASAN kernels, we can't use the libfdt that early in the boot process
since we are not ready to execute instrumented functions. So instead of
using the "generic" libfdt, we compile our own versions of those functions
that are not instrumented and that are prefixed so that they do not
conflict with the generic ones. We also need the non-instrumented versions
of the string functions and the prefixed versions of memcpy/memmove.

This is largely inspired by commit aacd149b62 ("arm64: head: avoid
relocating the kernel twice for KASLR") from which I removed compilation
flags that were not relevant to RISC-V at the moment (LTO, SCS). Also
note that we have to link with -z norelro to avoid ld.lld to throw a
warning with the new .got sections, like in commit 311bea3cb9 ("arm64:
link with -z norelro for LLD or aarch64-elf").

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Tested-by: Björn Töpel <bjorn@rivosinc.com>
Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
Link: https://lore.kernel.org/r/20230424092313.178699-2-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2023-04-26 07:30:52 -07:00
..
boot riscv: Use --emit-relocs in order to move .rela.dyn in init 2023-04-19 07:46:33 -07:00
configs riscv: defconfig: Enable the Allwinner D1 platform and drivers 2023-01-27 23:10:08 +01:00
errata RISC-V: hwprobe: Remove __init on probe_vendor_features() 2023-04-25 21:58:42 -07:00
include RISC-V: hwprobe: Remove __init on probe_vendor_features() 2023-04-25 21:58:42 -07:00
kernel riscv: Allow to downgrade paging mode from the command line 2023-04-26 07:30:52 -07:00
kvm RISC-V: KVM: Expose Zicboz to the guest 2023-03-14 21:26:08 -07:00
lib riscv: Allow to downgrade paging mode from the command line 2023-04-26 07:30:52 -07:00
mm riscv: Allow to downgrade paging mode from the command line 2023-04-26 07:30:52 -07:00
net riscv, bpf: Add bpf trampoline support for RV64 2023-02-17 21:45:30 +01:00
purgatory RISC-V: add infrastructure to allow different str* implementations 2023-01-31 11:43:23 -08:00
tools riscv: Check relocations at compile time 2023-04-19 07:46:32 -07:00
Kbuild riscv: move errata/ and kvm/ builds to arch/riscv/Kbuild 2022-06-01 22:26:32 -07:00
Kconfig Merge patch series "Introduce 64b relocatable kernel" 2023-04-19 07:47:45 -07:00
Kconfig.debug
Kconfig.errata Merge patch series "RISC-V: Fixes for riscv_has_extension[un]likely()'s alternative dependency" 2023-03-29 12:26:38 -07:00
Kconfig.socs RISC-V Patches for the 6.3 Merge Window, Part 1 2023-02-25 11:14:08 -08:00
Makefile riscv: Allow to downgrade paging mode from the command line 2023-04-26 07:30:52 -07:00
Makefile.postlink riscv: Use --emit-relocs in order to move .rela.dyn in init 2023-04-19 07:46:33 -07:00