1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
24baa9922SRussell King #ifndef __ASM_ARM_STRING_H
34baa9922SRussell King #define __ASM_ARM_STRING_H
44baa9922SRussell King
54baa9922SRussell King /*
64baa9922SRussell King * We don't do inline string functions, since the
74baa9922SRussell King * optimised inline asm versions are not small.
8*d6d51a96SLinus Walleij *
9*d6d51a96SLinus Walleij * The __underscore versions of some functions are for KASan to be able
10*d6d51a96SLinus Walleij * to replace them with instrumented versions.
114baa9922SRussell King */
124baa9922SRussell King
134baa9922SRussell King #define __HAVE_ARCH_STRRCHR
144baa9922SRussell King extern char * strrchr(const char * s, int c);
154baa9922SRussell King
164baa9922SRussell King #define __HAVE_ARCH_STRCHR
174baa9922SRussell King extern char * strchr(const char * s, int c);
184baa9922SRussell King
194baa9922SRussell King #define __HAVE_ARCH_MEMCPY
204baa9922SRussell King extern void * memcpy(void *, const void *, __kernel_size_t);
21*d6d51a96SLinus Walleij extern void *__memcpy(void *dest, const void *src, __kernel_size_t n);
224baa9922SRussell King
234baa9922SRussell King #define __HAVE_ARCH_MEMMOVE
244baa9922SRussell King extern void * memmove(void *, const void *, __kernel_size_t);
25*d6d51a96SLinus Walleij extern void *__memmove(void *dest, const void *src, __kernel_size_t n);
264baa9922SRussell King
274baa9922SRussell King #define __HAVE_ARCH_MEMCHR
284baa9922SRussell King extern void * memchr(const void *, int, __kernel_size_t);
294baa9922SRussell King
304baa9922SRussell King #define __HAVE_ARCH_MEMSET
314baa9922SRussell King extern void * memset(void *, int, __kernel_size_t);
32*d6d51a96SLinus Walleij extern void *__memset(void *s, int c, __kernel_size_t n);
334baa9922SRussell King
34fd1d3626SMatthew Wilcox #define __HAVE_ARCH_MEMSET32
35fd1d3626SMatthew Wilcox extern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t);
memset32(uint32_t * p,uint32_t v,__kernel_size_t n)36fd1d3626SMatthew Wilcox static inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
37fd1d3626SMatthew Wilcox {
38fd1d3626SMatthew Wilcox return __memset32(p, v, n * 4);
39fd1d3626SMatthew Wilcox }
40fd1d3626SMatthew Wilcox
41fd1d3626SMatthew Wilcox #define __HAVE_ARCH_MEMSET64
42fd1d3626SMatthew Wilcox extern void *__memset64(uint64_t *, uint32_t low, __kernel_size_t, uint32_t hi);
memset64(uint64_t * p,uint64_t v,__kernel_size_t n)43fd1d3626SMatthew Wilcox static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
44fd1d3626SMatthew Wilcox {
45fd1d3626SMatthew Wilcox return __memset64(p, v, n * 8, v >> 32);
46fd1d3626SMatthew Wilcox }
47fd1d3626SMatthew Wilcox
48*d6d51a96SLinus Walleij /*
49*d6d51a96SLinus Walleij * For files that are not instrumented (e.g. mm/slub.c) we
50*d6d51a96SLinus Walleij * must use non-instrumented versions of the mem*
51*d6d51a96SLinus Walleij * functions named __memcpy() etc. All such kernel code has
52*d6d51a96SLinus Walleij * been tagged with KASAN_SANITIZE_file.o = n, which means
53*d6d51a96SLinus Walleij * that the address sanitization argument isn't passed to the
54*d6d51a96SLinus Walleij * compiler, and __SANITIZE_ADDRESS__ is not set. As a result
55*d6d51a96SLinus Walleij * these defines kick in.
56*d6d51a96SLinus Walleij */
57*d6d51a96SLinus Walleij #if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__)
58*d6d51a96SLinus Walleij #define memcpy(dst, src, len) __memcpy(dst, src, len)
59*d6d51a96SLinus Walleij #define memmove(dst, src, len) __memmove(dst, src, len)
60*d6d51a96SLinus Walleij #define memset(s, c, n) __memset(s, c, n)
61*d6d51a96SLinus Walleij
62*d6d51a96SLinus Walleij #ifndef __NO_FORTIFY
63*d6d51a96SLinus Walleij #define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
64*d6d51a96SLinus Walleij #endif
65*d6d51a96SLinus Walleij
66*d6d51a96SLinus Walleij #endif
67*d6d51a96SLinus Walleij
684baa9922SRussell King #endif
69