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