linux/arch/arm64/include/asm/compat.h
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2012 ARM Ltd.
   3 *
   4 * This program is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License version 2 as
   6 * published by the Free Software Foundation.
   7 *
   8 * This program is distributed in the hope that it will be useful,
   9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11 * GNU General Public License for more details.
  12 *
  13 * You should have received a copy of the GNU General Public License
  14 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  15 */
  16#ifndef __ASM_COMPAT_H
  17#define __ASM_COMPAT_H
  18#ifdef __KERNEL__
  19
  20#include <asm-generic/compat.h>
  21
  22#ifdef CONFIG_COMPAT
  23
  24/*
  25 * Architecture specific compatibility types
  26 */
  27#include <linux/types.h>
  28#include <linux/sched.h>
  29#include <linux/sched/task_stack.h>
  30
  31#define COMPAT_USER_HZ          100
  32#ifdef __AARCH64EB__
  33#define COMPAT_UTS_MACHINE      "armv8b\0\0"
  34#else
  35#define COMPAT_UTS_MACHINE      "armv8l\0\0"
  36#endif
  37
  38typedef u16             __compat_uid_t;
  39typedef u16             __compat_gid_t;
  40typedef u16             __compat_uid16_t;
  41typedef u16             __compat_gid16_t;
  42typedef u32             __compat_uid32_t;
  43typedef u32             __compat_gid32_t;
  44typedef u16             compat_mode_t;
  45typedef u32             compat_dev_t;
  46typedef s32             compat_nlink_t;
  47typedef u16             compat_ipc_pid_t;
  48typedef u32             compat_caddr_t;
  49typedef __kernel_fsid_t compat_fsid_t;
  50typedef s64             compat_s64;
  51typedef u64             compat_u64;
  52
  53struct compat_stat {
  54#ifdef __AARCH64EB__
  55        short           st_dev;
  56        short           __pad1;
  57#else
  58        compat_dev_t    st_dev;
  59#endif
  60        compat_ino_t    st_ino;
  61        compat_mode_t   st_mode;
  62        compat_ushort_t st_nlink;
  63        __compat_uid16_t        st_uid;
  64        __compat_gid16_t        st_gid;
  65#ifdef __AARCH64EB__
  66        short           st_rdev;
  67        short           __pad2;
  68#else
  69        compat_dev_t    st_rdev;
  70#endif
  71        compat_off_t    st_size;
  72        compat_off_t    st_blksize;
  73        compat_off_t    st_blocks;
  74        compat_time_t   st_atime;
  75        compat_ulong_t  st_atime_nsec;
  76        compat_time_t   st_mtime;
  77        compat_ulong_t  st_mtime_nsec;
  78        compat_time_t   st_ctime;
  79        compat_ulong_t  st_ctime_nsec;
  80        compat_ulong_t  __unused4[2];
  81};
  82
  83struct compat_flock {
  84        short           l_type;
  85        short           l_whence;
  86        compat_off_t    l_start;
  87        compat_off_t    l_len;
  88        compat_pid_t    l_pid;
  89};
  90
  91#define F_GETLK64       12      /*  using 'struct flock64' */
  92#define F_SETLK64       13
  93#define F_SETLKW64      14
  94
  95struct compat_flock64 {
  96        short           l_type;
  97        short           l_whence;
  98        compat_loff_t   l_start;
  99        compat_loff_t   l_len;
 100        compat_pid_t    l_pid;
 101};
 102
 103struct compat_statfs {
 104        int             f_type;
 105        int             f_bsize;
 106        int             f_blocks;
 107        int             f_bfree;
 108        int             f_bavail;
 109        int             f_files;
 110        int             f_ffree;
 111        compat_fsid_t   f_fsid;
 112        int             f_namelen;      /* SunOS ignores this field. */
 113        int             f_frsize;
 114        int             f_flags;
 115        int             f_spare[4];
 116};
 117
 118#define COMPAT_RLIM_INFINITY            0xffffffff
 119
 120typedef u32             compat_old_sigset_t;
 121
 122#define _COMPAT_NSIG            64
 123#define _COMPAT_NSIG_BPW        32
 124
 125typedef u32             compat_sigset_word;
 126
 127#define COMPAT_OFF_T_MAX        0x7fffffff
 128
 129#define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
 130
 131static inline void __user *arch_compat_alloc_user_space(long len)
 132{
 133        return (void __user *)compat_user_stack_pointer() - len;
 134}
 135
 136struct compat_ipc64_perm {
 137        compat_key_t key;
 138        __compat_uid32_t uid;
 139        __compat_gid32_t gid;
 140        __compat_uid32_t cuid;
 141        __compat_gid32_t cgid;
 142        unsigned short mode;
 143        unsigned short __pad1;
 144        unsigned short seq;
 145        unsigned short __pad2;
 146        compat_ulong_t unused1;
 147        compat_ulong_t unused2;
 148};
 149
 150struct compat_semid64_ds {
 151        struct compat_ipc64_perm sem_perm;
 152        compat_ulong_t sem_otime;
 153        compat_ulong_t sem_otime_high;
 154        compat_ulong_t sem_ctime;
 155        compat_ulong_t sem_ctime_high;
 156        compat_ulong_t sem_nsems;
 157        compat_ulong_t __unused3;
 158        compat_ulong_t __unused4;
 159};
 160
 161struct compat_msqid64_ds {
 162        struct compat_ipc64_perm msg_perm;
 163        compat_ulong_t msg_stime;
 164        compat_ulong_t msg_stime_high;
 165        compat_ulong_t msg_rtime;
 166        compat_ulong_t msg_rtime_high;
 167        compat_ulong_t msg_ctime;
 168        compat_ulong_t msg_ctime_high;
 169        compat_ulong_t msg_cbytes;
 170        compat_ulong_t msg_qnum;
 171        compat_ulong_t msg_qbytes;
 172        compat_pid_t   msg_lspid;
 173        compat_pid_t   msg_lrpid;
 174        compat_ulong_t __unused4;
 175        compat_ulong_t __unused5;
 176};
 177
 178struct compat_shmid64_ds {
 179        struct compat_ipc64_perm shm_perm;
 180        compat_size_t  shm_segsz;
 181        compat_ulong_t shm_atime;
 182        compat_ulong_t shm_atime_high;
 183        compat_ulong_t shm_dtime;
 184        compat_ulong_t shm_dtime_high;
 185        compat_ulong_t shm_ctime;
 186        compat_ulong_t shm_ctime_high;
 187        compat_pid_t   shm_cpid;
 188        compat_pid_t   shm_lpid;
 189        compat_ulong_t shm_nattch;
 190        compat_ulong_t __unused4;
 191        compat_ulong_t __unused5;
 192};
 193
 194static inline int is_compat_task(void)
 195{
 196        return test_thread_flag(TIF_32BIT);
 197}
 198
 199static inline int is_compat_thread(struct thread_info *thread)
 200{
 201        return test_ti_thread_flag(thread, TIF_32BIT);
 202}
 203
 204#else /* !CONFIG_COMPAT */
 205
 206static inline int is_compat_thread(struct thread_info *thread)
 207{
 208        return 0;
 209}
 210
 211#endif /* CONFIG_COMPAT */
 212#endif /* __KERNEL__ */
 213#endif /* __ASM_COMPAT_H */
 214