xref: /openbmc/linux/arch/mips/include/asm/compat.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2384740dcSRalf Baechle #ifndef _ASM_COMPAT_H
3384740dcSRalf Baechle #define _ASM_COMPAT_H
4384740dcSRalf Baechle /*
5384740dcSRalf Baechle  * Architecture specific compatibility types
6384740dcSRalf Baechle  */
74302e5d5SRalf Baechle #include <linux/thread_info.h>
8384740dcSRalf Baechle #include <linux/types.h>
9384740dcSRalf Baechle #include <asm/page.h>
10384740dcSRalf Baechle #include <asm/ptrace.h>
11384740dcSRalf Baechle 
12*84a0c977SGuo Ren #define __compat_uid_t	__compat_uid_t
131a33b18bSArnd Bergmann typedef s32		__compat_uid_t;
141a33b18bSArnd Bergmann typedef s32		__compat_gid_t;
15*84a0c977SGuo Ren 
161a33b18bSArnd Bergmann typedef __compat_uid_t	__compat_uid32_t;
171a33b18bSArnd Bergmann typedef __compat_gid_t	__compat_gid32_t;
181a33b18bSArnd Bergmann #define __compat_uid32_t __compat_uid32_t
19*84a0c977SGuo Ren 
20*84a0c977SGuo Ren #define compat_statfs		compat_statfs
21*84a0c977SGuo Ren #define compat_ipc64_perm	compat_ipc64_perm
221a33b18bSArnd Bergmann 
231a33b18bSArnd Bergmann #define _COMPAT_NSIG		128		/* Don't ask !$@#% ...	*/
241a33b18bSArnd Bergmann #define _COMPAT_NSIG_BPW	32
251a33b18bSArnd Bergmann typedef u32		compat_sigset_word;
261a33b18bSArnd Bergmann 
27*84a0c977SGuo Ren #define COMPAT_RLIM_INFINITY	0x7fffffffUL
28*84a0c977SGuo Ren 
29fb373975SArnd Bergmann #include <asm-generic/compat.h>
30fb373975SArnd Bergmann 
31e28cbf22SChristoph Hellwig #define COMPAT_UTS_MACHINE	"mips\0\0\0"
32384740dcSRalf Baechle 
33384740dcSRalf Baechle typedef u32		compat_nlink_t;
34384740dcSRalf Baechle 
35384740dcSRalf Baechle struct compat_stat {
36384740dcSRalf Baechle 	compat_dev_t	st_dev;
37384740dcSRalf Baechle 	s32		st_pad1[3];
38384740dcSRalf Baechle 	compat_ino_t	st_ino;
39384740dcSRalf Baechle 	compat_mode_t	st_mode;
40384740dcSRalf Baechle 	compat_nlink_t	st_nlink;
41384740dcSRalf Baechle 	__compat_uid_t	st_uid;
42384740dcSRalf Baechle 	__compat_gid_t	st_gid;
43384740dcSRalf Baechle 	compat_dev_t	st_rdev;
44384740dcSRalf Baechle 	s32		st_pad2[2];
45384740dcSRalf Baechle 	compat_off_t	st_size;
46384740dcSRalf Baechle 	s32		st_pad3;
479afc5eeeSArnd Bergmann 	old_time32_t	st_atime;
48384740dcSRalf Baechle 	s32		st_atime_nsec;
499afc5eeeSArnd Bergmann 	old_time32_t	st_mtime;
50384740dcSRalf Baechle 	s32		st_mtime_nsec;
519afc5eeeSArnd Bergmann 	old_time32_t	st_ctime;
52384740dcSRalf Baechle 	s32		st_ctime_nsec;
53384740dcSRalf Baechle 	s32		st_blksize;
54384740dcSRalf Baechle 	s32		st_blocks;
55384740dcSRalf Baechle 	s32		st_pad4[14];
56384740dcSRalf Baechle };
57384740dcSRalf Baechle 
583ce0f237SChristoph Hellwig #define __ARCH_COMPAT_FLOCK_EXTRA_SYSID		s32 l_sysid;
593ce0f237SChristoph Hellwig #define __ARCH_COMPAT_FLOCK_PAD			s32 pad[4];
60384740dcSRalf Baechle 
61384740dcSRalf Baechle struct compat_statfs {
62384740dcSRalf Baechle 	int		f_type;
63384740dcSRalf Baechle 	int		f_bsize;
64384740dcSRalf Baechle 	int		f_frsize;
65384740dcSRalf Baechle 	int		f_blocks;
66384740dcSRalf Baechle 	int		f_bfree;
67384740dcSRalf Baechle 	int		f_files;
68384740dcSRalf Baechle 	int		f_ffree;
69384740dcSRalf Baechle 	int		f_bavail;
70384740dcSRalf Baechle 	compat_fsid_t	f_fsid;
71384740dcSRalf Baechle 	int		f_namelen;
721448c721SEric W. Biederman 	int		f_flags;
731448c721SEric W. Biederman 	int		f_spare[5];
74384740dcSRalf Baechle };
75384740dcSRalf Baechle 
76384740dcSRalf Baechle struct compat_ipc64_perm {
77384740dcSRalf Baechle 	compat_key_t key;
78384740dcSRalf Baechle 	__compat_uid32_t uid;
79384740dcSRalf Baechle 	__compat_gid32_t gid;
80384740dcSRalf Baechle 	__compat_uid32_t cuid;
81384740dcSRalf Baechle 	__compat_gid32_t cgid;
82384740dcSRalf Baechle 	compat_mode_t mode;
83384740dcSRalf Baechle 	unsigned short seq;
84384740dcSRalf Baechle 	unsigned short __pad2;
85384740dcSRalf Baechle 	compat_ulong_t __unused1;
86384740dcSRalf Baechle 	compat_ulong_t __unused2;
87384740dcSRalf Baechle };
88384740dcSRalf Baechle 
89384740dcSRalf Baechle struct compat_semid64_ds {
90384740dcSRalf Baechle 	struct compat_ipc64_perm sem_perm;
913f3a4b3fSArnd Bergmann 	compat_ulong_t	sem_otime;
923f3a4b3fSArnd Bergmann 	compat_ulong_t	sem_ctime;
93384740dcSRalf Baechle 	compat_ulong_t	sem_nsems;
943f3a4b3fSArnd Bergmann 	compat_ulong_t	sem_otime_high;
953f3a4b3fSArnd Bergmann 	compat_ulong_t	sem_ctime_high;
96384740dcSRalf Baechle };
97384740dcSRalf Baechle 
98384740dcSRalf Baechle struct compat_msqid64_ds {
99384740dcSRalf Baechle 	struct compat_ipc64_perm msg_perm;
100384740dcSRalf Baechle #ifndef CONFIG_CPU_LITTLE_ENDIAN
1013f3a4b3fSArnd Bergmann 	compat_ulong_t	msg_stime_high;
102384740dcSRalf Baechle #endif
1033f3a4b3fSArnd Bergmann 	compat_ulong_t	msg_stime;
104384740dcSRalf Baechle #ifdef CONFIG_CPU_LITTLE_ENDIAN
1053f3a4b3fSArnd Bergmann 	compat_ulong_t	msg_stime_high;
106384740dcSRalf Baechle #endif
107384740dcSRalf Baechle #ifndef CONFIG_CPU_LITTLE_ENDIAN
1083f3a4b3fSArnd Bergmann 	compat_ulong_t	msg_rtime_high;
109384740dcSRalf Baechle #endif
1103f3a4b3fSArnd Bergmann 	compat_ulong_t	msg_rtime;
111384740dcSRalf Baechle #ifdef CONFIG_CPU_LITTLE_ENDIAN
1123f3a4b3fSArnd Bergmann 	compat_ulong_t	msg_rtime_high;
113384740dcSRalf Baechle #endif
114384740dcSRalf Baechle #ifndef CONFIG_CPU_LITTLE_ENDIAN
1153f3a4b3fSArnd Bergmann 	compat_ulong_t	msg_ctime_high;
116384740dcSRalf Baechle #endif
1173f3a4b3fSArnd Bergmann 	compat_ulong_t	msg_ctime;
118384740dcSRalf Baechle #ifdef CONFIG_CPU_LITTLE_ENDIAN
1193f3a4b3fSArnd Bergmann 	compat_ulong_t	msg_ctime_high;
120384740dcSRalf Baechle #endif
121384740dcSRalf Baechle 	compat_ulong_t	msg_cbytes;
122384740dcSRalf Baechle 	compat_ulong_t	msg_qnum;
123384740dcSRalf Baechle 	compat_ulong_t	msg_qbytes;
124384740dcSRalf Baechle 	compat_pid_t	msg_lspid;
125384740dcSRalf Baechle 	compat_pid_t	msg_lrpid;
126384740dcSRalf Baechle 	compat_ulong_t	__unused4;
127384740dcSRalf Baechle 	compat_ulong_t	__unused5;
128384740dcSRalf Baechle };
129384740dcSRalf Baechle 
130384740dcSRalf Baechle struct compat_shmid64_ds {
131384740dcSRalf Baechle 	struct compat_ipc64_perm shm_perm;
132384740dcSRalf Baechle 	compat_size_t	shm_segsz;
1333f3a4b3fSArnd Bergmann 	compat_ulong_t	shm_atime;
1343f3a4b3fSArnd Bergmann 	compat_ulong_t	shm_dtime;
1353f3a4b3fSArnd Bergmann 	compat_ulong_t	shm_ctime;
136384740dcSRalf Baechle 	compat_pid_t	shm_cpid;
137384740dcSRalf Baechle 	compat_pid_t	shm_lpid;
138384740dcSRalf Baechle 	compat_ulong_t	shm_nattch;
1393f3a4b3fSArnd Bergmann 	compat_ushort_t	shm_atime_high;
1403f3a4b3fSArnd Bergmann 	compat_ushort_t	shm_dtime_high;
1413f3a4b3fSArnd Bergmann 	compat_ushort_t	shm_ctime_high;
1423f3a4b3fSArnd Bergmann 	compat_ushort_t	__unused2;
143384740dcSRalf Baechle };
144384740dcSRalf Baechle 
145ea536ad4SAl Viro /* MIPS has unusual order of fields in stack_t */
146ea536ad4SAl Viro typedef struct compat_sigaltstack {
147ea536ad4SAl Viro 	compat_uptr_t			ss_sp;
148ea536ad4SAl Viro 	compat_size_t			ss_size;
149ea536ad4SAl Viro 	int				ss_flags;
150ea536ad4SAl Viro } compat_stack_t;
151ea536ad4SAl Viro #define compat_sigaltstack compat_sigaltstack
152ea536ad4SAl Viro 
is_compat_task(void)1534302e5d5SRalf Baechle static inline int is_compat_task(void)
1544302e5d5SRalf Baechle {
1556ad560b4SRalf Baechle 	return test_thread_flag(TIF_32BIT_ADDR);
1564302e5d5SRalf Baechle }
1574302e5d5SRalf Baechle 
158384740dcSRalf Baechle #endif /* _ASM_COMPAT_H */
159