riscv: misaligned: remove CONFIG_RISCV_M_MODE specific code
authorClément Léger <cleger@rivosinc.com>
Tue, 6 Feb 2024 15:40:59 +0000 (16:40 +0100)
committerPalmer Dabbelt <palmer@rivosinc.com>
Sun, 28 Apr 2024 21:50:37 +0000 (14:50 -0700)
commit441381506ba7ca1cb8b44e651b130ab791d2e298
tree3cade8cfeb00326603cadc4658522653059a7890
parentfa7d7339016ab7850258e85d6adfd4c4abca5498
riscv: misaligned: remove CONFIG_RISCV_M_MODE specific code

While reworking code to fix sparse errors, it appears that the
RISCV_M_MODE specific could actually be removed and use the one for
normal mode. Even though RISCV_M_MODE can do direct user memory access,
using the user uaccess helpers is also going to work. Since there is no
need anymore for specific accessors (load_u8()/store_u8()), we can
directly use memcpy()/copy_{to/from}_user() and get rid of the copy
loop entirely. __read_insn() is also fixed to use an unsigned long
instead of a pointer which was cast in __user address space. The
insn_addr parameter is now cast from unsigned lnog to the correct
address space directly.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Link: https://lore.kernel.org/r/20240206154104.896809-1-cleger@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/traps_misaligned.c