This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch master updated. glibc-2.25-574-g3ec7c02
- From: fw at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 23 Jun 2017 15:38:46 -0000
- Subject: GNU C Library master sources branch master updated. glibc-2.25-574-g3ec7c02
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 3ec7c02cc3e922b9364dc8cfd1d4546671b91003 (commit)
from 7fa1d9462baabc5a1058efc13a48444af4678acf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=3ec7c02cc3e922b9364dc8cfd1d4546671b91003
commit 3ec7c02cc3e922b9364dc8cfd1d4546671b91003
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Jun 23 17:23:44 2017 +0200
x86-64: memcmp-avx2-movbe.S needs saturating subtraction [BZ #21662]
This code:
L(between_2_3):
/* Load as big endian with overlapping loads and bswap to avoid
branches. */
movzwl -2(%rdi, %rdx), %eax
movzwl -2(%rsi, %rdx), %ecx
shll $16, %eax
shll $16, %ecx
movzwl (%rdi), %edi
movzwl (%rsi), %esi
orl %edi, %eax
orl %esi, %ecx
bswap %eax
bswap %ecx
subl %ecx, %eax
ret
needs a saturating subtract because the full register is used.
With this commit, only the lower 24 bits of the register are used,
so a regular subtraction suffices.
The test case change adds coverage for these kinds of bugs.
diff --git a/ChangeLog b/ChangeLog
index 4f1ef82..12f1e3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-06-23 Florian Weimer <fweimer@redhat.com>
+
+ [BZ #21662]
+ * sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S (between_2_3):
+ Use only 24 bits of the register before the subtraction.
+ * string/test-memcmp.c (check1): Check with different lengths.
+
2017-06-23 Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
* sysdeps/ieee754/float128/Makefile (CFLAGS-strfromf128.c): Add
diff --git a/string/test-memcmp.c b/string/test-memcmp.c
index a7969ed..1538930 100644
--- a/string/test-memcmp.c
+++ b/string/test-memcmp.c
@@ -441,11 +441,12 @@ check1 (void)
n = 116;
for (size_t i = 0; i < n; i++)
- {
- exp_result = SIMPLE_MEMCMP (s1 + i, s2 + i, n - i);
- FOR_EACH_IMPL (impl, 0)
- check_result (impl, s1 + i, s2 + i, n - i, exp_result);
- }
+ for (size_t len = 0; len <= n - i; ++len)
+ {
+ exp_result = SIMPLE_MEMCMP (s1 + i, s2 + i, len);
+ FOR_EACH_IMPL (impl, 0)
+ check_result (impl, s1 + i, s2 + i, len, exp_result);
+ }
}
/* This test checks that memcmp doesn't overrun buffers. */
diff --git a/sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S b/sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S
index 47630dd..9d19210 100644
--- a/sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S
+++ b/sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S
@@ -137,18 +137,18 @@ L(exit):
.p2align 4
L(between_2_3):
- /* Load as big endian with overlapping loads and bswap to avoid
- branches. */
- movzwl -2(%rdi, %rdx), %eax
- movzwl -2(%rsi, %rdx), %ecx
- shll $16, %eax
- shll $16, %ecx
- movzwl (%rdi), %edi
- movzwl (%rsi), %esi
- orl %edi, %eax
- orl %esi, %ecx
+ /* Load as big endian to avoid branches. */
+ movzwl (%rdi), %eax
+ movzwl (%rsi), %ecx
+ shll $8, %eax
+ shll $8, %ecx
bswap %eax
bswap %ecx
+ movzbl -1(%rdi, %rdx), %edi
+ movzbl -1(%rsi, %rdx), %esi
+ orl %edi, %eax
+ orl %esi, %ecx
+ /* Subtraction is okay because the upper 8 bits a zero. */
subl %ecx, %eax
ret
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 7 +++++++
string/test-memcmp.c | 11 ++++++-----
sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S | 20 ++++++++++----------
3 files changed, 23 insertions(+), 15 deletions(-)
hooks/post-receive
--
GNU C Library master sources