On 12/14/21 2:28 PM, Reinette Chatre wrote:
Hi Shuah,
On 12/14/2021 12:10 PM, Shuah Khan wrote:
Let's not add one more __cpuid() define to the individual tests.
We so far have:
tools/testing/selftests/vm/pkey-x86.h
selftests/x86/corrupt_xstate_header.c
Let's move the defines to kselftest.h and remove all these duplicate
defines.
For now you could include vm/pkey-x86.h just to fix the build error
and do the proper cleanup.
Thank you so much for taking a look. We actually do have an alternative fix that could be considered for the other users of __cpuid(). Instead of another clone of the kernel's __cpuid() the fix includes cpuid.h and uses the existing __cpuid_count() from it.
Please see:
https://lore.kernel.org/linux-sgx/20211204202355.23005-1-jarkko@xxxxxxxxxx/
This looks good to me.
We decided against the above fix using __cpuid_count() because we could not explain why all the existing users of __cpuid() implement their own and decided to follow the custom instead ...
Most likely, copy and paste and taking the easy route. I looked at a couple of
defines and I dont't see a difference. If there are differences, that would be
a bigger concern. The whole idea of not having duplicates is that we don't have
bugs in these duplicates.
Do you see any problem with including cpuid.h into a selftest? If not, then we can go back to our original fix of this issue and I could also submit a change to remove all the __cpuid() clones and replace them with the library's __cpuid_count().
There are no problems including cpuid.h - where is this though. I couldn't find
it in my cscope search?
thanks,
-- Shuah