From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 401313858C83 for ; Tue, 15 Feb 2022 16:30:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 401313858C83 Received: by mail-pf1-x436.google.com with SMTP id u16so1683594pfg.12 for ; Tue, 15 Feb 2022 08:30:03 -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=SfAY08Cp0Z1WjEU+7C2vJpAeelmFeQI18I5VVMySVRE=; b=kqd32FVV3PnxzuQXWunM/tueoG1I+OaV5wZp0J9ERoIqaw3DowBeHPpCOn4qGz93Y9 0BsnqwEnZ3VqU8RWNRjim/i8ce1em+b/VOJ7EREXj9hZgTRAbLUP01Ezcck2UWFv6VaZ WQTlleF013zxjaUqSiiM2AUu9zGBDLlhLfc3Uhj+WmskNrdZyp0vQelNH7pbDQQcCv2W KKgrVYh75L2vUhjsYmn04V15Pf17+vq8B+ymUeIY7II6zzrvr3QYimzpoAD/uxiXdvXj +9AarA1SjQObrvspB1skXJr6X0tufMD3XdZ0VJHSdyT2Cetp0kMFzXrxeXkuXV3Sw3r1 oa3A== X-Gm-Message-State: AOAM532CxVuPyBxGXFtcpbMVtOu//gZODUU86XpbLrOi625XNnmqbD76 0a0xHqjI/J95b9XZUrPmfuH9rBamPLLrtil+P1c= X-Google-Smtp-Source: ABdhPJyROo0nezmjDwuufJ2+XuEM43otGOTjMrBoyExwu4p2aVChhl6/IFhSjXgUnDKexjE5f3Cm6K+mwek88Pt+2M4= X-Received: by 2002:aa7:8891:: with SMTP id z17mr5107737pfe.76.1644942602177; Tue, 15 Feb 2022 08:30:02 -0800 (PST) MIME-Version: 1.0 References: <20220215162751.281955-1-goldstein.w.n@gmail.com> In-Reply-To: <20220215162751.281955-1-goldstein.w.n@gmail.com> From: "H.J. Lu" Date: Tue, 15 Feb 2022 08:29:26 -0800 Message-ID: Subject: Re: [PATCH v1] x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896] To: Noah Goldstein Cc: GNU C Library , "Carlos O'Donell" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3017.2 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, UNWANTED_LANGUAGE_BODY 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: Tue, 15 Feb 2022 16:30:04 -0000 On Tue, Feb 15, 2022 at 8:28 AM Noah Goldstein wrote: > > In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would > call strcmp-avx2 and wcsncmp-avx2 respectively. This would have > not checks around vzeroupper and would trigger spurious > aborts. This commit fixes that. Include a testcase? > test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all > pass. Note not tested on a machine that supports RTM (non > available). > --- > sysdeps/x86_64/multiarch/strcmp-avx2.S | 8 ++------ > 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 +- > 5 files changed, 6 insertions(+), 8 deletions(-) > > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S > index 07a5a2c889..52ff5ad724 100644 > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S > @@ -193,10 +193,10 @@ L(ret_zero): > .p2align 4,, 5 > L(one_or_less): > jb L(ret_zero) > -# ifdef USE_AS_WCSCMP > /* 'nbe' covers the case where length is negative (large > unsigned). */ > - jnbe __wcscmp_avx2 > + jnbe OVERFLOW_STRCMP > +# ifdef USE_AS_WCSCMP > movl (%rdi), %edx > xorl %eax, %eax > cmpl (%rsi), %edx > @@ -205,10 +205,6 @@ L(one_or_less): > negl %eax > orl $1, %eax > # else > - /* 'nbe' covers the case where length is negative (large > - unsigned). */ > - > - jnbe __strcmp_avx2 > movzbl (%rdi), %eax > movzbl (%rsi), %ecx > subl %ecx, %eax > 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.25.1 > -- H.J.