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

Dmitry Safonov dsafonov at virtuozzo.com
Mon Jun 20 06:32:28 PDT 2016


On 06/20/2016 04:24 PM, Cyrill Gorcunov wrote:
> 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.

Oh, yep, thanks - will add to v3 resend.



More information about the CRIU mailing list