94084c
commit 03de6917bd11c0591867607ce74ef658f76eabb9
94084c
Author: Aurelien Jarno <aurelien@aurel32.net>
94084c
Date:   Wed Dec 15 23:46:19 2021 +0100
94084c
94084c
    elf: Fix tst-cpu-features-cpuinfo for KVM guests on some AMD systems [BZ #28704]
94084c
    
94084c
    On KVM guests running on some AMD systems, the IBRS feature is reported
94084c
    as a synthetic feature using the Intel feature, while the cpuinfo entry
94084c
    keeps the same. Handle that by first checking the presence of the Intel
94084c
    feature on AMD systems.
94084c
    
94084c
    Fixes bug 28704.
94084c
    
94084c
    (cherry picked from commit 94058f6cde8b887178885954740ac6c866d25eab)
94084c
94084c
diff --git a/sysdeps/x86/tst-cpu-features-cpuinfo.c b/sysdeps/x86/tst-cpu-features-cpuinfo.c
94084c
index 2d4927f5e52dc260..830aaca2ecae971b 100644
94084c
--- a/sysdeps/x86/tst-cpu-features-cpuinfo.c
94084c
+++ b/sysdeps/x86/tst-cpu-features-cpuinfo.c
94084c
@@ -169,7 +169,14 @@ do_test (int argc, char **argv)
94084c
   else if (cpu_features->basic.kind == arch_kind_amd)
94084c
     {
94084c
       fails += CHECK_PROC (ibpb, AMD_IBPB);
94084c
-      fails += CHECK_PROC (ibrs, AMD_IBRS);
94084c
+
94084c
+      /* The IBRS feature on AMD processors is reported using the Intel feature
94084c
+       * on KVM guests (synthetic bit).  In both cases the cpuinfo entry is the
94084c
+       * same.  */
94084c
+      if (HAS_CPU_FEATURE (IBRS_IBPB))
94084c
+        fails += CHECK_PROC (ibrs, IBRS_IBPB);
94084c
+      else
94084c
+        fails += CHECK_PROC (ibrs, AMD_IBRS);
94084c
       fails += CHECK_PROC (stibp, AMD_STIBP);
94084c
     }
94084c
   fails += CHECK_PROC (ibt, IBT);