]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
microblaze: Use simple memset implementation from lib/string.c
authorMichal Simek <michal.simek@xilinx.com>
Fri, 25 Feb 2022 13:55:34 +0000 (14:55 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 21 Apr 2022 08:54:20 +0000 (10:54 +0200)
On microblaze systems which are not using OPT_LIB_FUNCTION only simple
memset is used. This function is already implemented in lib/string.c that's
why it should be used instead.
This change is done in respect of issue fixed by commit 33d0f96ffd73
("lib/string.c: Use freestanding environment") where gcc-10.x moved
-ftree-loop-distribute-patterns optimization is to O2 optimization level.
This optimization causes GCC to convert the while loop in memset.c into a
call to memset. So This optimization is transforming a loop in a
memset/memcpy into a call to the function itself. This makes the memset
implementation as recursive.

Based on fix above -ffreestanding was used and it needs to be used on
Microblaze too but the patch is not adding this flag it removes simple
implementation to cause that generic implementation is used where this flag
is already setup.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
Link: https://lore.kernel.org/r/4a143e7654f72ee893dcea9769946e17d3570b16.1645797329.git.michal.simek@xilinx.com
arch/microblaze/include/asm/string.h
arch/microblaze/lib/memset.c

index 34071a848b6a235a578450f75a1183ed647fbdb7..dbdb9eb4a733c5f5100311af6c5d4db905a3b622 100644 (file)
@@ -8,7 +8,9 @@
 
 #ifdef __KERNEL__
 
+#ifdef CONFIG_OPT_LIB_FUNCTION
 #define __HAVE_ARCH_MEMSET
+#endif
 #define __HAVE_ARCH_MEMCPY
 #define __HAVE_ARCH_MEMMOVE
 
index eb6c8988af0271afbf7187610ed4820755948fae..615a2f8f53cbe542b6a97a06b310aaf3e6584ef6 100644 (file)
 #include <linux/compiler.h>
 #include <linux/string.h>
 
-#ifdef __HAVE_ARCH_MEMSET
-#ifndef CONFIG_OPT_LIB_FUNCTION
-void *memset(void *v_src, int c, __kernel_size_t n)
-{
-       char *src = v_src;
-
-       /* Truncate c to 8 bits */
-       c = (c & 0xFF);
-
-       /* Simple, byte oriented memset or the rest of count. */
-       while (n--)
-               *src++ = c;
-
-       return v_src;
-}
-#else /* CONFIG_OPT_LIB_FUNCTION */
+#ifdef CONFIG_OPT_LIB_FUNCTION
 void *memset(void *v_src, int c, __kernel_size_t n)
 {
        char *src = v_src;
@@ -94,6 +79,5 @@ void *memset(void *v_src, int c, __kernel_size_t n)
 
        return v_src;
 }
-#endif /* CONFIG_OPT_LIB_FUNCTION */
 EXPORT_SYMBOL(memset);
-#endif /* __HAVE_ARCH_MEMSET */
+#endif /* CONFIG_OPT_LIB_FUNCTION */