From patchwork Fri Aug 11 00:38:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 134260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp774497vqi; Thu, 10 Aug 2023 17:40:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE455KHl65zwSoT3ZyYpgmX/GacQaeoBTV7dQFr9BUY43X2moD5KY/FCDw11GVFw3hv8Wsd X-Received: by 2002:a17:906:9bd3:b0:99b:cc2f:c47c with SMTP id de19-20020a1709069bd300b0099bcc2fc47cmr335347ejc.53.1691714418534; Thu, 10 Aug 2023 17:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691714418; cv=none; d=google.com; s=arc-20160816; b=ivQmWGxQX17dM0+ur/oLEaubM1x8Ma0jrtQ8xMhSEAu0ADZewm4dN1JIdtYiSYW6/v oAd+LXYV4pbWgqe36Hs+gA1BDOs28K5FZZYS7Ax8tKE39FiPR1/jDvDCben5GepGgYVS qkBjxqS9N11E61xUH9kGyhxYm589hvI7WGiQuzxCqc/M/w0GSiT52cyYBLb83m8dsnYU T2OAnMZ9GBZwcHI1dDetjQPqQIHQdbFytRf4DVo2PM8PJQhYbHTELWv+lsauXGGSTTuH 1Pp8+VsFm/pkzZ8jCqgyIBQ5+5Nu84iD4fA30nRuTtA3F9xogHEvZIHKDOs5lspC///Y yWuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=4yVdvAcV5LgvoU/ykli/x6umh1+1IAoSyNnK+Jvzq4I=; fh=llebxEPKoNSxs7gbI+Ld+uStJG33hLeVKel30S6OACc=; b=Dgwy+LENHx8B5NnwgIBmk74g+kcdvTiyoM7BaPMdqBoI0E9KpNyrofxStyuc4ye9bj QLU8F69ixd4gfAT4uxlzX+FGXYUjwtVUHLiRdct8xQr7y0bH2RbX+xbYlEKQeZi1ZslL oaqBTBP5YbLUX41PItQK62X2ZnTtq/KBWrVQA5kyctCmDZqKmrIFBDcAPN2b07NwqfPH 6PKuHIclKtUEKGbDmTtFafw1CXdOR8aw0qmkgpUp++fc260k+wGv6eawV4PPcRGsvmJZ sOLj42X6mS1ckzrNAVs5D0yrdMn5+FMJ4hbSzY3su0y0wukQHsqZghyxTrJ/+rH4Go5E 09Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fp+5Mwfs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ko28-20020a170907987c00b00991f1e4b041si2406588ejc.737.2023.08.10.17.40.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 17:40:18 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fp+5Mwfs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 26D4E385770F for ; Fri, 11 Aug 2023 00:40:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26D4E385770F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691714417; bh=4yVdvAcV5LgvoU/ykli/x6umh1+1IAoSyNnK+Jvzq4I=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Fp+5MwfsuR2Uy8xtOgsmFuiy4bhDHqRUrEj3lgDDp+oAxxjbHDBcnKImHO9WGHWXs LXhOkdH4xtRkec1cJK7asdva9f4mN+dX11g8qXfftDILA9YDYmjN6GUNqDX6D2/ABm +viliUT1EToUnVOpAvnyguIyLa2TfI8scoNgNAA4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by sourceware.org (Postfix) with ESMTPS id 0BDB73857016 for ; Fri, 11 Aug 2023 00:39:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0BDB73857016 X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="356525144" X-IronPort-AV: E=Sophos;i="6.01,163,1684825200"; d="scan'208";a="356525144" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2023 17:38:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="846600098" X-IronPort-AV: E=Sophos;i="6.01,163,1684825200"; d="scan'208";a="846600098" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga002.fm.intel.com with ESMTP; 10 Aug 2023 17:38:11 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id C1985100519E; Fri, 11 Aug 2023 08:38:10 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com Subject: [PATCH] Software mitigation: Disable gather generation in vectorization for GDS affected Intel Processors. Date: Fri, 11 Aug 2023 08:38:10 +0800 Message-Id: <20230811003810.2669080-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: liuhongt via Gcc-patches From: liuhongt Reply-To: liuhongt Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773891138146356576 X-GMAIL-MSGID: 1773891138146356576 For more details of GDS (Gather Data Sampling), refer to https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/gather-data-sampling.html After microcode update, there's performance regression. To avoid that, the patch disables gather generation in autovectorization but uses gather scalar emulation instead. Ready push to trunk and backport. any comments? gcc/ChangeLog: * config/i386/i386-options.cc (m_GDS): New macro. * config/i386/x86-tune.def (X86_TUNE_USE_GATHER_2PARTS): Don't enable for m_GDS. (X86_TUNE_USE_GATHER_4PARTS): Ditto. (X86_TUNE_USE_GATHER): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/avx2-gather-2.c: Adjust options to keep gather vectorization. * gcc.target/i386/avx2-gather-6.c: Ditto. * gcc.target/i386/avx512f-pr88464-1.c: Ditto. * gcc.target/i386/avx512f-pr88464-5.c: Ditto. * gcc.target/i386/avx512vl-pr88464-1.c: Ditto. * gcc.target/i386/avx512vl-pr88464-11.c: Ditto. * gcc.target/i386/avx512vl-pr88464-3.c: Ditto. * gcc.target/i386/avx512vl-pr88464-9.c: Ditto. * gcc.target/i386/pr88531-1b.c: Ditto. * gcc.target/i386/pr88531-1c.c: Ditto. --- gcc/config/i386/i386-options.cc | 5 +++++ gcc/config/i386/x86-tune.def | 6 +++--- gcc/testsuite/gcc.target/i386/avx2-gather-2.c | 2 +- gcc/testsuite/gcc.target/i386/avx2-gather-6.c | 2 +- gcc/testsuite/gcc.target/i386/avx512f-pr88464-1.c | 2 +- gcc/testsuite/gcc.target/i386/avx512f-pr88464-5.c | 2 +- gcc/testsuite/gcc.target/i386/avx512vl-pr88464-1.c | 2 +- gcc/testsuite/gcc.target/i386/avx512vl-pr88464-11.c | 2 +- gcc/testsuite/gcc.target/i386/avx512vl-pr88464-3.c | 2 +- gcc/testsuite/gcc.target/i386/avx512vl-pr88464-9.c | 2 +- gcc/testsuite/gcc.target/i386/pr88531-1b.c | 2 +- gcc/testsuite/gcc.target/i386/pr88531-1c.c | 2 +- 12 files changed, 18 insertions(+), 13 deletions(-) diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc index 127ee24203c..e6ba33c370d 100644 --- a/gcc/config/i386/i386-options.cc +++ b/gcc/config/i386/i386-options.cc @@ -141,6 +141,11 @@ along with GCC; see the file COPYING3. If not see #define m_ARROWLAKE (HOST_WIDE_INT_1U<