aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/ia32/Makefile3
-rw-r--r--arch/x86/vdso/vdso32-setup.c33
-rw-r--r--include/asm-x86/elf.h88
4 files changed, 99 insertions, 26 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1992b8fe6a2f..d89b94528153 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1532,6 +1532,7 @@ source "fs/Kconfig.binfmt"
1532config IA32_EMULATION 1532config IA32_EMULATION
1533 bool "IA32 Emulation" 1533 bool "IA32 Emulation"
1534 depends on X86_64 1534 depends on X86_64
1535 select COMPAT_BINFMT_ELF
1535 help 1536 help
1536 Include code to run 32-bit programs under a 64-bit kernel. You should 1537 Include code to run 32-bit programs under a 64-bit kernel. You should
1537 likely turn this on, unless you're 100% sure that you don't have any 1538 likely turn this on, unless you're 100% sure that you don't have any
diff --git a/arch/x86/ia32/Makefile b/arch/x86/ia32/Makefile
index 93a6fda65f49..52d0ccfcf6ea 100644
--- a/arch/x86/ia32/Makefile
+++ b/arch/x86/ia32/Makefile
@@ -2,8 +2,7 @@
2# Makefile for the ia32 kernel emulation subsystem. 2# Makefile for the ia32 kernel emulation subsystem.
3# 3#
4 4
5obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o \ 5obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o
6 ia32_binfmt.o
7 6
8sysv-$(CONFIG_SYSVIPC) := ipc32.o 7sysv-$(CONFIG_SYSVIPC) := ipc32.o
9obj-$(CONFIG_IA32_EMULATION) += $(sysv-y) 8obj-$(CONFIG_IA32_EMULATION) += $(sysv-y)
diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
index e0feb66a2408..348f1341e1c8 100644
--- a/arch/x86/vdso/vdso32-setup.c
+++ b/arch/x86/vdso/vdso32-setup.c
@@ -377,6 +377,39 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
377 377
378__initcall(sysenter_setup); 378__initcall(sysenter_setup);
379 379
380#ifdef CONFIG_SYSCTL
381/* Register vsyscall32 into the ABI table */
382#include <linux/sysctl.h>
383
384static ctl_table abi_table2[] = {
385 {
386 .procname = "vsyscall32",
387 .data = &sysctl_vsyscall32,
388 .maxlen = sizeof(int),
389 .mode = 0644,
390 .proc_handler = proc_dointvec
391 },
392 {}
393};
394
395static ctl_table abi_root_table2[] = {
396 {
397 .ctl_name = CTL_ABI,
398 .procname = "abi",
399 .mode = 0555,
400 .child = abi_table2
401 },
402 {}
403};
404
405static __init int ia32_binfmt_init(void)
406{
407 register_sysctl_table(abi_root_table2);
408 return 0;
409}
410__initcall(ia32_binfmt_init);
411#endif
412
380#else /* CONFIG_X86_32 */ 413#else /* CONFIG_X86_32 */
381 414
382const char *arch_vma_name(struct vm_area_struct *vma) 415const char *arch_vma_name(struct vm_area_struct *vma)
diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h
index d6bf7421d7b0..dab4744f9586 100644
--- a/include/asm-x86/elf.h
+++ b/include/asm-x86/elf.h
@@ -73,6 +73,9 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
73#endif 73#endif
74 74
75#ifdef __KERNEL__ 75#ifdef __KERNEL__
76#include <asm/vdso.h>
77
78extern unsigned int vdso_enabled;
76 79
77/* 80/*
78 * This is used to ensure we don't load something for the wrong architecture. 81 * This is used to ensure we don't load something for the wrong architecture.
@@ -84,7 +87,6 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
84#include <asm/processor.h> 87#include <asm/processor.h>
85#include <asm/system.h> /* for savesegment */ 88#include <asm/system.h> /* for savesegment */
86#include <asm/desc.h> 89#include <asm/desc.h>
87#include <asm/vdso.h>
88 90
89#define elf_check_arch(x) elf_check_arch_ia32(x) 91#define elf_check_arch(x) elf_check_arch_ia32(x)
90 92
@@ -106,7 +108,6 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
106 108
107#define ELF_PLATFORM (utsname()->machine) 109#define ELF_PLATFORM (utsname()->machine)
108#define set_personality_64bit() do { } while (0) 110#define set_personality_64bit() do { } while (0)
109extern unsigned int vdso_enabled;
110 111
111#else /* CONFIG_X86_32 */ 112#else /* CONFIG_X86_32 */
112 113
@@ -118,29 +119,57 @@ extern unsigned int vdso_enabled;
118#define elf_check_arch(x) \ 119#define elf_check_arch(x) \
119 ((x)->e_machine == EM_X86_64) 120 ((x)->e_machine == EM_X86_64)
120 121
122#define compat_elf_check_arch(x) elf_check_arch_ia32(x)
123
124static inline void start_ia32_thread(struct pt_regs *regs, u32 ip, u32 sp)
125{
126 asm volatile("movl %0,%%fs" :: "r" (0));
127 asm volatile("movl %0,%%es; movl %0,%%ds" : : "r" (__USER32_DS));
128 load_gs_index(0);
129 regs->ip = ip;
130 regs->sp = sp;
131 regs->flags = X86_EFLAGS_IF;
132 regs->cs = __USER32_CS;
133 regs->ss = __USER32_DS;
134}
135
136static inline void elf_common_init(struct thread_struct *t,
137 struct pt_regs *regs, const u16 ds)
138{
139 regs->ax = regs->bx = regs->cx = regs->dx = 0;
140 regs->si = regs->di = regs->bp = 0;
141 regs->r8 = regs->r9 = regs->r10 = regs->r11 = 0;
142 regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0;
143 t->fs = t->gs = 0;
144 t->fsindex = t->gsindex = 0;
145 t->ds = t->es = ds;
146}
147
121#define ELF_PLAT_INIT(_r, load_addr) do { \ 148#define ELF_PLAT_INIT(_r, load_addr) do { \
122 struct task_struct *cur = current; \ 149 elf_common_init(&current->thread, _r, 0); \
123 (_r)->bx = 0; (_r)->cx = 0; (_r)->dx = 0; \
124 (_r)->si = 0; (_r)->di = 0; (_r)->bp = 0; \
125 (_r)->ax = 0; \
126 (_r)->r8 = 0; \
127 (_r)->r9 = 0; \
128 (_r)->r10 = 0; \
129 (_r)->r11 = 0; \
130 (_r)->r12 = 0; \
131 (_r)->r13 = 0; \
132 (_r)->r14 = 0; \
133 (_r)->r15 = 0; \
134 cur->thread.fs = 0; cur->thread.gs = 0; \
135 cur->thread.fsindex = 0; cur->thread.gsindex = 0; \
136 cur->thread.ds = 0; cur->thread.es = 0; \
137 clear_thread_flag(TIF_IA32); \ 150 clear_thread_flag(TIF_IA32); \
138} while (0) 151} while (0)
139 152
153#define COMPAT_ELF_PLAT_INIT(regs, load_addr) \
154 elf_common_init(&current->thread, regs, __USER_DS)
155#define compat_start_thread(regs, ip, sp) do { \
156 start_ia32_thread(regs, ip, sp); \
157 set_fs(USER_DS); \
158 } while (0)
159#define COMPAT_SET_PERSONALITY(ex, ibcs2) do { \
160 if (test_thread_flag(TIF_IA32)) \
161 clear_thread_flag(TIF_ABI_PENDING); \
162 else \
163 set_thread_flag(TIF_ABI_PENDING); \
164 current->personality |= force_personality32; \
165 } while (0)
166#define COMPAT_ELF_PLATFORM ("i686")
167
140/* I'm not sure if we can use '-' here */ 168/* I'm not sure if we can use '-' here */
141#define ELF_PLATFORM ("x86_64") 169#define ELF_PLATFORM ("x86_64")
142extern void set_personality_64bit(void); 170extern void set_personality_64bit(void);
143extern int vdso_enabled; 171extern unsigned int sysctl_vsyscall32;
172extern int force_personality32;
144 173
145#endif /* !CONFIG_X86_32 */ 174#endif /* !CONFIG_X86_32 */
146 175
@@ -179,17 +208,19 @@ extern int vdso_enabled;
179 208
180struct task_struct; 209struct task_struct;
181 210
211#define ARCH_DLINFO_IA32(vdso_enabled) \
212do if (vdso_enabled) { \
213 NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \
214 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \
215} while (0)
216
182#ifdef CONFIG_X86_32 217#ifdef CONFIG_X86_32
183 218
184#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO)) 219#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO))
185 220
186/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ 221#define ARCH_DLINFO ARCH_DLINFO_IA32(vdso_enabled)
187 222
188#define ARCH_DLINFO \ 223/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
189do if (vdso_enabled) { \
190 NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \
191 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \
192} while (0)
193 224
194#else /* CONFIG_X86_32 */ 225#else /* CONFIG_X86_32 */
195 226
@@ -203,6 +234,12 @@ do if (vdso_enabled) { \
203 NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\ 234 NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\
204} while (0) 235} while (0)
205 236
237#define AT_SYSINFO 32
238
239#define COMPAT_ARCH_DLINFO ARCH_DLINFO_IA32(sysctl_vsyscall32)
240
241#define COMPAT_ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
242
206#endif /* !CONFIG_X86_32 */ 243#endif /* !CONFIG_X86_32 */
207 244
208#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso) 245#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
@@ -216,6 +253,9 @@ struct linux_binprm;
216extern int arch_setup_additional_pages(struct linux_binprm *bprm, 253extern int arch_setup_additional_pages(struct linux_binprm *bprm,
217 int executable_stack); 254 int executable_stack);
218 255
256extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
257#define compat_arch_setup_additional_pages syscall32_setup_pages
258
219extern unsigned long arch_randomize_brk(struct mm_struct *mm); 259extern unsigned long arch_randomize_brk(struct mm_struct *mm);
220#define arch_randomize_brk arch_randomize_brk 260#define arch_randomize_brk arch_randomize_brk
221 261