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