[CRIU] [PATCH 2/4] restorer: Replace most hard-coded TASK_SIZE use

Christopher Covington cov at codeaurora.org
Fri Jul 31 07:36:25 PDT 2015


If we want one CRIU binary to work across all AArch64 kernel
configurations, a single task size value cannot be hard coded.
This fixes the following error on AArch64 kernels with
CONFIG_ARM64_64K_PAGES=y.

  pie: Error (pie/restorer.c:772): Unable to unmap (-): -1211695104

Signed-off-by: Christopher Covington <cov at codeaurora.org>
---
 cr-restore.c       |  2 ++
 include/restorer.h |  1 +
 pie/restorer.c     | 17 +++++++++--------
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index f7c13a8..82be8e1 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -2886,6 +2886,8 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
 	task_args->premmapped_addr = (unsigned long)rsti(current)->premmapped_addr;
 	task_args->premmapped_len = rsti(current)->premmapped_len;
 
+	task_args->task_size = kdat.task_size;
+
 #define remap_array(name, nr, cpos)	do {				\
 		task_args->name##_n = nr;				\
 		task_args->name = rst_mem_remap_ptr(cpos, RM_PRIVATE);	\
diff --git a/include/restorer.h b/include/restorer.h
index 97a012c..56b9938 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -139,6 +139,7 @@ struct task_restore_args {
 	unsigned int			zombies_n;
 	/* * * * * * * * * * * * * * * * * * * * */
 
+	unsigned long			task_size;
 	unsigned long			premmapped_addr;
 	unsigned long			premmapped_len;
 	rt_sigaction_t			sigchld_act;
diff --git a/pie/restorer.c b/pie/restorer.c
index 3bdb5a3..95ad2c7 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -727,16 +727,17 @@ void __export_unmap(void)
  * and arguments and the one with private vmas of the tasks we restore
  * (a.k.a. premmaped area):
  *
- * 0                       TASK_SIZE
+ * 0                       task_size
  * +----+====+----+====+---+
  *
  * Thus to unmap old memory we have to do 3 unmaps:
  * [ 0 -- 1st area start ]
  * [ 1st end -- 2nd start ]
- * [ 2nd start -- TASK_SIZE ]
+ * [ 2nd start -- task_size ]
  */
 static int unmap_old_vmas(void *premmapped_addr, unsigned long premmapped_len,
-		      void *bootstrap_start, unsigned long bootstrap_len)
+		      void *bootstrap_start, unsigned long bootstrap_len,
+		      unsigned long task_size)
 {
 	unsigned long s1, s2;
 	void *p1, *p2;
@@ -766,10 +767,10 @@ static int unmap_old_vmas(void *premmapped_addr, unsigned long premmapped_len,
 		return -1;
 	}
 
-	ret = sys_munmap(p2 + s2, (void *) TASK_SIZE - (p2 + s2));
+	ret = sys_munmap(p2 + s2, task_size - (unsigned long)(p2 + s2));
 	if (ret) {
 		pr_err("Unable to unmap (%p-%p): %d\n",
-				p2 + s2, (void *)TASK_SIZE, ret);
+				p2 + s2, (void *)task_size, ret);
 		return -1;
 	}
 
@@ -871,7 +872,7 @@ long __export_restore_task(struct task_restore_args *args)
 		goto core_restore_end;
 
 	if (unmap_old_vmas((void *)args->premmapped_addr, args->premmapped_len,
-				bootstrap_start, bootstrap_len))
+				bootstrap_start, bootstrap_len, args->task_size))
 		goto core_restore_end;
 
 	/* Shift private vma-s to the left */
@@ -881,7 +882,7 @@ long __export_restore_task(struct task_restore_args *args)
 		if (!vma_entry_is_private(vma_entry))
 			continue;
 
-		if (vma_entry->end >= TASK_SIZE)
+		if (vma_entry->end >= args->task_size)
 			continue;
 
 		if (vma_entry->start > vma_entry->shmid)
@@ -899,7 +900,7 @@ long __export_restore_task(struct task_restore_args *args)
 		if (!vma_entry_is_private(vma_entry))
 			continue;
 
-		if (vma_entry->start > TASK_SIZE)
+		if (vma_entry->start > args->task_size)
 			continue;
 
 		if (vma_entry->start < vma_entry->shmid)
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



More information about the CRIU mailing list