Gitweb:
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a97f52e67890fda6b373c1c1895ff1c1c69b36c8
Commit: a97f52e67890fda6b373c1c1895ff1c1c69b36c8
Parent: 60b3b9af35aad66345e395be911e46fb8443f0c5
Author: Roland McGrath [EMAIL PROTECTED]
AuthorDate: Wed Jan 30 13:31:55 2008 +0100
Committer: Ingo Molnar [EMAIL PROTECTED]
CommitDate: Wed Jan 30 13:31:55 2008 +0100
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 [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
arch/x86/Kconfig |1 +
arch/x86/ia32/Makefile |3 +-
arch/x86/vdso/vdso32-setup.c | 33
include/asm-x86/elf.h| 88 ++---
4 files changed, 99 insertions(+), 26 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1992b8f..d89b945 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1532,6 +1532,7 @@ source fs/Kconfig.binfmt
config IA32_EMULATION
bool IA32 Emulation
depends on X86_64
+ select COMPAT_BINFMT_ELF
help
Include code to run 32-bit programs under a 64-bit kernel. You should
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 93a6fda..52d0ccf 100644
--- a/arch/x86/ia32/Makefile
+++ b/arch/x86/ia32/Makefile
@@ -2,8 +2,7 @@
# Makefile for the ia32 kernel emulation subsystem.
#
-obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o \
- ia32_binfmt.o
+obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o
sysv-$(CONFIG_SYSVIPC) := ipc32.o
obj-$(CONFIG_IA32_EMULATION) += $(sysv-y)
diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
index e0feb66..348f134 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)
__initcall(sysenter_setup);
+#ifdef CONFIG_SYSCTL
+/* Register vsyscall32 into the ABI table */
+#include linux/sysctl.h
+
+static ctl_table abi_table2[] = {
+ {
+ .procname = vsyscall32,
+ .data = sysctl_vsyscall32,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec
+ },
+ {}
+};
+
+static ctl_table abi_root_table2[] = {
+ {
+ .ctl_name = CTL_ABI,
+ .procname = abi,
+ .mode = 0555,
+ .child = abi_table2
+ },
+ {}
+};
+
+static __init int ia32_binfmt_init(void)
+{
+ register_sysctl_table(abi_root_table2);
+ return 0;
+}
+__initcall(ia32_binfmt_init);
+#endif
+
#else /* CONFIG_X86_32 */
const char *arch_vma_name(struct vm_area_struct *vma)
diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h
index d6bf742..dab4744 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;
#endif
#ifdef __KERNEL__
+#include asm/vdso.h
+
+extern unsigned int vdso_enabled;
/*
* 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;
#include asm/processor.h
#include asm/system.h/* for savesegment */
#include asm/desc.h
-#include asm/vdso.h
#define elf_check_arch(x) elf_check_arch_ia32(x)
@@ -106,7 +108,6 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
#define ELF_PLATFORM (utsname()-machine)
#define set_personality_64bit()do { } while (0)
-extern unsigned int vdso_enabled;
#else /* CONFIG_X86_32 */
@@ -118,29 +119,57 @@ extern unsigned int vdso_enabled;
#define elf_check_arch(x) \
((x)-e_machine == EM_X86_64)
+#define compat_elf_check_arch(x) elf_check_arch_ia32(x)
+
+static inline void start_ia32_thread(struct pt_regs *regs, u32 ip, u32 sp)
+{
+ asm volatile(movl %0,%%fs :: r (0));
+ asm volatile(movl %0,%%es; movl %0,%%ds : : r (__USER32_DS));
+ load_gs_index(0);
+ regs-ip = ip;
+ regs-sp = sp;
+ regs-flags = X86_EFLAGS_IF;
+ regs-cs = __USER32_CS;
+ regs-ss = __USER32_DS;
+}
+
+static inline void elf_common_init(struct thread_struct *t,
+ struct pt_regs *regs, const u16 ds)
+{
+ regs-ax = regs-bx = regs-cx = regs-dx = 0;
+ regs-si = regs-di = regs-bp = 0;
+ regs-r8 = regs-r9 = regs-r10 = regs-r11 = 0;
+ regs-r12 = regs-r13 = regs-r14 = regs-r15 = 0;
+ t-fs = t-gs = 0;
+ t-fsindex = t-gsindex = 0;
+ t-ds = t-es = ds;
+}
+
#define ELF_PLAT_INIT(_r, load_addr) do