Loading...
Note: File does not exist in v6.8.
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15#ifndef _ASM_TILE_COMPAT_H
16#define _ASM_TILE_COMPAT_H
17
18/*
19 * Architecture specific compatibility types
20 */
21#include <linux/types.h>
22#include <linux/sched.h>
23
24#define COMPAT_USER_HZ 100
25
26/* "long" and pointer-based types are different. */
27typedef s32 compat_long_t;
28typedef u32 compat_ulong_t;
29typedef u32 compat_size_t;
30typedef s32 compat_ssize_t;
31typedef s32 compat_off_t;
32typedef s32 compat_time_t;
33typedef s32 compat_clock_t;
34typedef u32 compat_ino_t;
35typedef u32 compat_caddr_t;
36typedef u32 compat_uptr_t;
37
38/* Many types are "int" or otherwise the same. */
39typedef __kernel_pid_t compat_pid_t;
40typedef __kernel_uid_t __compat_uid_t;
41typedef __kernel_gid_t __compat_gid_t;
42typedef __kernel_uid32_t __compat_uid32_t;
43typedef __kernel_uid32_t __compat_gid32_t;
44typedef __kernel_mode_t compat_mode_t;
45typedef __kernel_dev_t compat_dev_t;
46typedef __kernel_loff_t compat_loff_t;
47typedef __kernel_ipc_pid_t compat_ipc_pid_t;
48typedef __kernel_daddr_t compat_daddr_t;
49typedef __kernel_fsid_t compat_fsid_t;
50typedef __kernel_timer_t compat_timer_t;
51typedef __kernel_key_t compat_key_t;
52typedef int compat_int_t;
53typedef s64 compat_s64;
54typedef uint compat_uint_t;
55typedef u64 compat_u64;
56
57/* We use the same register dump format in 32-bit images. */
58typedef unsigned long compat_elf_greg_t;
59#define COMPAT_ELF_NGREG (sizeof(struct pt_regs) / sizeof(compat_elf_greg_t))
60typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
61
62struct compat_timespec {
63 compat_time_t tv_sec;
64 s32 tv_nsec;
65};
66
67struct compat_timeval {
68 compat_time_t tv_sec;
69 s32 tv_usec;
70};
71
72#define compat_stat stat
73#define compat_statfs statfs
74
75struct compat_sysctl {
76 unsigned int name;
77 int nlen;
78 unsigned int oldval;
79 unsigned int oldlenp;
80 unsigned int newval;
81 unsigned int newlen;
82 unsigned int __unused[4];
83};
84
85
86struct compat_flock {
87 short l_type;
88 short l_whence;
89 compat_off_t l_start;
90 compat_off_t l_len;
91 compat_pid_t l_pid;
92};
93
94#define F_GETLK64 12 /* using 'struct flock64' */
95#define F_SETLK64 13
96#define F_SETLKW64 14
97
98struct compat_flock64 {
99 short l_type;
100 short l_whence;
101 compat_loff_t l_start;
102 compat_loff_t l_len;
103 compat_pid_t l_pid;
104};
105
106#define COMPAT_RLIM_INFINITY 0xffffffff
107
108#define _COMPAT_NSIG 64
109#define _COMPAT_NSIG_BPW 32
110
111typedef u32 compat_sigset_word;
112
113#define COMPAT_OFF_T_MAX 0x7fffffff
114#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
115
116struct compat_ipc64_perm {
117 compat_key_t key;
118 __compat_uid32_t uid;
119 __compat_gid32_t gid;
120 __compat_uid32_t cuid;
121 __compat_gid32_t cgid;
122 unsigned short mode;
123 unsigned short __pad1;
124 unsigned short seq;
125 unsigned short __pad2;
126 compat_ulong_t unused1;
127 compat_ulong_t unused2;
128};
129
130struct compat_semid64_ds {
131 struct compat_ipc64_perm sem_perm;
132 compat_time_t sem_otime;
133 compat_ulong_t __unused1;
134 compat_time_t sem_ctime;
135 compat_ulong_t __unused2;
136 compat_ulong_t sem_nsems;
137 compat_ulong_t __unused3;
138 compat_ulong_t __unused4;
139};
140
141struct compat_msqid64_ds {
142 struct compat_ipc64_perm msg_perm;
143 compat_time_t msg_stime;
144 compat_ulong_t __unused1;
145 compat_time_t msg_rtime;
146 compat_ulong_t __unused2;
147 compat_time_t msg_ctime;
148 compat_ulong_t __unused3;
149 compat_ulong_t msg_cbytes;
150 compat_ulong_t msg_qnum;
151 compat_ulong_t msg_qbytes;
152 compat_pid_t msg_lspid;
153 compat_pid_t msg_lrpid;
154 compat_ulong_t __unused4;
155 compat_ulong_t __unused5;
156};
157
158struct compat_shmid64_ds {
159 struct compat_ipc64_perm shm_perm;
160 compat_size_t shm_segsz;
161 compat_time_t shm_atime;
162 compat_ulong_t __unused1;
163 compat_time_t shm_dtime;
164 compat_ulong_t __unused2;
165 compat_time_t shm_ctime;
166 compat_ulong_t __unused3;
167 compat_pid_t shm_cpid;
168 compat_pid_t shm_lpid;
169 compat_ulong_t shm_nattch;
170 compat_ulong_t __unused4;
171 compat_ulong_t __unused5;
172};
173
174/*
175 * A pointer passed in from user mode. This should not
176 * be used for syscall parameters, just declare them
177 * as pointers because the syscall entry code will have
178 * appropriately converted them already.
179 */
180
181static inline void __user *compat_ptr(compat_uptr_t uptr)
182{
183 return (void __user *)(long)(s32)uptr;
184}
185
186static inline compat_uptr_t ptr_to_compat(void __user *uptr)
187{
188 return (u32)(unsigned long)uptr;
189}
190
191/* Sign-extend when storing a kernel pointer to a user's ptregs. */
192static inline unsigned long ptr_to_compat_reg(void __user *uptr)
193{
194 return (long)(int)(long __force)uptr;
195}
196
197static inline void __user *arch_compat_alloc_user_space(long len)
198{
199 struct pt_regs *regs = task_pt_regs(current);
200 return (void __user *)regs->sp - len;
201}
202
203static inline int is_compat_task(void)
204{
205 return current_thread_info()->status & TS_COMPAT;
206}
207
208extern int compat_setup_rt_frame(int sig, struct k_sigaction *ka,
209 siginfo_t *info, sigset_t *set,
210 struct pt_regs *regs);
211
212/* Compat syscalls. */
213struct compat_sigaction;
214struct compat_siginfo;
215struct compat_sigaltstack;
216long compat_sys_execve(const char __user *path,
217 compat_uptr_t __user *argv,
218 compat_uptr_t __user *envp, struct pt_regs *);
219long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act,
220 struct compat_sigaction __user *oact,
221 size_t sigsetsize);
222long compat_sys_rt_sigqueueinfo(int pid, int sig,
223 struct compat_siginfo __user *uinfo);
224long compat_sys_rt_sigreturn(struct pt_regs *);
225long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
226 struct compat_sigaltstack __user *uoss_ptr,
227 struct pt_regs *);
228long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high);
229long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high);
230long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count,
231 u32 dummy, u32 low, u32 high);
232long compat_sys_pwrite64(unsigned int fd, char __user *ubuf, size_t count,
233 u32 dummy, u32 low, u32 high);
234long compat_sys_lookup_dcookie(u32 low, u32 high, char __user *buf, size_t len);
235long compat_sys_sync_file_range2(int fd, unsigned int flags,
236 u32 offset_lo, u32 offset_hi,
237 u32 nbytes_lo, u32 nbytes_hi);
238long compat_sys_fallocate(int fd, int mode,
239 u32 offset_lo, u32 offset_hi,
240 u32 len_lo, u32 len_hi);
241long compat_sys_sched_rr_get_interval(compat_pid_t pid,
242 struct compat_timespec __user *interval);
243
244/* These are the intvec_64.S trampolines. */
245long _compat_sys_execve(const char __user *path,
246 const compat_uptr_t __user *argv,
247 const compat_uptr_t __user *envp);
248long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
249 struct compat_sigaltstack __user *uoss_ptr);
250long _compat_sys_rt_sigreturn(void);
251
252#endif /* _ASM_TILE_COMPAT_H */