riscv: add support for misaligned trap handling in S-mode
authorClément Léger <cleger@rivosinc.com>
Wed, 4 Oct 2023 15:13:59 +0000 (17:13 +0200)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 1 Nov 2023 15:34:53 +0000 (08:34 -0700)
commit7c83232161f609bbc452a1255f823f41afc411dd
tree8c03bf915d29719e12c25ba4ec0e805b3c5e10de
parentf19c3b4239f5bfb69aacbaf75d4277c095e7aa7d
riscv: add support for misaligned trap handling in S-mode

Misalignment trap handling is only supported for M-mode and uses direct
accesses to user memory. In S-mode, when handling usermode fault, this
requires to use the get_user()/put_user() accessors. Implement
load_u8(), store_u8() and get_insn() using these accessors for
userspace and direct text access for kernel.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
Link: https://lore.kernel.org/r/20231004151405.521596-3-cleger@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/Kconfig
arch/riscv/include/asm/entry-common.h
arch/riscv/kernel/Makefile
arch/riscv/kernel/traps.c
arch/riscv/kernel/traps_misaligned.c