syscall_get_* functions are required to be implemented on all
architectures in order to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFO request.

This introduces asm/syscall.h on m68k implementing all 5 syscall_get_*
functions as documented in asm-generic/syscall.h: syscall_get_nr,
syscall_get_arguments, syscall_get_error, syscall_get_return_value,
and syscall_get_arch.

Acked-by: Paul Moore <p...@paul-moore.com> # audit related parts
Cc: Geert Uytterhoeven <ge...@linux-m68k.org>
Cc: Oleg Nesterov <o...@redhat.com>
Cc: Andy Lutomirski <l...@kernel.org>
Cc: Elvira Khabirova <lineprin...@altlinux.org>
Cc: Eugene Syromyatnikov <e...@redhat.com>
Cc: linux-m...@lists.linux-m68k.org
Signed-off-by: Dmitry V. Levin <l...@altlinux.org>
---

Notes:
    v7: added Acked-by
    v6: added missing includes, use asm-generic/syscall.h
    v5: added syscall_get_nr, syscall_get_arguments, syscall_get_error,
        and syscall_get_return_value
    v1: added syscall_get_arch

 arch/m68k/include/asm/syscall.h | 42 +++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 arch/m68k/include/asm/syscall.h

diff --git a/arch/m68k/include/asm/syscall.h b/arch/m68k/include/asm/syscall.h
new file mode 100644
index 000000000000..c87b14417753
--- /dev/null
+++ b/arch/m68k/include/asm/syscall.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_M68K_SYSCALL_H
+#define _ASM_M68K_SYSCALL_H
+
+#include <asm/ptrace.h>
+#include <asm-generic/syscall.h>
+#include <linux/err.h>
+#include <uapi/linux/audit.h>
+
+static inline int
+syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
+{
+       return regs->orig_d0;
+}
+
+static inline void
+__syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
+                       unsigned int i, unsigned int n, unsigned long *args)
+{
+       BUILD_BUG_ON(sizeof(regs->d1) != sizeof(args[0]));
+       memcpy(args, &regs->d1 + i, n * sizeof(args[0]));
+}
+
+static inline long
+syscall_get_error(struct task_struct *task, struct pt_regs *regs)
+{
+       return IS_ERR_VALUE(regs->d0) ? regs->d0 : 0;
+}
+
+static inline long
+syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
+{
+       return regs->d0;
+}
+
+static inline int
+syscall_get_arch(void)
+{
+       return AUDIT_ARCH_M68K;
+}
+
+#endif /* _ASM_M68K_SYSCALL_H */
-- 
ldv

Reply via email to