From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 2D4C53858402 for ; Fri, 18 Feb 2022 22:56:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2D4C53858402 Received: by mail-pl1-x62c.google.com with SMTP id y18so8246159plb.11 for ; Fri, 18 Feb 2022 14:56:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dj20DUUKFSrMAUCJIgB29Rpky8V8HuFlFf4ju9iPZCc=; b=0UDBnQUrr7NHiaD8bq0mrEuofmAonQsF6hexKUR9I3xvGPyyh/120tcWtE5WGM5d8t 2lz5EfpXj9bOE7+Faaz2zysG8R1AhuITHAhwtDpr3aTPZe+zBzonWaLffcKUzfoGSEE5 d+t9Fv0BRR+6FmnzbUBchPpxN5SHY8akDF0vt5GYgi9i1m0GDW24JOICwR/GV3sXx5F3 kAQ130B6SkckV923ifrVkbN6IKW5OGMgEHEVF8VFmP5NlkfZU3j9icr0j0/EiufECZfW o5ZT8d5q9UtfP+agVAoGaYXErJUE5q25jT9SyjcOJEnH8ta/xTRWsoAHQRzd9uiJz0Ow Gq3Q== X-Gm-Message-State: AOAM530TEvtXGhLv32feDfxfwxzwVr9vbv1TsyQPWWm4zWLW7W9pNnVl DaKF62t5eUR4AnKvdsmy5mMXMrQ1SB4IARNZZJ2GwZq2 X-Google-Smtp-Source: ABdhPJzsLWZWW6vfBjgT1405VucoN5LWQc7GJaMpP37TPvVrHPi2YOXdp0GqtjCfXVV446v85bjrKlIaDppFhoFJzqQ= X-Received: by 2002:a17:902:8f98:b0:14e:ebbc:6da with SMTP id z24-20020a1709028f9800b0014eebbc06damr9256832plo.109.1645225016273; Fri, 18 Feb 2022 14:56:56 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Noah Goldstein Date: Fri, 18 Feb 2022 16:56:45 -0600 Message-ID: Subject: Re: [Backport PATCH 1/2] x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896] To: "H.J. Lu" Cc: Stable GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, 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-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2022 22:56:58 -0000 On Fri, Feb 18, 2022 at 4:55 PM H.J. Lu wrote: > > In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would > call strcmp-avx2 and wcscmp-avx2 respectively. This would have > not checks around vzeroupper and would trigger spurious > aborts. This commit fixes that. > > test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass on > AVX2 machines with and without RTM. > > Co-authored-by: H.J. Lu > > (cherry picked from commit c6272098323153db373f2986c67786ea8c85f1cf) > --- > sysdeps/x86/Makefile | 2 +- > sysdeps/x86/tst-strncmp-rtm.c | 17 ++++++++++++++++- > sysdeps/x86_64/multiarch/strcmp-avx2.S | 2 +- > sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S | 1 + > sysdeps/x86_64/multiarch/strncmp-avx2.S | 1 + > sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S | 2 +- > sysdeps/x86_64/multiarch/wcsncmp-avx2.S | 2 +- > 7 files changed, 22 insertions(+), 5 deletions(-) > > diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile > index 6cf708335c..d110f7b7f2 100644 > --- a/sysdeps/x86/Makefile > +++ b/sysdeps/x86/Makefile > @@ -109,7 +109,7 @@ CFLAGS-tst-memset-rtm.c += -mrtm > CFLAGS-tst-strchr-rtm.c += -mrtm > CFLAGS-tst-strcpy-rtm.c += -mrtm > CFLAGS-tst-strlen-rtm.c += -mrtm > -CFLAGS-tst-strncmp-rtm.c += -mrtm > +CFLAGS-tst-strncmp-rtm.c += -mrtm -Wno-error > CFLAGS-tst-strrchr-rtm.c += -mrtm > endif > > diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c > index 09ed6fa0d6..9e20abaacc 100644 > --- a/sysdeps/x86/tst-strncmp-rtm.c > +++ b/sysdeps/x86/tst-strncmp-rtm.c > @@ -16,6 +16,7 @@ > License along with the GNU C Library; if not, see > . */ > > +#include > #include > > #define LOOP 3000 > @@ -45,8 +46,22 @@ function (void) > return 1; > } > > +__attribute__ ((noinline, noclone)) > +static int > +function_overflow (void) > +{ > + if (strncmp (string1, string2, SIZE_MAX) == 0) > + return 0; > + else > + return 1; > +} > + > static int > do_test (void) > { > - return do_test_1 ("strncmp", LOOP, prepare, function); > + int status = do_test_1 ("strncmp", LOOP, prepare, function); > + if (status != EXIT_SUCCESS) > + return status; > + status = do_test_1 ("strncmp", LOOP, prepare, function_overflow); > + return status; > } Are we including the wcsncmp tests? > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S > index 9c73b5899d..cdcb3c5a26 100644 > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S > @@ -95,7 +95,7 @@ ENTRY (STRCMP) > length to bound a valid memory region. In these cases just use > 'wcscmp'. */ > shrq $56, %rcx > - jnz __wcscmp_avx2 > + jnz OVERFLOW_STRCMP > # endif > /* Convert units: from wide to byte char. */ > shl $2, %RDX_LP > diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S > index 37d1224bb9..68bad365ba 100644 > --- a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S > +++ b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S > @@ -1,3 +1,4 @@ > #define STRCMP __strncmp_avx2_rtm > #define USE_AS_STRNCMP 1 > +#define OVERFLOW_STRCMP __strcmp_avx2_rtm > #include "strcmp-avx2-rtm.S" > diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2.S b/sysdeps/x86_64/multiarch/strncmp-avx2.S > index 1678bcc235..f138e9f1fd 100644 > --- a/sysdeps/x86_64/multiarch/strncmp-avx2.S > +++ b/sysdeps/x86_64/multiarch/strncmp-avx2.S > @@ -1,3 +1,4 @@ > #define STRCMP __strncmp_avx2 > #define USE_AS_STRNCMP 1 > +#define OVERFLOW_STRCMP __strcmp_avx2 > #include "strcmp-avx2.S" > diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S > index 4e88c70cc6..f467582cbe 100644 > --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S > +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S > @@ -1,5 +1,5 @@ > #define STRCMP __wcsncmp_avx2_rtm > #define USE_AS_STRNCMP 1 > #define USE_AS_WCSCMP 1 > - > +#define OVERFLOW_STRCMP __wcscmp_avx2_rtm > #include "strcmp-avx2-rtm.S" > diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S > index 4fa1de4d3f..e9ede522b8 100644 > --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S > +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S > @@ -1,5 +1,5 @@ > #define STRCMP __wcsncmp_avx2 > #define USE_AS_STRNCMP 1 > #define USE_AS_WCSCMP 1 > - > +#define OVERFLOW_STRCMP __wcscmp_avx2 > #include "strcmp-avx2.S" > -- > 2.35.1 >