xref: /openbmc/linux/arch/s390/kernel/compat_linux.h (revision f15cbe6f1a4b4d9df59142fc8e4abb973302cf44)
1 #ifndef _ASM_S390X_S390_H
2 #define _ASM_S390X_S390_H
3 
4 #include <linux/compat.h>
5 #include <linux/socket.h>
6 #include <linux/syscalls.h>
7 #include <linux/nfs_fs.h>
8 #include <linux/sunrpc/svc.h>
9 #include <linux/nfsd/nfsd.h>
10 #include <linux/nfsd/export.h>
11 
12 /* Macro that masks the high order bit of an 32 bit pointer and converts it*/
13 /*       to a 64 bit pointer */
14 #define A(__x) ((unsigned long)((__x) & 0x7FFFFFFFUL))
15 #define AA(__x)				\
16 	((unsigned long)(__x))
17 
18 /* Now 32bit compatibility types */
19 struct ipc_kludge_32 {
20         __u32   msgp;                           /* pointer              */
21         __s32   msgtyp;
22 };
23 
24 struct old_sigaction32 {
25        __u32			sa_handler;	/* Really a pointer, but need to deal with 32 bits */
26        compat_old_sigset_t	sa_mask;	/* A 32 bit mask */
27        __u32			sa_flags;
28        __u32			sa_restorer;	/* Another 32 bit pointer */
29 };
30 
31 typedef struct compat_siginfo {
32 	int	si_signo;
33 	int	si_errno;
34 	int	si_code;
35 
36 	union {
37 		int _pad[((128/sizeof(int)) - 3)];
38 
39 		/* kill() */
40 		struct {
41 			pid_t	_pid;	/* sender's pid */
42 			uid_t	_uid;	/* sender's uid */
43 		} _kill;
44 
45 		/* POSIX.1b timers */
46 		struct {
47 			compat_timer_t _tid;		/* timer id */
48 			int _overrun;		/* overrun count */
49 			compat_sigval_t _sigval;	/* same as below */
50 			int _sys_private;       /* not to be passed to user */
51 		} _timer;
52 
53 		/* POSIX.1b signals */
54 		struct {
55 			pid_t			_pid;	/* sender's pid */
56 			uid_t			_uid;	/* sender's uid */
57 			compat_sigval_t		_sigval;
58 		} _rt;
59 
60 		/* SIGCHLD */
61 		struct {
62 			pid_t			_pid;	/* which child */
63 			uid_t			_uid;	/* sender's uid */
64 			int			_status;/* exit code */
65 			compat_clock_t		_utime;
66 			compat_clock_t		_stime;
67 		} _sigchld;
68 
69 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
70 		struct {
71 			__u32	_addr;	/* faulting insn/memory ref. - pointer */
72 		} _sigfault;
73 
74 		/* SIGPOLL */
75 		struct {
76 			int	_band;	/* POLL_IN, POLL_OUT, POLL_MSG */
77 			int	_fd;
78 		} _sigpoll;
79 	} _sifields;
80 } compat_siginfo_t;
81 
82 /*
83  * How these fields are to be accessed.
84  */
85 #define si_pid		_sifields._kill._pid
86 #define si_uid		_sifields._kill._uid
87 #define si_status	_sifields._sigchld._status
88 #define si_utime	_sifields._sigchld._utime
89 #define si_stime	_sifields._sigchld._stime
90 #define si_value	_sifields._rt._sigval
91 #define si_int		_sifields._rt._sigval.sival_int
92 #define si_ptr		_sifields._rt._sigval.sival_ptr
93 #define si_addr		_sifields._sigfault._addr
94 #define si_band		_sifields._sigpoll._band
95 #define si_fd		_sifields._sigpoll._fd
96 #define si_tid		_sifields._timer._tid
97 #define si_overrun	_sifields._timer._overrun
98 
99 /* asm/sigcontext.h */
100 typedef union
101 {
102 	__u64   d;
103 	__u32   f;
104 } freg_t32;
105 
106 typedef struct
107 {
108 	unsigned int	fpc;
109 	freg_t32	fprs[__NUM_FPRS];
110 } _s390_fp_regs32;
111 
112 typedef struct
113 {
114         __u32   mask;
115         __u32	addr;
116 } _psw_t32 __attribute__ ((aligned(8)));
117 
118 typedef struct
119 {
120 	_psw_t32	psw;
121 	__u32		gprs[__NUM_GPRS];
122 	__u32		acrs[__NUM_ACRS];
123 } _s390_regs_common32;
124 
125 typedef struct
126 {
127 	_s390_regs_common32 regs;
128 	_s390_fp_regs32     fpregs;
129 } _sigregs32;
130 
131 #define _SIGCONTEXT_NSIG32	64
132 #define _SIGCONTEXT_NSIG_BPW32	32
133 #define __SIGNAL_FRAMESIZE32	96
134 #define _SIGMASK_COPY_SIZE32	(sizeof(u32)*2)
135 
136 struct sigcontext32
137 {
138 	__u32	oldmask[_COMPAT_NSIG_WORDS];
139 	__u32	sregs;				/* pointer */
140 };
141 
142 /* asm/signal.h */
143 struct sigaction32 {
144 	__u32		sa_handler;		/* pointer */
145 	__u32		sa_flags;
146         __u32		sa_restorer;		/* pointer */
147 	compat_sigset_t	sa_mask;        /* mask last for extensibility */
148 };
149 
150 typedef struct {
151 	__u32			ss_sp;		/* pointer */
152 	int			ss_flags;
153 	compat_size_t		ss_size;
154 } stack_t32;
155 
156 /* asm/ucontext.h */
157 struct ucontext32 {
158 	__u32			uc_flags;
159 	__u32			uc_link;	/* pointer */
160 	stack_t32		uc_stack;
161 	_sigregs32		uc_mcontext;
162 	compat_sigset_t		uc_sigmask;	/* mask last for extensibility */
163 };
164 
165 struct __sysctl_args32;
166 struct stat64_emu31;
167 struct mmap_arg_struct_emu31;
168 struct fadvise64_64_args;
169 struct old_sigaction32;
170 struct old_sigaction32;
171 
172 long sys32_chown16(const char __user * filename, u16 user, u16 group);
173 long sys32_lchown16(const char __user * filename, u16 user, u16 group);
174 long sys32_fchown16(unsigned int fd, u16 user, u16 group);
175 long sys32_setregid16(u16 rgid, u16 egid);
176 long sys32_setgid16(u16 gid);
177 long sys32_setreuid16(u16 ruid, u16 euid);
178 long sys32_setuid16(u16 uid);
179 long sys32_setresuid16(u16 ruid, u16 euid, u16 suid);
180 long sys32_getresuid16(u16 __user *ruid, u16 __user *euid, u16 __user *suid);
181 long sys32_setresgid16(u16 rgid, u16 egid, u16 sgid);
182 long sys32_getresgid16(u16 __user *rgid, u16 __user *egid, u16 __user *sgid);
183 long sys32_setfsuid16(u16 uid);
184 long sys32_setfsgid16(u16 gid);
185 long sys32_getgroups16(int gidsetsize, u16 __user *grouplist);
186 long sys32_setgroups16(int gidsetsize, u16 __user *grouplist);
187 long sys32_getuid16(void);
188 long sys32_geteuid16(void);
189 long sys32_getgid16(void);
190 long sys32_getegid16(void);
191 long sys32_ipc(u32 call, int first, int second, int third, u32 ptr);
192 long sys32_truncate64(const char __user * path, unsigned long high,
193 		      unsigned long low);
194 long sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned long low);
195 long sys32_sched_rr_get_interval(compat_pid_t pid,
196 				 struct compat_timespec __user *interval);
197 long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
198 			  compat_sigset_t __user *oset, size_t sigsetsize);
199 long sys32_rt_sigpending(compat_sigset_t __user *set, size_t sigsetsize);
200 long sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo);
201 long sys32_execve(void);
202 long sys32_init_module(void __user *umod, unsigned long len,
203 		       const char __user *uargs);
204 long sys32_delete_module(const char __user *name_user, unsigned int flags);
205 long sys32_gettimeofday(struct compat_timeval __user *tv,
206 			struct timezone __user *tz);
207 long sys32_settimeofday(struct compat_timeval __user *tv,
208 			struct timezone __user *tz);
209 long sys32_pause(void);
210 long sys32_pread64(unsigned int fd, char __user *ubuf, size_t count,
211 		   u32 poshi, u32 poslo);
212 long sys32_pwrite64(unsigned int fd, const char __user *ubuf,
213 		    size_t count, u32 poshi, u32 poslo);
214 compat_ssize_t sys32_readahead(int fd, u32 offhi, u32 offlo, s32 count);
215 long sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset,
216 		    size_t count);
217 long sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset,
218 		      s32 count);
219 long sys32_sysctl(struct __sysctl_args32 __user *args);
220 long sys32_stat64(char __user * filename, struct stat64_emu31 __user * statbuf);
221 long sys32_lstat64(char __user * filename,
222 		   struct stat64_emu31 __user * statbuf);
223 long sys32_fstat64(unsigned long fd, struct stat64_emu31 __user * statbuf);
224 long sys32_fstatat64(unsigned int dfd, char __user *filename,
225 		     struct stat64_emu31 __user* statbuf, int flag);
226 unsigned long old32_mmap(struct mmap_arg_struct_emu31 __user *arg);
227 long sys32_mmap2(struct mmap_arg_struct_emu31 __user *arg);
228 long sys32_read(unsigned int fd, char __user * buf, size_t count);
229 long sys32_write(unsigned int fd, char __user * buf, size_t count);
230 long sys32_clone(void);
231 long sys32_fadvise64(int fd, loff_t offset, size_t len, int advise);
232 long sys32_fadvise64_64(struct fadvise64_64_args __user *args);
233 long sys32_sigaction(int sig, const struct old_sigaction32 __user *act,
234 		     struct old_sigaction32 __user *oact);
235 long sys32_rt_sigaction(int sig, const struct sigaction32 __user *act,
236 			struct sigaction32 __user *oact, size_t sigsetsize);
237 long sys32_sigaltstack(const stack_t32 __user *uss, stack_t32 __user *uoss);
238 #endif /* _ASM_S390X_S390_H */
239