about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/x86_64/swapcontext.S')
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/swapcontext.S20
1 files changed, 19 insertions, 1 deletions
diff --git a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
index 3dddb3cec2..4394e2ae9f 100644
--- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
+++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
@@ -35,7 +35,8 @@
   other than the PRESERVED state.  */
 
 ENTRY(__swapcontext)
-	/* Save the preserved registers and the return address.  */
+	/* Save the preserved registers, the registers used for passing args,
+	   and the return address.  */
 	movq	%rbx, oRBX(%rdi)
 	movq	%rbp, oRBP(%rdi)
 	movq	%r12, oR12(%rdi)
@@ -43,6 +44,13 @@ ENTRY(__swapcontext)
 	movq	%r14, oR14(%rdi)
 	movq	%r15, oR15(%rdi)
 
+	movq	%rdi, oRDI(%rdi)
+	movq	%rsi, oRSI(%rdi)
+	movq	%rdx, oRDX(%rdi)
+	movq	%rcx, oRCX(%rdi)
+	movq	%r8, oR8(%rdi)
+	movq	%r9, oR9(%rdi)
+
 	movq	(%rsp), %rcx
 	movq	%rcx, oRIP(%rdi)
 	leaq	8(%rsp), %rcx		/* Exclude the return address.  */
@@ -95,6 +103,16 @@ ENTRY(__swapcontext)
 	movq	oRIP(%rsi), %rcx
 	pushq	%rcx
 
+	/* Setup registers used for passing args.  */
+	movq	oRDI(%rsi), %rdi
+	movq	oRDX(%rsi), %rdx
+	movq	oRCX(%rsi), %rcx
+	movq	oR8(%rsi), %r8
+	movq	oR9(%rsi), %r9
+
+	/* Setup finally  %rsi.  */
+	movq	oRSI(%rsi), %rsi
+
 	/* Clear rax to indicate success.  */
 	xorq	%rax, %rax