[CRIU] [PATCH 11/22] restorer: wrapped the assembly calling sys_rt_sigreturn into the macro ARCH_RT_SIGRETURN

Alexander Kartashov alekskartashov at parallels.com
Thu Dec 27 01:51:02 EST 2012


Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
 arch/x86/include/asm/restorer.h |   12 ++++++++++++
 pie/restorer.c                  |   19 +++----------------
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/arch/x86/include/asm/restorer.h b/arch/x86/include/asm/restorer.h
index edbcae2..b3e927d 100644
--- a/arch/x86/include/asm/restorer.h
+++ b/arch/x86/include/asm/restorer.h
@@ -71,6 +71,18 @@ struct rt_sigframe {
 	/* fp state follows here */
 };
 
+
+#define ARCH_RT_SIGRETURN(new_sp)					\
+	asm volatile(							\
+		     "movq %0, %%rax				    \n"	\
+		     "movq %%rax, %%rsp				    \n"	\
+		     "movl $"__stringify(__NR_rt_sigreturn)", %%eax \n" \
+		     "syscall					    \n"	\
+		     :							\
+		     : "r"(new_sp)					\
+		     : "rax","rsp","memory")
+
+
 int restore_gpregs(struct rt_sigframe *f, UserX86RegsEntry *r);
 
 int restore_fpu(struct rt_sigframe *sigframe, struct thread_restore_args *args);
diff --git a/pie/restorer.c b/pie/restorer.c
index dab1450..adf7af0 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -198,14 +198,8 @@ long __export_restore_thread(struct thread_restore_args *args)
 	futex_dec_and_wake(&thread_inprogress);
 
 	new_sp = (long)rt_sigframe + 8;
-	asm volatile(
-		"movq %0, %%rax					\n"
-		"movq %%rax, %%rsp				\n"
-		"movl $"__stringify(__NR_rt_sigreturn)", %%eax	\n"
-		"syscall					\n"
-		:
-		: "r"(new_sp)
-		: "rax","rsp","memory");
+	ARCH_RT_SIGRETURN(new_sp);
+
 core_restore_end:
 	pr_err("Restorer abnormal termination for %ld\n", sys_getpid());
 	sys_exit_group(1);
@@ -737,14 +731,7 @@ long __export_restore_task(struct task_restore_core_args *args)
 	 * pure assembly since we don't need any additional
 	 * code insns from gcc.
 	 */
-	asm volatile(
-		"movq %0, %%rax					\n"
-		"movq %%rax, %%rsp				\n"
-		"movl $"__stringify(__NR_rt_sigreturn)", %%eax	\n"
-		"syscall					\n"
-		:
-		: "r"(new_sp)
-		: "rax","rsp","memory");
+	ARCH_RT_SIGRETURN(new_sp);
 
 core_restore_end:
 	pr_err("Restorer fail %ld\n", sys_getpid());
-- 
1.7.10.4



More information about the CRIU mailing list