xref: /openbmc/linux/arch/arm64/include/asm/compat.h (revision e9b7b8b3)
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 #define compat_mode_t compat_mode_t
9 typedef u16		compat_mode_t;
10 
11 #define __compat_uid_t	__compat_uid_t
12 typedef u16		__compat_uid_t;
13 typedef u16		__compat_gid_t;
14 
15 #define compat_ipc_pid_t compat_ipc_pid_t
16 typedef u16		compat_ipc_pid_t;
17 
18 #define compat_statfs	compat_statfs
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 #ifdef __AARCH64EB__
32 #define COMPAT_UTS_MACHINE	"armv8b\0\0"
33 #else
34 #define COMPAT_UTS_MACHINE	"armv8l\0\0"
35 #endif
36 
37 typedef u16		__compat_uid16_t;
38 typedef u16		__compat_gid16_t;
39 typedef s32		compat_nlink_t;
40 
41 struct compat_stat {
42 #ifdef __AARCH64EB__
43 	short		st_dev;
44 	short		__pad1;
45 #else
46 	compat_dev_t	st_dev;
47 #endif
48 	compat_ino_t	st_ino;
49 	compat_mode_t	st_mode;
50 	compat_ushort_t	st_nlink;
51 	__compat_uid16_t	st_uid;
52 	__compat_gid16_t	st_gid;
53 #ifdef __AARCH64EB__
54 	short		st_rdev;
55 	short		__pad2;
56 #else
57 	compat_dev_t	st_rdev;
58 #endif
59 	compat_off_t	st_size;
60 	compat_off_t	st_blksize;
61 	compat_off_t	st_blocks;
62 	old_time32_t	st_atime;
63 	compat_ulong_t	st_atime_nsec;
64 	old_time32_t	st_mtime;
65 	compat_ulong_t	st_mtime_nsec;
66 	old_time32_t	st_ctime;
67 	compat_ulong_t	st_ctime_nsec;
68 	compat_ulong_t	__unused4[2];
69 };
70 
71 struct compat_statfs {
72 	int		f_type;
73 	int		f_bsize;
74 	int		f_blocks;
75 	int		f_bfree;
76 	int		f_bavail;
77 	int		f_files;
78 	int		f_ffree;
79 	compat_fsid_t	f_fsid;
80 	int		f_namelen;	/* SunOS ignores this field. */
81 	int		f_frsize;
82 	int		f_flags;
83 	int		f_spare[4];
84 };
85 
86 #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
87 #define COMPAT_MINSIGSTKSZ	2048
88 
89 static inline int is_compat_task(void)
90 {
91 	return test_thread_flag(TIF_32BIT);
92 }
93 
94 static inline int is_compat_thread(struct thread_info *thread)
95 {
96 	return test_ti_thread_flag(thread, TIF_32BIT);
97 }
98 
99 long compat_arm_syscall(struct pt_regs *regs, int scno);
100 
101 #else /* !CONFIG_COMPAT */
102 
103 static inline int is_compat_thread(struct thread_info *thread)
104 {
105 	return 0;
106 }
107 
108 #endif /* CONFIG_COMPAT */
109 #endif /* __ASM_COMPAT_H */
110