1caab277bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 23dd681d9SWill Deacon /* 33dd681d9SWill Deacon * Copyright (C) 2012 ARM Ltd. 43dd681d9SWill Deacon */ 53dd681d9SWill Deacon #ifndef __ASM_COMPAT_H 63dd681d9SWill Deacon #define __ASM_COMPAT_H 7556d687aSArnd Bergmann 81a33b18bSArnd Bergmann #define compat_mode_t compat_mode_t 91a33b18bSArnd Bergmann typedef u16 compat_mode_t; 101a33b18bSArnd Bergmann 11*84a0c977SGuo Ren #define __compat_uid_t __compat_uid_t 12*84a0c977SGuo Ren typedef u16 __compat_uid_t; 13*84a0c977SGuo Ren typedef u16 __compat_gid_t; 14*84a0c977SGuo Ren 15*84a0c977SGuo Ren #define compat_ipc_pid_t compat_ipc_pid_t 16*84a0c977SGuo Ren typedef u16 compat_ipc_pid_t; 17*84a0c977SGuo Ren 18*84a0c977SGuo Ren #define compat_statfs compat_statfs 19*84a0c977SGuo Ren 20556d687aSArnd Bergmann #include <asm-generic/compat.h> 21556d687aSArnd Bergmann 223dd681d9SWill Deacon #ifdef CONFIG_COMPAT 233dd681d9SWill Deacon 243dd681d9SWill Deacon /* 253dd681d9SWill Deacon * Architecture specific compatibility types 263dd681d9SWill Deacon */ 273dd681d9SWill Deacon #include <linux/types.h> 283dd681d9SWill Deacon #include <linux/sched.h> 2968db0cf1SIngo Molnar #include <linux/sched/task_stack.h> 303dd681d9SWill Deacon 31a795a38eSWill Deacon #ifdef __AARCH64EB__ 32a795a38eSWill Deacon #define COMPAT_UTS_MACHINE "armv8b\0\0" 33a795a38eSWill Deacon #else 343dd681d9SWill Deacon #define COMPAT_UTS_MACHINE "armv8l\0\0" 35a795a38eSWill Deacon #endif 363dd681d9SWill Deacon 37f15a2a12SCatalin Marinas typedef u16 __compat_uid16_t; 38f15a2a12SCatalin Marinas typedef u16 __compat_gid16_t; 39f15a2a12SCatalin Marinas typedef s32 compat_nlink_t; 403dd681d9SWill Deacon 413dd681d9SWill Deacon struct compat_stat { 42a795a38eSWill Deacon #ifdef __AARCH64EB__ 43a795a38eSWill Deacon short st_dev; 44a795a38eSWill Deacon short __pad1; 45a795a38eSWill Deacon #else 463dd681d9SWill Deacon compat_dev_t st_dev; 47a795a38eSWill Deacon #endif 483dd681d9SWill Deacon compat_ino_t st_ino; 493dd681d9SWill Deacon compat_mode_t st_mode; 50f15a2a12SCatalin Marinas compat_ushort_t st_nlink; 51f15a2a12SCatalin Marinas __compat_uid16_t st_uid; 52f15a2a12SCatalin Marinas __compat_gid16_t st_gid; 53a795a38eSWill Deacon #ifdef __AARCH64EB__ 54a795a38eSWill Deacon short st_rdev; 55a795a38eSWill Deacon short __pad2; 56a795a38eSWill Deacon #else 573dd681d9SWill Deacon compat_dev_t st_rdev; 58a795a38eSWill Deacon #endif 593dd681d9SWill Deacon compat_off_t st_size; 603dd681d9SWill Deacon compat_off_t st_blksize; 613dd681d9SWill Deacon compat_off_t st_blocks; 629afc5eeeSArnd Bergmann old_time32_t st_atime; 63f15a2a12SCatalin Marinas compat_ulong_t st_atime_nsec; 649afc5eeeSArnd Bergmann old_time32_t st_mtime; 65f15a2a12SCatalin Marinas compat_ulong_t st_mtime_nsec; 669afc5eeeSArnd Bergmann old_time32_t st_ctime; 67f15a2a12SCatalin Marinas compat_ulong_t st_ctime_nsec; 68f15a2a12SCatalin Marinas compat_ulong_t __unused4[2]; 693dd681d9SWill Deacon }; 703dd681d9SWill Deacon 713dd681d9SWill Deacon struct compat_statfs { 723dd681d9SWill Deacon int f_type; 733dd681d9SWill Deacon int f_bsize; 743dd681d9SWill Deacon int f_blocks; 753dd681d9SWill Deacon int f_bfree; 763dd681d9SWill Deacon int f_bavail; 773dd681d9SWill Deacon int f_files; 783dd681d9SWill Deacon int f_ffree; 793dd681d9SWill Deacon compat_fsid_t f_fsid; 803dd681d9SWill Deacon int f_namelen; /* SunOS ignores this field. */ 813dd681d9SWill Deacon int f_frsize; 823dd681d9SWill Deacon int f_flags; 833dd681d9SWill Deacon int f_spare[4]; 843dd681d9SWill Deacon }; 853dd681d9SWill Deacon 86adc235afSArnd Bergmann #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current))) 8724951465SWill Deacon #define COMPAT_MINSIGSTKSZ 2048 889b064fc3SAl Viro is_compat_task(void)893dd681d9SWill Deaconstatic inline int is_compat_task(void) 903dd681d9SWill Deacon { 913dd681d9SWill Deacon return test_thread_flag(TIF_32BIT); 923dd681d9SWill Deacon } 933dd681d9SWill Deacon is_compat_thread(struct thread_info * thread)943dd681d9SWill Deaconstatic inline int is_compat_thread(struct thread_info *thread) 953dd681d9SWill Deacon { 963dd681d9SWill Deacon return test_ti_thread_flag(thread, TIF_32BIT); 973dd681d9SWill Deacon } 983dd681d9SWill Deacon 993dd681d9SWill Deacon long compat_arm_syscall(struct pt_regs *regs, int scno); 1003dd681d9SWill Deacon 1013dd681d9SWill Deacon #else /* !CONFIG_COMPAT */ 1023dd681d9SWill Deacon is_compat_thread(struct thread_info * thread)1033dd681d9SWill Deaconstatic inline int is_compat_thread(struct thread_info *thread) 1043dd681d9SWill Deacon { 1053dd681d9SWill Deacon return 0; 1063dd681d9SWill Deacon } 1073dd681d9SWill Deacon 108 #endif /* CONFIG_COMPAT */ 109 #endif /* __ASM_COMPAT_H */ 110