All of lore.kernel.org
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Dave Hansen <dave.hansen@intel.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	Shuah Khan <shuah@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	<linux-kselftest@vger.kernel.org>, <linux-sgx@vger.kernel.org>
Subject: Re: [PATCH] selftests/sgx: Fix corrupted cpuid macro invocation
Date: Mon, 6 Dec 2021 15:32:29 -0800	[thread overview]
Message-ID: <c4257eaf-ecf8-ed35-aa67-5594005aa68c@intel.com> (raw)
In-Reply-To: <eb4a5d7a-64f4-bdf3-2d12-879607f914c3@intel.com>

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



  reply	other threads:[~2021-12-06 23:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-04 20:23 [PATCH] selftests/sgx: Fix corrupted cpuid macro invocation Jarkko Sakkinen
2021-12-05  0:32 ` Reinette Chatre
2021-12-06 22:54   ` Dave Hansen
2021-12-06 23:32     ` Reinette Chatre [this message]
2021-12-06 23:36       ` Dave Hansen
2021-12-15  0:19 ` Reinette Chatre
2021-12-22  0:40   ` Jarkko Sakkinen
2021-12-17 16:58 ` [tip: x86/sgx] " tip-bot2 for Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c4257eaf-ecf8-ed35-aa67-5594005aa68c@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jarkko@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.