All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/x86: Adjust stack pointer in xen_sysexit
@ 2015-11-13 23:18 Boris Ostrovsky
  2015-11-13 23:26 ` Andy Lutomirski
  2015-11-13 23:26 ` Andy Lutomirski
  0 siblings, 2 replies; 51+ messages in thread
From: Boris Ostrovsky @ 2015-11-13 23:18 UTC (permalink / raw)
  To: konrad.wilk, david.vrabel; +Cc: xen-devel, linux-kernel, luto, boris.ostrovsky

After 32-bit syscall rewrite, and specifically after commit 5f310f739b4c
("x86/entry/32: Re-implement SYSENTER using the new C path"), the stack
frame that is passed to xen_sysexit is no longer a "standard" one (i.e.
it's not pt_regs).

We need to adjust it so that subsequent xen_iret can use it.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---

Alternatively, we could return 0 from do_fast_syscall_32() if paravirt_enabled()
is true since Xen PV guests will end up using xen_iret one way or the other. And
then we won't need xen_sysexit at all.

 arch/x86/xen/xen-asm_32.S |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
index fd92a64..c70ec37 100644
--- a/arch/x86/xen/xen-asm_32.S
+++ b/arch/x86/xen/xen-asm_32.S
@@ -36,15 +36,24 @@ check_events:
 
 /*
  * We can't use sysexit directly, because we're not running in ring0.
- * But we can easily fake it up using iret.  Assuming xen_sysexit is
- * jumped to with a standard stack frame, we can just strip it back to
- * a standard iret frame and use iret.
+ * But we can easily fake it up using iret.
+ * We came here from the opportunistic SYSEXIT path in entry_SYSENTER_32
+ * which left the stack looking like this:
+ * 	$__USER_DS
+ * 	%ecx
+ * 	eflags
+ *	$__USER_CS
+ *	%eip
+ *	%eax
+ *	%gs
+ *	%fs
+ *	%es
+ *	%ds	<-- %esp
+ *
+ * so we need to adjust it to look like a standard iret frame
  */
 ENTRY(xen_sysexit)
-	movl PT_EAX(%esp), %eax			/* Shouldn't be necessary? */
-	orl $X86_EFLAGS_IF, PT_EFLAGS(%esp)
-	lea PT_EIP(%esp), %esp
-
+	add $5*4, %esp
 	jmp xen_iret
 ENDPROC(xen_sysexit)
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 51+ messages in thread
* [PATCH] xen/x86: Adjust stack pointer in xen_sysexit
@ 2015-11-13 23:18 Boris Ostrovsky
  0 siblings, 0 replies; 51+ messages in thread
From: Boris Ostrovsky @ 2015-11-13 23:18 UTC (permalink / raw)
  To: konrad.wilk, david.vrabel; +Cc: boris.ostrovsky, linux-kernel, luto, xen-devel

After 32-bit syscall rewrite, and specifically after commit 5f310f739b4c
("x86/entry/32: Re-implement SYSENTER using the new C path"), the stack
frame that is passed to xen_sysexit is no longer a "standard" one (i.e.
it's not pt_regs).

We need to adjust it so that subsequent xen_iret can use it.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---

Alternatively, we could return 0 from do_fast_syscall_32() if paravirt_enabled()
is true since Xen PV guests will end up using xen_iret one way or the other. And
then we won't need xen_sysexit at all.

 arch/x86/xen/xen-asm_32.S |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
index fd92a64..c70ec37 100644
--- a/arch/x86/xen/xen-asm_32.S
+++ b/arch/x86/xen/xen-asm_32.S
@@ -36,15 +36,24 @@ check_events:
 
 /*
  * We can't use sysexit directly, because we're not running in ring0.
- * But we can easily fake it up using iret.  Assuming xen_sysexit is
- * jumped to with a standard stack frame, we can just strip it back to
- * a standard iret frame and use iret.
+ * But we can easily fake it up using iret.
+ * We came here from the opportunistic SYSEXIT path in entry_SYSENTER_32
+ * which left the stack looking like this:
+ * 	$__USER_DS
+ * 	%ecx
+ * 	eflags
+ *	$__USER_CS
+ *	%eip
+ *	%eax
+ *	%gs
+ *	%fs
+ *	%es
+ *	%ds	<-- %esp
+ *
+ * so we need to adjust it to look like a standard iret frame
  */
 ENTRY(xen_sysexit)
-	movl PT_EAX(%esp), %eax			/* Shouldn't be necessary? */
-	orl $X86_EFLAGS_IF, PT_EFLAGS(%esp)
-	lea PT_EIP(%esp), %esp
-
+	add $5*4, %esp
 	jmp xen_iret
 ENDPROC(xen_sysexit)
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2015-11-17 19:38 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 23:18 [PATCH] xen/x86: Adjust stack pointer in xen_sysexit Boris Ostrovsky
2015-11-13 23:26 ` Andy Lutomirski
2015-11-14  1:23   ` Boris Ostrovsky
2015-11-14  1:23   ` Boris Ostrovsky
2015-11-15 18:02     ` Andy Lutomirski
2015-11-15 18:02     ` Andy Lutomirski
2015-11-16 16:25       ` Boris Ostrovsky
2015-11-16 16:25       ` Boris Ostrovsky
2015-11-16 19:03         ` Andy Lutomirski
2015-11-16 19:59           ` Borislav Petkov
2015-11-16 20:11             ` Andy Lutomirski
2015-11-16 20:11             ` Andy Lutomirski
2015-11-16 20:22               ` Borislav Petkov
2015-11-16 20:22               ` Borislav Petkov
2015-11-16 20:48                 ` Boris Ostrovsky
2015-11-16 20:50                   ` Andy Lutomirski
2015-11-16 21:00                     ` Borislav Petkov
2015-11-16 21:00                     ` Borislav Petkov
2015-11-16 21:03                     ` Konrad Rzeszutek Wilk
2015-11-16 21:04                       ` Andy Lutomirski
2015-11-17 10:53                         ` Joao Martins
2015-11-17 10:53                         ` Joao Martins
2015-11-16 21:04                       ` Andy Lutomirski
2015-11-16 20:50                   ` Andy Lutomirski
2015-11-16 20:48                 ` Boris Ostrovsky
2015-11-16 21:55                 ` H. Peter Anvin
2015-11-16 21:55                 ` H. Peter Anvin
2015-11-17 14:40                   ` Boris Ostrovsky
2015-11-17 14:40                   ` Boris Ostrovsky
2015-11-17 18:49                     ` Andy Lutomirski
2015-11-17 19:12                       ` Andrew Cooper
2015-11-17 19:12                       ` [Xen-devel] " Andrew Cooper
2015-11-17 19:16                         ` Andy Lutomirski
2015-11-17 19:21                           ` Borislav Petkov
2015-11-17 19:21                           ` [Xen-devel] " Borislav Petkov
2015-11-17 19:29                           ` Andrew Cooper
2015-11-17 19:36                             ` Andy Lutomirski
2015-11-17 19:36                             ` Andy Lutomirski
2015-11-17 19:29                           ` Andrew Cooper
2015-11-17 19:37                           ` [Xen-devel] " Boris Ostrovsky
2015-11-17 19:38                             ` Boris Ostrovsky
2015-11-17 19:38                             ` [Xen-devel] " Boris Ostrovsky
2015-11-17 19:37                           ` Boris Ostrovsky
2015-11-17 19:16                         ` Andy Lutomirski
2015-11-17 18:49                     ` Andy Lutomirski
2015-11-16 19:59           ` Borislav Petkov
2015-11-16 20:31           ` Boris Ostrovsky
2015-11-16 20:31           ` Boris Ostrovsky
2015-11-16 19:03         ` Andy Lutomirski
2015-11-13 23:26 ` Andy Lutomirski
2015-11-13 23:18 Boris Ostrovsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.