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