[CRIU] [PATCH 4/4] vdso: Generate vdso proxy on restore if needed

Pavel Emelyanov xemul at parallels.com
Wed May 22 05:03:43 EDT 2013


On 05/22/2013 12:37 PM, Cyrill Gorcunov wrote:
> 
> With help of vdso engine detect if we need vdso proxy
> and then generate one.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  cr-restore.c       | 28 +++++++++++++++++++++++++---
>  include/restorer.h |  4 ++++
>  pie/restorer.c     | 43 +++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 72 insertions(+), 3 deletions(-)
> 


> --- a/pie/restorer.c
> +++ b/pie/restorer.c
> @@ -492,6 +492,7 @@ long __export_restore_task(struct task_restore_core_args *args)
>  	u64 va;
>  	unsigned long premmapped_end = args->premmapped_addr + args->premmapped_len;
>  
> +	symtable_t *sym_rt = &args->vdso_proxy.sym_rt;
>  	struct rt_sigframe *rt_sigframe;
>  	unsigned long new_sp;
>  	pid_t my_pid = sys_getpid();
> @@ -521,6 +522,22 @@ long __export_restore_task(struct task_restore_core_args *args)
>  
>  		pr_debug("Examine %"PRIx64"-%"PRIx64"\n", vma_entry->start, vma_entry->end);
>  
> +
> +		/*
> +		 * If we have runtime vdso, it must be remaped at
> +		 * known place. Then we either substitude dumpee
> +		 * vdso or mark it if proxy needed.
> +		 */
> +		if (vma_entry_is(vma_entry, VMA_AREA_VDSO)) {
> +			BUG_ON(vma_entry->start != sym_rt->vma_start);
> +
> +			if (vdso_remap("rt-vdso", sym_rt->vma_start,
> +				       args->vdso_proxy.remap_rt_at,
> +				       symtable_vma_size(sym_rt)))
> +				goto core_restore_end;
> +			continue;
> +		}
> +
>  		if (addr < args->premmapped_addr) {
>  			if (vma_entry->end >= args->premmapped_addr)
>  				len = args->premmapped_addr - addr;
> @@ -566,6 +583,16 @@ long __export_restore_task(struct task_restore_core_args *args)
>  		if (vma_remap(vma_premmaped_start(vma_entry),
>  				vma_entry->start, vma_entry_len(vma_entry)))
>  			goto core_restore_end;
> +
> +		if (vma_entry_is(vma_entry, VMA_AREA_VDSO) && args->vdso_proxy.directly) {
> +			BUG_ON(vma_entry_len(vma_entry) != symtable_vma_size(sym_rt));
> +
> +			if (vdso_remap("rt-vdso from left",
> +				       args->vdso_proxy.remap_rt_at,
> +				       vma_entry->start,
> +				       symtable_vma_size(sym_rt)))
> +				goto core_restore_end;
> +		}
>  	}
>  
>  	/* Shift private vma-s to the right */
> @@ -586,6 +613,16 @@ long __export_restore_task(struct task_restore_core_args *args)
>  		if (vma_remap(vma_premmaped_start(vma_entry),
>  				vma_entry->start, vma_entry_len(vma_entry)))
>  			goto core_restore_end;
> +
> +		if (vma_entry_is(vma_entry, VMA_AREA_VDSO) && args->vdso_proxy.directly) {
> +			BUG_ON(vma_entry_len(vma_entry) != symtable_vma_size(sym_rt));
> +
> +			if (vdso_remap("rt-vdso from right",
> +				       args->vdso_proxy.remap_rt_at,
> +				       vma_entry->start,
> +				       symtable_vma_size(sym_rt)))
> +				goto core_restore_end;
> +		}
>  	}
>  
>  	/*
> @@ -607,6 +644,12 @@ long __export_restore_task(struct task_restore_core_args *args)
>  	}
>  
>  	/*
> +	 * Don't forget to put vdso mark, so next
> +	 * checkpoint will detect it.
> +	 */
> +	vdso_put_mark(&args->vdso_proxy);
> +
> +	/*
>  	 * Walk though all VMAs again to drop PROT_WRITE
>  	 * if it was not there.
>  	 */

I don't understand why this code is scattered over the restorer. Can't we
mark proxy in crtools? Why? Can't we prepare the vma_entry with proxy so that
the generic restorer code remaps it in proper position? Why?


More information about the CRIU mailing list