blob: 2e49748b27dab5ca3e62c2b4f63909c50058a593 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_S390X_COMPAT_H
2#define _ASM_S390X_COMPAT_H
3/*
4 * Architecture specific compatibility types
5 */
6#include <linux/types.h>
7#include <linux/sched.h>
Heiko Carstens77575912009-06-12 10:26:25 +02008#include <linux/thread_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Gerald Schaeferc1821c22007-02-05 21:18:17 +010010#define PSW32_MASK_PER 0x40000000UL
11#define PSW32_MASK_DAT 0x04000000UL
12#define PSW32_MASK_IO 0x02000000UL
13#define PSW32_MASK_EXT 0x01000000UL
14#define PSW32_MASK_KEY 0x00F00000UL
Martin Schwidefskyb50511e2011-10-30 15:16:50 +010015#define PSW32_MASK_BASE 0x00080000UL /* Always one */
Gerald Schaeferc1821c22007-02-05 21:18:17 +010016#define PSW32_MASK_MCHECK 0x00040000UL
17#define PSW32_MASK_WAIT 0x00020000UL
18#define PSW32_MASK_PSTATE 0x00010000UL
19#define PSW32_MASK_ASC 0x0000C000UL
20#define PSW32_MASK_CC 0x00003000UL
21#define PSW32_MASK_PM 0x00000f00UL
22
Martin Schwidefskyb50511e2011-10-30 15:16:50 +010023#define PSW32_MASK_USER 0x00003F00UL
24
25#define PSW32_ADDR_AMODE 0x80000000UL
Gerald Schaeferc1821c22007-02-05 21:18:17 +010026#define PSW32_ADDR_INSN 0x7FFFFFFFUL
27
Martin Schwidefskyb50511e2011-10-30 15:16:50 +010028#define PSW32_DEFAULT_KEY (((u32) PAGE_DEFAULT_ACC) << 20)
Gerald Schaeferc1821c22007-02-05 21:18:17 +010029
30#define PSW32_ASC_PRIMARY 0x00000000UL
31#define PSW32_ASC_ACCREG 0x00004000UL
32#define PSW32_ASC_SECONDARY 0x00008000UL
33#define PSW32_ASC_HOME 0x0000C000UL
34
Martin Schwidefskyb50511e2011-10-30 15:16:50 +010035extern u32 psw32_user_bits;
Gerald Schaeferc1821c22007-02-05 21:18:17 +010036
Christoph Hellwige28cbf22010-03-10 15:21:19 -080037#define COMPAT_USER_HZ 100
38#define COMPAT_UTS_MACHINE "s390\0\0\0\0"
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40typedef u32 compat_size_t;
41typedef s32 compat_ssize_t;
42typedef s32 compat_time_t;
43typedef s32 compat_clock_t;
44typedef s32 compat_pid_t;
Stephen Rothwell202e5972005-09-06 15:16:40 -070045typedef u16 __compat_uid_t;
46typedef u16 __compat_gid_t;
47typedef u32 __compat_uid32_t;
48typedef u32 __compat_gid32_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049typedef u16 compat_mode_t;
50typedef u32 compat_ino_t;
51typedef u16 compat_dev_t;
52typedef s32 compat_off_t;
53typedef s64 compat_loff_t;
54typedef u16 compat_nlink_t;
55typedef u16 compat_ipc_pid_t;
56typedef s32 compat_daddr_t;
57typedef u32 compat_caddr_t;
58typedef __kernel_fsid_t compat_fsid_t;
59typedef s32 compat_key_t;
60typedef s32 compat_timer_t;
61
62typedef s32 compat_int_t;
63typedef s32 compat_long_t;
Arnd Bergmann4b777582007-07-15 23:41:11 -070064typedef s64 compat_s64;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065typedef u32 compat_uint_t;
66typedef u32 compat_ulong_t;
Arnd Bergmann4b777582007-07-15 23:41:11 -070067typedef u64 compat_u64;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69struct compat_timespec {
70 compat_time_t tv_sec;
71 s32 tv_nsec;
72};
73
74struct compat_timeval {
75 compat_time_t tv_sec;
76 s32 tv_usec;
77};
78
79struct compat_stat {
80 compat_dev_t st_dev;
81 u16 __pad1;
82 compat_ino_t st_ino;
83 compat_mode_t st_mode;
84 compat_nlink_t st_nlink;
Stephen Rothwell202e5972005-09-06 15:16:40 -070085 __compat_uid_t st_uid;
86 __compat_gid_t st_gid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 compat_dev_t st_rdev;
88 u16 __pad2;
89 u32 st_size;
90 u32 st_blksize;
91 u32 st_blocks;
92 u32 st_atime;
93 u32 st_atime_nsec;
94 u32 st_mtime;
95 u32 st_mtime_nsec;
96 u32 st_ctime;
97 u32 st_ctime_nsec;
98 u32 __unused4;
99 u32 __unused5;
100};
101
102struct compat_flock {
103 short l_type;
104 short l_whence;
105 compat_off_t l_start;
106 compat_off_t l_len;
107 compat_pid_t l_pid;
108};
109
110#define F_GETLK64 12
111#define F_SETLK64 13
112#define F_SETLKW64 14
113
114struct compat_flock64 {
115 short l_type;
116 short l_whence;
117 compat_loff_t l_start;
118 compat_loff_t l_len;
119 compat_pid_t l_pid;
120};
121
122struct compat_statfs {
123 s32 f_type;
124 s32 f_bsize;
125 s32 f_blocks;
126 s32 f_bfree;
127 s32 f_bavail;
128 s32 f_files;
129 s32 f_ffree;
130 compat_fsid_t f_fsid;
131 s32 f_namelen;
132 s32 f_frsize;
Eric W. Biederman1448c722011-10-17 13:40:02 -0700133 s32 f_flags;
134 s32 f_spare[5];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135};
136
137#define COMPAT_RLIM_OLD_INFINITY 0x7fffffff
138#define COMPAT_RLIM_INFINITY 0xffffffff
139
140typedef u32 compat_old_sigset_t; /* at least 32 bits */
141
142#define _COMPAT_NSIG 64
143#define _COMPAT_NSIG_BPW 32
144
145typedef u32 compat_sigset_word;
146
147#define COMPAT_OFF_T_MAX 0x7fffffff
148#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
149
150/*
151 * A pointer passed in from user mode. This should not
152 * be used for syscall parameters, just declare them
153 * as pointers because the syscall entry code will have
Marcin Ĺšlusarz8b3de0d2008-02-03 16:32:51 +0200154 * appropriately converted them already.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 */
156typedef u32 compat_uptr_t;
157
158static inline void __user *compat_ptr(compat_uptr_t uptr)
159{
160 return (void __user *)(unsigned long)(uptr & 0x7fffffffUL);
161}
162
Ingo Molnarf267fa92006-03-27 01:16:09 -0800163static inline compat_uptr_t ptr_to_compat(void __user *uptr)
164{
165 return (u32)(unsigned long)uptr;
166}
167
Heiko Carstens77575912009-06-12 10:26:25 +0200168#ifdef CONFIG_COMPAT
169
170static inline int is_compat_task(void)
171{
Heiko Carstensa05c90f2011-01-12 09:55:29 +0100172 return is_32bit_task();
Heiko Carstens77575912009-06-12 10:26:25 +0200173}
174
175#else
176
177static inline int is_compat_task(void)
178{
179 return 0;
180}
181
182#endif
183
H. Peter Anvinc41d68a2010-09-07 16:16:18 -0700184static inline void __user *arch_compat_alloc_user_space(long len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185{
186 unsigned long stack;
187
188 stack = KSTK_ESP(current);
Heiko Carstens77575912009-06-12 10:26:25 +0200189 if (is_compat_task())
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 stack &= 0x7fffffffUL;
191 return (void __user *) (stack - len);
192}
193
194struct compat_ipc64_perm {
195 compat_key_t key;
Stephen Rothwell202e5972005-09-06 15:16:40 -0700196 __compat_uid32_t uid;
197 __compat_gid32_t gid;
198 __compat_uid32_t cuid;
199 __compat_gid32_t cgid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 compat_mode_t mode;
201 unsigned short __pad1;
202 unsigned short seq;
203 unsigned short __pad2;
204 unsigned int __unused1;
205 unsigned int __unused2;
206};
207
208struct compat_semid64_ds {
209 struct compat_ipc64_perm sem_perm;
210 compat_time_t sem_otime;
211 compat_ulong_t __pad1;
212 compat_time_t sem_ctime;
213 compat_ulong_t __pad2;
214 compat_ulong_t sem_nsems;
215 compat_ulong_t __unused1;
216 compat_ulong_t __unused2;
217};
218
219struct compat_msqid64_ds {
220 struct compat_ipc64_perm msg_perm;
221 compat_time_t msg_stime;
222 compat_ulong_t __pad1;
223 compat_time_t msg_rtime;
224 compat_ulong_t __pad2;
225 compat_time_t msg_ctime;
226 compat_ulong_t __pad3;
227 compat_ulong_t msg_cbytes;
228 compat_ulong_t msg_qnum;
229 compat_ulong_t msg_qbytes;
230 compat_pid_t msg_lspid;
231 compat_pid_t msg_lrpid;
232 compat_ulong_t __unused1;
233 compat_ulong_t __unused2;
234};
235
236struct compat_shmid64_ds {
237 struct compat_ipc64_perm shm_perm;
238 compat_size_t shm_segsz;
239 compat_time_t shm_atime;
240 compat_ulong_t __pad1;
241 compat_time_t shm_dtime;
242 compat_ulong_t __pad2;
243 compat_time_t shm_ctime;
244 compat_ulong_t __pad3;
245 compat_pid_t shm_cpid;
246 compat_pid_t shm_lpid;
247 compat_ulong_t shm_nattch;
248 compat_ulong_t __unused1;
249 compat_ulong_t __unused2;
250};
251#endif /* _ASM_S390X_COMPAT_H */