~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/string_64.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _ASM_X86_STRING_64_H
  3 #define _ASM_X86_STRING_64_H
  4 
  5 #ifdef __KERNEL__
  6 #include <linux/jump_label.h>
  7 
  8 /* Written 2002 by Andi Kleen */
  9 
 10 /* Even with __builtin_ the compiler may decide to use the out of line
 11    function. */
 12 
 13 #if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY)
 14 #include <linux/kmsan_string.h>
 15 #endif
 16 
 17 #define __HAVE_ARCH_MEMCPY 1
 18 extern void *memcpy(void *to, const void *from, size_t len);
 19 extern void *__memcpy(void *to, const void *from, size_t len);
 20 
 21 #define __HAVE_ARCH_MEMSET
 22 void *memset(void *s, int c, size_t n);
 23 void *__memset(void *s, int c, size_t n);
 24 
 25 /*
 26  * KMSAN needs to instrument as much code as possible. Use C versions of
 27  * memsetXX() from lib/string.c under KMSAN.
 28  */
 29 #if !defined(CONFIG_KMSAN)
 30 #define __HAVE_ARCH_MEMSET16
 31 static inline void *memset16(uint16_t *s, uint16_t v, size_t n)
 32 {
 33         const __auto_type s0 = s;
 34         asm volatile (
 35                 "rep stosw"
 36                 : "+D" (s), "+c" (n)
 37                 : "a" (v)
 38                 : "memory"
 39         );
 40         return s0;
 41 }
 42 
 43 #define __HAVE_ARCH_MEMSET32
 44 static inline void *memset32(uint32_t *s, uint32_t v, size_t n)
 45 {
 46         const __auto_type s0 = s;
 47         asm volatile (
 48                 "rep stosl"
 49                 : "+D" (s), "+c" (n)
 50                 : "a" (v)
 51                 : "memory"
 52         );
 53         return s0;
 54 }
 55 
 56 #define __HAVE_ARCH_MEMSET64
 57 static inline void *memset64(uint64_t *s, uint64_t v, size_t n)
 58 {
 59         const __auto_type s0 = s;
 60         asm volatile (
 61                 "rep stosq"
 62                 : "+D" (s), "+c" (n)
 63                 : "a" (v)
 64                 : "memory"
 65         );
 66         return s0;
 67 }
 68 #endif
 69 
 70 #define __HAVE_ARCH_MEMMOVE
 71 void *memmove(void *dest, const void *src, size_t count);
 72 void *__memmove(void *dest, const void *src, size_t count);
 73 
 74 int memcmp(const void *cs, const void *ct, size_t count);
 75 size_t strlen(const char *s);
 76 char *strcpy(char *dest, const char *src);
 77 char *strcat(char *dest, const char *src);
 78 int strcmp(const char *cs, const char *ct);
 79 
 80 #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
 81 #define __HAVE_ARCH_MEMCPY_FLUSHCACHE 1
 82 void __memcpy_flushcache(void *dst, const void *src, size_t cnt);
 83 static __always_inline void memcpy_flushcache(void *dst, const void *src, size_t cnt)
 84 {
 85         if (__builtin_constant_p(cnt)) {
 86                 switch (cnt) {
 87                         case 4:
 88                                 asm ("movntil %1, %0" : "=m"(*(u32 *)dst) : "r"(*(u32 *)src));
 89                                 return;
 90                         case 8:
 91                                 asm ("movntiq %1, %0" : "=m"(*(u64 *)dst) : "r"(*(u64 *)src));
 92                                 return;
 93                         case 16:
 94                                 asm ("movntiq %1, %0" : "=m"(*(u64 *)dst) : "r"(*(u64 *)src));
 95                                 asm ("movntiq %1, %0" : "=m"(*(u64 *)(dst + 8)) : "r"(*(u64 *)(src + 8)));
 96                                 return;
 97                 }
 98         }
 99         __memcpy_flushcache(dst, src, cnt);
100 }
101 #endif
102 
103 #endif /* __KERNEL__ */
104 
105 #endif /* _ASM_X86_STRING_64_H */
106 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php