Skip to content

Commit

Permalink
selftests: sud_test: return correct emulated syscall value on RISC-V
Browse files Browse the repository at this point in the history
Currently, the sud_test expects the emulated syscall to return the
emulated syscall number. This assumption only works on architectures
were the syscall calling convention use the same register for syscall
number/syscall return value. This is not the case for RISC-V and thus
the return value must be also emulated using the provided ucontext.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
  • Loading branch information
clementleger authored and Björn Töpel committed Nov 9, 2023
1 parent f71180c commit 1408a36
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/testing/selftests/syscall_user_dispatch/sud_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ static void handle_sigsys(int sig, siginfo_t *info, void *ucontext)

/* In preparation for sigreturn. */
SYSCALL_DISPATCH_OFF(glob_sel);

/*
* Modify interrupted context returned value according to syscall
* calling convention
*/
#if defined(__riscv)
((ucontext_t*)ucontext)->uc_mcontext.__gregs[REG_A0] = MAGIC_SYSCALL_1;
#endif
}

TEST(dispatch_and_return)
Expand Down

0 comments on commit 1408a36

Please sign in to comment.