about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2021-12-15 23:46:19 +0100
committerAurelien Jarno <aurelien@aurel32.net>2021-12-17 20:20:15 +0100
commit94058f6cde8b887178885954740ac6c866d25eab (patch)
tree17fe49c56e33720c4d6dead0a7aeb7af955ef151
parentae91d3df24a4a1b1f264d101a71a298bff310d14 (diff)
downloadglibc-94058f6cde8b887178885954740ac6c866d25eab.tar.gz
glibc-94058f6cde8b887178885954740ac6c866d25eab.tar.xz
glibc-94058f6cde8b887178885954740ac6c866d25eab.zip
elf: Fix tst-cpu-features-cpuinfo for KVM guests on some AMD systems [BZ #28704]
On KVM guests running on some AMD systems, the IBRS feature is reported
as a synthetic feature using the Intel feature, while the cpuinfo entry
keeps the same. Handle that by first checking the presence of the Intel
feature on AMD systems.

Fixes bug 28704.
-rw-r--r--sysdeps/x86/tst-cpu-features-cpuinfo.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sysdeps/x86/tst-cpu-features-cpuinfo.c b/sysdeps/x86/tst-cpu-features-cpuinfo.c
index 2d4927f5e5..830aaca2ec 100644
--- a/sysdeps/x86/tst-cpu-features-cpuinfo.c
+++ b/sysdeps/x86/tst-cpu-features-cpuinfo.c
@@ -169,7 +169,14 @@ do_test (int argc, char **argv)
   else if (cpu_features->basic.kind == arch_kind_amd)
     {
       fails += CHECK_PROC (ibpb, AMD_IBPB);
-      fails += CHECK_PROC (ibrs, AMD_IBRS);
+
+      /* The IBRS feature on AMD processors is reported using the Intel feature
+       * on KVM guests (synthetic bit).  In both cases the cpuinfo entry is the
+       * same.  */
+      if (HAS_CPU_FEATURE (IBRS_IBPB))
+        fails += CHECK_PROC (ibrs, IBRS_IBPB);
+      else
+        fails += CHECK_PROC (ibrs, AMD_IBRS);
       fails += CHECK_PROC (stibp, AMD_STIBP);
     }
   fails += CHECK_PROC (ibt, IBT);