public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] elf: Fix tst-cpu-features-cpuinfo for KVM guests on some AMD systems [BZ #28704]
@ 2021-12-16  6:41 Aurelien Jarno
  2021-12-16 13:39 ` H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Aurelien Jarno @ 2021-12-16  6:41 UTC (permalink / raw)
  To: libc-alpha; +Cc: H . J . Lu, Aurelien Jarno

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] elf: Fix tst-cpu-features-cpuinfo for KVM guests on some AMD systems [BZ #28704]
  2021-12-16  6:41 [PATCH] elf: Fix tst-cpu-features-cpuinfo for KVM guests on some AMD systems [BZ #28704] Aurelien Jarno
@ 2021-12-16 13:39 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2021-12-16 13:39 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: GNU C Library

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.

-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-16 13:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16  6:41 [PATCH] elf: Fix tst-cpu-features-cpuinfo for KVM guests on some AMD systems [BZ #28704] Aurelien Jarno
2021-12-16 13:39 ` H.J. Lu

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