[CRIU] [PATCH 20/22] cr-restore.c: introduced the multiarch support.
Alexander Kartashov
alekskartashov at parallels.com
Thu Dec 27 01:51:11 EST 2012
* Introduced the macro CORE_GPREGS to access machine general-purpose registers
in a machine-independent way.
* Introduced the macro get_core_tls to extract the thread TLS value from
the thread core in a machine-independent way.
* Fetch saved AUXV in a machine-independent way.
Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
arch/x86/include/asm/restore.h | 4 ++++
cr-restore.c | 22 ++++++++++++----------
include/restorer.h | 2 +-
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/arch/x86/include/asm/restore.h b/arch/x86/include/asm/restore.h
index 08e3b4b..d0b5fab 100644
--- a/arch/x86/include/asm/restore.h
+++ b/arch/x86/include/asm/restore.h
@@ -15,4 +15,8 @@
"g"(task_args) \
: "rsp", "rdi", "rsi", "rbx", "rax", "memory")
+#define CORE_GPREGS(core) (core->thread_info->gpregs)
+
+#define get_core_tls(x, y)
+
#endif
diff --git a/cr-restore.c b/cr-restore.c
index 8046ddc..abdd6e2 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -705,7 +705,7 @@ static int check_core(CoreEntry *core)
{
int ret = -1;
- if (core->mtype != CORE_ENTRY__MARCH__X86_64) {
+ if (core->mtype != CORE_ENTRY__MARCH) {
pr_err("Core march mismatch %d\n", (int)core->mtype);
goto out;
}
@@ -721,7 +721,7 @@ static int check_core(CoreEntry *core)
goto out;
}
- if (!core->thread_info) {
+ if (!CORE_THREAD_INFO(core)) {
pr_err("Core info data missed for non-zombie\n");
goto out;
}
@@ -1245,7 +1245,6 @@ int cr_restore_tasks(pid_t pid, struct cr_options *opts)
return restore_root_task(root_item, opts);
}
-#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
static long restorer_get_vma_hint(pid_t pid, struct list_head *tgt_vma_list,
struct list_head *self_vma_list, long vma_len)
{
@@ -1253,7 +1252,7 @@ static long restorer_get_vma_hint(pid_t pid, struct list_head *tgt_vma_list,
long prev_vma_end = 0;
struct vma_area end_vma;
- end_vma.vma.start = end_vma.vma.end = TASK_SIZE_MAX;
+ end_vma.vma.start = end_vma.vma.end = TASK_SIZE;
prev_vma_end = PAGE_SIZE * 0x10; /* CONFIG_LSM_MMAP_MIN_ADDR=65536 */
s_vma = list_first_entry(self_vma_list, struct vma_area, list);
@@ -1453,7 +1452,7 @@ static VmaEntry *vma_list_remap(void *addr, unsigned long len, struct list_head
static int prepare_mm(pid_t pid, struct task_restore_core_args *args)
{
- int fd, exe_fd, ret = -1;
+ int fd, exe_fd, i, ret = -1;
MmEntry *mm;
fd = open_image_ro(CR_FD_MM, pid);
@@ -1475,8 +1474,10 @@ static int prepare_mm(pid_t pid, struct task_restore_core_args *args)
}
args->mm_saved_auxv_size = pb_repeated_size(mm, mm_saved_auxv);
- memcpy(args->mm_saved_auxv, mm->mm_saved_auxv,
- args->mm_saved_auxv_size);
+
+ for (i = 0; i < mm->n_mm_saved_auxv; ++i) {
+ args->mm_saved_auxv[i] = (auxv_t)mm->mm_saved_auxv[i];
+ }
exe_fd = open_reg_by_id(args->mm.exe_file_id);
if (exe_fd < 0)
@@ -1848,7 +1849,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
* Arguments for task restoration.
*/
- BUG_ON(core->mtype != CORE_ENTRY__MARCH__X86_64);
+ BUG_ON(core->mtype != CORE_ENTRY__MARCH);
task_args->logfd = log_get_fd();
task_args->loglevel = log_get_loglevel();
@@ -1894,8 +1895,9 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
}
thread_args[i].ta = task_args;
- thread_args[i].gpregs = *tcore->thread_info->gpregs;
- thread_args[i].clear_tid_addr = tcore->thread_info->clear_tid_addr;
+ thread_args[i].gpregs = *CORE_GPREGS(tcore);
+ thread_args[i].clear_tid_addr = CORE_THREAD_INFO(tcore)->clear_tid_addr;
+ get_core_tls(tcore, &thread_args[i].tls);
if (tcore->thread_core) {
thread_args[i].has_futex = true;
diff --git a/include/restorer.h b/include/restorer.h
index 3bb40b9..febdf6f 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -122,7 +122,7 @@ struct task_restore_core_args {
uint32_t cap_bnd[CR_CAP_SIZE];
MmEntry mm;
- u64 mm_saved_auxv[AT_VECTOR_SIZE];
+ auxv_t mm_saved_auxv[AT_VECTOR_SIZE];
u32 mm_saved_auxv_size;
char comm[TASK_COMM_LEN];
uint32_t tls;
--
1.7.10.4
More information about the CRIU
mailing list