[PATCH 4/4] arm64: tools: Update syscall user dispatch tests

From: houdek . ryan
Date: Sat May 29 2021 - 04:17:09 EST


From: Ryan Houdek <Houdek.Ryan@xxxxxxxxxxx>

This is a fairly trivial change to support syscall user dispatch in
these selftests.

One of the tests is relying on the syscall to return the syscall number
in the return. Which is a byproduct from the scnum and return registers
being the same.
Since arm64 places the scnum in x8 and the return in x0 it just needs to
move the result over.

Signed-off-by: Ryan Houdek <Houdek.Ryan@xxxxxxxxxxx>
---
.../selftests/syscall_user_dispatch/sud_benchmark.c | 2 +-
tools/testing/selftests/syscall_user_dispatch/sud_test.c | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
index 073a03702ff5..6059abe75cb3 100644
--- a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
+++ b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
@@ -41,7 +41,7 @@
* out of the box, but don't enable them until they support syscall user
* dispatch.
*/
-#if defined(__x86_64__) || defined(__i386__)
+#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
#define TEST_BLOCKED_RETURN
#endif

diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_test.c b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
index b5d592d4099e..11cf4ad6aa6e 100644
--- a/tools/testing/selftests/syscall_user_dispatch/sud_test.c
+++ b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
@@ -150,6 +150,15 @@ int si_errno;

static void handle_sigsys(int sig, siginfo_t *info, void *ucontext)
{
+#ifdef __aarch64__
+ /* This test expects the syscall number will be returned in r0
+ * Copy it over from r8 which is the scnum in the ABI
+ */
+ ucontext_t *_context = (ucontext_t *)ucontext;
+
+ _context->uc_mcontext.regs[0] = _context->uc_mcontext.regs[8];
+#endif
+
si_code = info->si_code;
si_errno = info->si_errno;

--
2.30.2