Re: [PATCH] m68k/kernel - wire up syscall_trace_enter/leave for m68k

Geert Uytterhoeven
2020-08-26T11:47:53Z

Hi Adrian,

On Mon, 27 Jul 2020, John Paul Adrian Glaubitz wrote:
> On 7/27/20 10:48 PM, Michael Schmitz wrote:
>> I can't test any of the later seccomp related stuff, so I'd rather leave that bit to someone else who can.
>
> I will work on the necessary changes for libseccomp this week, so that we can test
> whether the libseccomp live tests pass correctly on a patched kernel.

Any update on this?

With the below, you can run "make kselftest-all" (does not support O=!),
copy tools/testing/selftests/seccomp/seccomp_bpf and
tools/testing/selftests/seccomp/seccomp_benchmark to your m68k system,
and run the tests. Of course they fail, as the actual seccomp support
hasn't been written yet...

From f5d325fadc43823f2a7ab2ff2e436da5ebb31565 Mon Sep 17 00:00:00 2001
From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Wed, 26 Aug 2020 11:52:26 +0200
Subject: [PATCH] [WIP] selftests/seccomp: Add m68k support

FIXME

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
tools/testing/selftests/seccomp/seccomp_bpf.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 7a6d40286a421c63..21cfcd3fec9ddc61 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -135,6 +135,8 @@ struct seccomp_data {
# define __NR_seccomp 337
# elif defined(__sh__)
# define __NR_seccomp 372
+# elif defined(__mc68000__)
+# define __NR_seccomp 380
# else
# warning "seccomp syscall number unknown for this architecture"
# define __NR_seccomp 0xffff
@@ -1725,6 +1727,10 @@ TEST_F(TRACE_poke, getpid_runs_normally)
# define ARCH_REGS struct pt_regs
# define SYSCALL_NUM gpr[3]
# define SYSCALL_RET gpr[0]
+#elif defined(__mc68000__)
+# define ARCH_REGS struct pt_regs
+# define SYSCALL_NUM orig_d0
+# define SYSCALL_RET d0
#else
# error "Do not know how to find your architecture's registers and syscalls"
#endif
@@ -1748,7 +1754,7 @@ TEST_F(TRACE_poke, getpid_runs_normally)
/* Use PTRACE_GETREGS and PTRACE_SETREGS when available. This is useful for
* architectures without HAVE_ARCH_TRACEHOOK (e.g. User-mode Linux).
*/
-#if defined(__x86_64__) || defined(__i386__) || defined(__mips__)
+#if defined(__x86_64__) || defined(__i386__) || defined(__mips__) || defined(__mc68000)
#define HAVE_GETREGS
#endif

@@ -1797,7 +1803,8 @@ void change_syscall(struct __test_metadata *_metadata,

#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
defined(__s390__) || defined(__hppa__) || defined(__riscv) || \
- defined(__xtensa__) || defined(__csky__) || defined(__sh__)
+ defined(__xtensa__) || defined(__csky__) || defined(__sh__) || \
+ defined(__mc68000)
{
regs.SYSCALL_NUM = syscall;
}
--
2.17.1

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds