[PATCH 17/18] x86 vDSO: reorder vdso32 code

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>, Thomas Gleixner <tglx@...>, Ingo Molnar <mingo@...>, H. Peter Anvin <hpa@...>
Cc: <linux-kernel@...>
Date: Monday, November 19, 2007 - 6:07 pm

This reorders the code in the 32-bit vDSO images to put the signal
trampolines first and __kernel_vsyscall after them.  The order does
not matter to userland, it just uses what AT_SYSINFO or e_entry
says.  Since the signal trampolines are the same size in both
versions of the vDSO, putting them first is the simplest way to get
the addresses to line up.  This makes it work to use a more compact
layout for the vDSO.

Signed-off-by: Roland McGrath <roland@redhat.com>
---
 arch/x86/vdso/vdso32/int80.S     |   15 +++++----------
 arch/x86/vdso/vdso32/sigreturn.S |   20 +++++++++-----------
 arch/x86/vdso/vdso32/syscall.S   |   15 +++++++--------
 arch/x86/vdso/vdso32/sysenter.S  |   17 ++++++-----------
 4 files changed, 27 insertions(+), 40 deletions(-)

diff --git a/arch/x86/vdso/vdso32/int80.S b/arch/x86/vdso/vdso32/int80.S
index 3c8e4c6..9d382c9 100644
--- a/arch/x86/vdso/vdso32/int80.S
+++ b/arch/x86/vdso/vdso32/int80.S
@@ -1,15 +1,15 @@
 /*
- * Code for the vsyscall page.  This version uses the old int $0x80 method.
+ * Code for the vDSO.  This version uses the old int $0x80 method.
  *
- * NOTE:
- * 1) __kernel_vsyscall _must_ be first in this page.
- * 2) there are alignment constraints on this stub, see vsyscall-sigreturn.S
- *    for details.
+ * First get the common code for the sigreturn entry points.
+ * This must come first.
  */
+#include "sigreturn.S"
 
 	.text
 	.globl __kernel_vsyscall
 	.type __kernel_vsyscall,@function
+	ALIGN
 __kernel_vsyscall:
 .LSTART_vsyscall:
 	int $0x80
@@ -46,8 +46,3 @@ __kernel_vsyscall:
 	.align 4
 .LENDFDEDLSI:
 	.previous
-
-/*
- * Get the common code for the sigreturn entry points.
- */
-#include "sigreturn.S"
diff --git a/arch/x86/vdso/vdso32/sigreturn.S b/arch/x86/vdso/vdso32/sigreturn.S
index f222889..0c1a606 100644
--- a/arch/x86/vdso/vdso32/sigreturn.S
+++ b/arch/x86/vdso/vdso32/sigreturn.S
@@ -1,11 +1,12 @@
 /*
- * Common code for the sigreturn entry points on the vsyscall page.
+ * Common code for the sigreturn entry points in vDSO images.
  * So far this code is the same for both int80 and sysenter versions.
- * This file is #include'd by vsyscall-*.S to define them after the
- * vsyscall entry point.  The kernel assumes that the addresses of these
- * routines are constant for all vsyscall implementations.
+ * This file is #include'd by int80.S et al to define them first thing.
+ * The kernel assumes that the addresses of these routines are constant
+ * for all vDSO implementations.
  */
 
+#include <linux/linkage.h>
 #include <asm/unistd_32.h>
 #include <asm/asm-offsets.h>
 
@@ -13,32 +14,29 @@
 #define	SYSCALL_ENTER_KERNEL	int $0x80
 #endif
 
-/* XXX
-   Should these be named "_sigtramp" or something?
-*/
-
 	.text
-	.org __kernel_vsyscall+32,0x90
 	.globl __kernel_sigreturn
 	.type __kernel_sigreturn,@function
+	ALIGN
 __kernel_sigreturn:
 .LSTART_sigreturn:
 	popl %eax		/* XXX does this mean it needs unwind info? */
 	movl $__NR_sigreturn, %eax
 	SYSCALL_ENTER_KERNEL
 .LEND_sigreturn:
+	nop
 	.size __kernel_sigreturn,.-.LSTART_sigreturn
 
-	.balign 32
 	.globl __kernel_rt_sigreturn
 	.type __kernel_rt_sigreturn,@function
