2019-06-03 12:44:50 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2012-03-05 18:49:33 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_SYSCALL_H
|
|
|
|
#define __ASM_SYSCALL_H
|
|
|
|
|
2014-07-04 14:28:30 +07:00
|
|
|
#include <uapi/linux/audit.h>
|
|
|
|
#include <linux/compat.h>
|
2012-03-05 18:49:33 +07:00
|
|
|
#include <linux/err.h>
|
|
|
|
|
2019-05-25 05:11:16 +07:00
|
|
|
typedef long (*syscall_fn_t)(const struct pt_regs *regs);
|
2018-07-11 20:56:42 +07:00
|
|
|
|
|
|
|
extern const syscall_fn_t sys_call_table[];
|
2012-03-05 18:49:33 +07:00
|
|
|
|
2018-07-11 20:56:45 +07:00
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
extern const syscall_fn_t compat_sys_call_table[];
|
|
|
|
#endif
|
|
|
|
|
2012-03-05 18:49:33 +07: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 04:26:37 +07:00
|
|
|
args[0] = regs->orig_x0;
|
|
|
|
args++;
|
2012-03-05 18:49:33 +07:00
|
|
|
|
2016-11-08 04:26:37 +07:00
|
|
|
memcpy(args, ®s->regs[1], 5 * sizeof(args[0]));
|
2012-03-05 18:49:33 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void syscall_set_arguments(struct task_struct *task,
|
|
|
|
struct pt_regs *regs,
|
|
|
|
const unsigned long *args)
|
|
|
|
{
|
2019-03-28 07:07:31 +07:00
|
|
|
regs->orig_x0 = args[0];
|
|
|
|
args++;
|
|
|
|
|
|
|
|
memcpy(®s->regs[1], args, 5 * sizeof(args[0]));
|
2012-03-05 18:49:33 +07:00
|
|
|
}
|
|
|
|
|
2014-07-04 14:28:30 +07: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 06:30:18 +07:00
|
|
|
static inline int syscall_get_arch(struct task_struct *task)
|
2014-07-04 14:28:30 +07:00
|
|
|
{
|
2019-03-18 06:30:18 +07:00
|
|
|
if (is_compat_thread(task_thread_info(task)))
|
2014-07-04 14:28:30 +07:00
|
|
|
return AUDIT_ARCH_ARM;
|
|
|
|
|
|
|
|
return AUDIT_ARCH_AARCH64;
|
|
|
|
}
|
|
|
|
|
2012-03-05 18:49:33 +07:00
|
|
|
#endif /* __ASM_SYSCALL_H */
|