public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: libc-alpha@sourceware.org
Subject: [PATCH] x86: Disable OSXSAVE related features [BZ #27605]
Date: Fri, 19 Mar 2021 06:27:51 -0700	[thread overview]
Message-ID: <20210319132751.3845006-1-hjl.tools@gmail.com> (raw)

If OSXSAVE is disabled by glibc tunables, disable features which depend
on OSXSAVE.
---
 sysdeps/x86/cpu-features.c | 40 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index d7248cbb45..804e9a879b 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -654,6 +654,46 @@ no_cpuid:
 
 #if HAVE_TUNABLES
   TUNABLE_GET (hwcaps, tunable_val_t *, TUNABLE_CALLBACK (set_hwcaps));
+
+  if (!CPU_FEATURE_USABLE_P (cpu_features, OSXSAVE))
+    {
+      /* These features are usable only if OSXSAVE is usable.  */
+      cpu_features->xsave_state_size = 0;
+      CPU_FEATURE_UNSET (cpu_features, AVX);
+      CPU_FEATURE_UNSET (cpu_features, AVX2);
+      CPU_FEATURE_UNSET (cpu_features, AVX_VNNI);
+      CPU_FEATURE_UNSET (cpu_features, FMA);
+      CPU_FEATURE_UNSET (cpu_features, VAES);
+      CPU_FEATURE_UNSET (cpu_features, VPCLMULQDQ);
+      CPU_FEATURE_UNSET (cpu_features, XOP);
+      CPU_FEATURE_UNSET (cpu_features, F16C);
+      CPU_FEATURE_UNSET (cpu_features, AVX512F);
+      CPU_FEATURE_UNSET (cpu_features, AVX512CD);
+      CPU_FEATURE_UNSET (cpu_features, AVX512ER);
+      CPU_FEATURE_UNSET (cpu_features, AVX512PF);
+      CPU_FEATURE_UNSET (cpu_features, AVX512VL);
+      CPU_FEATURE_UNSET (cpu_features, AVX512DQ);
+      CPU_FEATURE_UNSET (cpu_features, AVX512BW);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_4FMAPS);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_4VNNIW);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_BITALG);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_IFMA);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_VBMI);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_VBMI2);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_VNNI);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_VPOPCNTDQ);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_VP2INTERSECT);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_BF16);
+      CPU_FEATURE_UNSET (cpu_features, AVX512_FP16);
+      CPU_FEATURE_UNSET (cpu_features, AMX_BF16);
+      CPU_FEATURE_UNSET (cpu_features, AMX_TILE);
+      CPU_FEATURE_UNSET (cpu_features, AMX_INT8);
+      CPU_FEATURE_UNSET (cpu_features, XSAVE);
+      CPU_FEATURE_UNSET (cpu_features, XSAVEOPT);
+      CPU_FEATURE_UNSET (cpu_features, XSAVEC);
+      CPU_FEATURE_UNSET (cpu_features, XGETBV_ECX_1);
+      CPU_FEATURE_UNSET (cpu_features, XFD);
+    }
 #elif defined SHARED
   /* Reuse dl_platform, dl_hwcap and dl_hwcap_mask for x86.  The
      glibc.cpu.hwcap_mask tunable is initialized already, so no
-- 
2.30.2


             reply	other threads:[~2021-03-19 13:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19 13:27 H.J. Lu [this message]
2021-03-19 21:42 ` DJ Delorie
2021-03-19 22:22   ` [PATCH v2] " H.J. Lu
2021-03-20  0:06     ` [PATCH v3] x86: Properly disable XSAVE " H.J. Lu
2021-03-22 18:32       ` DJ Delorie
2021-03-22 18:38         ` H.J. Lu
2021-03-22 18:42           ` DJ Delorie
2021-03-23 13:08             ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210319132751.3845006-1-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).