aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/x86/corrupt_xstate_header.c
diff options
context:
space:
mode:
authorReinette Chatre <reinette.chatre@intel.com>2022-04-25 14:01:14 -0700
committerShuah Khan <skhan@linuxfoundation.org>2022-04-25 15:13:03 -0600
commit170d1c23f2a356932259034f73d579d0bab857d6 (patch)
tree26e690f352e3a391745d9b4e0a517600ed2799a9 /tools/testing/selftests/x86/corrupt_xstate_header.c
parentselftests/x86/amx: Use provided __cpuid_count() macro (diff)
downloadlinux-dev-170d1c23f2a356932259034f73d579d0bab857d6.tar.xz
linux-dev-170d1c23f2a356932259034f73d579d0bab857d6.zip
selftests/x86/corrupt_xstate_header: Use provided __cpuid_count() macro
kselftest.h makes the __cpuid_count() macro available to conveniently call the CPUID instruction. Remove the local CPUID wrapper and use __cpuid_count() from kselftest.h instead. __cpuid_count() from kselftest.h is used instead of the macro provided by the compiler since gcc v4.4 (via cpuid.h) because the selftest needs to be supported with gcc v3.2, the minimal required version for stable kernels. Cc: Andy Lutomirski <luto@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@suse.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: x86@kernel.org Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/x86/corrupt_xstate_header.c')
-rw-r--r--tools/testing/selftests/x86/corrupt_xstate_header.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/tools/testing/selftests/x86/corrupt_xstate_header.c b/tools/testing/selftests/x86/corrupt_xstate_header.c
index ab8599c10ce5..cf9ce8fbb656 100644
--- a/tools/testing/selftests/x86/corrupt_xstate_header.c
+++ b/tools/testing/selftests/x86/corrupt_xstate_header.c
@@ -17,25 +17,13 @@
#include <stdint.h>
#include <sys/wait.h>
-static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- asm volatile(
- "cpuid;"
- : "=a" (*eax),
- "=b" (*ebx),
- "=c" (*ecx),
- "=d" (*edx)
- : "0" (*eax), "2" (*ecx));
-}
+#include "../kselftest.h" /* For __cpuid_count() */
static inline int xsave_enabled(void)
{
unsigned int eax, ebx, ecx, edx;
- eax = 0x1;
- ecx = 0x0;
- __cpuid(&eax, &ebx, &ecx, &edx);
+ __cpuid_count(0x1, 0x0, eax, ebx, ecx, edx);
/* Is CR4.OSXSAVE enabled ? */
return ecx & (1U << 27);