Re: [PATCH 0/3] selftests: Remove duplicate CPUID wrappers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/4/22 5:11 PM, Reinette Chatre wrote:
Hi Shuah,

On 2/4/2022 3:39 PM, Shuah Khan wrote:
On 2/4/22 12:17 PM, Reinette Chatre wrote:
A few tests that require running CPUID do so with a private
implementation of a wrapper for CPUID. This duplication of
the CPUID wrapper should be avoided but having one is also
unnecessary because of the existence of a macro that can
be used instead.

This series replaces private CPUID wrappers with calls
to the __cpuid_count() macro from cpuid.h as made available
by gcc and clang/llvm.

Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: Ram Pai <linuxram@xxxxxxxxxx>
Cc: Sandipan Das <sandipan@xxxxxxxxxxxxx>
Cc: Florian Weimer <fweimer@xxxxxxxxxx>
Cc: "Desnes A. Nunes do Rosario" <desnesn@xxxxxxxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Thiago Jung Bauermann <bauerman@xxxxxxxxxxxxx>
Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
Cc: Michal Suchanek <msuchanek@xxxxxxx>
Cc: linux-mm@xxxxxxxxx
Cc: Chang S. Bae <chang.seok.bae@xxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: x86@xxxxxxxxxx
Cc: Andy Lutomirski <luto@xxxxxxxxxx>

Reinette Chatre (3):
    selftests/vm/pkeys: Use existing __cpuid_count() macro
    selftests/x86/amx: Use existing __cpuid_count() macro
    selftests/x86/corrupt_xstate_header: Use existing __cpuid_count()
      macro

   tools/testing/selftests/vm/pkey-x86.h         | 22 +++---------------
   tools/testing/selftests/x86/amx.c             | 23 +++++--------------
   .../selftests/x86/corrupt_xstate_header.c     | 17 ++------------
   3 files changed, 11 insertions(+), 51 deletions(-)


I am all for this cleanup. However, I am not finding __cpuid_count()
marco on my system with gcc:

gcc --version
gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0

My concern is regression on older gcc versions.

Please see this message from our earlier thread where you were able
to find it on your system:
https://lore.kernel.org/linux-kselftest/63293c72-55ca-9446-35eb-74aff4c8ba5d@xxxxxxxxxxxxxxxxxxx/


Right. After I sent off the response, I was thinking we discussed
this before. Thanks for the refresh.

As mentioned in that thread, on my system it arrived via user space's
libgcc-dev package. This does not seem to be the first time including
files from this source - I did a quick check and from what I can tell
existing kselftest includes like stdarg.h, stdbool.h, stdatomic.h,
unwind.h, x86intrin.h ... arrive via libgcc-dev.


This will work fine on newer versions of gcc/clang. However this could
fail when mainline kselftest is used on stable releases on test rings
and so on, especially if they have older versions of gcc/clang.

We will have to find a solution for this. Instead of deleting the local
define, let's keep it under ifndef __cpuid_count

/usr/lib/gcc/x86_64-linux-gnu/11/include/cpuid.h

#define __cpuid_count(level, count, a, b, c, d)                         \
  __asm__ __volatile__ ("cpuid\n\t"                                     \
                        : "=a" (a), "=b" (b), "=c" (c), "=d" (d)        \
                        : "0" (level), "2" (count))

thanks,
-- Shuah



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux