public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
From: Sunil Pandey <skpgkp2@gmail.com>
To: Noah Goldstein <goldstein.w.n@gmail.com>,
	 Libc-stable Mailing List <libc-stable@sourceware.org>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] x86-64: Fix SSE2 memcmp and SSSE3 memmove for x32
Date: Thu, 12 May 2022 13:12:15 -0700	[thread overview]
Message-ID: <CAMAf5_d0oAqcOCq=ysjqMH9V6Tsbh+AQx7JbXP1j_ShDhPUeKA@mail.gmail.com> (raw)
In-Reply-To: <CAFUsyfKkX-GGqs18SM9rhhqCihkge43T5LN0+pD1wBHEqekBWw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]

On Fri, Apr 22, 2022 at 11:07 AM Noah Goldstein via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> On Fri, Apr 22, 2022 at 12:58 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > Clear the upper 32 bits in RDX (memory size) for x32 to fix
> >
> > FAIL: string/tst-size_t-memcmp
> > FAIL: string/tst-size_t-memcmp-2
> > FAIL: string/tst-size_t-memcpy
> > FAIL: wcsmbs/tst-size_t-wmemcmp
> >
> > on x32 introduced by
> >
> > 8804157ad9 x86: Optimize memcmp SSE2 in memcmp.S
> > 26b2478322 x86: Reduce code size of mem{move|pcpy|cpy}-ssse3
> > ---
> >  sysdeps/x86_64/memcmp.S                  | 4 ++++
> >  sysdeps/x86_64/multiarch/memmove-ssse3.S | 4 ++++
> >  2 files changed, 8 insertions(+)
> >
> > diff --git a/sysdeps/x86_64/memcmp.S b/sysdeps/x86_64/memcmp.S
> > index b153694048..5718a7da86 100644
> > --- a/sysdeps/x86_64/memcmp.S
> > +++ b/sysdeps/x86_64/memcmp.S
> > @@ -46,6 +46,10 @@
> >
> >         .text
> >  ENTRY(MEMCMP)
> > +# ifdef __ILP32__
> > +       /* Clear the upper 32 bits.  */
> > +       movl    %edx, %edx
> > +# endif
> >  #ifdef USE_AS_WMEMCMP
> >         /* Use 0xffff to test for mismatches on pmovmskb bitmask. Store
> >            in ecx for code size. This is preferable to using `incw` as
> > diff --git a/sysdeps/x86_64/multiarch/memmove-ssse3.S b/sysdeps/x86_64/multiarch/memmove-ssse3.S
> > index 215583e7bd..310ff62b86 100644
> > --- a/sysdeps/x86_64/multiarch/memmove-ssse3.S
> > +++ b/sysdeps/x86_64/multiarch/memmove-ssse3.S
> > @@ -27,6 +27,10 @@ ENTRY(MEMMOVE_CHK)
> >  END(MEMMOVE_CHK)
> >
> >  ENTRY_P2ALIGN(MEMMOVE, 6)
> > +# ifdef __ILP32__
> > +       /* Clear the upper 32 bits.  */
> > +       movl    %edx, %edx
> > +# endif
> >         movq    %rdi, %rax
> >  L(start):
> >         cmpq    $16, %rdx
> > --
> > 2.35.1
> >
>
> LGTM.

I would like to backport this patch to release branches.
Any comments or objections?

Conflict resolution patch attached.

--Sunil

[-- Attachment #2: 0023-x86-64-Fix-SSE2-memcmp-and-SSSE3-memmove-for-x32.patch --]
[-- Type: application/octet-stream, Size: 1187 bytes --]

From 6e37b24194e2361b513a49ab92a686956f1cbeac Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 22 Apr 2022 10:53:13 -0700
Subject: [PATCH 23/26] x86-64: Fix SSE2 memcmp and SSSE3 memmove for x32

Clear the upper 32 bits in RDX (memory size) for x32 to fix

FAIL: string/tst-size_t-memcmp
FAIL: string/tst-size_t-memcmp-2
FAIL: string/tst-size_t-memcpy
FAIL: wcsmbs/tst-size_t-wmemcmp

on x32 introduced by

8804157ad9 x86: Optimize memcmp SSE2 in memcmp.S
26b2478322 x86: Reduce code size of mem{move|pcpy|cpy}-ssse3

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
(cherry picked from commit 8ea20ee5f6145de4bff9481d3e09ac36ba9df8f3)
---
 sysdeps/x86_64/memcmp.S | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sysdeps/x86_64/memcmp.S b/sysdeps/x86_64/memcmp.S
index b153694048..5718a7da86 100644
--- a/sysdeps/x86_64/memcmp.S
+++ b/sysdeps/x86_64/memcmp.S
@@ -46,6 +46,10 @@
 
 	.text
 ENTRY(MEMCMP)
+# ifdef __ILP32__
+	/* Clear the upper 32 bits.  */
+	movl	%edx, %edx
+# endif
 #ifdef USE_AS_WMEMCMP
 	/* Use 0xffff to test for mismatches on pmovmskb bitmask. Store
 	   in ecx for code size. This is preferable to using `incw` as
-- 
2.35.1


           reply	other threads:[~2022-05-12 20:12 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CAFUsyfKkX-GGqs18SM9rhhqCihkge43T5LN0+pD1wBHEqekBWw@mail.gmail.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMAf5_d0oAqcOCq=ysjqMH9V6Tsbh+AQx7JbXP1j_ShDhPUeKA@mail.gmail.com' \
    --to=skpgkp2@gmail.com \
    --cc=goldstein.w.n@gmail.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-stable@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).