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

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

 



Hi Dave,

On 12/6/2021 2:54 PM, Dave Hansen wrote:
On 12/4/21 4:32 PM, Reinette Chatre wrote:
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, is there some reason using __cpuid_count() won't work for the
SGX test?  Or is your concern that it _might_ break something because
you haven't tested it?

As a sanity check I tested with __cpuid_count() and it works.

My concern is actually about the kselftest framework where I could not answer the following question with certainty: why are there so many usages of cpuid but everybody writes their own instead of including cpuid.h? I am concerned that there are some environment constraints that I am not familiar with and thus decided to follow the custom.

One speculation is that since cpuid.h arrives with libgcc's dev package instead of the regular libc dev package there may now be a new dependency on what users need to have on their systems to run these tests.

Reinette





[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux