mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +00:00
restore: Iterate tgt vmas by number, not by terminating point
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
55a04580d5
commit
d7db85e9dc
@ -2000,7 +2000,7 @@ static VmaEntry *vma_list_remap(void *addr, unsigned long len, struct vm_area_li
|
|||||||
vma++;
|
vma++;
|
||||||
}
|
}
|
||||||
|
|
||||||
vma->start = 0;
|
vma->start = 1;
|
||||||
free_mappings(vmas);
|
free_mappings(vmas);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -578,6 +578,7 @@ static int unmap_old_vmas(void *premmapped_addr, unsigned long premmapped_len,
|
|||||||
long __export_restore_task(struct task_restore_core_args *args)
|
long __export_restore_task(struct task_restore_core_args *args)
|
||||||
{
|
{
|
||||||
long ret = -1;
|
long ret = -1;
|
||||||
|
int i;
|
||||||
VmaEntry *vma_entry;
|
VmaEntry *vma_entry;
|
||||||
unsigned long va;
|
unsigned long va;
|
||||||
|
|
||||||
@ -615,7 +616,9 @@ long __export_restore_task(struct task_restore_core_args *args)
|
|||||||
goto core_restore_end;
|
goto core_restore_end;
|
||||||
|
|
||||||
/* Shift private vma-s to the left */
|
/* Shift private vma-s to the left */
|
||||||
for (vma_entry = args->tgt_vmas; vma_entry->start != 0; vma_entry++) {
|
for (i = 0; i < args->nr_vmas; i++) {
|
||||||
|
vma_entry = args->tgt_vmas + i;
|
||||||
|
|
||||||
if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
|
if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -640,8 +643,9 @@ long __export_restore_task(struct task_restore_core_args *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Shift private vma-s to the right */
|
/* Shift private vma-s to the right */
|
||||||
for (vma_entry = args->tgt_vmas + args->nr_vmas -1;
|
for (i = args->nr_vmas - 1; i >= 0; i--) {
|
||||||
vma_entry >= args->tgt_vmas; vma_entry--) {
|
vma_entry = args->tgt_vmas + i;
|
||||||
|
|
||||||
if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
|
if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -668,7 +672,9 @@ long __export_restore_task(struct task_restore_core_args *args)
|
|||||||
/*
|
/*
|
||||||
* OK, lets try to map new one.
|
* OK, lets try to map new one.
|
||||||
*/
|
*/
|
||||||
for (vma_entry = args->tgt_vmas; vma_entry->start != 0; vma_entry++) {
|
for (i = 0; i < args->nr_vmas; i++) {
|
||||||
|
vma_entry = args->tgt_vmas + i;
|
||||||
|
|
||||||
if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
|
if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -687,7 +693,9 @@ long __export_restore_task(struct task_restore_core_args *args)
|
|||||||
* Walk though all VMAs again to drop PROT_WRITE
|
* Walk though all VMAs again to drop PROT_WRITE
|
||||||
* if it was not there.
|
* if it was not there.
|
||||||
*/
|
*/
|
||||||
for (vma_entry = args->tgt_vmas; vma_entry->start != 0; vma_entry++) {
|
for (i = 0; i < args->nr_vmas; i++) {
|
||||||
|
vma_entry = args->tgt_vmas + i;
|
||||||
|
|
||||||
if (!(vma_entry_is(vma_entry, VMA_AREA_REGULAR)))
|
if (!(vma_entry_is(vma_entry, VMA_AREA_REGULAR)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -712,30 +720,31 @@ long __export_restore_task(struct task_restore_core_args *args)
|
|||||||
/*
|
/*
|
||||||
* Finally restore madivse() bits
|
* Finally restore madivse() bits
|
||||||
*/
|
*/
|
||||||
for (vma_entry = args->tgt_vmas; vma_entry->start != 0; vma_entry++) {
|
for (i = 0; i < args->nr_vmas; i++) {
|
||||||
unsigned long i;
|
unsigned long m;
|
||||||
|
|
||||||
|
vma_entry = args->tgt_vmas + i;
|
||||||
if (!vma_entry->has_madv || !vma_entry->madv)
|
if (!vma_entry->has_madv || !vma_entry->madv)
|
||||||
continue;
|
continue;
|
||||||
for (i = 0; i < sizeof(vma_entry->madv) * 8; i++) {
|
|
||||||
if (vma_entry->madv & (1ul << i)) {
|
for (m = 0; m < sizeof(vma_entry->madv) * 8; m++) {
|
||||||
|
if (vma_entry->madv & (1ul << m)) {
|
||||||
ret = sys_madvise(vma_entry->start,
|
ret = sys_madvise(vma_entry->start,
|
||||||
vma_entry_len(vma_entry),
|
vma_entry_len(vma_entry),
|
||||||
i);
|
m);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_err("madvise(%"PRIx64", %"PRIu64", %ld) "
|
pr_err("madvise(%"PRIx64", %"PRIu64", %ld) "
|
||||||
"failed with %ld\n",
|
"failed with %ld\n",
|
||||||
vma_entry->start,
|
vma_entry->start,
|
||||||
vma_entry_len(vma_entry),
|
vma_entry_len(vma_entry),
|
||||||
i, ret);
|
m, ret);
|
||||||
goto core_restore_end;
|
goto core_restore_end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sys_munmap(args->tgt_vmas,
|
sys_munmap(args->tgt_vmas, args->nr_vmas * sizeof(VmaEntry));
|
||||||
((void *)(vma_entry + 1) - ((void *)args->tgt_vmas)));
|
|
||||||
|
|
||||||
ret = sys_munmap(args->shmems, SHMEMS_SIZE);
|
ret = sys_munmap(args->shmems, SHMEMS_SIZE);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user