This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PowerPC: fix memrchr for POWER7


My memrchr testcase uncovered a nasty bug in memrchr implementation for POWER7
that triggers an invalid memory access for in calculation of remaining bytes
for some large inputs.

Tested on PPC32/POWER7 and PPC64/POWER7. Ok to apply?

---
2013-09-05  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>

	* sysdeps/powerpc/powerpc32/power7/memrchr.S (__memrchr): Fix invalid
	memory access for final bytes in some large inputs.
	* sysdeps/powerpc/powerpc64/power7/memrchr.S (__memrchr): Likewise.
--

diff --git a/sysdeps/powerpc/powerpc32/power7/memrchr.S b/sysdeps/powerpc/powerpc32/power7/memrchr.S
index d1e3fda..defd832 100644
--- a/sysdeps/powerpc/powerpc32/power7/memrchr.S
+++ b/sysdeps/powerpc/powerpc32/power7/memrchr.S
@@ -101,8 +101,8 @@ L(loop):
 	/* We're here because the counter reached 0, and that means we
 	   didn't have any matches for BYTE in the whole range.  Just return
 	   the original range.  */
-	addi	r9,r8,4
-	cmplw	cr6,r9,r7
+	addi	r8,r8,4
+	cmplw	cr6,r8,r7
 	bgt	cr6,L(loop_small)
 	b	L(null)
 
diff --git a/sysdeps/powerpc/powerpc64/power7/memrchr.S b/sysdeps/powerpc/powerpc64/power7/memrchr.S
index d24fbbb..c499952 100644
--- a/sysdeps/powerpc/powerpc64/power7/memrchr.S
+++ b/sysdeps/powerpc/powerpc64/power7/memrchr.S
@@ -102,8 +102,8 @@ L(loop):
 	/* We're here because the counter reached 0, and that means we
 	   didn't have any matches for BYTE in the whole range.  Just return
 	   the original range.  */
-	addi	r9,r8,8
-	cmpld	cr6,r9,r7
+	addi	r8,r8,8
+	cmpld	cr6,r8,r7
 	bgt	cr6,L(loop_small)
 	b	L(null)
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]