From: "H.J. Lu" <hjl.tools@gmail.com>
To: GNU C Library <libc-alpha@sourceware.org>
Subject: [PATCH] x86: Check SSBD and STIBP only on Intel CPUs
Date: Sat, 30 Jan 2021 05:59:55 -0800 [thread overview]
Message-ID: <CAMe9rOqaQyWdRaDw8jxCTzLSuS0J0-0fTOk5tEsfaGfCKVU1mA@mail.gmail.com> (raw)
In-Reply-To: <YBUx7aYd+wo9773E@winnix.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 1512 bytes --]
On Sat, Jan 30, 2021 at 2:26 AM Winfried Magerl
<winfried.magerl@t-online.de> wrote:
>
> Hello,
>
> On Sat, Jan 30, 2021 at 09:34:56AM +0100, Winfried Magerl wrote:
> > Hello,
> >
> > I got a suspicious error when building current upcoming glibc-2.33:
> >
> > FAIL: elf/tst-cpu-features-cpuinfo
> >
> > The relavant details from elf/tst-cpu-features-cpuinfo.out
> > (likely invariant_tsc can be ignored):
> >
> > Checking HAS_CPU_FEATURE (INVARIANT_TSC):
> > HAS_CPU_FEATURE (INVARIANT_TSC): 1
> > cpuinfo (invariant_tsc): 0
> > *** missing in /proc/cpuinfo ***
> > Checking HAS_CPU_FEATURE (SSBD):
> > HAS_CPU_FEATURE (SSBD): 0
> > cpuinfo (ssbd): 1
> > *** failure ***
> > Checking HAS_CPU_FEATURE (STIBP):
> > HAS_CPU_FEATURE (STIBP): 0
> > cpuinfo (stibp): 1
> > *** failure ***
> > 2 differences between /proc/cpuinfo and glibc code.
> >
> > The details of the build-system:
> > cpu: AMD Ryzen 9 3900X 12-Core Processor
> > os: openSUSE Tumbleweed 20210128
> > gcc: gcc-10-3.1.x86_64
> > binutils: binutils-2.35.1-1.1
>
> the missing kernel-version:
> openSUSE: kernel-default-5.10.9-1.2.x86_64
>
> also tested with vanilla-kernels with identical result:
> linux-5.9.16
> linux-5.11-rc5
>
> > Maybe this helps to track down the problem. From a quick look it's
> > likely uncritical because the feature is simply missing (as opposed
> > to a missdetected non-existing feature).
Try this.
--
H.J.
[-- Attachment #2: 0001-x86-Check-SSBD-and-STIBP-only-on-Intel-CPUs.patch --]
[-- Type: text/x-patch, Size: 2536 bytes --]
From 132ba6e1daf5463975467cf3af5ec0f0602d96e9 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 30 Jan 2021 05:44:40 -0800
Subject: [PATCH] x86: Check SSBD and STIBP only on Intel CPUs
Since /proc/cpuinfo reports different SSBD and STIBP on AMD CPUs, check
SSBD and STIBP only on Intel CPUs. Also /proc/cpuinfo doesn't report
IBRS_IBPB.
---
sysdeps/x86/tst-cpu-features-cpuinfo.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/sysdeps/x86/tst-cpu-features-cpuinfo.c b/sysdeps/x86/tst-cpu-features-cpuinfo.c
index 3c2fa7d9b6..ebe7337ab8 100644
--- a/sysdeps/x86/tst-cpu-features-cpuinfo.c
+++ b/sysdeps/x86/tst-cpu-features-cpuinfo.c
@@ -16,7 +16,7 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <sys/platform/x86.h>
+#include <cpu-features.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -99,6 +99,7 @@ static int
do_test (int argc, char **argv)
{
int fails = 0;
+ const struct cpu_features *cpu_features = __get_cpu_features ();
get_cpuinfo ();
fails += CHECK_PROC (acpi, ACPI);
@@ -159,7 +160,10 @@ do_test (int argc, char **argv)
fails += CHECK_PROC (hle, HLE);
fails += CHECK_PROC (ht, HTT);
fails += CHECK_PROC (hybrid, HYBRID);
- fails += CHECK_PROC (ibrs, IBRS_IBPB);
+#if 0
+ /* NB: /proc/cpuinfo doesn't report this feature. */
+ fails += CHECK_PROC (ibrs_ibpb, IBRS_IBPB);
+#endif
fails += CHECK_PROC (ibt, IBT);
fails += CHECK_PROC (invariant_tsc, INVARIANT_TSC);
fails += CHECK_PROC (invpcid, INVPCID);
@@ -220,7 +224,9 @@ do_test (int argc, char **argv)
fails += CHECK_PROC (smep, SMEP);
fails += CHECK_PROC (smx, SMX);
fails += CHECK_PROC (ss, SS);
- fails += CHECK_PROC (ssbd, SSBD);
+ /* NB: /proc/cpuinfo reports different SSBD on AMD CPUs. */
+ if (cpu_features->basic.kind == arch_kind_intel)
+ fails += CHECK_PROC (ssbd, SSBD);
fails += CHECK_PROC (sse, SSE);
fails += CHECK_PROC (sse2, SSE2);
fails += CHECK_PROC (pni, SSE3);
@@ -228,7 +234,9 @@ do_test (int argc, char **argv)
fails += CHECK_PROC (sse4_2, SSE4_2);
fails += CHECK_PROC (sse4a, SSE4A);
fails += CHECK_PROC (ssse3, SSSE3);
- fails += CHECK_PROC (stibp, STIBP);
+ /* NB: /proc/cpuinfo reports different STIBP on AMD CPUs. */
+ if (cpu_features->basic.kind == arch_kind_intel)
+ fails += CHECK_PROC (stibp, STIBP);
fails += CHECK_PROC (svm, SVM);
#ifdef __x86_64__
/* NB: SYSCALL_SYSRET is 64-bit only. */
--
2.29.2
next prev parent reply other threads:[~2021-01-30 14:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-30 8:34 AMD 3900X: FAIL: elf/tst-cpu-features-cpuinfo Winfried Magerl
2021-01-30 10:16 ` Winfried Magerl
2021-01-30 13:59 ` H.J. Lu [this message]
2021-01-30 16:26 ` [PATCH] x86: Check SSBD and STIBP only on Intel CPUs Winfried Magerl
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=CAMe9rOqaQyWdRaDw8jxCTzLSuS0J0-0fTOk5tEsfaGfCKVU1mA@mail.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).