From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 30E5F385841F for ; Sat, 1 Oct 2022 22:17:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 30E5F385841F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x632.google.com with SMTP id rk17so15586600ejb.1 for ; Sat, 01 Oct 2022 15:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=jm/3kOeMbsQsNJaacmPvg1Mr/LW4o3AONhTDzF734Mk=; b=PAdS1LX2JmyT/wfUJJNuROPoy5nmdLht2XFdxaq/4L7ffN8CCgSCs54pMlApsYT8QN FQCSxY927qx8ucq3UAaPmxJdWa6JIMNLYzRUwRigECiyGJlkaiEYZsWPBEgwdd34E3Jy xr2AYU/734bxxgSo8sZwYM2rvpN/Clg5vUipnOyUzAA7wuJOuOWBDueQXvmZ2RP/CBxl 3WdVD1RRWpHl/jMF/SkOaqebE2JGliCPNQAHHVWZ8mon3Cc1wyKGa5q7f+cr6QW4+er5 FPSJQzkEg2D0Y9vVvLX/836gyUaOvX5UkyfSRbGYxN61BzdnejLH+WDi2NiALiCxSEey 752A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=jm/3kOeMbsQsNJaacmPvg1Mr/LW4o3AONhTDzF734Mk=; b=q4vqNu2Tem22vAFfC1YnbYHN7f/NNsH6wIQFjluzf1uQ7XLp+6yL+mx8Lmya3xbCXp z6k4xh2+0TsBC2gN1291nET0pGBNU4PNOAlawFPQULxSi68tgcRIV9iE94nD+B6JVGLL 1RUHu+qRBk48buHqo41roSHQr1HVIX6HleRbpAR83+AYDpDzFKo4a//2DcN5MeOL2Ws9 3znuXitjKJYhj5Co80ju+Dq3lzljmT44YghbSru8Y7V9O6qlsg+vIFxnnN5ObIgdNsgT qh0tsV4fUIWzaq2hSe7nedZIrS0Y0qS1mJnjyrG4ebJSNjO3YNX9qNExwPsUAXSqrnS1 DITQ== X-Gm-Message-State: ACrzQf2pE7ZEe7NHPXXZtmOiQmtDN0fqfrYHAL52R/BcNB/IGrnMSIA9 noYprWTDfm623Uqcl/vn+bFHS/3C7kTgS4+09hE4mGn72OM= X-Google-Smtp-Source: AMsMyM6oXNE42bUi5SD4LmZKVNcoOrER5EkXO4I7nGB1qByxGp6O53FhBYIk8kmQD2s/kCciPUGHPE0VKbZ7yh7UNMg= X-Received: by 2002:a17:907:6ea1:b0:783:cc69:342 with SMTP id sh33-20020a1709076ea100b00783cc690342mr10321879ejc.97.1664662677947; Sat, 01 Oct 2022 15:17:57 -0700 (PDT) MIME-Version: 1.0 References: <20221001190911.2994478-1-aurelien@aurel32.net> In-Reply-To: From: Noah Goldstein Date: Sat, 1 Oct 2022 15:17:46 -0700 Message-ID: Subject: Re: [PATCH 0/4] x86: Fix AVX2 string functions requiring BMI2 or LZCNT (BZ #29611) To: Aurelien Jarno Cc: libc-alpha@sourceware.org, "H . J . Lu" , Sunil K Pandey Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sat, Oct 1, 2022 at 3:11 PM Noah Goldstein wrote: > > On Sat, Oct 1, 2022 at 12:09 PM Aurelien Jarno wrote: > > > > Some early Intel Haswell CPU have AVX2 instructions, but do not have > > BMI2 instructions. Some AVX2 string functions only check for AVX2, but > > use BMI2 or LZCNT instructions. This patchset tries to fix that. > > > > While most fixes only change ifunc-impl-list.c, and thus only concerns > > the testsuite, the strn(case)cmp is a real issue affecting early Intel > > Haswell CPU, reported to affect Debian Sid and Fedora Rawhide. > > > > On the other hand, the check for LZCNT in memrchr is purely for > > correctness, I am not aware of a CPU implementing AVX2 without LZCNT. > > > > This has been tested by remplacing all BMI2 and LZCNT instruction in the > > source code by the "ud2" instruction and disabling the BMI1, BMI2 > > feature detection, and running the testsuite. > > > > Resolves: BZ #29611 > > > > Aurelien Jarno (4): > > x86: include BMI1 and BMI2 in x86-64-v3 level > > x86-64: Require BMI2 for AVX2 strn(case)cmp and wcsncmp > > implementations > > x86-64: Require BMI2 for AVX2 (raw|w)memchr implementations > > x86-64: Require LZCNT for AVX2 memrchr implementation > > > > We also need BMI2 check in ifunc-impl-list for: > strcasecmp > strcmp > strcasecmp_l > strrchr > wcsrchr > wcscmp > > If you want you can make patches, otherwise I can. This is a duplicate of a comment I left in the strn(case)cmp patchset, but leaving here so the information is not scattered: The ifunc change in strncmp.c and ifunc-strcasecmp.h need to be backport to 2.33, 2.34, 2.35. Also separate changes for ifunc need to be backport to strncmp.c: 2.32, 2.31, 2.30, 2.29, 2.28 for a `tzcnt` usage that needs BMI1. Finally a corresponding fix is needed for strcmp.c as well (there is missing BMI2 check in strcmp.c ifunc selection as well as missing checks in the impl list). > > sysdeps/x86/get-isa-level.h | 2 + > > sysdeps/x86_64/multiarch/ifunc-avx2.h | 1 + > > sysdeps/x86_64/multiarch/ifunc-impl-list.c | 44 +++++++++++++++------ > > sysdeps/x86_64/multiarch/ifunc-strcasecmp.h | 1 + > > sysdeps/x86_64/multiarch/strncmp.c | 4 +- > > 5 files changed, 38 insertions(+), 14 deletions(-) > > > > -- > > 2.35.1 > >