xref: /linux/arch/x86/include/asm/ia32.h (revision eb2f932100288dbb881eadfed02e1459c6b9504c)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_IA32_H
3 #define _ASM_X86_IA32_H
4 
5 #ifdef CONFIG_IA32_EMULATION
6 
7 #include <linux/compat.h>
8 
9 /*
10  * 32 bit structures for IA32 support.
11  */
12 
13 #include <uapi/asm/sigcontext.h>
14 
15 /* signal.h */
16 
17 struct ucontext_ia32 {
18 	unsigned int	  uc_flags;
19 	unsigned int 	  uc_link;
20 	compat_stack_t	  uc_stack;
21 	struct sigcontext_32 uc_mcontext;
22 	compat_sigset_t	  uc_sigmask;	/* mask last for extensibility */
23 };
24 
25 /* This matches struct stat64 in glibc2.2, hence the absolutely
26  * insane amounts of padding around dev_t's.
27  */
28 struct stat64 {
29 	unsigned long long	st_dev;
30 	unsigned char		__pad0[4];
31 
32 #define STAT64_HAS_BROKEN_ST_INO	1
33 	unsigned int		__st_ino;
34 
35 	unsigned int		st_mode;
36 	unsigned int		st_nlink;
37 
38 	unsigned int		st_uid;
39 	unsigned int		st_gid;
40 
41 	unsigned long long	st_rdev;
42 	unsigned char		__pad3[4];
43 
44 	long long		st_size;
45 	unsigned int		st_blksize;
46 
47 	long long		st_blocks;/* Number 512-byte blocks allocated */
48 
49 	unsigned 		st_atime;
50 	unsigned 		st_atime_nsec;
51 	unsigned 		st_mtime;
52 	unsigned 		st_mtime_nsec;
53 	unsigned 		st_ctime;
54 	unsigned 		st_ctime_nsec;
55 
56 	unsigned long long	st_ino;
57 } __attribute__((packed));
58 
59 #define IA32_STACK_TOP IA32_PAGE_OFFSET
60 
61 #ifdef __KERNEL__
62 struct linux_binprm;
63 extern int ia32_setup_arg_pages(struct linux_binprm *bprm,
64 				unsigned long stack_top, int exec_stack);
65 struct mm_struct;
66 extern void ia32_pick_mmap_layout(struct mm_struct *mm);
67 
68 #endif
69 
70 extern bool __ia32_enabled;
71 
72 static inline bool ia32_enabled(void)
73 {
74 	return __ia32_enabled;
75 }
76 
77 static inline void ia32_disable(void)
78 {
79 	__ia32_enabled = false;
80 }
81 
82 #else /* !CONFIG_IA32_EMULATION */
83 
84 static inline bool ia32_enabled(void)
85 {
86 	return IS_ENABLED(CONFIG_X86_32);
87 }
88 
89 static inline void ia32_disable(void) {}
90 
91 #endif
92 
93 static inline bool ia32_enabled_verbose(void)
94 {
95 	bool enabled = ia32_enabled();
96 
97 	if (IS_ENABLED(CONFIG_IA32_EMULATION) && !enabled)
98 		pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n");
99 
100 	return enabled;
101 }
102 
103 #endif /* _ASM_X86_IA32_H */
104