^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_SPARC64_COMPAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_SPARC64_COMPAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Architecture specific compatibility types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm-generic/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define COMPAT_USER_HZ 100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define COMPAT_UTS_MACHINE "sparc\0\0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) typedef u16 __compat_uid_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) typedef u16 __compat_gid_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) typedef u32 __compat_uid32_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) typedef u32 __compat_gid32_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) typedef u16 compat_mode_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) typedef u16 compat_dev_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) typedef s16 compat_nlink_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) typedef u16 compat_ipc_pid_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) typedef u32 compat_caddr_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) typedef __kernel_fsid_t compat_fsid_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct compat_stat {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) compat_dev_t st_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) compat_ino_t st_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) compat_mode_t st_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) compat_nlink_t st_nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) __compat_uid_t st_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) __compat_gid_t st_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) compat_dev_t st_rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) compat_off_t st_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) old_time32_t st_atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) compat_ulong_t st_atime_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) old_time32_t st_mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) compat_ulong_t st_mtime_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) old_time32_t st_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) compat_ulong_t st_ctime_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) compat_off_t st_blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) compat_off_t st_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) u32 __unused4[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct compat_stat64 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) unsigned long long st_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned long long st_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned int st_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) unsigned int st_nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) unsigned int st_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned int st_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) unsigned long long st_rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) unsigned char __pad3[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) long long st_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) unsigned int st_blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) unsigned char __pad4[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) unsigned int st_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) unsigned int st_atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) unsigned int st_atime_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) unsigned int st_mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) unsigned int st_mtime_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) unsigned int st_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) unsigned int st_ctime_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) unsigned int __unused4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) unsigned int __unused5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct compat_flock {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) short l_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) short l_whence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) compat_off_t l_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) compat_off_t l_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) compat_pid_t l_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) short __unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define F_GETLK64 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define F_SETLK64 13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define F_SETLKW64 14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct compat_flock64 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) short l_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) short l_whence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) compat_loff_t l_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) compat_loff_t l_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) compat_pid_t l_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) short __unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct compat_statfs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) int f_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) int f_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int f_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int f_bfree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int f_bavail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int f_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) int f_ffree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) compat_fsid_t f_fsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int f_namelen; /* SunOS ignores this field. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int f_frsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) int f_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int f_spare[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define COMPAT_RLIM_INFINITY 0x7fffffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) typedef u32 compat_old_sigset_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define _COMPAT_NSIG 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define _COMPAT_NSIG_BPW 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) typedef u32 compat_sigset_word;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define COMPAT_OFF_T_MAX 0x7fffffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static inline void __user *arch_compat_alloc_user_space(long len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct pt_regs *regs = current_thread_info()->kregs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) unsigned long usp = regs->u_regs[UREG_I6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (test_thread_64bit_stack(usp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) usp += STACK_BIAS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (test_thread_flag(TIF_32BIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) usp &= 0xffffffffUL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) usp -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) usp &= ~0x7UL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) return (void __user *) usp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct compat_ipc64_perm {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) compat_key_t key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) __compat_uid32_t uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) __compat_gid32_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) __compat_uid32_t cuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) __compat_gid32_t cgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) unsigned short __pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) compat_mode_t mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) unsigned short __pad2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) unsigned short seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) unsigned long __unused1; /* yes they really are 64bit pads */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) unsigned long __unused2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct compat_semid64_ds {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct compat_ipc64_perm sem_perm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) unsigned int sem_otime_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) unsigned int sem_otime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) unsigned int sem_ctime_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) unsigned int sem_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) u32 sem_nsems;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) u32 __unused1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) u32 __unused2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct compat_msqid64_ds {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct compat_ipc64_perm msg_perm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) unsigned int msg_stime_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) unsigned int msg_stime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) unsigned int msg_rtime_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) unsigned int msg_rtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) unsigned int msg_ctime_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) unsigned int msg_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) unsigned int msg_cbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) unsigned int msg_qnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) unsigned int msg_qbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) compat_pid_t msg_lspid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) compat_pid_t msg_lrpid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) unsigned int __unused1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) unsigned int __unused2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct compat_shmid64_ds {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) struct compat_ipc64_perm shm_perm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) unsigned int shm_atime_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) unsigned int shm_atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) unsigned int shm_dtime_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) unsigned int shm_dtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) unsigned int shm_ctime_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) unsigned int shm_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) compat_size_t shm_segsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) compat_pid_t shm_cpid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) compat_pid_t shm_lpid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) unsigned int shm_nattch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) unsigned int __unused1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) unsigned int __unused2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static inline int is_compat_task(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return test_thread_flag(TIF_32BIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static inline bool in_compat_syscall(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /* Vector 0x110 is LINUX_32BIT_SYSCALL_TRAP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return pt_regs_trap_type(current_pt_regs()) == 0x110;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #define in_compat_syscall in_compat_syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) #endif /* _ASM_SPARC64_COMPAT_H */