[CRIU] [PATCHv1 18/26] restorer: unmapping native blob in compat task

Dmitry Safonov dsafonov at virtuozzo.com
Thu Jun 16 03:53:35 PDT 2016


We need to do it in pure ia32 asm.

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/arch/aarch64/include/asm/types.h |  1 +
 criu/arch/arm/include/asm/types.h     |  1 +
 criu/arch/ppc64/include/asm/types.h   |  1 +
 criu/cr-restore.c                     |  8 +++++++-
 criu/pie/restorer.c                   | 25 +++++++++++++++++++++++--
 5 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h
index 203b44ab363f..2ebc5dea096b 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -62,6 +62,7 @@ typedef struct user_pt_regs user_regs_struct_t;
 #define REG_SYSCALL_NR(regs)	((u64)(regs).regs[8])
 
 #define user_regs_native(pregs)			true
+#define core_is_compat(core)			false
 
 /*
  * Range for task size calculated from the following Linux kernel files:
diff --git a/criu/arch/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h
index 87f4c3c817d1..f19c616d4782 100644
--- a/criu/arch/arm/include/asm/types.h
+++ b/criu/arch/arm/include/asm/types.h
@@ -97,6 +97,7 @@ struct user_vfp_exc {
 #define REG_SYSCALL_NR(regs) ((regs).ARM_r7)
 
 #define user_regs_native(pregs)			true
+#define core_is_compat(core)			false
 
 /*
  * Range for task size calculated from the following Linux kernel files:
diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h
index fed09c465888..bf8878f893d1 100644
--- a/criu/arch/ppc64/include/asm/types.h
+++ b/criu/arch/ppc64/include/asm/types.h
@@ -80,6 +80,7 @@ typedef UserPpc64RegsEntry UserRegsEntry;
 #define REG_SYSCALL_NR(regs)    ((u64)(regs).gpr[0])
 
 #define user_regs_native(pregs)			true
+#define core_is_compat(core)			false
 
 #define CORE_THREAD_ARCH_INFO(core) core->ti_ppc64
 
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 169b964517fd..315f51614b8c 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -109,6 +109,7 @@
 
 #ifndef arch_export_unmap
 #define arch_export_unmap		__export_unmap
+#define arch_export_unmap_compat	__export_unmap_compat
 #endif
 
 struct pstree_item *current;
@@ -2804,7 +2805,12 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
 	 */
 	task_args->clone_restore_fn	= restorer_sym(mem, arch_export_restore_thread);
 	restore_task_exec_start		= restorer_sym(mem, arch_export_restore_task);
-	rsti(current)->munmap_restorer	= restorer_sym(mem, arch_export_unmap);
+	if (core_is_compat(core))
+		rsti(current)->munmap_restorer =
+			restorer_sym(mem, arch_export_unmap_compat);
+	else
+		rsti(current)->munmap_restorer =
+			restorer_sym(mem, arch_export_unmap);
 
 	task_args->bootstrap_start = mem;
 	mem += restorer_len;
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 2aeece4d549d..7b7299fd967b 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -940,8 +940,6 @@ static void restore_posix_timers(struct task_restore_args *args)
 		sys_timer_settime((kernel_timer_t)rt->spt.it_id, 0, &rt->val, NULL);
 	}
 }
-static void *bootstrap_start;
-static unsigned int bootstrap_len;
 
 /*
  * sys_munmap must not return here. The controll process must
@@ -953,11 +951,34 @@ static unsigned long vdso_rt_size;
 #define vdso_rt_size	(0)
 #endif
 
+static void *bootstrap_start;
+static unsigned int bootstrap_len;
+
 void __export_unmap(void)
 {
 	sys_munmap(bootstrap_start, bootstrap_len - vdso_rt_size);
 }
 
+#ifdef CONFIG_X86_64
+asm (
+	"	.pushsection .text\n"
+	"	.global	__export_unmap_compat\n"
+	"__export_unmap_compat:\n"
+	"	.code32\n"
+	"	mov bootstrap_start, %ebx\n"
+	"	mov bootstrap_len, %ecx\n"
+	"	movl $"__stringify(__NR32_munmap)", %eax\n"
+	"	int	$0x80\n"
+	"	.code64\n"
+	"	.popsection\n"
+);
+extern char __export_unmap_compat;
+#else
+void __export_unmap_compat(void)
+{
+}
+#endif
+
 /*
  * This function unmaps all VMAs, which don't belong to
  * the restored process or the restorer.
-- 
2.8.3



More information about the CRIU mailing list