diff options
author | Roland McGrath <roland@redhat.com> | 2008-01-30 07:31:55 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:31:55 -0500 |
commit | a97f52e67890fda6b373c1c1895ff1c1c69b36c8 (patch) | |
tree | 3cf522fd85e30519eb8b202c6d4243395ccb8653 /include | |
parent | 60b3b9af35aad66345e395be911e46fb8443f0c5 (diff) |
x86: compat_binfmt_elf
This switches x86-64's 32-bit ELF support to use the shared
fs/compat_binfmt_elf.c code instead of our own ia32_binfmt.c.
Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-x86/elf.h | 88 |
1 files changed, 64 insertions, 24 deletions
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 | |||
78 | extern 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) |
109 | extern 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 | |||
124 | static 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 | |||
136 | static 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(¤t->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(¤t->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") |
142 | extern void set_personality_64bit(void); | 170 | extern void set_personality_64bit(void); |
143 | extern int vdso_enabled; | 171 | extern unsigned int sysctl_vsyscall32; |
172 | extern 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 | ||
180 | struct task_struct; | 209 | struct task_struct; |
181 | 210 | ||
211 | #define ARCH_DLINFO_IA32(vdso_enabled) \ | ||
212 | do 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 */ |
189 | do 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; | |||
216 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, | 253 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, |
217 | int executable_stack); | 254 | int executable_stack); |
218 | 255 | ||
256 | extern int syscall32_setup_pages(struct linux_binprm *, int exstack); | ||
257 | #define compat_arch_setup_additional_pages syscall32_setup_pages | ||
258 | |||
219 | extern unsigned long arch_randomize_brk(struct mm_struct *mm); | 259 | extern 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 | ||