[PATCH 13/18] x86 vDSO: ia32 sysenter_return

!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:06 pm

This changes the 64-bit kernel's support for the 32-bit sysenter
instruction to use stored fields rather than constants for the
user-mode return address, as the 32-bit kernel does.  This adds a
sysenter_return field to struct thread_info, as 32-bit has.  There
is no observable effect from this yet.  It makes the assembly code
independent of the 32-bit vDSO mapping address, paving the way for
making the vDSO address vary as it does on the 32-bit kernel.

Signed-off-by: Roland McGrath <roland@redhat.com>
---
 arch/x86/ia32/ia32entry.S        |    7 +++----
 arch/x86/ia32/syscall32.c        |    4 ++++
 arch/x86/kernel/asm-offsets_64.c |    1 +
 include/asm-x86/thread_info_64.h |    3 +++
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index df588f0..2499a32 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -12,7 +12,6 @@
 #include <asm/ia32_unistd.h>	
 #include <asm/thread_info.h>	
 #include <asm/segment.h>
-#include <asm/vsyscall32.h>
 #include <asm/irqflags.h>
 #include <linux/linkage.h>
 
@@ -104,7 +103,7 @@ ENTRY(ia32_sysenter_target)
 	pushfq
 	CFI_ADJUST_CFA_OFFSET 8
 	/*CFI_REL_OFFSET rflags,0*/
-	movl	$VSYSCALL32_SYSEXIT, %r10d
+	movl	8*3-THREAD_SIZE+threadinfo_sysenter_return(%rsp), %r10d
 	CFI_REGISTER rip,r10
 	pushq	$__USER32_CS
 	CFI_ADJUST_CFA_OFFSET 8
@@ -142,6 +141,8 @@ sysenter_do_call:
 	andl    $~TS_COMPAT,threadinfo_status(%r10)
 	/* clear IF, that popfq doesn't enable interrupts early */
 	andl  $~0x200,EFLAGS-R11(%rsp) 
+	movl	RIP-R11(%rsp),%edx		/* User %eip */
+	CFI_REGISTER rip,rdx
 	RESTORE_ARGS 1,24,1,1,1,1
 	popfq
 	CFI_ADJUST_CFA_OFFSET -8
@@ -149,8 +150,6 @@ sysenter_do_call:
 	popq	%rcx				/* User %esp */
 	CFI_ADJUST_CFA_OFFSET -8
 	CFI_REGISTER rsp,rcx
-	movl	$VSYSCALL32_SYSEXIT,%edx	/* User %eip */
-	CFI_REGISTER rip,rdx
 	TRACE_IRQS_ON
 	swapgs
 	sti		/* sti only takes effect after the next instruction */
diff --git a/arch/x86/ia32/syscall32.c b/arch/x86/ia32/syscall32.c
index 15013ba..2c9c145 100644
--- a/arch/x86/ia32/syscall32.c
+++ b/arch/x86/ia32/syscall32.c
@@ -45,6 +45,10 @@ int syscall32_setup_pages(struct linux_binprm *bprm, int exstack)
 				      VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
 				      VM_ALWAYSDUMP,
 				      syscall32_pages);
+	if (ret == 0) {
+		current->mm->context.vdso = (void __user *)VSYSCALL32_BASE;
+		current_thread_info()->sysenter_return = VSYSCALL32_SYSEXIT;
+	}
 	up_write(&mm->mmap_sem);
 	return ret;
 }
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index d1b6ed9..1f9b0b5 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -47,6 +47,7 @@ int main(void)
 	ENTRY(addr_limit);
 	ENTRY(preempt_count);
 	ENTRY(status);
+	ENTRY(sysenter_return);
 	BLANK();
 #undef ENTRY
 #define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))
diff --git a/include/asm-x86/thread_info_64.h b/include/asm-x86/thread_info_64.h
index beae2bf..f81638e 100644
--- a/include/asm-x86/thread_info_64.h
+++ b/include/asm-x86/thread_info_64.h
@@ -33,6 +33,9 @@ struct thread_info {
 
 	mm_segment_t		addr_limit;	
 	struct restart_block    restart_block;
+#ifdef CONFIG_IA32_EMULATION
+	void __user		*sysenter_return;
+#endif
 };
 #endif
 
-
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)