[CRIU] [PATCHv3 18/30] restorer: unmapping native blob in compat task
Dmitry Safonov
dsafonov at virtuozzo.com
Tue Jun 28 12:24:11 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 71db6daa3c3b..2c7c4752b709 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -59,6 +59,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 fcebaff7ba3b..90beb96f8ebd 100644
--- a/criu/arch/arm/include/asm/types.h
+++ b/criu/arch/arm/include/asm/types.h
@@ -94,6 +94,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 a668ed15a529..8b3468149427 100644
--- a/criu/arch/ppc64/include/asm/types.h
+++ b/criu/arch/ppc64/include/asm/types.h
@@ -77,6 +77,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 874ff3484713..84ed12634827 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -108,6 +108,7 @@
#ifndef arch_export_unmap
#define arch_export_unmap __export_unmap
+#define arch_export_unmap_compat __export_unmap_compat
#endif
struct pstree_item *current;
@@ -2820,7 +2821,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 0eee36378344..7b1c129a38f9 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.9.0
More information about the CRIU
mailing list