• Ben Dooks's avatar
    riscv: fix __user annotation in traps_misaligned.c · ca0e433b
    Ben Dooks authored
    The instruction reading code can read from either user or kernel addresses
    and thus the use of __user on pointers to instructions depends on which
    context. Fix a few sparse warnings by using __user for user-accesses and
    remove it when not.
    
    Fixes:
    
    arch/riscv/kernel/traps_misaligned.c:361:21: warning: dereference of noderef expression
    arch/riscv/kernel/traps_misaligned.c:373:21: warning: dereference of noderef expression
    arch/riscv/kernel/traps_misaligned.c:381:21: warning: dereference of noderef expression
    arch/riscv/kernel/traps_misaligned.c:322:24: warning: incorrect type in initializer (different address spaces)
    arch/riscv/kernel/traps_misaligned.c:322:24:    expected unsigned char const [noderef] __user *__gu_ptr
    arch/riscv/kernel/traps_misaligned.c:322:24:    got unsigned char const [usertype] *addr
    arch/riscv/kernel/traps_misaligned.c:361:21: warning: dereference of noderef expression
    arch/riscv/kernel/traps_misaligned.c:373:21: warning: dereference of noderef expression
    arch/riscv/kernel/traps_misaligned.c:381:21: warning: dereference of noderef expression
    arch/riscv/kernel/traps_misaligned.c:332:24: warning: incorrect type in initializer (different address spaces)
    arch/riscv/kernel/traps_misaligned.c:332:24:    expected unsigned char [noderef] __user *__gu_ptr
    arch/riscv/kernel/traps_misaligned.c:332:24:    got unsigned char [usertype] *addr
    
    Fixes: 7c832321 ("riscv: add support for misaligned trap handling in S-mode")
    Signed-off-by: default avatarBen Dooks <ben.dooks@codethink.co.uk>
    Link: https://lore.kernel.org/r/20231123141617.259591-1-ben.dooks@codethink.co.ukSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
    ca0e433b
traps_misaligned.c 16.2 KB