[CRIU] [PATCH] Per architecture restorer trampolines
Laurent Dufour
ldufour at linux.vnet.ibm.com
Thu Apr 30 07:52:44 PDT 2015
Some architectures like ppc64 requires a trampoline to be called prior to
the standard restorer services.
This patch introduces 3 trampolines which can be overwritten by
architectures in arch/x/include/asm/restore.h:
- arch_export_restore_thread
- arch_export_restore_task
- arch_export_unmap
The architecture which doesn't need to overwrite them, has nothing to do.
Signed-off-by: Laurent Dufour <ldufour at linux.vnet.ibm.com>
---
arch/ppc64/include/asm/restore.h | 3 +++
cr-restore.c | 23 +++++++++++++++--------
include/restorer.h | 4 +++-
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/arch/ppc64/include/asm/restore.h b/arch/ppc64/include/asm/restore.h
index 3ca0c534d843..a66046422118 100644
--- a/arch/ppc64/include/asm/restore.h
+++ b/arch/ppc64/include/asm/restore.h
@@ -30,4 +30,7 @@
int restore_fpu(struct rt_sigframe *sigframe, CoreEntry *core);
+#define arch_export_restore_task __export_restore_task_trampoline
+#define arch_export_unmap __export_unmap_trampoline
+
#endif /* __CR_ASM_RESTORE_H__ */
diff --git a/cr-restore.c b/cr-restore.c
index e100164d4fcb..73bb9ca2df21 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -90,6 +90,18 @@
#include "cr-errno.h"
+#ifndef arch_export_restore_thread
+#define arch_export_restore_thread __export_restore_thread
+#endif
+
+#ifndef arch_export_restore_task
+#define arch_export_restore_task __export_restore_task
+#endif
+
+#ifndef arch_export_unmap
+#define arch_export_unmap __export_unmap
+#endif
+
static struct pstree_item *current;
static int restore_task_with_children(void *);
@@ -2750,14 +2762,9 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
* Prepare a memory map for restorer. Note a thread space
* might be completely unused so it's here just for convenience.
*/
- restore_thread_exec_start = restorer_sym(exec_mem_hint, __export_restore_thread);
-#ifdef CONFIG_PPC64
- restore_task_exec_start = restorer_sym(exec_mem_hint, __export_restore_task_trampoline);
- rsti(current)->munmap_restorer = restorer_sym(exec_mem_hint, __export_unmap_trampoline);
-#else
- restore_task_exec_start = restorer_sym(exec_mem_hint, __export_restore_task);
- rsti(current)->munmap_restorer = restorer_sym(exec_mem_hint, __export_unmap);
-#endif
+ restore_thread_exec_start = restorer_sym(exec_mem_hint, arch_export_restore_thread);
+ restore_task_exec_start = restorer_sym(exec_mem_hint, arch_export_restore_task);
+ rsti(current)->munmap_restorer = restorer_sym(exec_mem_hint, arch_export_unmap);
exec_mem_hint += restorer_len;
diff --git a/include/restorer.h b/include/restorer.h
index ded084a522df..8b63a95fc5f4 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -195,6 +195,8 @@ enum {
/* the restorer_blob_offset__ prefix is added by gen_offsets.sh */
-#define restorer_sym(rblob, name) ((void *)(rblob) + restorer_blob_offset__##name)
+#define __blob_offset(name) restorer_blob_offset__ ## name
+#define _blob_offset(name) __blob_offset(name)
+#define restorer_sym(rblob, name) (void*)(rblob + _blob_offset(name))
#endif /* __CR_RESTORER_H__ */
--
1.9.1
More information about the CRIU
mailing list