Hi Jarkko,
(Dave: I am very sorry - selftests on x86/sgx on tip.git is currently broken because of this)
On 12/4/2021 12:23 PM, Jarkko Sakkinen wrote:
Compilation results:
$ make -C tools/testing/selftests/sgx/ make: Entering directory '/home/jarkko/Projects/linux-sgx/tools/testing/selftests/sgx' gcc -Wall -Werror -g -I../../../../tools/include -fPIC -z noexecstack -c main.c -o /home/jarkko/Projects/linux-sgx/tools/testing/selftests/sgx/main.o 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); | ^~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:33: /home/jarkko/Projects/linux-sgx/tools/testing/selftests/sgx/main.o] Error 1 make: Leaving directory '/home/jarkko/Projects/linux-sgx/tools/testing/selftests/sgx'
Include to cpuid.h is missing and the macro usage is incorrect.
Include cpuid.h and use __cpuid_count() macro in order to fix the compilation issue.
Fixes: f0ff2447b861 ("selftests/sgx: Add a new kselftest: Unclobbered_vdso_oversubscribed") Signed-off-by: Jarkko Sakkinen jarkko@kernel.org
I am sorry - this was my mistake because of a last minute change to that patch that I submitted with a dependency that only arrives in a later patch that is not upstream yet.
Jarkko, thank you very much for catching this.
I am not sure what the right way is to fix it though - my original intention, what the code uses, was to add a snippet as below as is the custom for all tests needing to run cpuid. There are many usages of cpuid among the selftests but none rely on the cpuid.h to bring in __cpuid_count. I do not know the motivation for this but preferred to stick with the custom for my implementation.
+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) + : "memory"); +}
Reinette