From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id AE984385BC23 for ; Fri, 18 Feb 2022 05:02:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AE984385BC23 Received: by mail-pl1-x629.google.com with SMTP id y18so6265775plb.11 for ; Thu, 17 Feb 2022 21:02:22 -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=l8PoFYTpqmJ/Y1CcH2dhjpje4D4Gr9XDb8iJCMYtIi4=; b=uozYWj0TLfxUCe4dBxDTYJ6fs9aqaqynWAyxt5Az4LhLRnZGEznuCuMBWcWL1ft8HY ttdAE0XjWNg4guOo+8EGiIDX6dZgsZOOTk3GTpcKfkb69rSVfaXR5me18B5/xbJuj9dQ PhojgrPcoQMuD+sC0qg2SeyfVU6q/E+qJ1cDFuLAD69axuDWks3MMAvFexomKLevwDf+ ORQLm/PunBj3oV2dYTg5Xzz28r7JDhy0HqNZldRkwK6ZzHx0ujosr20hJ1fM8EGXVf/b v2c6xgJjnWYduAunhwMZkTHsKuPHfO+CNjF5S+Fc9vTVtL7TjCgS2N2D0glcRb4n4ffk FYlg== X-Gm-Message-State: AOAM532qA0i+xcUspUJsnwWKPwVbE+LcKoOBhwWNJTdXNq8hrXqEx33O kXg2k1yzlAStQv4a3eiQ1ISDa2jamLBtlFQbznw= X-Google-Smtp-Source: ABdhPJxpUYry7cDapW7bRB6bjzVHK3zpkZYtaKTI2Tsr6i/X8wgokHUqy3FMTZY1C+LBzq9xGLty2Q99ztP6HEjlC94= X-Received: by 2002:a17:90a:e38e:b0:1b9:c98b:62e4 with SMTP id b14-20020a17090ae38e00b001b9c98b62e4mr6570982pjz.208.1645160541812; Thu, 17 Feb 2022 21:02:21 -0800 (PST) MIME-Version: 1.0 References: <20220218033735.1429857-1-goldstein.w.n@gmail.com> In-Reply-To: From: Noah Goldstein Date: Thu, 17 Feb 2022 23:02:10 -0600 Message-ID: Subject: Re: [PATCH v1] x86: Test wcscmp RTM in the wcsncmp overflow case [BZ #28896] To: "H.J. Lu" Cc: GNU C Library , "Carlos O'Donell" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.8 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-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2022 05:02:24 -0000 On Thu, Feb 17, 2022 at 9:58 PM H.J. Lu wrote: > > On Thu, Feb 17, 2022 at 7:54 PM H.J. Lu wrote: > > > > On Thu, Feb 17, 2022 at 7:37 PM Noah Goldstein 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. > > > --- > > > sysdeps/x86/Makefile | 4 +++- > > > sysdeps/x86/tst-strncmp-rtm.c | 33 ++++++++++++++++++++++++--------- > > > sysdeps/x86/tst-wcsncmp-rtm.c | 20 ++++++++++++++++++++ > > > 3 files changed, 47 insertions(+), 10 deletions(-) > > > create mode 100644 sysdeps/x86/tst-wcsncmp-rtm.c > > > > > > diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile > > > index d110f7b7f2..b13b556425 100644 > > > --- a/sysdeps/x86/Makefile > > > +++ b/sysdeps/x86/Makefile > > > @@ -99,7 +99,8 @@ tests += \ > > > tst-strcpy-rtm \ > > > tst-strlen-rtm \ > > > tst-strncmp-rtm \ > > > - tst-strrchr-rtm > > > + tst-strrchr-rtm \ > > > + tst-wcsncmp-rtm > > Also change it to > > tst-wcsncmp-rtm \ > # tests Fixed in v2 > > > > CFLAGS-tst-memchr-rtm.c += -mrtm > > > CFLAGS-tst-memcmp-rtm.c += -mrtm > > > @@ -111,6 +112,7 @@ CFLAGS-tst-strcpy-rtm.c += -mrtm > > > CFLAGS-tst-strlen-rtm.c += -mrtm > > > CFLAGS-tst-strncmp-rtm.c += -mrtm -Wno-error > > > CFLAGS-tst-strrchr-rtm.c += -mrtm > > > +CFLAGS-tst-wcsncmp-rtm.c += -mrtm -Wno-error > > > endif > > > > > > ifneq ($(enable-cet),no) > > > diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c > > > index 9e20abaacc..5c6f40e5aa 100644 > > > --- a/sysdeps/x86/tst-strncmp-rtm.c > > > +++ b/sysdeps/x86/tst-strncmp-rtm.c > > > @@ -17,20 +17,35 @@ > > > . */ > > > > > > #include > > > +#include > > > #include > > > > > > +#ifdef WIDE > > > > Move #include here. > > Fixed in v2. > > > +# define CHAR wchar_t > > > +# define MEMSET wmemset > > > +# define STRNCMP wcsncmp > > > +# define TEST_NAME wcsncmp > > > +#else /* !WIDE */ > > > +# define CHAR char > > > +# define MEMSET memset > > > +# define STRNCMP strncmp > > > +# define TEST_NAME strncmp > > > +#endif /* !WIDE */ > > > + > > > + > > > + > > > #define LOOP 3000 > > > #define STRING_SIZE 1024 > > > -char string1[STRING_SIZE]; > > > -char string2[STRING_SIZE]; > > > +CHAR string1[STRING_SIZE]; > > > +CHAR string2[STRING_SIZE]; > > > > > > __attribute__ ((noinline, noclone)) > > > static int > > > prepare (void) > > > { > > > - memset (string1, 'a', STRING_SIZE - 1); > > > - memset (string2, 'a', STRING_SIZE - 1); > > > - if (strncmp (string1, string2, STRING_SIZE) == 0) > > > + MEMSET (string1, 'a', STRING_SIZE - 1); > > > + MEMSET (string2, 'a', STRING_SIZE - 1); > > > + if (STRNCMP (string1, string2, STRING_SIZE) == 0) > > > return EXIT_SUCCESS; > > > else > > > return EXIT_FAILURE; > > > @@ -40,7 +55,7 @@ __attribute__ ((noinline, noclone)) > > > static int > > > function (void) > > > { > > > - if (strncmp (string1, string2, STRING_SIZE) == 0) > > > + if (STRNCMP (string1, string2, STRING_SIZE) == 0) > > > return 0; > > > else > > > return 1; > > > @@ -50,7 +65,7 @@ __attribute__ ((noinline, noclone)) > > > static int > > > function_overflow (void) > > > { > > > - if (strncmp (string1, string2, SIZE_MAX) == 0) > > > + if (STRNCMP (string1, string2, SIZE_MAX) == 0) > > > return 0; > > > else > > > return 1; > > > @@ -59,9 +74,9 @@ function_overflow (void) > > > static int > > > do_test (void) > > > { > > > - int status = do_test_1 ("strncmp", LOOP, prepare, function); > > > + int status = do_test_1 (TEST_NAME, LOOP, prepare, function); > > > if (status != EXIT_SUCCESS) > > > return status; > > > - status = do_test_1 ("strncmp", LOOP, prepare, function_overflow); > > > + status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow); > > > return status; > > > } > > > diff --git a/sysdeps/x86/tst-wcsncmp-rtm.c b/sysdeps/x86/tst-wcsncmp-rtm.c > > > new file mode 100644 > > > index 0000000000..86f97e4035 > > > --- /dev/null > > > +++ b/sysdeps/x86/tst-wcsncmp-rtm.c > > > @@ -0,0 +1,20 @@ > > > +/* Test case for wcsncmp inside a transactionally executing RTM region. > > > + Copyright (C) 2021-2022 Free Software Foundation, Inc. > > ^^^^^ Just 2022 > > > + This file is part of the GNU C Library. > > > + > > > + The GNU C Library is free software; you can redistribute it and/or > > > + modify it under the terms of the GNU Lesser General Public > > > + License as published by the Free Software Foundation; either > > > + version 2.1 of the License, or (at your option) any later version. > > > + > > > + The GNU C Library is distributed in the hope that it will be useful, > > > + but WITHOUT ANY WARRANTY; without even the implied warranty of > > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > > + Lesser General Public License for more details. > > > + > > > + You should have received a copy of the GNU Lesser General Public > > > + License along with the GNU C Library; if not, see > > > + . */ > > > + > > > +#define WIDE 1 > > > +#include "tst-strncmp-rtm.c" > > > -- > > > 2.25.1 > > > > > > > Thanks. > > > > -- > > H.J. > > > > -- > H.J.