riscv: Fix syscall wrapper for >word-size arguments
authorSami Tolvanen <samitolvanen@google.com>
Mon, 11 Mar 2024 19:31:44 +0000 (19:31 +0000)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 20 Mar 2024 18:37:51 +0000 (11:37 -0700)
commita9ad73295cc1e3af0253eee7d08943b2419444c4
tree3a1d9966c8241e594f7f08a7e97da99f85bf0409
parenteeb7a8933e71f98354536c3d849a26978539b09f
riscv: Fix syscall wrapper for >word-size arguments

The current syscall wrapper macros break 64-bit arguments on
rv32 because they only guarantee the first N input registers are
passed to syscalls that accept N arguments. According to the
calling convention, values twice the word size reside in register
pairs and as a result, syscall arguments don't always have a
direct register mapping on rv32.

Instead of using `__MAP(x,__SC_LONG,__VA_ARGS__)` to declare the
type of the `__se(_compat)_sys_*` functions on rv32, change the
function declarations to accept `ulong` arguments and alias them
to the actual syscall implementations, similarly to the existing
macros in include/linux/syscalls.h. This matches previous
behavior and ensures registers are passed to syscalls as-is, no
matter which argument types they expect.

Fixes: 08d0ce30e0e4 ("riscv: Implement syscall wrappers")
Reported-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Link: https://lore.kernel.org/r/20240311193143.2981310-2-samitolvanen@google.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/include/asm/syscall_wrapper.h