xref: /openbmc/linux/arch/parisc/include/asm/compat.h (revision 6d99a79c)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_PARISC_COMPAT_H
3 #define _ASM_PARISC_COMPAT_H
4 /*
5  * Architecture specific compatibility types
6  */
7 #include <linux/types.h>
8 #include <linux/sched.h>
9 #include <linux/thread_info.h>
10 
11 #include <asm-generic/compat.h>
12 
13 #define COMPAT_USER_HZ 		100
14 #define COMPAT_UTS_MACHINE	"parisc\0\0"
15 
16 typedef u32	__compat_uid_t;
17 typedef u32	__compat_gid_t;
18 typedef u32	__compat_uid32_t;
19 typedef u32	__compat_gid32_t;
20 typedef u16	compat_mode_t;
21 typedef u32	compat_dev_t;
22 typedef u16	compat_nlink_t;
23 typedef u16	compat_ipc_pid_t;
24 typedef u32	compat_caddr_t;
25 typedef s64	compat_s64;
26 typedef u64	compat_u64;
27 
28 struct compat_stat {
29 	compat_dev_t		st_dev;	/* dev_t is 32 bits on parisc */
30 	compat_ino_t		st_ino;	/* 32 bits */
31 	compat_mode_t		st_mode;	/* 16 bits */
32 	compat_nlink_t  	st_nlink;	/* 16 bits */
33 	u16			st_reserved1;	/* old st_uid */
34 	u16			st_reserved2;	/* old st_gid */
35 	compat_dev_t		st_rdev;
36 	compat_off_t		st_size;
37 	old_time32_t		st_atime;
38 	u32			st_atime_nsec;
39 	old_time32_t		st_mtime;
40 	u32			st_mtime_nsec;
41 	old_time32_t		st_ctime;
42 	u32			st_ctime_nsec;
43 	s32			st_blksize;
44 	s32			st_blocks;
45 	u32			__unused1;	/* ACL stuff */
46 	compat_dev_t		__unused2;	/* network */
47 	compat_ino_t		__unused3;	/* network */
48 	u32			__unused4;	/* cnodes */
49 	u16			__unused5;	/* netsite */
50 	short			st_fstype;
51 	compat_dev_t		st_realdev;
52 	u16			st_basemode;
53 	u16			st_spareshort;
54 	__compat_uid32_t	st_uid;
55 	__compat_gid32_t	st_gid;
56 	u32			st_spare4[3];
57 };
58 
59 struct compat_flock {
60 	short			l_type;
61 	short			l_whence;
62 	compat_off_t		l_start;
63 	compat_off_t		l_len;
64 	compat_pid_t		l_pid;
65 };
66 
67 struct compat_flock64 {
68 	short			l_type;
69 	short			l_whence;
70 	compat_loff_t		l_start;
71 	compat_loff_t		l_len;
72 	compat_pid_t		l_pid;
73 };
74 
75 struct compat_statfs {
76 	s32		f_type;
77 	s32		f_bsize;
78 	s32		f_blocks;
79 	s32		f_bfree;
80 	s32		f_bavail;
81 	s32		f_files;
82 	s32		f_ffree;
83 	__kernel_fsid_t	f_fsid;
84 	s32		f_namelen;
85 	s32		f_frsize;
86 	s32		f_flags;
87 	s32		f_spare[4];
88 };
89 
90 struct compat_sigcontext {
91 	compat_int_t sc_flags;
92 	compat_int_t sc_gr[32]; /* PSW in sc_gr[0] */
93 	u64 sc_fr[32];
94 	compat_int_t sc_iasq[2];
95 	compat_int_t sc_iaoq[2];
96 	compat_int_t sc_sar; /* cr11 */
97 };
98 
99 #define COMPAT_RLIM_INFINITY 0xffffffff
100 
101 typedef u32		compat_old_sigset_t;	/* at least 32 bits */
102 
103 #define _COMPAT_NSIG		64
104 #define _COMPAT_NSIG_BPW	32
105 
106 typedef u32		compat_sigset_word;
107 
108 #define COMPAT_OFF_T_MAX	0x7fffffff
109 
110 struct compat_ipc64_perm {
111 	compat_key_t key;
112 	__compat_uid_t uid;
113 	__compat_gid_t gid;
114 	__compat_uid_t cuid;
115 	__compat_gid_t cgid;
116 	unsigned short int __pad1;
117 	compat_mode_t mode;
118 	unsigned short int __pad2;
119 	unsigned short int seq;
120 	unsigned int __pad3;
121 	unsigned long __unused1;	/* yes they really are 64bit pads */
122 	unsigned long __unused2;
123 };
124 
125 struct compat_semid64_ds {
126 	struct compat_ipc64_perm sem_perm;
127 	unsigned int sem_otime_high;
128 	unsigned int sem_otime;
129 	unsigned int sem_ctime_high;
130 	unsigned int sem_ctime;
131 	compat_ulong_t sem_nsems;
132 	compat_ulong_t __unused3;
133 	compat_ulong_t __unused4;
134 };
135 
136 struct compat_msqid64_ds {
137 	struct compat_ipc64_perm msg_perm;
138 	unsigned int msg_stime_high;
139 	unsigned int msg_stime;
140 	unsigned int msg_rtime_high;
141 	unsigned int msg_rtime;
142 	unsigned int msg_ctime_high;
143 	unsigned int msg_ctime;
144 	compat_ulong_t msg_cbytes;
145 	compat_ulong_t msg_qnum;
146 	compat_ulong_t msg_qbytes;
147 	compat_pid_t msg_lspid;
148 	compat_pid_t msg_lrpid;
149 	compat_ulong_t __unused4;
150 	compat_ulong_t __unused5;
151 };
152 
153 struct compat_shmid64_ds {
154 	struct compat_ipc64_perm shm_perm;
155 	unsigned int shm_atime_high;
156 	unsigned int shm_atime;
157 	unsigned int shm_dtime_high;
158 	unsigned int shm_dtime;
159 	unsigned int shm_ctime_high;
160 	unsigned int shm_ctime;
161 	unsigned int __unused4;
162 	compat_size_t shm_segsz;
163 	compat_pid_t shm_cpid;
164 	compat_pid_t shm_lpid;
165 	compat_ulong_t shm_nattch;
166 	compat_ulong_t __unused5;
167 	compat_ulong_t __unused6;
168 };
169 
170 /*
171  * The type of struct elf_prstatus.pr_reg in compatible core dumps.
172  */
173 #define COMPAT_ELF_NGREG 80
174 typedef compat_ulong_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
175 
176 /*
177  * A pointer passed in from user mode. This should not
178  * be used for syscall parameters, just declare them
179  * as pointers because the syscall entry code will have
180  * appropriately converted them already.
181  */
182 
183 static inline void __user *compat_ptr(compat_uptr_t uptr)
184 {
185 	return (void __user *)(unsigned long)uptr;
186 }
187 
188 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
189 {
190 	return (u32)(unsigned long)uptr;
191 }
192 
193 static __inline__ void __user *arch_compat_alloc_user_space(long len)
194 {
195 	struct pt_regs *regs = &current->thread.regs;
196 	return (void __user *)regs->gr[30];
197 }
198 
199 static inline int __is_compat_task(struct task_struct *t)
200 {
201 	return test_ti_thread_flag(task_thread_info(t), TIF_32BIT);
202 }
203 
204 static inline int is_compat_task(void)
205 {
206 	return __is_compat_task(current);
207 }
208 
209 #endif /* _ASM_PARISC_COMPAT_H */
210