1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21965aae3SH. Peter Anvin #ifndef _ASM_X86_COMPAT_H 31965aae3SH. Peter Anvin #define _ASM_X86_COMPAT_H 4bb898558SAl Viro 5bb898558SAl Viro /* 6bb898558SAl Viro * Architecture specific compatibility types 7bb898558SAl Viro */ 8bb898558SAl Viro #include <linux/types.h> 9bb898558SAl Viro #include <linux/sched.h> 10d375cf15SAndy Lutomirski #include <linux/sched/task_stack.h> 11d1a797f3SH. Peter Anvin #include <asm/processor.h> 12bb898558SAl Viro #include <asm/user32.h> 13fca460f9SH. Peter Anvin #include <asm/unistd.h> 14bb898558SAl Viro 151a33b18bSArnd Bergmann #define compat_mode_t compat_mode_t 161a33b18bSArnd Bergmann typedef u16 compat_mode_t; 171a33b18bSArnd Bergmann 18*84a0c977SGuo Ren #define __compat_uid_t __compat_uid_t 19bb898558SAl Viro typedef u16 __compat_uid_t; 20bb898558SAl Viro typedef u16 __compat_gid_t; 21*84a0c977SGuo Ren 22*84a0c977SGuo Ren #define compat_dev_t compat_dev_t 23bb898558SAl Viro typedef u16 compat_dev_t; 24*84a0c977SGuo Ren 25*84a0c977SGuo Ren #define compat_ipc_pid_t compat_ipc_pid_t 26bb898558SAl Viro typedef u16 compat_ipc_pid_t; 27*84a0c977SGuo Ren 28*84a0c977SGuo Ren #define compat_statfs compat_statfs 29*84a0c977SGuo Ren 30*84a0c977SGuo Ren #include <asm-generic/compat.h> 31*84a0c977SGuo Ren 32*84a0c977SGuo Ren #define COMPAT_UTS_MACHINE "i686\0\0" 33*84a0c977SGuo Ren 34*84a0c977SGuo Ren typedef u16 compat_nlink_t; 35bb898558SAl Viro 36bb898558SAl Viro struct compat_stat { 37932aba1eSMikulas Patocka u32 st_dev; 38bb898558SAl Viro compat_ino_t st_ino; 39bb898558SAl Viro compat_mode_t st_mode; 40bb898558SAl Viro compat_nlink_t st_nlink; 41bb898558SAl Viro __compat_uid_t st_uid; 42bb898558SAl Viro __compat_gid_t st_gid; 43932aba1eSMikulas Patocka u32 st_rdev; 44bb898558SAl Viro u32 st_size; 45bb898558SAl Viro u32 st_blksize; 46bb898558SAl Viro u32 st_blocks; 47bb898558SAl Viro u32 st_atime; 48bb898558SAl Viro u32 st_atime_nsec; 49bb898558SAl Viro u32 st_mtime; 50bb898558SAl Viro u32 st_mtime_nsec; 51bb898558SAl Viro u32 st_ctime; 52bb898558SAl Viro u32 st_ctime_nsec; 53bb898558SAl Viro u32 __unused4; 54bb898558SAl Viro u32 __unused5; 55bb898558SAl Viro }; 56bb898558SAl Viro 57bb898558SAl Viro /* 583ce0f237SChristoph Hellwig * IA32 uses 4 byte alignment for 64 bit quantities, so we need to pack the 593ce0f237SChristoph Hellwig * compat flock64 structure. 60bb898558SAl Viro */ 613ce0f237SChristoph Hellwig #define __ARCH_NEED_COMPAT_FLOCK64_PACKED 62bb898558SAl Viro 63bb898558SAl Viro struct compat_statfs { 64bb898558SAl Viro int f_type; 65bb898558SAl Viro int f_bsize; 66bb898558SAl Viro int f_blocks; 67bb898558SAl Viro int f_bfree; 68bb898558SAl Viro int f_bavail; 69bb898558SAl Viro int f_files; 70bb898558SAl Viro int f_ffree; 71bb898558SAl Viro compat_fsid_t f_fsid; 72bb898558SAl Viro int f_namelen; /* SunOS ignores this field. */ 73bb898558SAl Viro int f_frsize; 741448c721SEric W. Biederman int f_flags; 751448c721SEric W. Biederman int f_spare[4]; 76bb898558SAl Viro }; 77bb898558SAl Viro 787b2dd368SDmitry Safonov #ifdef CONFIG_X86_X32_ABI 79d1a797f3SH. Peter Anvin #define COMPAT_USE_64BIT_TIME \ 80d1a797f3SH. Peter Anvin (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)) 81d1a797f3SH. Peter Anvin #endif 82bb898558SAl Viro in_x32_syscall(void)83abfb9498SDmitry Safonovstatic inline bool in_x32_syscall(void) 84a628b684SH. Peter Anvin { 85fca460f9SH. Peter Anvin #ifdef CONFIG_X86_X32_ABI 86fca460f9SH. Peter Anvin if (task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT) 87fca460f9SH. Peter Anvin return true; 88fca460f9SH. Peter Anvin #endif 89fca460f9SH. Peter Anvin return false; 90bb898558SAl Viro } 91bb898558SAl Viro in_32bit_syscall(void)92a846446bSDmitry Safonovstatic inline bool in_32bit_syscall(void) 93a628b684SH. Peter Anvin { 94abfb9498SDmitry Safonov return in_ia32_syscall() || in_x32_syscall(); 95a628b684SH. Peter Anvin } 96a846446bSDmitry Safonov 97a846446bSDmitry Safonov #ifdef CONFIG_COMPAT in_compat_syscall(void)98a846446bSDmitry Safonovstatic inline bool in_compat_syscall(void) 99a846446bSDmitry Safonov { 100a846446bSDmitry Safonov return in_32bit_syscall(); 101a846446bSDmitry Safonov } 102f970165bSAndy Lutomirski #define in_compat_syscall in_compat_syscall /* override the generic impl */ 103527c4125SChristoph Hellwig #define compat_need_64bit_alignment_fixup in_ia32_syscall 104a846446bSDmitry Safonov #endif 105a628b684SH. Peter Anvin 106ea64d5acSEric W. Biederman struct compat_siginfo; 107c3b3f524SChristoph Hellwig 108c3b3f524SChristoph Hellwig #ifdef CONFIG_X86_X32_ABI 109c3b3f524SChristoph Hellwig int copy_siginfo_to_user32(struct compat_siginfo __user *to, 110c3b3f524SChristoph Hellwig const kernel_siginfo_t *from); 111c3b3f524SChristoph Hellwig #define copy_siginfo_to_user32 copy_siginfo_to_user32 112c3b3f524SChristoph Hellwig #endif /* CONFIG_X86_X32_ABI */ 113ea64d5acSEric W. Biederman 1141965aae3SH. Peter Anvin #endif /* _ASM_X86_COMPAT_H */ 115