[CRIU] [PATCH 19/22] cr-restore.c: wrapped the restorer blob trampoline assembly into the macro JUMP_TO_RESTORER_BLOB.

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


Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
 arch/x86/include/asm/restore.h |   18 ++++++++++++++++++
 cr-restore.c                   |   15 ++++-----------
 2 files changed, 22 insertions(+), 11 deletions(-)
 create mode 100644 arch/x86/include/asm/restore.h

diff --git a/arch/x86/include/asm/restore.h b/arch/x86/include/asm/restore.h
new file mode 100644
index 0000000..08e3b4b
--- /dev/null
+++ b/arch/x86/include/asm/restore.h
@@ -0,0 +1,18 @@
+#ifndef __CR_ASM_RESTORE_H__
+#define __CR_ASM_RESTORE_H__
+
+#define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start,          \
+			      task_args)				\
+	asm volatile(							\
+		     "movq %0, %%rbx				    \n" \
+		     "movq %1, %%rax				    \n" \
+		     "movq %2, %%rdi				    \n" \
+		     "movq %%rbx, %%rsp			       	    \n"	\
+		     "callq *%%rax				    \n" \
+		     :							\
+		     : "g"(new_sp),					\
+		       "g"(restore_task_exec_start),			\
+		       "g"(task_args)					\
+		     : "rsp", "rdi", "rsi", "rbx", "rax", "memory")
+
+#endif
diff --git a/cr-restore.c b/cr-restore.c
index ec5bd4c..8046ddc 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -61,6 +61,8 @@
 #include "protobuf/itimer.pb-c.h"
 #include "protobuf/vma.pb-c.h"
 
+#include "asm/restore.h"
+
 static struct pstree_item *current;
 
 static int restore_task_with_children(void *);
@@ -1971,17 +1973,8 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
 	 * An indirect call to task_restore, note it never resturns
 	 * and restoreing core is extremely destructive.
 	 */
-	asm volatile(
-		"movq %0, %%rbx						\n"
-		"movq %1, %%rax						\n"
-		"movq %2, %%rdi						\n"
-		"movq %%rbx, %%rsp					\n"
-		"callq *%%rax						\n"
-		:
-		: "g"(new_sp),
-		  "g"(restore_task_exec_start),
-		  "g"(task_args)
-		: "rsp", "rdi", "rsi", "rbx", "rax", "memory");
+
+	JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start, task_args);
 
 err:
 	free_mappings(&self_vma_list);
-- 
1.7.10.4



More information about the CRIU mailing list