x86: compat_binfmt_elf

2008-01-30 Thread Linux Kernel Mailing List
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

x86: compat_binfmt_elf Kconfig

2008-01-30 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b9d36d5d000294a128f7f174fe67623a10e29d61
Commit: b9d36d5d000294a128f7f174fe67623a10e29d61
Parent: 2f79e48ae2651fff08d08dab3acf1294467c1155
Author: Roland McGrath [EMAIL PROTECTED]
AuthorDate: Wed Jan 30 13:31:46 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Wed Jan 30 13:31:46 2008 +0100

x86: compat_binfmt_elf Kconfig

This adds Kconfig and Makefile bits to build fs/compat_binfmt_elf.c,
just added.  Each arch that wants to use this file needs to add a
select COMPAT_BINFMT_ELF line in its Kconfig bits that enable COMPAT.

Signed-off-by: Roland McGrath [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
 fs/Kconfig.binfmt |4 
 fs/Makefile   |1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index d4fc609..7c3d5f9 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -23,6 +23,10 @@ config BINFMT_ELF
  ld.so (check the file file:Documentation/Changes for location and
  latest version).
 
+config COMPAT_BINFMT_ELF
+   bool
+   depends on COMPAT  MMU
+
 config BINFMT_ELF_FDPIC
bool Kernel support for FDPIC ELF binaries
default y
diff --git a/fs/Makefile b/fs/Makefile
index 500cf15..1e7a11b 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_BINFMT_MISC) += binfmt_misc.o
 obj-y  += binfmt_script.o
 
 obj-$(CONFIG_BINFMT_ELF)   += binfmt_elf.o
+obj-$(CONFIG_COMPAT_BINFMT_ELF)+= compat_binfmt_elf.o
 obj-$(CONFIG_BINFMT_ELF_FDPIC) += binfmt_elf_fdpic.o
 obj-$(CONFIG_BINFMT_SOM)   += binfmt_som.o
 obj-$(CONFIG_BINFMT_FLAT)  += binfmt_flat.o
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html