Skip to content

selftests: Remove duplicate CPUID wrappers

Reinette Chatre linux-kselftest linux-mm 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 1 replyIn review
  2. v24 patches 5 repliesSuperseded
  3. v13 patches 4 repliesSuperseded

Changes in v3 from the cover letter

- V2: https://lore.kernel.org/lkml/[email protected]/
- Rebased against v5.18-rc4, no functional changes.
- Add text in cover letter and first patch to highlight that
the __cpuid_count() macro provided is not a new implementation but copied from gcc.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4selftests: Provide local define of __cpuid_count()tools/testing/selftests/kselftest.h+15 -00 replies
2/4selftests/vm/pkeys: Use provided __cpuid_count() macrotools/testing/selftests/vm/pkey-x86.h+2 -190 replies
3/4selftests/x86/amx: Use provided __cpuid_count() macrotools/testing/selftests/x86/amx.c+7 -170 replies
4/4selftests/x86/corrupt_xstate_header: Use provided __cpuid_count() macrotools/testing/selftests/x86/corrupt_xstate_header.c+2 -140 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH V3 0/4] selftests: Remove duplicate CPUID wrappers

Changes since V2:
- V2: https://lore.kernel.org/lkml/[email protected]/
- Rebased against v5.18-rc4, no functional changes.
- Add text in cover letter and first patch to highlight that
the __cpuid_count() macro provided is not a new implementation but copied from gcc.

Changes since V1:
- V1: https://lore.kernel.org/lkml/[email protected]/
- Change solution to not use __cpuid_count() from compiler's
cpuid.h but instead use a local define of __cpuid_count()
provided in kselftest.h to ensure tests continue working
in all supported environments. (Shuah)
- Rewrite cover letter and changelogs to reflect new solution.

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.

Both gcc and clang/LLVM provide wrappers for CPUID but the wrappers are not available in the minimal required version of gcc, v3.2, that the selftests need to be used in. __cpuid_count() was added to gcc in v4.4, which is ok for kernels after v4.19 when the gcc minimal required version was changed to v4.6.

Copy gcc's __cpuid_count() to provide a local define of __cpuid_count() to kselftest.h to ensure that selftests can still work in environments with older stable kernels (v4.9 and v4.14 that have the minimal required version of gcc of v3.2). Update tests with private CPUID wrappers to use the new macro.

Cc Dave Hansen <[email protected]>
Cc Sandipan Das <[email protected]>
Cc Florian Weimer <[email protected]>
Cc "Desnes A. Nunes do Rosario" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thiago Jung Bauermann <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Michal Suchanek <[email protected]>
Cc Chang S. Bae <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Andy Lutomirski <[email protected]>

Reinette Chatre (4):
selftests: Provide local define of __cpuid_count() selftests/vm/pkeys: Use provided __cpuid_count() macro selftests/x86/amx: Use provided __cpuid_count() macro selftests/x86/corrupt_xstate_header: Use provided __cpuid_count()
macro

 tools/testing/selftests/kselftest.h           | 15 ++++++++++++
 tools/testing/selftests/vm/pkey-x86.h         | 21 ++--------------
 tools/testing/selftests/x86/amx.c             | 24 ++++++-------------
 .../selftests/x86/corrupt_xstate_header.c     | 16 ++-----------
 4 files changed, 26 insertions(+), 50 deletions(-)

base-commit: af2d861d4cd2a4da5137f795ee3509e6f944a25b

Signature · 1 line
2.25.1