[CRIU] [PATCHv2 26/26] x86: restore TLS

Cyrill Gorcunov gorcunov at gmail.com
Mon Jun 20 06:24:19 PDT 2016


On Mon, Jun 20, 2016 at 04:18:10PM +0300, Dmitry Safonov wrote:
> +
> +static void __restore_tls(tls_t *ptls)
> +{
> +	char *stack32 = (void*)sys_mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
> +				MAP_32BIT | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
> +	int i;
> +
> +	if (stack32 == MAP_FAILED) {
> +		pr_err("Failed to allocate stack for 32-bit TLS restore\n");
> +		return;
> +	}
> +
> +	for (i = 0; i < GDT_ENTRY_TLS_NUM; i++) {
> +		user_desc_t *desc = &ptls->desc[i];
> +		int ret;
> +
> +		if (desc->seg_not_present)
> +			continue;
> +
> +		memcpy(stack32, desc, sizeof(user_desc_t));

You happend to have memcpy inlined, but this won't be always the case,
so use builtin_memcpy instead.


More information about the CRIU mailing list