2019-06-03 13:44:50 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2012-03-05 19:49:33 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_SYSCALL_H
|
|
|
|
#define __ASM_SYSCALL_H
|
|
|
|
|
2014-07-04 15:28:30 +08:00
|
|
|
#include <uapi/linux/audit.h>
|
|
|
|
#include <linux/compat.h>
|
2012-03-05 19:49:33 +08:00
|
|
|
#include <linux/err.h>
|
|
|
|
|
2019-05-25 06:11:16 +08:00
|
|
|
typedef long (*syscall_fn_t)(const struct pt_regs *regs);
|
2018-07-11 21:56:42 +08:00
|
|
|
|
|
|
|
extern const syscall_fn_t sys_call_table[];
|
2012-03-05 19:49:33 +08:00
|
|
|
|
2018-07-11 21:56:45 +08:00
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
extern const syscall_fn_t compat_sys_call_table[];
|
|
|
|
#endif
|
|
|
|
|
2012-03-05 19:49:33 +08:00
|
|
|
static inline int syscall_get_nr(struct task_struct *task,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
return regs->syscallno;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void syscall_rollback(struct task_struct *task,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
regs->regs[0] = regs->orig_x0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline long syscall_get_error(struct task_struct *task,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
unsigned long error = regs->regs[0];
|
|
|
|
return IS_ERR_VALUE(error) ? error : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long syscall_get_return_value(struct task_struct *task,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
return regs->regs[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void syscall_set_return_value(struct task_struct *task,
|
|
|
|
struct pt_regs *regs,
|
|
|
|
int error, long val)
|
|
|
|
{
|
|
|
|
regs->regs[0] = (long) error ? error : val;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SYSCALL_MAX_ARGS 6
|
|
|
|
|
|
|
|
static inline void syscall_get_arguments(struct task_struct *task,
|
|
|
|
struct pt_regs *regs,
|
|
|
|
unsigned long *args)
|
|
|
|
{
|
2016-11-08 05:26:37 +08:00
|
|
|
args[0] = regs->orig_x0;
|
|
|
|
args++;
|
2012-03-05 19:49:33 +08:00
|
|
|
|
2016-11-08 05:26:37 +08:00
|
|
|
memcpy(args, ®s->regs[1], 5 * sizeof(args[0]));
|
2012-03-05 19:49:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void syscall_set_arguments(struct task_struct *task,
|
|
|
|
struct pt_regs *regs,
|
|
|
|
const unsigned long *args)
|
|
|
|
{
|
2019-03-28 08:07:31 +08:00
|
|
|
regs->orig_x0 = args[0];
|
|
|
|
args++;
|
|
|
|
|
|
|
|
memcpy(®s->regs[1], args, 5 * sizeof(args[0]));
|
2012-03-05 19:49:33 +08:00
|
|
|
}
|
|
|
|
|
2014-07-04 15:28:30 +08:00
|
|
|
/*
|
|
|
|
* We don't care about endianness (__AUDIT_ARCH_LE bit) here because
|
|
|
|
* AArch64 has the same system calls both on little- and big- endian.
|
|
|
|
*/
|
2019-03-18 07:30:18 +08:00
|
|
|
static inline int syscall_get_arch(struct task_struct *task)
|
2014-07-04 15:28:30 +08:00
|
|
|
{
|
2019-03-18 07:30:18 +08:00
|
|
|
if (is_compat_thread(task_thread_info(task)))
|
2014-07-04 15:28:30 +08:00
|
|
|
return AUDIT_ARCH_ARM;
|
|
|
|
|
|
|
|
return AUDIT_ARCH_AARCH64;
|
|
|
|
}
|
|
|
|
|
2012-03-05 19:49:33 +08:00
|
|
|
#endif /* __ASM_SYSCALL_H */
|