Commit 7451fc7d authored by Christopher Covington's avatar Christopher Covington Committed by Pavel Emelyanov

restorer: Replace most hard-coded TASK_SIZE use

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: 's avatarChristopher Covington <cov@codeaurora.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c0c0546c
...@@ -2893,6 +2893,8 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core) ...@@ -2893,6 +2893,8 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
task_args->premmapped_addr = (unsigned long)rsti(current)->premmapped_addr; task_args->premmapped_addr = (unsigned long)rsti(current)->premmapped_addr;
task_args->premmapped_len = rsti(current)->premmapped_len; task_args->premmapped_len = rsti(current)->premmapped_len;
task_args->task_size = kdat.task_size;
#define remap_array(name, nr, cpos) do { \ #define remap_array(name, nr, cpos) do { \
task_args->name##_n = nr; \ task_args->name##_n = nr; \
task_args->name = rst_mem_remap_ptr(cpos, RM_PRIVATE); \ task_args->name = rst_mem_remap_ptr(cpos, RM_PRIVATE); \
......
...@@ -139,6 +139,7 @@ struct task_restore_args { ...@@ -139,6 +139,7 @@ struct task_restore_args {
unsigned int zombies_n; unsigned int zombies_n;
/* * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * */
unsigned long task_size;
unsigned long premmapped_addr; unsigned long premmapped_addr;
unsigned long premmapped_len; unsigned long premmapped_len;
rt_sigaction_t sigchld_act; rt_sigaction_t sigchld_act;
......
...@@ -727,16 +727,17 @@ void __export_unmap(void) ...@@ -727,16 +727,17 @@ void __export_unmap(void)
* and arguments and the one with private vmas of the tasks we restore * and arguments and the one with private vmas of the tasks we restore
* (a.k.a. premmaped area): * (a.k.a. premmaped area):
* *
* 0 TASK_SIZE * 0 task_size
* +----+====+----+====+---+ * +----+====+----+====+---+
* *
* Thus to unmap old memory we have to do 3 unmaps: * Thus to unmap old memory we have to do 3 unmaps:
* [ 0 -- 1st area start ] * [ 0 -- 1st area start ]
* [ 1st end -- 2nd 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, 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; unsigned long s1, s2;
void *p1, *p2; void *p1, *p2;
...@@ -766,10 +767,10 @@ static int unmap_old_vmas(void *premmapped_addr, unsigned long premmapped_len, ...@@ -766,10 +767,10 @@ static int unmap_old_vmas(void *premmapped_addr, unsigned long premmapped_len,
return -1; 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) { if (ret) {
pr_err("Unable to unmap (%p-%p): %d\n", pr_err("Unable to unmap (%p-%p): %d\n",
p2 + s2, (void *)TASK_SIZE, ret); p2 + s2, (void *)task_size, ret);
return -1; return -1;
} }
...@@ -870,7 +871,7 @@ long __export_restore_task(struct task_restore_args *args) ...@@ -870,7 +871,7 @@ long __export_restore_task(struct task_restore_args *args)
goto core_restore_end; goto core_restore_end;
if (unmap_old_vmas((void *)args->premmapped_addr, args->premmapped_len, 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; goto core_restore_end;
/* Shift private vma-s to the left */ /* Shift private vma-s to the left */
...@@ -880,7 +881,7 @@ long __export_restore_task(struct task_restore_args *args) ...@@ -880,7 +881,7 @@ long __export_restore_task(struct task_restore_args *args)
if (!vma_entry_is_private(vma_entry)) if (!vma_entry_is_private(vma_entry))
continue; continue;
if (vma_entry->end >= TASK_SIZE) if (vma_entry->end >= args->task_size)
continue; continue;
if (vma_entry->start > vma_entry->shmid) if (vma_entry->start > vma_entry->shmid)
...@@ -898,7 +899,7 @@ long __export_restore_task(struct task_restore_args *args) ...@@ -898,7 +899,7 @@ long __export_restore_task(struct task_restore_args *args)
if (!vma_entry_is_private(vma_entry)) if (!vma_entry_is_private(vma_entry))
continue; continue;
if (vma_entry->start > TASK_SIZE) if (vma_entry->start > args->task_size)
continue; continue;
if (vma_entry->start < vma_entry->shmid) if (vma_entry->start < vma_entry->shmid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment