arm64: Execute DSB during thread switching for TLB/cache maintenance
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm64 / include / asm / compat.h
CommitLineData
3dd681d9
WD
1/*
2 * Copyright (C) 2012 ARM Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef __ASM_COMPAT_H
17#define __ASM_COMPAT_H
18#ifdef __KERNEL__
19#ifdef CONFIG_COMPAT
20
21/*
22 * Architecture specific compatibility types
23 */
24#include <linux/types.h>
25#include <linux/sched.h>
7ae42c96 26#include <linux/ptrace.h>
3dd681d9
WD
27
28#define COMPAT_USER_HZ 100
29#define COMPAT_UTS_MACHINE "armv8l\0\0"
30
31typedef u32 compat_size_t;
32typedef s32 compat_ssize_t;
33typedef s32 compat_time_t;
34typedef s32 compat_clock_t;
35typedef s32 compat_pid_t;
36typedef u32 __compat_uid_t;
37typedef u32 __compat_gid_t;
38typedef u32 __compat_uid32_t;
39typedef u32 __compat_gid32_t;
40typedef u32 compat_mode_t;
41typedef u32 compat_ino_t;
42typedef u32 compat_dev_t;
43typedef s32 compat_off_t;
44typedef s64 compat_loff_t;
45typedef s16 compat_nlink_t;
46typedef u16 compat_ipc_pid_t;
47typedef s32 compat_daddr_t;
48typedef u32 compat_caddr_t;
49typedef __kernel_fsid_t compat_fsid_t;
50typedef s32 compat_key_t;
51typedef s32 compat_timer_t;
52
53typedef s32 compat_int_t;
54typedef s32 compat_long_t;
55typedef s64 compat_s64;
56typedef u32 compat_uint_t;
57typedef u32 compat_ulong_t;
58typedef u64 compat_u64;
751f409d 59typedef u32 compat_uptr_t;
3dd681d9
WD
60
61struct compat_timespec {
62 compat_time_t tv_sec;
63 s32 tv_nsec;
64};
65
66struct compat_timeval {
67 compat_time_t tv_sec;
68 s32 tv_usec;
69};
70
71struct compat_stat {
72 compat_dev_t st_dev;
73 compat_ino_t st_ino;
74 compat_mode_t st_mode;
75 compat_nlink_t st_nlink;
76 __compat_uid32_t st_uid;
77 __compat_gid32_t st_gid;
78 compat_dev_t st_rdev;
79 compat_off_t st_size;
80 compat_off_t st_blksize;
81 compat_off_t st_blocks;
82 compat_time_t st_atime;
83 u32 st_atime_nsec;
84 compat_time_t st_mtime;
85 u32 st_mtime_nsec;
86 compat_time_t st_ctime;
87 u32 st_ctime_nsec;
88 u32 __unused4[2];
89};
90
91struct compat_flock {
92 short l_type;
93 short l_whence;
94 compat_off_t l_start;
95 compat_off_t l_len;
96 compat_pid_t l_pid;
97};
98
99#define F_GETLK64 12 /* using 'struct flock64' */
100#define F_SETLK64 13
101#define F_SETLKW64 14
102
103struct compat_flock64 {
104 short l_type;
105 short l_whence;
106 compat_loff_t l_start;
107 compat_loff_t l_len;
108 compat_pid_t l_pid;
109};
110
111struct compat_statfs {
112 int f_type;
113 int f_bsize;
114 int f_blocks;
115 int f_bfree;
116 int f_bavail;
117 int f_files;
118 int f_ffree;
119 compat_fsid_t f_fsid;
120 int f_namelen; /* SunOS ignores this field. */
121 int f_frsize;
122 int f_flags;
123 int f_spare[4];
124};
125
126#define COMPAT_RLIM_INFINITY 0xffffffff
127
128typedef u32 compat_old_sigset_t;
129
130#define _COMPAT_NSIG 64
131#define _COMPAT_NSIG_BPW 32
132
133typedef u32 compat_sigset_word;
134
751f409d
DV
135typedef union compat_sigval {
136 compat_int_t sival_int;
137 compat_uptr_t sival_ptr;
138} compat_sigval_t;
139
140typedef struct compat_siginfo {
141 int si_signo;
142 int si_errno;
143 int si_code;
144
145 union {
146 /* The padding is the same size as AArch64. */
147 int _pad[128/sizeof(int) - 3];
148
149 /* kill() */
150 struct {
151 compat_pid_t _pid; /* sender's pid */
152 __compat_uid32_t _uid; /* sender's uid */
153 } _kill;
154
155 /* POSIX.1b timers */
156 struct {
157 compat_timer_t _tid; /* timer id */
158 int _overrun; /* overrun count */
159 compat_sigval_t _sigval; /* same as below */
160 int _sys_private; /* not to be passed to user */
161 } _timer;
162
163 /* POSIX.1b signals */
164 struct {
165 compat_pid_t _pid; /* sender's pid */
166 __compat_uid32_t _uid; /* sender's uid */
167 compat_sigval_t _sigval;
168 } _rt;
169
170 /* SIGCHLD */
171 struct {
172 compat_pid_t _pid; /* which child */
173 __compat_uid32_t _uid; /* sender's uid */
174 int _status; /* exit code */
175 compat_clock_t _utime;
176 compat_clock_t _stime;
177 } _sigchld;
178
179 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
180 struct {
181 compat_uptr_t _addr; /* faulting insn/memory ref. */
182 short _addr_lsb; /* LSB of the reported address */
183 } _sigfault;
184
185 /* SIGPOLL */
186 struct {
187 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
188 int _fd;
189 } _sigpoll;
190 } _sifields;
191} compat_siginfo_t;
192
3dd681d9
WD
193#define COMPAT_OFF_T_MAX 0x7fffffff
194#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
195
196/*
197 * A pointer passed in from user mode. This should not
198 * be used for syscall parameters, just declare them
199 * as pointers because the syscall entry code will have
200 * appropriately converted them already.
201 */
3dd681d9
WD
202
203static inline void __user *compat_ptr(compat_uptr_t uptr)
204{
205 return (void __user *)(unsigned long)uptr;
206}
207
208static inline compat_uptr_t ptr_to_compat(void __user *uptr)
209{
210 return (u32)(unsigned long)uptr;
211}
212
9b064fc3
AV
213#define compat_user_stack_pointer() (current_pt_regs()->compat_sp)
214
3dd681d9
WD
215static inline void __user *arch_compat_alloc_user_space(long len)
216{
9b064fc3 217 return (void __user *)compat_user_stack_pointer() - len;
3dd681d9
WD
218}
219
220struct compat_ipc64_perm {
221 compat_key_t key;
222 __compat_uid32_t uid;
223 __compat_gid32_t gid;
224 __compat_uid32_t cuid;
225 __compat_gid32_t cgid;
226 unsigned short mode;
227 unsigned short __pad1;
228 unsigned short seq;
229 unsigned short __pad2;
230 compat_ulong_t unused1;
231 compat_ulong_t unused2;
232};
233
234struct compat_semid64_ds {
235 struct compat_ipc64_perm sem_perm;
236 compat_time_t sem_otime;
237 compat_ulong_t __unused1;
238 compat_time_t sem_ctime;
239 compat_ulong_t __unused2;
240 compat_ulong_t sem_nsems;
241 compat_ulong_t __unused3;
242 compat_ulong_t __unused4;
243};
244
245struct compat_msqid64_ds {
246 struct compat_ipc64_perm msg_perm;
247 compat_time_t msg_stime;
248 compat_ulong_t __unused1;
249 compat_time_t msg_rtime;
250 compat_ulong_t __unused2;
251 compat_time_t msg_ctime;
252 compat_ulong_t __unused3;
253 compat_ulong_t msg_cbytes;
254 compat_ulong_t msg_qnum;
255 compat_ulong_t msg_qbytes;
256 compat_pid_t msg_lspid;
257 compat_pid_t msg_lrpid;
258 compat_ulong_t __unused4;
259 compat_ulong_t __unused5;
260};
261
262struct compat_shmid64_ds {
263 struct compat_ipc64_perm shm_perm;
264 compat_size_t shm_segsz;
265 compat_time_t shm_atime;
266 compat_ulong_t __unused1;
267 compat_time_t shm_dtime;
268 compat_ulong_t __unused2;
269 compat_time_t shm_ctime;
270 compat_ulong_t __unused3;
271 compat_pid_t shm_cpid;
272 compat_pid_t shm_lpid;
273 compat_ulong_t shm_nattch;
274 compat_ulong_t __unused4;
275 compat_ulong_t __unused5;
276};
277
278static inline int is_compat_task(void)
279{
280 return test_thread_flag(TIF_32BIT);
281}
282
283static inline int is_compat_thread(struct thread_info *thread)
284{
285 return test_ti_thread_flag(thread, TIF_32BIT);
286}
287
288#else /* !CONFIG_COMPAT */
289
290static inline int is_compat_task(void)
291{
292 return 0;
293}
294
295static inline int is_compat_thread(struct thread_info *thread)
296{
297 return 0;
298}
299
300#endif /* CONFIG_COMPAT */
301#endif /* __KERNEL__ */
302#endif /* __ASM_COMPAT_H */