Message ID | 20220324205033.3274646-1-goldstein.w.n@gmail.com |
---|---|
State | Accepted, archived |
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95A603858D3C for <patchwork@sourceware.org>; Thu, 24 Mar 2022 20:51:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95A603858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1648155063; bh=o0KQLxgY2ZKJbX61GwAIyfVvI8gDKiQXUP3mSFcBIXI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ImbqN+BYoYHS5aL4ZTyAE0BUZg0g8Eq60kT9CwLorbewgkQX0ORtGY/8z2kqOg6Ai 4wbWcOCDCGs5mWRv52w6Z6dZ/VLM1+evTxlSgDi4ULdUcXDfFKRYrbaxNw9icChdfW 7lYP6XCUqcuA8E6HKXUlqJfJE7FB7gsMoJU9EV/M= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id 58D1B3858D3C for <libc-alpha@sourceware.org>; Thu, 24 Mar 2022 20:50:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 58D1B3858D3C Received: by mail-il1-x129.google.com with SMTP id e9so3978452ilu.9 for <libc-alpha@sourceware.org>; Thu, 24 Mar 2022 13:50:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o0KQLxgY2ZKJbX61GwAIyfVvI8gDKiQXUP3mSFcBIXI=; b=pRQW/0dszkrydRlNKTyqIAoV/cvscbMCjKDarA1eaxHTxL/Mrwev/tDugA+M69uckt zuiCTWs5KyV55QPehw3Qr1mJ7zbnmPI1VC/VWQm9dr2oRknA30p4IiDzO90qNENM3RZH BE/qmYNBAzPmhh8fLBy/fevpIUG/TxUOCdhMZeUJmMhV1WX2wP1dt0Z0VMUIfvHLuiHa YEdAEAgYp0XCzCNfKEzouYRtBp7gjt2u4fnnOviuEtF2i7Hm+WFFEaz8WD08WTCZ0P4H 9vKxxUtuB67BGXUySYEur4Yo/PeIQjIWmYnDPd8aFZ/m4oDmZkzc3yAYKEieMSWroXIV pAdA== X-Gm-Message-State: AOAM5338fqc+bPxbPCf3rADQfBjorAVCTPcgCbtz6D0TKcsHAK9JDghs QFiOkBPI6aBFeEbJ+2tzS3LWMv9e8Hw= X-Google-Smtp-Source: ABdhPJzB5YBYefsH/2XEiDLL+QsSScQ1mYx+5axipUyqHo0ZgfKB+p+NKALgkAl1QKQztEVFBA47NA== X-Received: by 2002:a92:dd86:0:b0:2bc:805c:23c7 with SMTP id g6-20020a92dd86000000b002bc805c23c7mr3504453iln.279.1648155042484; Thu, 24 Mar 2022 13:50:42 -0700 (PDT) Received: from localhost.localdomain (node-17-161.flex.volo.net. [76.191.17.161]) by smtp.googlemail.com with ESMTPSA id s12-20020a92cbcc000000b002bd04428740sm1954237ilq.80.2022.03.24.13.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 13:50:42 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 12/31] x86: Fix fallback for wcsncmp_avx2 in strcmp-avx2.S [BZ #28896] Date: Thu, 24 Mar 2022 15:50:33 -0500 Message-Id: <20220324205033.3274646-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323215734.3927131-12-goldstein.w.n@gmail.com> References: <20220323215734.3927131-12-goldstein.w.n@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Noah Goldstein via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Noah Goldstein <goldstein.w.n@gmail.com> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
None
|
|
Commit Message
Noah Goldstein
March 24, 2022, 8:50 p.m. UTC
Overflow case for __wcsncmp_avx2_rtm should be __wcscmp_avx2_rtm not __wcscmp_avx2. commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] Set the wrong fallback function for `__wcsncmp_avx2_rtm`. It was set to fallback on to `__wcscmp_avx2` instead of `__wcscmp_avx2_rtm` which can cause spurious aborts. This change will need to be backported. All string/memory tests pass. --- sysdeps/x86/tst-strncmp-rtm.c | 15 +++++++++++++++ sysdeps/x86_64/multiarch/strcmp-avx2.S | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-)
Comments
On Thu, Mar 24, 2022 at 1:50 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote: > > Overflow case for __wcsncmp_avx2_rtm should be __wcscmp_avx2_rtm not > __wcscmp_avx2. > > commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 > Author: Noah Goldstein <goldstein.w.n@gmail.com> > Date: Sun Jan 9 16:02:21 2022 -0600 > > x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] > > Set the wrong fallback function for `__wcsncmp_avx2_rtm`. It was set > to fallback on to `__wcscmp_avx2` instead of `__wcscmp_avx2_rtm` which > can cause spurious aborts. > > This change will need to be backported. > > All string/memory tests pass. > --- > sysdeps/x86/tst-strncmp-rtm.c | 15 +++++++++++++++ > sysdeps/x86_64/multiarch/strcmp-avx2.S | 2 +- > 2 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c > index 300bc8c281..a3b14e72ff 100644 > --- a/sysdeps/x86/tst-strncmp-rtm.c > +++ b/sysdeps/x86/tst-strncmp-rtm.c > @@ -70,6 +70,16 @@ function_overflow (void) > return 1; > } > > +__attribute__ ((noinline, noclone)) > +static int > +function_overflow2 (void) > +{ > + if (STRNCMP (string1, string2, SIZE_MAX >> 4) == 0) > + return 0; > + else > + return 1; > +} > + > static int > do_test (void) > { > @@ -77,5 +87,10 @@ do_test (void) > if (status != EXIT_SUCCESS) > return status; > status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow); > + if (status != EXIT_SUCCESS) > + return status; > + status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow2); > + if (status != EXIT_SUCCESS) > + return status; > return status; > } > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S > index 52ff5ad724..86a86b68e3 100644 > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S > @@ -122,7 +122,7 @@ ENTRY(STRCMP) > are cases where length is large enough that it can never be a > bound on valid memory so just use wcscmp. */ > shrq $56, %rcx > - jnz __wcscmp_avx2 > + jnz OVERFLOW_STRCMP > > leaq (, %rdx, 4), %rdx > # endif > -- > 2.25.1 > LGTM. Verified on AVX2 machine with RTM. Without the fix, the new testcase failed. Reviewed-by: H.J. Lu <hjl.tools@gmail.com> Thanks.
On Thu, Mar 24, 2022 at 4:26 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > On Thu, Mar 24, 2022 at 1:50 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote: > > > > Overflow case for __wcsncmp_avx2_rtm should be __wcscmp_avx2_rtm not > > __wcscmp_avx2. > > > > commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 > > Author: Noah Goldstein <goldstein.w.n@gmail.com> > > Date: Sun Jan 9 16:02:21 2022 -0600 > > > > x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] > > > > Set the wrong fallback function for `__wcsncmp_avx2_rtm`. It was set > > to fallback on to `__wcscmp_avx2` instead of `__wcscmp_avx2_rtm` which > > can cause spurious aborts. > > > > This change will need to be backported. > > > > All string/memory tests pass. > > --- > > sysdeps/x86/tst-strncmp-rtm.c | 15 +++++++++++++++ > > sysdeps/x86_64/multiarch/strcmp-avx2.S | 2 +- > > 2 files changed, 16 insertions(+), 1 deletion(-) > > > > diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c > > index 300bc8c281..a3b14e72ff 100644 > > --- a/sysdeps/x86/tst-strncmp-rtm.c > > +++ b/sysdeps/x86/tst-strncmp-rtm.c > > @@ -70,6 +70,16 @@ function_overflow (void) > > return 1; > > } > > > > +__attribute__ ((noinline, noclone)) > > +static int > > +function_overflow2 (void) > > +{ > > + if (STRNCMP (string1, string2, SIZE_MAX >> 4) == 0) > > + return 0; > > + else > > + return 1; > > +} > > + > > static int > > do_test (void) > > { > > @@ -77,5 +87,10 @@ do_test (void) > > if (status != EXIT_SUCCESS) > > return status; > > status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow); > > + if (status != EXIT_SUCCESS) > > + return status; > > + status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow2); > > + if (status != EXIT_SUCCESS) > > + return status; > > return status; > > } > > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S > > index 52ff5ad724..86a86b68e3 100644 > > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S > > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S > > @@ -122,7 +122,7 @@ ENTRY(STRCMP) > > are cases where length is large enough that it can never be a > > bound on valid memory so just use wcscmp. */ > > shrq $56, %rcx > > - jnz __wcscmp_avx2 > > + jnz OVERFLOW_STRCMP > > > > leaq (, %rdx, 4), %rdx > > # endif > > -- > > 2.25.1 > > > > LGTM. Verified on AVX2 machine with RTM. Without the fix, > the new testcase failed. And that w/ the fix it passes? > > Reviewed-by: H.J. Lu <hjl.tools@gmail.com> > > Thanks. > > -- > H.J.
On Thu, Mar 24, 2022 at 2:43 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote: > > On Thu, Mar 24, 2022 at 4:26 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > > > On Thu, Mar 24, 2022 at 1:50 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote: > > > > > > Overflow case for __wcsncmp_avx2_rtm should be __wcscmp_avx2_rtm not > > > __wcscmp_avx2. > > > > > > commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 > > > Author: Noah Goldstein <goldstein.w.n@gmail.com> > > > Date: Sun Jan 9 16:02:21 2022 -0600 > > > > > > x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] > > > > > > Set the wrong fallback function for `__wcsncmp_avx2_rtm`. It was set > > > to fallback on to `__wcscmp_avx2` instead of `__wcscmp_avx2_rtm` which > > > can cause spurious aborts. > > > > > > This change will need to be backported. > > > > > > All string/memory tests pass. > > > --- > > > sysdeps/x86/tst-strncmp-rtm.c | 15 +++++++++++++++ > > > sysdeps/x86_64/multiarch/strcmp-avx2.S | 2 +- > > > 2 files changed, 16 insertions(+), 1 deletion(-) > > > > > > diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c > > > index 300bc8c281..a3b14e72ff 100644 > > > --- a/sysdeps/x86/tst-strncmp-rtm.c > > > +++ b/sysdeps/x86/tst-strncmp-rtm.c > > > @@ -70,6 +70,16 @@ function_overflow (void) > > > return 1; > > > } > > > > > > +__attribute__ ((noinline, noclone)) > > > +static int > > > +function_overflow2 (void) > > > +{ > > > + if (STRNCMP (string1, string2, SIZE_MAX >> 4) == 0) > > > + return 0; > > > + else > > > + return 1; > > > +} > > > + > > > static int > > > do_test (void) > > > { > > > @@ -77,5 +87,10 @@ do_test (void) > > > if (status != EXIT_SUCCESS) > > > return status; > > > status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow); > > > + if (status != EXIT_SUCCESS) > > > + return status; > > > + status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow2); > > > + if (status != EXIT_SUCCESS) > > > + return status; > > > return status; > > > } > > > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S > > > index 52ff5ad724..86a86b68e3 100644 > > > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S > > > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S > > > @@ -122,7 +122,7 @@ ENTRY(STRCMP) > > > are cases where length is large enough that it can never be a > > > bound on valid memory so just use wcscmp. */ > > > shrq $56, %rcx > > > - jnz __wcscmp_avx2 > > > + jnz OVERFLOW_STRCMP > > > > > > leaq (, %rdx, 4), %rdx > > > # endif > > > -- > > > 2.25.1 > > > > > > > LGTM. Verified on AVX2 machine with RTM. Without the fix, > > the new testcase failed. > > And that w/ the fix it passes? Yes. > > > > Reviewed-by: H.J. Lu <hjl.tools@gmail.com> > > > > Thanks. > > > > -- > > H.J.
On Thu, Mar 24, 2022 at 2:59 PM H.J. Lu via Libc-alpha <libc-alpha@sourceware.org> wrote: > > On Thu, Mar 24, 2022 at 2:43 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote: > > > > On Thu, Mar 24, 2022 at 4:26 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > > > > > On Thu, Mar 24, 2022 at 1:50 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote: > > > > > > > > Overflow case for __wcsncmp_avx2_rtm should be __wcscmp_avx2_rtm not > > > > __wcscmp_avx2. > > > > > > > > commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 > > > > Author: Noah Goldstein <goldstein.w.n@gmail.com> > > > > Date: Sun Jan 9 16:02:21 2022 -0600 > > > > > > > > x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] > > > > > > > > Set the wrong fallback function for `__wcsncmp_avx2_rtm`. It was set > > > > to fallback on to `__wcscmp_avx2` instead of `__wcscmp_avx2_rtm` which > > > > can cause spurious aborts. > > > > > > > > This change will need to be backported. > > > > > > > > All string/memory tests pass. > > > > --- > > > > sysdeps/x86/tst-strncmp-rtm.c | 15 +++++++++++++++ > > > > sysdeps/x86_64/multiarch/strcmp-avx2.S | 2 +- > > > > 2 files changed, 16 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c > > > > index 300bc8c281..a3b14e72ff 100644 > > > > --- a/sysdeps/x86/tst-strncmp-rtm.c > > > > +++ b/sysdeps/x86/tst-strncmp-rtm.c > > > > @@ -70,6 +70,16 @@ function_overflow (void) > > > > return 1; > > > > } > > > > > > > > +__attribute__ ((noinline, noclone)) > > > > +static int > > > > +function_overflow2 (void) > > > > +{ > > > > + if (STRNCMP (string1, string2, SIZE_MAX >> 4) == 0) > > > > + return 0; > > > > + else > > > > + return 1; > > > > +} > > > > + > > > > static int > > > > do_test (void) > > > > { > > > > @@ -77,5 +87,10 @@ do_test (void) > > > > if (status != EXIT_SUCCESS) > > > > return status; > > > > status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow); > > > > + if (status != EXIT_SUCCESS) > > > > + return status; > > > > + status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow2); > > > > + if (status != EXIT_SUCCESS) > > > > + return status; > > > > return status; > > > > } > > > > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S > > > > index 52ff5ad724..86a86b68e3 100644 > > > > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S > > > > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S > > > > @@ -122,7 +122,7 @@ ENTRY(STRCMP) > > > > are cases where length is large enough that it can never be a > > > > bound on valid memory so just use wcscmp. */ > > > > shrq $56, %rcx > > > > - jnz __wcscmp_avx2 > > > > + jnz OVERFLOW_STRCMP > > > > > > > > leaq (, %rdx, 4), %rdx > > > > # endif > > > > -- > > > > 2.25.1 > > > > > > > > > > LGTM. Verified on AVX2 machine with RTM. Without the fix, > > > the new testcase failed. > > > > And that w/ the fix it passes? > > Yes. > > > > > > > Reviewed-by: H.J. Lu <hjl.tools@gmail.com> > > > > > > Thanks. > > > > > > -- > > > H.J. > > > > -- > H.J. I would like to backport this patch to release branches. Any comments or objections? --Sunil
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c index 300bc8c281..a3b14e72ff 100644 --- a/sysdeps/x86/tst-strncmp-rtm.c +++ b/sysdeps/x86/tst-strncmp-rtm.c @@ -70,6 +70,16 @@ function_overflow (void) return 1; } +__attribute__ ((noinline, noclone)) +static int +function_overflow2 (void) +{ + if (STRNCMP (string1, string2, SIZE_MAX >> 4) == 0) + return 0; + else + return 1; +} + static int do_test (void) { @@ -77,5 +87,10 @@ do_test (void) if (status != EXIT_SUCCESS) return status; status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow); + if (status != EXIT_SUCCESS) + return status; + status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow2); + if (status != EXIT_SUCCESS) + return status; return status; } diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S index 52ff5ad724..86a86b68e3 100644 --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S @@ -122,7 +122,7 @@ ENTRY(STRCMP) are cases where length is large enough that it can never be a bound on valid memory so just use wcscmp. */ shrq $56, %rcx - jnz __wcscmp_avx2 + jnz OVERFLOW_STRCMP leaq (, %rdx, 4), %rdx # endif