All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Reinette Chatre <reinette.chatre@intel.com>
Cc: Shuah Khan <shuah@kernel.org>,
	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: Wed, 22 Dec 2021 02:40:04 +0200	[thread overview]
Message-ID: <YcJz5HScqjAiWUBk@iki.fi> (raw)
In-Reply-To: <1eefe8b4-feec-3f2a-7eae-c10e49fbedf0@intel.com>

On Tue, Dec 14, 2021 at 04:19:24PM -0800, Reinette Chatre wrote:
> 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@kernel.org>
> > ---
> >   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@intel.com>
> 
> Reinette
> 
> [1] https://lore.kernel.org/linux-kselftest/63293c72-55ca-9446-35eb-74aff4c8ba5d@linuxfoundation.org/

OK, cool, thanks!

/Jarkko

  reply	other threads:[~2021-12-22  0:40 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
2021-12-06 23:36       ` Dave Hansen
2021-12-15  0:19 ` Reinette Chatre
2021-12-22  0:40   ` Jarkko Sakkinen [this message]
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=YcJz5HScqjAiWUBk@iki.fi \
    --to=jarkko@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=reinette.chatre@intel.com \
    --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.