selftests/sgx: Fix corrupted cpuid macro invocation
authorJarkko Sakkinen <jarkko@kernel.org>
Sat, 4 Dec 2021 20:23:55 +0000 (22:23 +0200)
committerDave Hansen <dave.hansen@linux.intel.com>
Fri, 17 Dec 2021 16:52:33 +0000 (08:52 -0800)
The SGX selftest fails to build on tip/x86/sgx:

main.c: In function ‘get_total_epc_mem’:
main.c:296:17: error: implicit declaration of function ‘__cpuid’ [-Werror=implicit-function-declaration]
  296 |                 __cpuid(&eax, &ebx, &ecx, &edx);
      |                 ^~~~~~~

Include cpuid.h and use __cpuid_count() macro in order to fix the
compilation issue.

[ dhansen: tweak commit message ]

Fixes: f0ff2447b861 ("selftests/sgx: Add a new kselftest: Unclobbered_vdso_oversubscribed")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lkml.kernel.org/r/20211204202355.23005-1-jarkko@kernel.org
Cc: Shuah Khan <shuah@kernel.org>
tools/testing/selftests/sgx/main.c

index 7e912db4c6c5ee231046c264dc4f5668c4671edf..370c4995f7c4abccb8c2741b872a3871a0c874a6 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*  Copyright(c) 2016-20 Intel Corporation. */
 
+#include <cpuid.h>
 #include <elf.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -291,9 +292,7 @@ static unsigned long get_total_epc_mem(void)
        int section = 0;
 
        while (true) {
-               eax = SGX_CPUID;
-               ecx = section + SGX_CPUID_EPC;
-               __cpuid(&eax, &ebx, &ecx, &edx);
+               __cpuid_count(SGX_CPUID, section + SGX_CPUID_EPC, eax, ebx, ecx, edx);
 
                type = eax & SGX_CPUID_EPC_MASK;
                if (type == SGX_CPUID_EPC_INVALID)