[CRIU] [PATCHv2 15/17] parasite-syscall: choose between native/compat blobs
Dmitry Safonov
dsafonov at virtuozzo.com
Tue Apr 12 09:10:53 PDT 2016
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
criu/parasite-syscall.c | 44 +++++++++++++++++++++++++++++++++-----------
criu/pie/parasite-blob.h | 3 +--
criu/pie/pie-relocs.h | 1 -
3 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index c6c600017c73..a5b2fc79f6a2 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -1331,13 +1331,27 @@ static int parasite_start_daemon(struct parasite_ctl *ctl, struct pstree_item *i
return 0;
}
-/* FIXME: parasite native/compat */
+#define init_parasite_ctl(ctl, blob_type) \
+ do { \
+ memcpy(ctl->local_map, parasite_##blob_type##_blob, \
+ sizeof(parasite_##blob_type##_blob)); \
+ ELF_RELOCS_APPLY(parasite_##blob_type, \
+ ctl->local_map, ctl->remote_map); \
+ /* Setup the rest of a control block */ \
+ ctl->parasite_ip = (unsigned long)parasite_sym(ctl->remote_map, \
+ blob_type, __export_parasite_head_start); \
+ ctl->addr_cmd = parasite_sym(ctl->local_map, blob_type, \
+ __export_parasite_cmd); \
+ ctl->addr_args = parasite_sym(ctl->local_map, blob_type, \
+ __export_parasite_args); \
+ } while (0)
+
struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
struct vm_area_list *vma_area_list)
{
int ret;
struct parasite_ctl *ctl;
- unsigned long p, map_exchange_size;
+ unsigned long p, map_exchange_size, parasite_size;
BUG_ON(item->threads[0].real != pid);
@@ -1355,9 +1369,18 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
* without using ptrace at all.
*/
+ if (user_regs_native(&ctl->orig.regs))
+ parasite_size = pie_size(parasite_native);
+#ifdef CONFIG_X86_64 /* compat blob isn't defined for other archs */
+ else
+ parasite_size = pie_size(parasite_compat);
+#endif
+
ctl->args_size = round_up(parasite_args_size, PAGE_SIZE);
parasite_args_size = PARASITE_ARG_SIZE_MIN; /* reset for next task */
- map_exchange_size = pie_size(parasite_native) + ctl->args_size;
+ parasite_size += ctl->args_size;
+
+ map_exchange_size = parasite_size;
map_exchange_size += RESTORE_STACK_SIGFRAME + PARASITE_STACK_SIZE;
if (item->nr_threads > 1)
map_exchange_size += PARASITE_STACK_SIZE;
@@ -1369,16 +1392,15 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
goto err_restore;
pr_info("Putting parasite blob into %p->%p\n", ctl->local_map, ctl->remote_map);
- memcpy(ctl->local_map, parasite_native_blob, sizeof(parasite_native_blob));
-
- ELF_RELOCS_APPLY(parasite_native, ctl->local_map, ctl->remote_map);
- /* Setup the rest of a control block */
- ctl->parasite_ip = (unsigned long)parasite_sym(ctl->remote_map, native, __export_parasite_head_start);
- ctl->addr_cmd = parasite_sym(ctl->local_map, native, __export_parasite_cmd);
- ctl->addr_args = parasite_sym(ctl->local_map, native, __export_parasite_args);
+ if (user_regs_native(&ctl->orig.regs))
+ init_parasite_ctl(ctl, native);
+#ifdef CONFIG_X86_64 /* compat blob isn't defined for other archs */
+ else
+ init_parasite_ctl(ctl, compat);
+#endif
- p = pie_size(parasite_native) + ctl->args_size;
+ p = parasite_size;
ctl->rsigframe = ctl->remote_map + p;
ctl->sigframe = ctl->local_map + p;
diff --git a/criu/pie/parasite-blob.h b/criu/pie/parasite-blob.h
index 278ca6d85845..796d36ed23e6 100644
--- a/criu/pie/parasite-blob.h
+++ b/criu/pie/parasite-blob.h
@@ -1,6 +1,5 @@
#include "parasite-native-blob.h"
#ifdef CONFIG_X86_64
-/* FIXME: parasite_compat_blob defined but not used */
-/* # include "parasite-compat-blob.h"*/
+# include "parasite-compat-blob.h"
#endif
diff --git a/criu/pie/pie-relocs.h b/criu/pie/pie-relocs.h
index 9af029eb8bc0..2873d5b39970 100644
--- a/criu/pie/pie-relocs.h
+++ b/criu/pie/pie-relocs.h
@@ -10,7 +10,6 @@
extern __maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size,
elf_reloc_t *elf_relocs, size_t nr_relocs);
-/* FIXME: native/compat pie's pie_size(), ELF_RELOCS_APPLY() */
#define pie_size(__pie_name) (round_up(sizeof(__pie_name##_blob) + \
__pie_name ## _nr_gotpcrel * sizeof(long), page_size()))
#define ELF_RELOCS_APPLY(__pie_name, __mem, __vbase) \
--
2.8.0
More information about the CRIU
mailing list