[CRIU] [PATCH 3/4] arch: x86 -- Add dumping of vDSO layout

Pavel Emelyanov xemul at parallels.com
Wed Apr 17 09:00:05 EDT 2013


On 04/16/2013 10:27 PM, Cyrill Gorcunov wrote:
> 
> Here we introduce vDSO dumping. Because vDSO is generated by a kernel
> and all processes in a system do host the same vDSO content, we simply
> dump own crtools vDSO not touching dumpee memory at all.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  arch/x86/Makefile  |   1 +
>  arch/x86/crtools.c |  68 ++++++++++++++++++++++
>  arch/x86/vdso.c    | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  cr-dump.c          |   4 ++
>  include/vdso.h     |  98 +++++++++++++++++++++++++++++++
>  5 files changed, 336 insertions(+)
>  create mode 100644 arch/x86/vdso.c
>  create mode 100644 include/vdso.h
> 


> +int arch_fill_self_vdso(symtable_t *t)
> +{
> +	char buf[512];
> +	int ret = -1;
> +	FILE *maps;
> +
> +	maps = fopen("/proc/self/maps", "r");

We do maps parsing already. Just utilize root task's vdso info for that.
All the more so different tasks may have different VDSOs in the future
(32-bit support).

> +	if (!maps) {
> +		pr_perror("Can't open self-vma");
> +		return -1;
> +	}
> +
> +	while (fgets(buf, sizeof(buf), maps)) {
> +		unsigned long start, end;
> +
> +		if (strstr(buf, "[vdso]") == NULL)
> +			continue;
> +
> +		ret = sscanf(buf, "%lx-%lx", &start, &end);
> +		if (ret != 2) {
> +			ret = -1;
> +			pr_err("Can't find vDSO bounds\n");
> +			break;
> +		}
> +
> +		pr_debug("vdso: Got area %lx-%lx\n", start, end);
> +
> +		t->vma_start = start;
> +		t->vma_end = end;
> +		ret = arch_parse_vdso((void *)start, end - start, t);
> +		break;
> +	}
> +
> +	fclose(maps);
> +	return ret;
> +}

> +	for (i = 0; ret == 0 && i < VDSO_SYMBOL_MAX; i++) {

Plz use explicit if (ret) break; below

> +		symbol.name = t.sym[i].name;
> +		symbol.offset = t.sym[i].offset;
> +		ret = pb_write_one(fd, &symbol, PB_VDSO);
> +	}

> --- /dev/null
> +++ b/include/vdso.h

Not all code below is used in non-arch code. Plz revisit.

> +#if CONFIG_X86_64

Not nice.

> +extern const char *arch_vdso_get_symbol_name(unsigned int index);
> +extern unsigned int arch_vdso_get_symbol_index(char *symbol);
> +extern int arch_fill_self_vdso(symtable_t *t);
> +extern int arch_dump_vdso_layout(void);
> +extern int arch_parse_vdso(char *mem, size_t size, symtable_t *t);
> +#else
> +extern const char *arch_vdso_get_symbol_name(unsigned int index) { return NULL; }
> +static inline unsigned int arch_vdso_get_symbol_index(char *symbol) { return VDSO_SYMBOL_MAX; };
> +static inline int arch_fill_self_vdso(symtable_t *t) { return 0; }
> +static inline int arch_dump_vdso_layout(void) { }
> +static inline int arch_parse_vdso(char *mem, size_t size, symtable_t *t) { return 0; }
> +#endif



More information about the CRIU mailing list