[PATCH 3.14 079/100] sparc: Let memset return the address argument

2014-10-27 Thread Greg Kroah-Hartman
3.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Andreas Larsson 

[ Upstream commit 74cad25c076a2f5253312c2fe82d1a4daecc1323 ]

This makes memset follow the standard (instead of returning 0 on success). This
is needed when certain versions of gcc optimizes around memset calls and assume
that the address argument is preserved in %o0.

Signed-off-by: Andreas Larsson 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/sparc/lib/memset.S |   18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

--- a/arch/sparc/lib/memset.S
+++ b/arch/sparc/lib/memset.S
@@ -3,8 +3,9 @@
  * Copyright (C) 1996,1997 Jakub Jelinek (j...@sunsite.mff.cuni.cz)
  * Copyright (C) 1996 David S. Miller (da...@caip.rutgers.edu)
  *
- * Returns 0, if ok, and number of bytes not yet set if exception
- * occurs and we were called as clear_user.
+ * Calls to memset returns initial %o0. Calls to bzero returns 0, if ok, and
+ * number of bytes not yet set if exception occurs and we were called as
+ * clear_user.
  */
 
 #include 
@@ -65,6 +66,8 @@ __bzero_begin:
.globl  __memset_start, __memset_end
 __memset_start:
 memset:
+   mov %o0, %g1
+   mov 1, %g4
and %o1, 0xff, %g3
sll %g3, 8, %g2
or  %g3, %g2, %g3
@@ -89,6 +92,7 @@ memset:
 sub%o0, %o2, %o0
 
 __bzero:
+   clr %g4
mov %g0, %g3
 1:
cmp %o1, 7
@@ -151,8 +155,8 @@ __bzero:
bne,a   8f
 EX(stb %g3, [%o0], and %o1, 1)
 8:
-   retl
-clr%o0
+   b   0f
+nop
 7:
be  13b
 orcc   %o1, 0, %g0
@@ -164,6 +168,12 @@ __bzero:
bne 8b
 EX(stb %g3, [%o0 - 1], add %o1, 1)
 0:
+   andcc   %g4, 1, %g0
+   be  5f
+nop
+   retl
+mov%g1, %o0
+5:
retl
 clr%o0
 __memset_end:


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.14 079/100] sparc: Let memset return the address argument

2014-10-27 Thread Greg Kroah-Hartman
3.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Andreas Larsson andr...@gaisler.com

[ Upstream commit 74cad25c076a2f5253312c2fe82d1a4daecc1323 ]

This makes memset follow the standard (instead of returning 0 on success). This
is needed when certain versions of gcc optimizes around memset calls and assume
that the address argument is preserved in %o0.

Signed-off-by: Andreas Larsson andr...@gaisler.com
Signed-off-by: David S. Miller da...@davemloft.net
Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 arch/sparc/lib/memset.S |   18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

--- a/arch/sparc/lib/memset.S
+++ b/arch/sparc/lib/memset.S
@@ -3,8 +3,9 @@
  * Copyright (C) 1996,1997 Jakub Jelinek (j...@sunsite.mff.cuni.cz)
  * Copyright (C) 1996 David S. Miller (da...@caip.rutgers.edu)
  *
- * Returns 0, if ok, and number of bytes not yet set if exception
- * occurs and we were called as clear_user.
+ * Calls to memset returns initial %o0. Calls to bzero returns 0, if ok, and
+ * number of bytes not yet set if exception occurs and we were called as
+ * clear_user.
  */
 
 #include asm/ptrace.h
@@ -65,6 +66,8 @@ __bzero_begin:
.globl  __memset_start, __memset_end
 __memset_start:
 memset:
+   mov %o0, %g1
+   mov 1, %g4
and %o1, 0xff, %g3
sll %g3, 8, %g2
or  %g3, %g2, %g3
@@ -89,6 +92,7 @@ memset:
 sub%o0, %o2, %o0
 
 __bzero:
+   clr %g4
mov %g0, %g3
 1:
cmp %o1, 7
@@ -151,8 +155,8 @@ __bzero:
bne,a   8f
 EX(stb %g3, [%o0], and %o1, 1)
 8:
-   retl
-clr%o0
+   b   0f
+nop
 7:
be  13b
 orcc   %o1, 0, %g0
@@ -164,6 +168,12 @@ __bzero:
bne 8b
 EX(stb %g3, [%o0 - 1], add %o1, 1)
 0:
+   andcc   %g4, 1, %g0
+   be  5f
+nop
+   retl
+mov%g1, %o0
+5:
retl
 clr%o0
 __memset_end:


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/