+	ALIGN
 __kernel_rt_sigreturn:
 .LSTART_rt_sigreturn:
 	movl $__NR_rt_sigreturn, %eax
 	SYSCALL_ENTER_KERNEL
 .LEND_rt_sigreturn:
+	nop
 	.size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
-	.balign 32
 	.previous
 
 	.section .eh_frame,"a",@progbits
diff --git a/arch/x86/vdso/vdso32/syscall.S b/arch/x86/vdso/vdso32/syscall.S
index 333bfb5..c5ccc98 100644
--- a/arch/x86/vdso/vdso32/syscall.S
+++ b/arch/x86/vdso/vdso32/syscall.S
@@ -1,13 +1,18 @@
 /*
- * Code for the vsyscall page.  This version uses the syscall instruction.
+ * Code for the vDSO.  This version uses the syscall instruction.
+ *
+ * First get the common code for the sigreturn entry points.
+ * This must come first.
  */
+#define SYSCALL_ENTER_KERNEL	syscall
+#include "sigreturn.S"
 
-#include <asm/asm-offsets.h>
 #include <asm/segment.h>
 
 	.text
 	.globl __kernel_vsyscall
 	.type __kernel_vsyscall,@function
+	ALIGN
 __kernel_vsyscall:
 .LSTART_vsyscall:
 	push	%ebp
@@ -61,9 +66,3 @@ __kernel_vsyscall:
 	.uleb128 4
 	.align 4
 .LENDFDE1:
-
-/*
- * Get the common code for the sigreturn entry points.
- */
-#define SYSCALL_ENTER_KERNEL	syscall
-#include "sigreturn.S"
diff --git a/arch/x86/vdso/vdso32/sysenter.S b/arch/x86/vdso/vdso32/sysenter.S
index 109bfa3..a9bb825 100644
--- a/arch/x86/vdso/vdso32/sysenter.S
+++ b/arch/x86/vdso/vdso32/sysenter.S
@@ -1,11 +1,10 @@
 /*
- * Code for the vsyscall page.  This version uses the sysenter instruction.
+ * Code for the vDSO.  This version uses the sysenter instruction.
  *
- * NOTE:
- * 1) __kernel_vsyscall _must_ be first in this page.
- * 2) there are alignment constraints on this stub, see vsyscall-sigreturn.S
- *    for details.
+ * First get the common code for the sigreturn entry points.
+ * This must come first.
  */
+#include "sigreturn.S"
 
 /*
  * The caller puts arg2 in %ecx, which gets pushed. The kernel will use
@@ -23,11 +22,12 @@
  * arg6 from the stack.
  *
  * You can not use this vsyscall for the clone() syscall because the
- * three dwords on the parent stack do not get copied to the child.
+ * three words on the parent stack do not get copied to the child.
  */
 	.text
 	.globl __kernel_vsyscall
 	.type __kernel_vsyscall,@function
+	ALIGN
 __kernel_vsyscall:
 .LSTART_vsyscall:
 	push %ecx
@@ -114,8 +114,3 @@ VDSO32_SYSENTER_RETURN:	/* Symbol used by sysenter.c via vdso32-syms.h */
 	.align 4
 .LENDFDEDLSI:
 	.previous
