Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_S390X_COMPAT_H
0003 #define _ASM_S390X_COMPAT_H
0004 /*
0005  * Architecture specific compatibility types
0006  */
0007 #include <linux/types.h>
0008 #include <linux/sched.h>
0009 #include <linux/sched/task_stack.h>
0010 #include <linux/thread_info.h>
0011 #include <asm/ptrace.h>
0012 
0013 #define compat_mode_t   compat_mode_t
0014 typedef u16     compat_mode_t;
0015 
0016 #define __compat_uid_t  __compat_uid_t
0017 typedef u16     __compat_uid_t;
0018 typedef u16     __compat_gid_t;
0019 
0020 #define compat_dev_t    compat_dev_t
0021 typedef u16     compat_dev_t;
0022 
0023 #define compat_ipc_pid_t compat_ipc_pid_t
0024 typedef u16      compat_ipc_pid_t;
0025 
0026 #define compat_statfs   compat_statfs
0027 
0028 #include <asm-generic/compat.h>
0029 
0030 #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p( \
0031                 typeof(0?(__force t)0:0ULL), u64))
0032 
0033 #define __SC_DELOUSE(t,v) ({ \
0034     BUILD_BUG_ON(sizeof(t) > 4 && !__TYPE_IS_PTR(t)); \
0035     (__force t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \
0036 })
0037 
0038 #define PSW32_MASK_USER     0x0000FF00UL
0039 
0040 #define PSW32_USER_BITS (PSW32_MASK_DAT | PSW32_MASK_IO | PSW32_MASK_EXT | \
0041              PSW32_DEFAULT_KEY | PSW32_MASK_BASE | \
0042              PSW32_MASK_MCHECK | PSW32_MASK_PSTATE | \
0043              PSW32_ASC_PRIMARY)
0044 
0045 #define COMPAT_UTS_MACHINE  "s390\0\0\0\0"
0046 
0047 typedef u16     compat_nlink_t;
0048 
0049 typedef struct {
0050     u32 mask;
0051     u32 addr;
0052 } __aligned(8) psw_compat_t;
0053 
0054 typedef struct {
0055     psw_compat_t psw;
0056     u32 gprs[NUM_GPRS];
0057     u32 acrs[NUM_ACRS];
0058     u32 orig_gpr2;
0059 } s390_compat_regs;
0060 
0061 typedef struct {
0062     u32 gprs_high[NUM_GPRS];
0063 } s390_compat_regs_high;
0064 
0065 struct compat_stat {
0066     compat_dev_t    st_dev;
0067     u16     __pad1;
0068     compat_ino_t    st_ino;
0069     compat_mode_t   st_mode;
0070     compat_nlink_t  st_nlink;
0071     __compat_uid_t  st_uid;
0072     __compat_gid_t  st_gid;
0073     compat_dev_t    st_rdev;
0074     u16     __pad2;
0075     u32     st_size;
0076     u32     st_blksize;
0077     u32     st_blocks;
0078     u32     st_atime;
0079     u32     st_atime_nsec;
0080     u32     st_mtime;
0081     u32     st_mtime_nsec;
0082     u32     st_ctime;
0083     u32     st_ctime_nsec;
0084     u32     __unused4;
0085     u32     __unused5;
0086 };
0087 
0088 struct compat_statfs {
0089     u32     f_type;
0090     u32     f_bsize;
0091     u32     f_blocks;
0092     u32     f_bfree;
0093     u32     f_bavail;
0094     u32     f_files;
0095     u32     f_ffree;
0096     compat_fsid_t   f_fsid;
0097     u32     f_namelen;
0098     u32     f_frsize;
0099     u32     f_flags;
0100     u32     f_spare[4];
0101 };
0102 
0103 struct compat_statfs64 {
0104     u32     f_type;
0105     u32     f_bsize;
0106     u64     f_blocks;
0107     u64     f_bfree;
0108     u64     f_bavail;
0109     u64     f_files;
0110     u64     f_ffree;
0111     compat_fsid_t   f_fsid;
0112     u32     f_namelen;
0113     u32     f_frsize;
0114     u32     f_flags;
0115     u32     f_spare[4];
0116 };
0117 
0118 /*
0119  * A pointer passed in from user mode. This should not
0120  * be used for syscall parameters, just declare them
0121  * as pointers because the syscall entry code will have
0122  * appropriately converted them already.
0123  */
0124 
0125 static inline void __user *compat_ptr(compat_uptr_t uptr)
0126 {
0127     return (void __user *)(unsigned long)(uptr & 0x7fffffffUL);
0128 }
0129 #define compat_ptr(uptr) compat_ptr(uptr)
0130 
0131 #ifdef CONFIG_COMPAT
0132 
0133 static inline int is_compat_task(void)
0134 {
0135     return test_thread_flag(TIF_31BIT);
0136 }
0137 
0138 #endif
0139 
0140 #endif /* _ASM_S390X_COMPAT_H */