[CRIU] [PATCH 4/4] x86/compat: provide optimized memcpy_x86

Dmitry Safonov dsafonov at virtuozzo.com
Tue Nov 22 05:28:08 PST 2016


On 11/22/2016 04:26 PM, Pavel Emelyanov wrote:
> On 11/22/2016 02:42 PM, Dmitry Safonov wrote:
>> Implementation for PIE's builtin_memcpy located at
>> criu/arch/x86/include/asm/string.h
>>
>> Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
>> ---
>>  criu/arch/x86/compat/memcpy-compat.c | 25 +++++++++++++++++++++++++
>>  1 file changed, 25 insertions(+)
>>  create mode 100644 criu/arch/x86/compat/memcpy-compat.c
>>
>> diff --git a/criu/arch/x86/compat/memcpy-compat.c b/criu/arch/x86/compat/memcpy-compat.c
>> new file mode 100644
>> index 000000000000..793c27dcaa7d
>> --- /dev/null
>> +++ b/criu/arch/x86/compat/memcpy-compat.c
>
> Another memcpy for pie? Shouldn't they all be in compel?

Hmm, 64-bit memcpy lays here, AFAICS:
criu/arch/x86/memcpy.S

But anyway, skip this patch for a while - with 32-bit entry and 64-bit
working parasite I will not need this - left the patch only for the
purpose if we gonna support native 32-bit build.

>
>> @@ -0,0 +1,25 @@
>> +#include <stddef.h>
>> +
>> +/*
>> + * This provides an optimized implementation of memcpy, and a simplified
>> + * implementation of memset and memmove. These are used here because the
>> + * standard kernel runtime versions are not yet available and we don't
>> + * trust the gcc built-in implementations as they may do unexpected things
>> + * (e.g. FPU ops) in the minimal decompression stub execution environment.
>> + *
>> + * From Linux kernel boot helpers: arch/x86/boot/compressed/string.c
>> + */
>> +
>> +void *memcpy_x86(void *dest, const void *src, size_t n)
>> +{
>> +	int d0, d1, d2;
>> +	asm volatile(
>> +		"rep ; movsl\n\t"
>> +		"movl %4,%%ecx\n\t"
>> +		"rep ; movsb\n\t"
>> +		: "=&c" (d0), "=&D" (d1), "=&S" (d2)
>> +		: "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
>> +		: "memory");
>> +
>> +	return dest;
>> +}
>>
>


-- 
              Dmitry


More information about the CRIU mailing list