Thomas Gleixner | caab277 | 2019-06-03 07:44:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2012 ARM Ltd. |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 4 | */ |
| 5 | #ifndef __ASM_COMPAT_H |
| 6 | #define __ASM_COMPAT_H |
Arnd Bergmann | 556d687 | 2019-12-09 16:16:20 +0100 | [diff] [blame] | 7 | |
Arnd Bergmann | 1a33b18 | 2021-07-22 16:28:58 +0200 | [diff] [blame] | 8 | #define compat_mode_t compat_mode_t |
| 9 | typedef u16 compat_mode_t; |
| 10 | |
Arnd Bergmann | 556d687 | 2019-12-09 16:16:20 +0100 | [diff] [blame] | 11 | #include <asm-generic/compat.h> |
| 12 | |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 13 | #ifdef CONFIG_COMPAT |
| 14 | |
| 15 | /* |
| 16 | * Architecture specific compatibility types |
| 17 | */ |
| 18 | #include <linux/types.h> |
| 19 | #include <linux/sched.h> |
Ingo Molnar | 68db0cf | 2017-02-08 18:51:37 +0100 | [diff] [blame] | 20 | #include <linux/sched/task_stack.h> |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 21 | |
| 22 | #define COMPAT_USER_HZ 100 |
Will Deacon | a795a38 | 2013-10-11 14:52:12 +0100 | [diff] [blame] | 23 | #ifdef __AARCH64EB__ |
| 24 | #define COMPAT_UTS_MACHINE "armv8b\0\0" |
| 25 | #else |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 26 | #define COMPAT_UTS_MACHINE "armv8l\0\0" |
Will Deacon | a795a38 | 2013-10-11 14:52:12 +0100 | [diff] [blame] | 27 | #endif |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 28 | |
Victor Kamensky | 971a5b6 | 2014-10-14 06:55:05 +0100 | [diff] [blame] | 29 | typedef u16 __compat_uid_t; |
| 30 | typedef u16 __compat_gid_t; |
Catalin Marinas | f15a2a1 | 2013-04-25 11:23:41 +0100 | [diff] [blame] | 31 | typedef u16 __compat_uid16_t; |
| 32 | typedef u16 __compat_gid16_t; |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 33 | typedef u32 compat_dev_t; |
Catalin Marinas | f15a2a1 | 2013-04-25 11:23:41 +0100 | [diff] [blame] | 34 | typedef s32 compat_nlink_t; |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 35 | typedef u16 compat_ipc_pid_t; |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 36 | typedef __kernel_fsid_t compat_fsid_t; |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 37 | |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 38 | struct compat_stat { |
Will Deacon | a795a38 | 2013-10-11 14:52:12 +0100 | [diff] [blame] | 39 | #ifdef __AARCH64EB__ |
| 40 | short st_dev; |
| 41 | short __pad1; |
| 42 | #else |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 43 | compat_dev_t st_dev; |
Will Deacon | a795a38 | 2013-10-11 14:52:12 +0100 | [diff] [blame] | 44 | #endif |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 45 | compat_ino_t st_ino; |
| 46 | compat_mode_t st_mode; |
Catalin Marinas | f15a2a1 | 2013-04-25 11:23:41 +0100 | [diff] [blame] | 47 | compat_ushort_t st_nlink; |
| 48 | __compat_uid16_t st_uid; |
| 49 | __compat_gid16_t st_gid; |
Will Deacon | a795a38 | 2013-10-11 14:52:12 +0100 | [diff] [blame] | 50 | #ifdef __AARCH64EB__ |
| 51 | short st_rdev; |
| 52 | short __pad2; |
| 53 | #else |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 54 | compat_dev_t st_rdev; |
Will Deacon | a795a38 | 2013-10-11 14:52:12 +0100 | [diff] [blame] | 55 | #endif |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 56 | compat_off_t st_size; |
| 57 | compat_off_t st_blksize; |
| 58 | compat_off_t st_blocks; |
Arnd Bergmann | 9afc5ee | 2018-07-13 12:52:28 +0200 | [diff] [blame] | 59 | old_time32_t st_atime; |
Catalin Marinas | f15a2a1 | 2013-04-25 11:23:41 +0100 | [diff] [blame] | 60 | compat_ulong_t st_atime_nsec; |
Arnd Bergmann | 9afc5ee | 2018-07-13 12:52:28 +0200 | [diff] [blame] | 61 | old_time32_t st_mtime; |
Catalin Marinas | f15a2a1 | 2013-04-25 11:23:41 +0100 | [diff] [blame] | 62 | compat_ulong_t st_mtime_nsec; |
Arnd Bergmann | 9afc5ee | 2018-07-13 12:52:28 +0200 | [diff] [blame] | 63 | old_time32_t st_ctime; |
Catalin Marinas | f15a2a1 | 2013-04-25 11:23:41 +0100 | [diff] [blame] | 64 | compat_ulong_t st_ctime_nsec; |
| 65 | compat_ulong_t __unused4[2]; |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | struct compat_flock { |
| 69 | short l_type; |
| 70 | short l_whence; |
| 71 | compat_off_t l_start; |
| 72 | compat_off_t l_len; |
| 73 | compat_pid_t l_pid; |
| 74 | }; |
| 75 | |
| 76 | #define F_GETLK64 12 /* using 'struct flock64' */ |
| 77 | #define F_SETLK64 13 |
| 78 | #define F_SETLKW64 14 |
| 79 | |
| 80 | struct compat_flock64 { |
| 81 | short l_type; |
| 82 | short l_whence; |
| 83 | compat_loff_t l_start; |
| 84 | compat_loff_t l_len; |
| 85 | compat_pid_t l_pid; |
| 86 | }; |
| 87 | |
| 88 | struct compat_statfs { |
| 89 | int f_type; |
| 90 | int f_bsize; |
| 91 | int f_blocks; |
| 92 | int f_bfree; |
| 93 | int f_bavail; |
| 94 | int f_files; |
| 95 | int f_ffree; |
| 96 | compat_fsid_t f_fsid; |
| 97 | int f_namelen; /* SunOS ignores this field. */ |
| 98 | int f_frsize; |
| 99 | int f_flags; |
| 100 | int f_spare[4]; |
| 101 | }; |
| 102 | |
| 103 | #define COMPAT_RLIM_INFINITY 0xffffffff |
| 104 | |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 105 | #define COMPAT_OFF_T_MAX 0x7fffffff |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 106 | |
Arnd Bergmann | adc235a | 2015-11-16 17:32:15 +0100 | [diff] [blame] | 107 | #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current))) |
Will Deacon | 2495146 | 2018-09-05 15:34:43 +0100 | [diff] [blame] | 108 | #define COMPAT_MINSIGSTKSZ 2048 |
Al Viro | 9b064fc | 2012-12-14 13:49:35 -0500 | [diff] [blame] | 109 | |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 110 | struct compat_ipc64_perm { |
| 111 | compat_key_t key; |
| 112 | __compat_uid32_t uid; |
| 113 | __compat_gid32_t gid; |
| 114 | __compat_uid32_t cuid; |
| 115 | __compat_gid32_t cgid; |
| 116 | unsigned short mode; |
| 117 | unsigned short __pad1; |
| 118 | unsigned short seq; |
| 119 | unsigned short __pad2; |
| 120 | compat_ulong_t unused1; |
| 121 | compat_ulong_t unused2; |
| 122 | }; |
| 123 | |
| 124 | struct compat_semid64_ds { |
| 125 | struct compat_ipc64_perm sem_perm; |
Arnd Bergmann | 83335eb | 2018-04-12 12:34:16 +0200 | [diff] [blame] | 126 | compat_ulong_t sem_otime; |
| 127 | compat_ulong_t sem_otime_high; |
| 128 | compat_ulong_t sem_ctime; |
| 129 | compat_ulong_t sem_ctime_high; |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 130 | compat_ulong_t sem_nsems; |
| 131 | compat_ulong_t __unused3; |
| 132 | compat_ulong_t __unused4; |
| 133 | }; |
| 134 | |
| 135 | struct compat_msqid64_ds { |
| 136 | struct compat_ipc64_perm msg_perm; |
Arnd Bergmann | 83335eb | 2018-04-12 12:34:16 +0200 | [diff] [blame] | 137 | compat_ulong_t msg_stime; |
| 138 | compat_ulong_t msg_stime_high; |
| 139 | compat_ulong_t msg_rtime; |
| 140 | compat_ulong_t msg_rtime_high; |
| 141 | compat_ulong_t msg_ctime; |
| 142 | compat_ulong_t msg_ctime_high; |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 143 | compat_ulong_t msg_cbytes; |
| 144 | compat_ulong_t msg_qnum; |
| 145 | compat_ulong_t msg_qbytes; |
| 146 | compat_pid_t msg_lspid; |
| 147 | compat_pid_t msg_lrpid; |
| 148 | compat_ulong_t __unused4; |
| 149 | compat_ulong_t __unused5; |
| 150 | }; |
| 151 | |
| 152 | struct compat_shmid64_ds { |
| 153 | struct compat_ipc64_perm shm_perm; |
| 154 | compat_size_t shm_segsz; |
Arnd Bergmann | 83335eb | 2018-04-12 12:34:16 +0200 | [diff] [blame] | 155 | compat_ulong_t shm_atime; |
| 156 | compat_ulong_t shm_atime_high; |
| 157 | compat_ulong_t shm_dtime; |
| 158 | compat_ulong_t shm_dtime_high; |
| 159 | compat_ulong_t shm_ctime; |
| 160 | compat_ulong_t shm_ctime_high; |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 161 | compat_pid_t shm_cpid; |
| 162 | compat_pid_t shm_lpid; |
| 163 | compat_ulong_t shm_nattch; |
| 164 | compat_ulong_t __unused4; |
| 165 | compat_ulong_t __unused5; |
| 166 | }; |
| 167 | |
| 168 | static inline int is_compat_task(void) |
| 169 | { |
| 170 | return test_thread_flag(TIF_32BIT); |
| 171 | } |
| 172 | |
| 173 | static inline int is_compat_thread(struct thread_info *thread) |
| 174 | { |
| 175 | return test_ti_thread_flag(thread, TIF_32BIT); |
| 176 | } |
| 177 | |
| 178 | #else /* !CONFIG_COMPAT */ |
| 179 | |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 180 | static inline int is_compat_thread(struct thread_info *thread) |
| 181 | { |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | #endif /* CONFIG_COMPAT */ |
Will Deacon | 3dd681d | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 186 | #endif /* __ASM_COMPAT_H */ |