diff mbox series

elf: Fix tst-cpu-features-cpuinfo for KVM guests on some AMD systems [BZ #28704]

Message ID 20211216064131.457656-1-aurelien@aurel32.net
State Committed
Commit 94058f6cde8b887178885954740ac6c866d25eab
Headers show
Series elf: Fix tst-cpu-features-cpuinfo for KVM guests on some AMD systems [BZ #28704] | expand

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Aurelien Jarno Dec. 16, 2021, 6:41 a.m. UTC
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.
---
 sysdeps/x86/tst-cpu-features-cpuinfo.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(H.J. Lu: resending because I wrongly send it to you instead of sending
it to the list and Cc:ing you. Sorry)

Comments

H.J. Lu Dec. 16, 2021, 1:39 p.m. UTC | #1
On Wed, Dec 15, 2021 at 10:41 PM Aurelien Jarno <aurelien@aurel32.net> wrote:
>
> 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.
> ---
>  sysdeps/x86/tst-cpu-features-cpuinfo.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> (H.J. Lu: resending because I wrongly send it to you instead of sending
> it to the list and Cc:ing you. Sorry)
>
> 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);
> --
> 2.33.0
>

LGTM.

Thanks.
diff mbox series

Patch

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);