From cbffef75b77b4a369301f1b7eb41f474d274ef36 Mon Sep 17 00:00:00 2001 From: Alexander Kartashov Date: Wed, 9 Jan 2013 17:39:23 +0400 Subject: [PATCH] cr-restore.c: wrapped the restorer blob trampoline assembly into the macro JUMP_TO_RESTORER_BLOB. Signed-off-by: Alexander Kartashov Signed-off-by: Pavel Emelyanov --- 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 000000000..08e3b4b7b --- /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 ec5bd4c99..8046ddca1 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);