-
-/*
- * Get the common code for the sigreturn entry points.
- */
-#include "sigreturn.S"
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/18] x86 vDSO revamp, Roland McGrath, (Mon Nov 19, 5:59 pm)
[PATCH 16/18] x86 vDSO: ia32 vsyscall removal, Roland McGrath, (Mon Nov 19, 6:06 pm)
[PATCH 17/18] x86 vDSO: reorder vdso32 code, Roland McGrath, (Mon Nov 19, 6:07 pm)
[PATCH 15/18] x86 vDSO: consolidate vdso32, Roland McGrath, (Mon Nov 19, 6:06 pm)
Re: [PATCH 15/18] x86 vDSO: consolidate vdso32, Zachary Amsden, (Tue Nov 20, 8:13 pm)
Re: [PATCH 15/18] x86 vDSO: consolidate vdso32, Roland McGrath, (Tue Nov 20, 8:32 pm)
Re: [PATCH 15/18] x86 vDSO: consolidate vdso32, Andi Kleen, (Tue Nov 20, 8:15 pm)
Re: [PATCH 15/18] x86 vDSO: consolidate vdso32, Ingo Molnar, (Tue Nov 20, 8:13 pm)
[PATCH 14/18] x86 vDSO: ia32 vdso32-syscall build, Roland McGrath, (Mon Nov 19, 6:06 pm)
[PATCH 18/18] x86 vDSO: makefile cleanup, Roland McGrath, (Mon Nov 19, 6:07 pm)
[PATCH 13/18] x86 vDSO: ia32 sysenter_return, Roland McGrath, (Mon Nov 19, 6:06 pm)
Re: [PATCH 13/18] x86 vDSO: ia32 sysenter_return, Zachary Amsden, (Tue Nov 20, 8:05 pm)
Re: [PATCH 13/18] x86 vDSO: ia32 sysenter_return, Roland McGrath, (Tue Nov 20, 8:34 pm)
[PATCH 12/18] x86 vDSO: ia32_sysenter_target, Roland McGrath, (Mon Nov 19, 6:06 pm)
[PATCH 08/18] x86 vDSO: i386 vdso32, Roland McGrath, (Mon Nov 19, 6:05 pm)
[PATCH 11/18] x86 vDSO: vdso32 setup, Roland McGrath, (Mon Nov 19, 6:06 pm)
[PATCH 10/18] x86 vDSO: i386 vdso32 install, Roland McGrath, (Mon Nov 19, 6:05 pm)
[PATCH 09/18] x86 vDSO: absolute relocs, Roland McGrath, (Mon Nov 19, 6:05 pm)
[PATCH 07/18] x86 vDSO: vdso32 build, Roland McGrath, (Mon Nov 19, 6:05 pm)
Re: [PATCH 07/18] x86 vDSO: vdso32 build, Sam Ravnborg, (Wed Nov 21, 2:02 am)
Re: [PATCH 07/18] x86 vDSO: vdso32 build, Roland McGrath, (Wed Nov 21, 3:10 am)
Re: [PATCH 07/18] x86 vDSO: vdso32 build, Sam Ravnborg, (Wed Nov 21, 3:32 am)
Re: [PATCH 07/18] x86 vDSO: vdso32 build, Roland McGrath, (Wed Nov 21, 3:55 am)
[PATCH 06/18] x86 vDSO: arch/x86/vdso/vdso32, Roland McGrath, (Mon Nov 19, 6:04 pm)
Re: [PATCH 06/18] x86 vDSO: arch/x86/vdso/vdso32, Thomas Gleixner, (Tue Nov 20, 9:05 am)
Re: [PATCH 06/18] x86 vDSO: arch/x86/vdso/vdso32, Roland McGrath, (Tue Nov 20, 4:57 pm)
Re: [PATCH 06/18] x86 vDSO: arch/x86/vdso/vdso32, Thomas Gleixner, (Tue Nov 20, 7:07 pm)
Re: [PATCH 06/18] x86 vDSO: arch/x86/vdso/vdso32, Roland McGrath, (Tue Nov 20, 7:27 pm)
Re: [PATCH 06/18] x86 vDSO: arch/x86/vdso/vdso32, Linus Torvalds, (Mon Nov 26, 9:53 pm)
Re: [PATCH 06/18] x86 vDSO: arch/x86/vdso/vdso32, Roland McGrath, (Mon Nov 26, 10:01 pm)
Re: [PATCH 06/18] x86 vDSO: arch/x86/vdso/vdso32, Thomas Gleixner, (Tue Nov 20, 7:50 pm)
[PATCH 04/18] x86 vDSO: new layout, Roland McGrath, (Mon Nov 19, 6:03 pm)
[PATCH 05/18] x86 vDSO: harmonize asm-offsets, Roland McGrath, (Mon Nov 19, 6:03 pm)
[PATCH 03/18] x86 vDSO: remove vdso-syms.o, Roland McGrath, (Mon Nov 19, 6:02 pm)
[PATCH 02/18] x86 vDSO: use vdso-syms.lds, Roland McGrath, (Mon Nov 19, 6:02 pm)
[PATCH 01/18] x86 vDSO: generate vdso-syms.lds, Roland McGrath, (Mon Nov 19, 6:01 pm)