2 * Access to user system call parameters and results
4 * Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved.
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU General Public License v.2.
10 * See asm-generic/syscall.h for descriptions of what we must do here.
13 #ifndef _ASM_X86_SYSCALL_H
14 #define _ASM_X86_SYSCALL_H
16 #include <linux/sched.h>
17 #include <linux/err.h>
18 #include <asm/asm-offsets.h> /* For NR_syscalls */
20 extern const unsigned long sys_call_table
[];
23 * Only the low 32 bits of orig_ax are meaningful, so we return int.
24 * This importantly ignores the high bits on 64-bit, so comparisons
25 * sign-extend the low 32 bits.
27 static inline int syscall_get_nr(struct task_struct
*task
, struct pt_regs
*regs
)
32 static inline void syscall_rollback(struct task_struct
*task
,
35 regs
->ax
= regs
->orig_ax
;
38 static inline long syscall_get_error(struct task_struct
*task
,
41 unsigned long error
= regs
->ax
;
42 #ifdef CONFIG_IA32_EMULATION
44 * TS_COMPAT is set for 32-bit syscall entries and then
45 * remains set until we return to user mode.
47 if (task_thread_info(task
)->status
& TS_COMPAT
)
49 * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
50 * and will match correctly in comparisons.
52 error
= (long) (int) error
;
54 return IS_ERR_VALUE(error
) ? error
: 0;
57 static inline long syscall_get_return_value(struct task_struct
*task
,
63 static inline void syscall_set_return_value(struct task_struct
*task
,
67 regs
->ax
= (long) error
?: val
;
72 static inline void syscall_get_arguments(struct task_struct
*task
,
74 unsigned int i
, unsigned int n
,
78 memcpy(args
, ®s
->bx
+ i
, n
* sizeof(args
[0]));
81 static inline void syscall_set_arguments(struct task_struct
*task
,
83 unsigned int i
, unsigned int n
,
84 const unsigned long *args
)
87 memcpy(®s
->bx
+ i
, args
, n
* sizeof(args
[0]));
90 #else /* CONFIG_X86_64 */
92 static inline void syscall_get_arguments(struct task_struct
*task
,
94 unsigned int i
, unsigned int n
,
97 # ifdef CONFIG_IA32_EMULATION
98 if (task_thread_info(task
)->status
& TS_COMPAT
)
153 static inline void syscall_set_arguments(struct task_struct
*task
,
154 struct pt_regs
*regs
,
155 unsigned int i
, unsigned int n
,
156 const unsigned long *args
)
158 # ifdef CONFIG_IA32_EMULATION
159 if (task_thread_info(task
)->status
& TS_COMPAT
)
214 #endif /* CONFIG_X86_32 */
216 #endif /* _ASM_X86_SYSCALL_H */