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>
19 extern const unsigned long sys_call_table
[];
22 * Only the low 32 bits of orig_ax are meaningful, so we return int.
23 * This importantly ignores the high bits on 64-bit, so comparisons
24 * sign-extend the low 32 bits.
26 static inline int syscall_get_nr(struct task_struct
*task
, struct pt_regs
*regs
)
31 static inline void syscall_rollback(struct task_struct
*task
,
34 regs
->ax
= regs
->orig_ax
;
37 static inline long syscall_get_error(struct task_struct
*task
,
40 unsigned long error
= regs
->ax
;
41 #ifdef CONFIG_IA32_EMULATION
43 * TS_COMPAT is set for 32-bit syscall entries and then
44 * remains set until we return to user mode.
46 if (task_thread_info(task
)->status
& TS_COMPAT
)
48 * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
49 * and will match correctly in comparisons.
51 error
= (long) (int) error
;
53 return IS_ERR_VALUE(error
) ? error
: 0;
56 static inline long syscall_get_return_value(struct task_struct
*task
,
62 static inline void syscall_set_return_value(struct task_struct
*task
,
66 regs
->ax
= (long) error
?: val
;
71 static inline void syscall_get_arguments(struct task_struct
*task
,
73 unsigned int i
, unsigned int n
,
77 memcpy(args
, ®s
->bx
+ i
, n
* sizeof(args
[0]));
80 static inline void syscall_set_arguments(struct task_struct
*task
,
82 unsigned int i
, unsigned int n
,
83 const unsigned long *args
)
86 memcpy(®s
->bx
+ i
, args
, n
* sizeof(args
[0]));
89 #else /* CONFIG_X86_64 */
91 static inline void syscall_get_arguments(struct task_struct
*task
,
93 unsigned int i
, unsigned int n
,
96 # ifdef CONFIG_IA32_EMULATION
97 if (task_thread_info(task
)->status
& TS_COMPAT
)
152 static inline void syscall_set_arguments(struct task_struct
*task
,
153 struct pt_regs
*regs
,
154 unsigned int i
, unsigned int n
,
155 const unsigned long *args
)
157 # ifdef CONFIG_IA32_EMULATION
158 if (task_thread_info(task
)->status
& TS_COMPAT
)
213 #endif /* CONFIG_X86_32 */
215 #endif /* _ASM_X86_SYSCALL_H */