* [PATCH] selftests/sgx: Fix build error caused by missing dependency
@ 2021-12-07 19:40 Reinette Chatre
2021-12-11 8:15 ` Jarkko Sakkinen
0 siblings, 1 reply; 3+ messages in thread
From: Reinette Chatre @ 2021-12-07 19:40 UTC (permalink / raw)
To: dave.hansen, jarkko, linux-sgx, shuah; +Cc: linux-kselftest
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 /path/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: /path/linux/tools/testing/selftests/sgx/main.o] Error 1
$
Make the kernel's __cpuid() available locally in support of the
test's usage.
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.
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/sgx: Fix build error caused by missing dependency
2021-12-07 19:40 [PATCH] selftests/sgx: Fix build error caused by missing dependency Reinette Chatre
@ 2021-12-11 8:15 ` Jarkko Sakkinen
2021-12-13 19:53 ` Reinette Chatre
0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Sakkinen @ 2021-12-11 8:15 UTC (permalink / raw)
To: Reinette Chatre, dave.hansen, linux-sgx, shuah; +Cc: linux-kselftest
On Tue, 2021-12-07 at 11:40 -0800, 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 /path/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: /path/linux/tools/testing/selftests/sgx/main.o] Error 1
> $
>
> Make the kernel's __cpuid() available locally in support of the
> test's usage.
It's too abstract, rather
"Clone kernel's __cpuid() implementation to the self-test in order
to make it available for 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 code change is acceptable.
/Jarkko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/sgx: Fix build error caused by missing dependency
2021-12-11 8:15 ` Jarkko Sakkinen
@ 2021-12-13 19:53 ` Reinette Chatre
0 siblings, 0 replies; 3+ messages in thread
From: Reinette Chatre @ 2021-12-13 19:53 UTC (permalink / raw)
To: Jarkko Sakkinen, dave.hansen, linux-sgx, shuah; +Cc: linux-kselftest
Hi Jarkko,
On 12/11/2021 12:15 AM, Jarkko Sakkinen wrote:
> On Tue, 2021-12-07 at 11:40 -0800, 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 /path/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: /path/linux/tools/testing/selftests/sgx/main.o] Error 1
>> $
>>
>> Make the kernel's __cpuid() available locally in support of the
>> test's usage.
>
> It's too abstract, rather
>
> "Clone kernel's __cpuid() implementation to the self-test in order
> to make it available for the EPC enumeration code."
Will do. Thank you.
>
>> 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 code change is acceptable.
Thank you.
Reinette
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-13 19:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 19:40 [PATCH] selftests/sgx: Fix build error caused by missing dependency Reinette Chatre
2021-12-11 8:15 ` Jarkko Sakkinen
2021-12-13 19:53 ` Reinette Chatre
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).