From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id DAA2F3858288 for ; Wed, 9 Aug 2023 06:39:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DAA2F3858288 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-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-51d95aed33aso8564519a12.3 for ; Tue, 08 Aug 2023 23:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691563146; x=1692167946; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xqkpGA17hPfaO0skApcYdWJddT6flCAwfIDErLeXQ7w=; b=mbzv+LfoVExvZJKeGTGqoLQPWpa28Jv6sQLkkKKuKZoYI5nJQZqBxFNj6CrBgPOZi5 dXRfpeTNZXUbEc9tTMbu1I3+Yj+wfIOInPDHTuW4IhO2GgwmmTZq+kfhAGfcLzxru7SR XzVjGn92xuV4fODGtPXYICMs6Jz8bvdIHkexyTVjh3ooEzPUl7FITzbfwcJpvPC2vMFO cHrUAxeoK1b1RmA6Xdo0HJxJ8M+xN4bQeIo3rt5lTo/1UeoMfRF6ULRvQDdets8IiD14 EC4tM/FYkZdgJNSWK5iWF8mlrho6LuhM6VveGds1PVM7RhebJWSQQ8osXAA+U0g2hJgT GSIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691563146; x=1692167946; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xqkpGA17hPfaO0skApcYdWJddT6flCAwfIDErLeXQ7w=; b=MDQsbMaEeFRtCKnJZXJ2tfssIOuP59zSZ13bEYZHzr4WzcfY6IHrqNr914oQvPua3q VAcWxq5zlvpV3neJAbTf2Cg5Degrp6isB8IBHX6snW1cKmObgfoYbTX5AKlMKnMkHbRu jg7fAbBN1HVzf/NEuUrNEYwEOC4YegSz4M0veAFgjdG8Foo/ulzGX3j1MgOmtnxkH5ma 53z3/k1n3bYuY0pytTrVwPgU5vZmtCRdtvzDaUdAYYdvEneJwXhFfjrlxa0m5E+QZLTr KeUebaxR6cqGp53X4i1fcHHFeaIP6ZeiTbOrdehX6s1VBsH5DLyuhUQxVYpdb6BDRaxV 4mGw== X-Gm-Message-State: AOJu0YzCBDvSyulykj6anMu7TVkvuSjNfkX1mjSDmIsRK3NxMnTwlILJ v7s1e2dSJmJzD2rPVpRslN8R5AeD9peea15xqJM= X-Google-Smtp-Source: AGHT+IHB1GfCpBHKmy/mTHJzD0Behe+ClaU+Niko85fGM6DhaQ0W7uikWFaBEwidMtVZQLqj076jIbplkgjnM0iVowE= X-Received: by 2002:aa7:d894:0:b0:51f:f1a4:edc6 with SMTP id u20-20020aa7d894000000b0051ff1a4edc6mr1600908edq.37.1691563146511; Tue, 08 Aug 2023 23:39:06 -0700 (PDT) MIME-Version: 1.0 References: <20230809014756.19615-1-hongtao.liu@intel.com> In-Reply-To: From: Uros Bizjak Date: Wed, 9 Aug 2023 08:38:55 +0200 Message-ID: Subject: Re: [PATCH V2] [X86] Workaround possible CPUID bug in Sandy Bridge. To: "Liu, Hongtao" Cc: "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 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 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 Wed, Aug 9, 2023 at 8:37=E2=80=AFAM Liu, Hongtao = wrote: > > > > > -----Original Message----- > > From: Uros Bizjak > > Sent: Wednesday, August 9, 2023 2:33 PM > > To: Liu, Hongtao > > Cc: gcc-patches@gcc.gnu.org > > Subject: Re: [PATCH V2] [X86] Workaround possible CPUID bug in Sandy > > Bridge. > > > > On Wed, Aug 9, 2023 at 3:48=E2=80=AFAM liuhongt = wrote: > > > > > > > Please rather do it in a more self-descriptive way, as proposed in > > > > the attached patch. You won't need a comment then. > > > > > > > > > > Adjusted in V2 patch. > > > > > > Don't access leaf 7 subleaf 1 unless subleaf 0 says it is supported > > > via EAX. > > > > > > Intel documentation says invalid subleaves return 0. We had been > > > relying on that behavior instead of checking the max sublef number. > > > > > > It appears that some Sandy Bridge CPUs return at least the subleaf 0 > > > EDX value for subleaf 1. Best guess is that this is a bug in a > > > microcode patch since all of the bits we're seeing set in EDX were > > > introduced after Sandy Bridge was originally released. > > > > > > This is causing avxvnniint16 to be incorrectly enabled with > > > -march=3Dnative on these CPUs. > > > > > > gcc/ChangeLog: > > > > > > * common/config/i386/cpuinfo.h (get_available_features): Chec= k > > > EAX for valid subleaf before use CPUID. > > > --- > > > gcc/common/config/i386/cpuinfo.h | 82 > > > +++++++++++++++++--------------- > > > 1 file changed, 43 insertions(+), 39 deletions(-) > > > > > > diff --git a/gcc/common/config/i386/cpuinfo.h > > > b/gcc/common/config/i386/cpuinfo.h > > > index 30ef0d334ca..9fa4dec2a7e 100644 > > > --- a/gcc/common/config/i386/cpuinfo.h > > > +++ b/gcc/common/config/i386/cpuinfo.h > > > @@ -663,6 +663,7 @@ get_available_features (struct __processor_model > > *cpu_model, > > > unsigned int max_cpuid_level =3D cpu_model2->__cpu_max_level; > > > unsigned int eax, ebx; > > > unsigned int ext_level; > > > + unsigned int subleaf_level; > > > > Oh, I failed this in my previous review. This variable should be named > > max_subleaf_level, as it represents the maximum supported ECX value. > I've committed previous patch ,but not backport yet. > Guess I can just commit another patch to change the name? > For backport, I'll merge the change together with just 1 commit. Yes. It is a trivial minor change. Uros.