Re: [PATCH] selftests/sgx: Fix corrupted cpuid macro invocation

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

 



Hi Dave and Jarkko,

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@xxxxxxxxxx>
---
  tools/testing/selftests/sgx/main.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c
index 7e912db4c6c5..370c4995f7c4 100644
--- a/tools/testing/selftests/sgx/main.c
+++ b/tools/testing/selftests/sgx/main.c
@@ -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)


Shuah confirmed ([1]) that there is no problem including cpuid.h and that this is the preferred fix.

Thank you very much Jarkko.

Acked-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>

Reinette

[1] https://lore.kernel.org/linux-kselftest/63293c72-55ca-9446-35eb-74aff4c8ba5d@xxxxxxxxxxxxxxxxxxx/



[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