David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Access to user system call parameters and results |
| 4 | * |
| 5 | * Copyright (C) 2008 Intel Corp. Shaohua Li <shaohua.li@intel.com> |
| 6 | * |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 7 | * See asm-generic/syscall.h for descriptions of what we must do here. |
| 8 | */ |
| 9 | |
| 10 | #ifndef _ASM_SYSCALL_H |
| 11 | #define _ASM_SYSCALL_H 1 |
| 12 | |
| 13 | #include <uapi/linux/audit.h> |
| 14 | #include <linux/sched.h> |
| 15 | #include <linux/err.h> |
| 16 | |
| 17 | static inline long syscall_get_nr(struct task_struct *task, |
| 18 | struct pt_regs *regs) |
| 19 | { |
| 20 | if ((long)regs->cr_ifs < 0) /* Not a syscall */ |
| 21 | return -1; |
| 22 | |
| 23 | return regs->r15; |
| 24 | } |
| 25 | |
| 26 | static inline void syscall_rollback(struct task_struct *task, |
| 27 | struct pt_regs *regs) |
| 28 | { |
| 29 | /* do nothing */ |
| 30 | } |
| 31 | |
| 32 | static inline long syscall_get_error(struct task_struct *task, |
| 33 | struct pt_regs *regs) |
| 34 | { |
| 35 | return regs->r10 == -1 ? regs->r8:0; |
| 36 | } |
| 37 | |
| 38 | static inline long syscall_get_return_value(struct task_struct *task, |
| 39 | struct pt_regs *regs) |
| 40 | { |
| 41 | return regs->r8; |
| 42 | } |
| 43 | |
| 44 | static inline void syscall_set_return_value(struct task_struct *task, |
| 45 | struct pt_regs *regs, |
| 46 | int error, long val) |
| 47 | { |
| 48 | if (error) { |
| 49 | /* error < 0, but ia64 uses > 0 return value */ |
| 50 | regs->r8 = -error; |
| 51 | regs->r10 = -1; |
| 52 | } else { |
| 53 | regs->r8 = val; |
| 54 | regs->r10 = 0; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | extern void ia64_syscall_get_set_arguments(struct task_struct *task, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 59 | struct pt_regs *regs, unsigned long *args, int rw); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 60 | static inline void syscall_get_arguments(struct task_struct *task, |
| 61 | struct pt_regs *regs, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 62 | unsigned long *args) |
| 63 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 64 | ia64_syscall_get_set_arguments(task, regs, args, 0); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | static inline void syscall_set_arguments(struct task_struct *task, |
| 68 | struct pt_regs *regs, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 69 | unsigned long *args) |
| 70 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 71 | ia64_syscall_get_set_arguments(task, regs, args, 1); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 72 | } |
| 73 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 74 | static inline int syscall_get_arch(struct task_struct *task) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 75 | { |
| 76 | return AUDIT_ARCH_IA64; |
| 77 | } |
| 78 | #endif /* _ASM_SYSCALL_H */ |