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/audit.h>
17 #include <linux/sched.h>
18 #include <linux/err.h>
19 #include <asm/asm-offsets.h> /* For NR_syscalls */
20 #include <asm/thread_info.h> /* for TS_COMPAT */
21 #include <asm/unistd.h>
23 typedef void (*sys_call_ptr_t
)(void);
24 extern const sys_call_ptr_t sys_call_table
[];
27 * Only the low 32 bits of orig_ax are meaningful, so we return int.
28 * This importantly ignores the high bits on 64-bit, so comparisons
29 * sign-extend the low 32 bits.
31 static inline int syscall_get_nr(struct task_struct
*task
, struct pt_regs
*regs
)
36 static inline void syscall_rollback(struct task_struct
*task
,
39 regs
->ax
= regs
->orig_ax
;
42 static inline long syscall_get_error(struct task_struct
*task
,
45 unsigned long error
= regs
->ax
;
46 #ifdef CONFIG_IA32_EMULATION
48 * TS_COMPAT is set for 32-bit syscall entries and then
49 * remains set until we return to user mode.
51 if (task_thread_info(task
)->status
& TS_COMPAT
)
53 * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
54 * and will match correctly in comparisons.
56 error
= (long) (int) error
;
58 return IS_ERR_VALUE(error
) ? error
: 0;
61 static inline long syscall_get_return_value(struct task_struct
*task
,
67 static inline void syscall_set_return_value(struct task_struct
*task
,
71 regs
->ax
= (long) error
?: val
;
76 static inline void syscall_get_arguments(struct task_struct
*task
,
78 unsigned int i
, unsigned int n
,
82 memcpy(args
, ®s
->bx
+ i
, n
* sizeof(args
[0]));
85 static inline void syscall_set_arguments(struct task_struct
*task
,
87 unsigned int i
, unsigned int n
,
88 const unsigned long *args
)
91 memcpy(®s
->bx
+ i
, args
, n
* sizeof(args
[0]));
94 static inline int syscall_get_arch(struct task_struct
*task
,
97 return AUDIT_ARCH_I386
;
100 #else /* CONFIG_X86_64 */
102 static inline void syscall_get_arguments(struct task_struct
*task
,
103 struct pt_regs
*regs
,
104 unsigned int i
, unsigned int n
,
107 # ifdef CONFIG_IA32_EMULATION
108 if (task_thread_info(task
)->status
& TS_COMPAT
)
163 static inline void syscall_set_arguments(struct task_struct
*task
,
164 struct pt_regs
*regs
,
165 unsigned int i
, unsigned int n
,
166 const unsigned long *args
)
168 # ifdef CONFIG_IA32_EMULATION
169 if (task_thread_info(task
)->status
& TS_COMPAT
)
224 static inline int syscall_get_arch(struct task_struct
*task
,
225 struct pt_regs
*regs
)
227 #ifdef CONFIG_IA32_EMULATION
229 * TS_COMPAT is set for 32-bit syscall entry and then
230 * remains set until we return to user mode.
232 * TIF_IA32 tasks should always have TS_COMPAT set at
235 * x32 tasks should be considered AUDIT_ARCH_X86_64.
237 if (task_thread_info(task
)->status
& TS_COMPAT
)
238 return AUDIT_ARCH_I386
;
240 /* Both x32 and x86_64 are considered "64-bit". */
241 return AUDIT_ARCH_X86_64
;
243 #endif /* CONFIG_X86_32 */
245 #endif /* _ASM_X86_SYSCALL_H */