[CRIU] [PATCH 33/44] auxv: save and restore AUXV's in a machine-independent way.
Alexander Kartashov
alekskartashov at parallels.com
Mon Jan 7 10:05:02 EST 2013
The size of an auxv is the machine pointer but a 64-bit integer is reserved
in a MmEntry protobuf message to store an auxv. Moreover the number of auxv's
varies from one architecture to another. So the following is proposed
to alleviate the issue.
* Introduced the type auxv_t representing a machine-pointer sized integer.
* The size of auxv array is extracted from a MmEntry message instead of using
the value of the macro AT_VECTOR_SIZE.
Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
arch/x86/include/asm/types.h | 2 ++
cr-dump.c | 4 ++--
cr-restore.c | 9 +++++----
include/restorer.h | 2 +-
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
index 626b9ac..9722c99 100644
--- a/arch/x86/include/asm/types.h
+++ b/arch/x86/include/asm/types.h
@@ -258,4 +258,6 @@ typedef struct {
#define TI_SP(core) ((core)->thread_info->gpregs->sp)
+typedef uint64_t auxv_t;
+
#endif /* __CR_ASM_TYPES_H__ */
diff --git a/cr-dump.c b/cr-dump.c
index 6b700d2..ff41fe0 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -548,10 +548,10 @@ static int get_task_auxv(pid_t pid, MmEntry *mm, size_t *size)
for (i = 0; i < AT_VECTOR_SIZE; i++) {
ret = read(fd, &mm->mm_saved_auxv[i],
- sizeof(mm->mm_saved_auxv[0]));
+ sizeof(auxv_t));
if (ret == 0)
break;
- else if (ret != sizeof(mm->mm_saved_auxv[0])) {
+ else if (ret != sizeof(auxv_t)) {
ret = -1;
pr_perror("Error readind %d's auxv[%d]",
pid, i);
diff --git a/cr-restore.c b/cr-restore.c
index ec5bd4c..43c3193 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1451,7 +1451,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);
@@ -1472,9 +1472,10 @@ static int prepare_mm(pid_t pid, struct task_restore_core_args *args)
goto out;
}
- 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);
+ args->mm_saved_auxv_size = mm->n_mm_saved_auxv*sizeof(auxv_t);
+ 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)
diff --git a/include/restorer.h b/include/restorer.h
index c6a4601..e6f6c6e 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -121,7 +121,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];
--
1.7.10.4
More information about the CRIU
mailing list