Blame SOURCES/glibc-rh689471.patch

b40826
2011-03-20  H.J. Lu  <hongjiu.lu@intel.com>
b40826
b40826
	[BZ #12597]
b40826
	* string/test-strncmp.c (do_page_test): New function.
b40826
	(check2): Likewise.
b40826
	(test_main): Call check2.
b40826
	* sysdeps/x86_64/multiarch/strcmp.S: Properly cross page boundary.
b40826
b40826
Index: glibc-2.12-2-gc4ccff1/string/test-strncmp.c
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/string/test-strncmp.c
b40826
+++ glibc-2.12-2-gc4ccff1/string/test-strncmp.c
b40826
@@ -200,6 +200,27 @@ do_test (size_t align1, size_t align2, s
b40826
 }
b40826
 
b40826
 static void
b40826
+do_page_test (size_t offset1, size_t offset2, char *s2)
b40826
+{
b40826
+  char *s1;
b40826
+  int exp_result;
b40826
+
b40826
+  if (offset1 >= page_size || offset2 >= page_size)
b40826
+    return;
b40826
+
b40826
+  s1 = (char *) (buf1 + offset1);
b40826
+  s2 += offset2;
b40826
+
b40826
+  exp_result= *s1;
b40826
+  
b40826
+  FOR_EACH_IMPL (impl, 0)
b40826
+    {
b40826
+      check_result (impl, s1, s2, page_size, -exp_result);
b40826
+      check_result (impl, s2, s1, page_size, exp_result);
b40826
+    }
b40826
+}
b40826
+
b40826
+static void
b40826
 do_random_tests (void)
b40826
 {
b40826
   size_t i, j, n, align1, align2, pos, len1, len2, size;
b40826
@@ -312,6 +333,25 @@ check1 (void)
b40826
     }
b40826
 }
b40826
 
b40826
+static void
b40826
+check2 (void)
b40826
+{
b40826
+  size_t i;
b40826
+  char *s1, *s2;
b40826
+
b40826
+  s1 = (char *) buf1;
b40826
+  for (i = 0; i < page_size - 1; i++)
b40826
+    s1[i] = 23;
b40826
+  s1[i] = 0;
b40826
+
b40826
+  s2 = strdup (s1);
b40826
+
b40826
+  for (i = 0; i < 64; ++i)
b40826
+    do_page_test (3990 + i, 2635, s2);
b40826
+
b40826
+  free (s2);
b40826
+}
b40826
+
b40826
 int
b40826
 test_main (void)
