linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Reinette Chatre <reinette.chatre@intel.com>,
	dave.hansen@linux.intel.com, jarkko@kernel.org,
	linux-sgx@vger.kernel.org, shuah@kernel.org
Cc: linux-kselftest@vger.kernel.org, Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH V2] selftests/sgx: Fix build error caused by missing dependency
Date: Tue, 14 Dec 2021 13:10:56 -0700	[thread overview]
Message-ID: <8b7c98f4-f050-bc1c-5699-fa598ecc66a2@linuxfoundation.org> (raw)
In-Reply-To: <de2a262e97e7b173548b909a608e9e99aab38e9d.1639509500.git.reinette.chatre@intel.com>

On 12/14/21 12:26 PM, Reinette Chatre wrote:
> Commit f0ff2447b861 ("selftests/sgx: Add a new kselftest:
> Unclobbered_vdso_oversubscribed") depends on __cpuid() without
> providing the dependency and thus introduces a build error:
> 
> $ make
> gcc -Wall -Werror -g -I../../../../tools/include -fPIC -z noexecstack -c main.c -o ../linux/tools/testing/selftests/sgx/main.o
> main.c: In function ‘get_total_epc_mem’:
> main.c:296:3: 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: ../linux/tools/testing/selftests/sgx/main.o] Error 1
> $
> 
> Clone kernel's __cpuid() implementation to the self-test in order
> to make it available to the EPC enumeration code.
> 
> Fixes: f0ff2447b861 ("selftests/sgx: Add a new kselftest: Unclobbered_vdso_oversubscribed")
> Reported-by: Jarkko Sakkinen <jarkko@kernel.org>
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
> 
> The commit introducing the issue can be found on
> the x86/sgx branch of tip.git.
> 
> Changes since V1:
> - V1: https://lore.kernel.org/linux-sgx/797ff1331cfe540fc378fcc4a4a7b00ff5099fbe.1638905135.git.reinette.chatre@intel.com/
> - Improve commit message. (Jarkko)
> 
>   tools/testing/selftests/sgx/main.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c
> index 7e912db4c6c5..6dead57a3121 100644
> --- a/tools/testing/selftests/sgx/main.c
> +++ b/tools/testing/selftests/sgx/main.c
> @@ -73,6 +73,18 @@ static bool vdso_get_symtab(void *addr, struct vdso_symtab *symtab)
>   	return true;
>   }
>   
> +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");
> +}
> +
>   static unsigned long elf_sym_hash(const char *name)
>   {
>   	unsigned long h = 0, high;
> 

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.

There has been a proliferation of defines in tools and selftests.
I just fixed/remove 25+ ARRAY_SIZE duplicate define in selftests.
  
thanks,
-- Shuah

  reply	other threads:[~2021-12-14 20:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 19:26 [PATCH V2] selftests/sgx: Fix build error caused by missing dependency Reinette Chatre
2021-12-14 20:10 ` Shuah Khan [this message]
2021-12-14 21:28   ` Reinette Chatre
2021-12-14 21:55     ` Shuah Khan
2021-12-14 22:27       ` Reinette Chatre
2021-12-14 22:59         ` Shuah Khan

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=8b7c98f4-f050-bc1c-5699-fa598ecc66a2@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=jarkko@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).