Messages in this thread Patch in this message | | | Date | Mon, 10 Dec 2018 07:30:41 +0300 | From | "Dmitry V. Levin" <> | Subject | [PATCH v5 19/25] xtensa: define syscall_get_* functions |
| |
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 adds all 5 syscall_get_* functions on xtensa as documented in asm-generic/syscall.h: syscall_get_nr, syscall_get_arguments, syscall_get_error, syscall_get_return_value, and syscall_get_arch.
Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Elvira Khabirova <lineprinter@altlinux.org> Cc: Eugene Syromyatnikov <esyr@redhat.com> Cc: Chris Zankel <chris@zankel.net> Cc: Paul Moore <paul@paul-moore.com> Cc: Eric Paris <eparis@redhat.com> Cc: linux-xtensa@linux-xtensa.org Cc: linux-audit@redhat.com Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> ---
Notes: v5: added syscall_get_nr, syscall_get_arguments, syscall_get_error, and syscall_get_return_value v2: added Acked-by v1: added syscall_get_arch
arch/xtensa/include/asm/syscall.h | 69 +++++++++++++++++++++++++++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 70 insertions(+)
diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/syscall.h index 3673ff1f1bc5..d529c855a144 100644 --- a/arch/xtensa/include/asm/syscall.h +++ b/arch/xtensa/include/asm/syscall.h @@ -8,6 +8,75 @@ * Copyright (C) 2001 - 2007 Tensilica Inc. */ +#include <uapi/linux/audit.h> + +static inline int +syscall_get_nr(struct task_struct *task, struct pt_regs *regs) +{ + return regs->syscall; +} + +static inline void +syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, + unsigned int i, unsigned int n, unsigned long *args) +{ + switch (i) { + case 0: + if (!n--) + break; + *args++ = regs->areg[6]; + /* fall through */ + case 1: + if (!n--) + break; + *args++ = regs->areg[3]; + /* fall through */ + case 2: + if (!n--) + break; + *args++ = regs->areg[4]; + /* fall through */ + case 3: + if (!n--) + break; + *args++ = regs->areg[5]; + /* fall through */ + case 4: + if (!n--) + break; + *args++ = regs->areg[8]; + /* fall through */ + case 5: + if (!n--) + break; + *args++ = regs->areg[9]; + /* fall through */ + case 6: + if (!n--) + break; + /* fall through */ + default: + BUG(); + } +} + +static inline long +syscall_get_error(struct task_struct *task, struct pt_regs *regs) +{ + return IS_ERR_VALUE(regs->areg[2]) ? regs->areg[2] : 0; + +static inline long +syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) +{ + return regs->areg[2]; +} + +static inline int +syscall_get_arch(void) +{ + return AUDIT_ARCH_XTENSA; +} + struct pt_regs; asmlinkage long xtensa_ptrace(long, long, long, long); asmlinkage long xtensa_sigreturn(struct pt_regs*); diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h index 1e9808f3a240..bcc0619b046f 100644 --- a/include/uapi/linux/audit.h +++ b/include/uapi/linux/audit.h @@ -425,6 +425,7 @@ enum { #define AUDIT_ARCH_TILEGX32 (EM_TILEGX|__AUDIT_ARCH_LE) #define AUDIT_ARCH_TILEPRO (EM_TILEPRO|__AUDIT_ARCH_LE) #define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_XTENSA (EM_XTENSA) #define AUDIT_PERM_EXEC 1 #define AUDIT_PERM_WRITE 2 -- ldv
| |