b40826
 {
b40826
@@ -320,6 +360,7 @@ test_main (void)
b40826
   test_init ();
b40826
 
b40826
   check1 ();
b40826
+  check2 ();
b40826
 
b40826
   printf ("%23s", "");
b40826
   FOR_EACH_IMPL (impl, 0)
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/strcmp.S
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/sysdeps/x86_64/multiarch/strcmp.S
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/strcmp.S
b40826
@@ -452,6 +452,7 @@ LABEL(loop_ashr_1_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_1_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_1_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $1, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -499,7 +500,7 @@ LABEL(nibble_ashr_1_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$14, %ecx
b40826
-	ja	LABEL(loop_ashr_1_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_1_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -544,6 +545,7 @@ LABEL(loop_ashr_2_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_2_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_2_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $2, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -591,7 +593,7 @@ LABEL(nibble_ashr_2_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$13, %ecx
b40826
-	ja	LABEL(loop_ashr_2_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_2_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -636,6 +638,7 @@ LABEL(loop_ashr_3_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_3_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_3_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $3, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -683,7 +686,7 @@ LABEL(nibble_ashr_3_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$12, %ecx
b40826
-	ja	LABEL(loop_ashr_3_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_3_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -729,6 +732,7 @@ LABEL(loop_ashr_4_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_4_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_4_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $4, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -776,7 +780,7 @@ LABEL(nibble_ashr_4_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$11, %ecx
b40826
-	ja	LABEL(loop_ashr_4_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_4_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -822,6 +826,7 @@ LABEL(loop_ashr_5_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_5_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_5_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $5, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -870,7 +875,7 @@ LABEL(nibble_ashr_5_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$10, %ecx
b40826
-	ja	LABEL(loop_ashr_5_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_5_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -916,6 +921,7 @@ LABEL(loop_ashr_6_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_6_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_6_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $6, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -963,7 +969,7 @@ LABEL(nibble_ashr_6_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$9, %ecx
b40826
-	ja	LABEL(loop_ashr_6_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_6_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -1009,6 +1015,7 @@ LABEL(loop_ashr_7_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_7_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_7_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $7, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -1056,7 +1063,7 @@ LABEL(nibble_ashr_7_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$8, %ecx
b40826
-	ja	LABEL(loop_ashr_7_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_7_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -1102,6 +1109,7 @@ LABEL(loop_ashr_8_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_8_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_8_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $8, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -1149,7 +1157,7 @@ LABEL(nibble_ashr_8_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$7, %ecx
b40826
-	ja	LABEL(loop_ashr_8_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_8_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -1195,6 +1203,7 @@ LABEL(loop_ashr_9_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_9_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_9_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 
b40826
 	palignr $9, -16(%rdi, %rdx), %xmm0
b40826
@@ -1243,7 +1252,7 @@ LABEL(nibble_ashr_9_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$6, %ecx
b40826
-	ja	LABEL(loop_ashr_9_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_9_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -1289,6 +1298,7 @@ LABEL(loop_ashr_10_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_10_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_10_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $10, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -1336,7 +1346,7 @@ LABEL(nibble_ashr_10_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$5, %ecx
b40826
-	ja	LABEL(loop_ashr_10_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_10_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -1382,6 +1392,7 @@ LABEL(loop_ashr_11_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_11_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_11_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $11, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -1429,7 +1440,7 @@ LABEL(nibble_ashr_11_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$4, %ecx
b40826
-	ja	LABEL(loop_ashr_11_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_11_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -1475,6 +1486,7 @@ LABEL(loop_ashr_12_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_12_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_12_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $12, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -1522,7 +1534,7 @@ LABEL(nibble_ashr_12_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$3, %ecx
b40826
-	ja	LABEL(loop_ashr_12_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_12_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -1569,6 +1581,7 @@ LABEL(loop_ashr_13_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_13_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_13_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $13, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -1616,7 +1629,7 @@ LABEL(nibble_ashr_13_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$2, %ecx
b40826
-	ja	LABEL(loop_ashr_13_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_13_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -1663,6 +1676,7 @@ LABEL(loop_ashr_14_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_14_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_14_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $14, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -1710,7 +1724,7 @@ LABEL(nibble_ashr_14_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$1, %ecx
b40826
-	ja	LABEL(loop_ashr_14_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_14_use_sse4_2_restart)
b40826
 
b40826
 	jmp	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 
b40826
@@ -1759,6 +1773,7 @@ LABEL(loop_ashr_15_use_sse4_2):
b40826
 	add	$16, %r10
b40826
 	jg	LABEL(nibble_ashr_15_use_sse4_2)
b40826
 
b40826
+LABEL(nibble_ashr_15_use_sse4_2_restart):
b40826
 	movdqa	(%rdi, %rdx), %xmm0
b40826
 	palignr $15, -16(%rdi, %rdx), %xmm0
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L
b40826
@@ -1806,7 +1821,7 @@ LABEL(nibble_ashr_15_use_sse4_2):
b40826
 	jae	LABEL(nibble_ashr_use_sse4_2_exit)
b40826
 # endif
b40826
 	cmp	$0, %ecx
b40826
-	ja	LABEL(loop_ashr_15_use_sse4_2)
b40826
+	ja	LABEL(nibble_ashr_15_use_sse4_2_restart)
b40826
 
b40826
 LABEL(nibble_ashr_use_sse4_2_exit):
b40826
 # if !defined USE_AS_STRCASECMP_L && !defined USE_AS_STRNCASECMP_L