blob: 4130734dde84b2ed8ce36199202ee0e91308bb0a [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/*
2 * From code in arch/x86/lib/usercopy_64.c, copied to keep tools/ copy
3 * of the kernel's arch/x86/lib/memcpy_64.s used in 'perf bench mem memcpy'
4 * happy.
5 */
6#include <linux/types.h>
7
8unsigned long __memcpy_mcsafe(void *dst, const void *src, size_t cnt);
9unsigned long mcsafe_handle_tail(char *to, char *from, unsigned len);
10
11unsigned long mcsafe_handle_tail(char *to, char *from, unsigned len)
12{
13 for (; len; --len, to++, from++) {
14 /*
15 * Call the assembly routine back directly since
16 * memcpy_mcsafe() may silently fallback to memcpy.
17 */
18 unsigned long rem = __memcpy_mcsafe(to, from, 1);
19
20 if (rem)
21 break;
22 }
23 return len;
24}