lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ae32280e-e3a2-418c-a148-c59956b6521c@linuxfoundation.org>
Date: Fri, 6 Sep 2024 08:15:29 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Muhammad Usama Anjum <Usama.Anjum@...labora.com>, shuah@...nel.org,
 fenghua.yu@...el.com, reinette.chatre@...el.com,
 ilpo.jarvinen@...ux.intel.com
Cc: linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
 Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] selftests:resctrl: Fix build failure on archs without
 __cpuid_count()

On 9/6/24 01:35, Muhammad Usama Anjum wrote:
> Hi Shuah,
> 
> Thank you for fixing it.
> 
> On 9/5/24 11:02 PM, Shuah Khan wrote:
>> When resctrl is built on architectures without __cpuid_count()
>> support, build fails. resctrl uses __cpuid_count() defined in
>> kselftest.h.
>>
>> Even though the problem is seen while building resctrl on aarch64,
>> this error can be seen on any platform that doesn't support CPUID.
>>
>> CPUID is a x86/x86-64 feature and code paths with CPUID asm commands
>> will fail to build on all other architectures.
>>
>> All others tests call __cpuid_count() do so from x86/x86_64 code paths
>> when _i386__ or __x86_64__ are defined. resctrl is an exception.
>>
>> Fix the problem by defining __cpuid_count() only when __i386__ or
>> __x86_64__ are defined in kselftest.h and changing resctrl to call
>> __cpuid_count() only when __i386__ or __x86_64__ are defined.
>>
>> In file included from resctrl.h:24,
>>                   from cat_test.c:11:
>> In function ‘arch_supports_noncont_cat’,
>>      inlined from ‘noncont_cat_run_test’ at cat_test.c:326:6:
>> ../kselftest.h:74:9: error: impossible constraint in ‘asm’
>>     74 |         __asm__ __volatile__ ("cpuid\n\t"                               \
>>        |         ^~~~~~~
>> cat_test.c:304:17: note: in expansion of macro ‘__cpuid_count’
>>    304 |                 __cpuid_count(0x10, 1, eax, ebx, ecx, edx);
>>        |                 ^~~~~~~~~~~~~
>> ../kselftest.h:74:9: error: impossible constraint in ‘asm’
>>     74 |         __asm__ __volatile__ ("cpuid\n\t"                               \
>>        |         ^~~~~~~
>> cat_test.c:306:17: note: in expansion of macro ‘__cpuid_count’
>>    306 |                 __cpuid_count(0x10, 2, eax, ebx, ecx, edx);
>>
>> Reported-by: Muhammad Usama Anjum <usama.anjum@...labora.com>
>> Reported-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
>> Signed-off-by: Shuah Khan <skhan@...uxfoundation.org>
> LGTM
> Reviewed-by: Muhammad Usama Anjum <usama.anjum@...labora.com>

Thank you for the review and finding the problem to begin with.
Much appreciated.

> 
> ...
>> diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
>> index 742782438ca3..ae3f0fa5390b 100644
>> --- a/tools/testing/selftests/resctrl/cat_test.c
>> +++ b/tools/testing/selftests/resctrl/cat_test.c
>> @@ -290,12 +290,12 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
>>   
>>   static bool arch_supports_noncont_cat(const struct resctrl_test *test)
>>   {
>> -	unsigned int eax, ebx, ecx, edx;
>> -
>>   	/* AMD always supports non-contiguous CBM. */
>>   	if (get_vendor() == ARCH_AMD)
>>   		return true;
>>   
>> +#if defined(__i386__) || defined(__x86_64__) /* arch */
>> +	unsigned int eax, ebx, ecx, edx;
>>   	/* Intel support for non-contiguous CBM needs to be discovered. */
>>   	if (!strcmp(test->resource, "L3"))
>>   		__cpuid_count(0x10, 1, eax, ebx, ecx, edx);
>> @@ -305,6 +305,8 @@ static bool arch_supports_noncont_cat(const struct resctrl_test *test)
>>   		return false;
>>   
>>   	return ((ecx >> 3) & 1);
>> +#endif /* end arch */
>> +	return false;
> nit: empty line before return

Will do.

> 
>>   }
>>   
>>   static int noncont_cat_run_test(const struct resctrl_test *test,
> 

thanks,
-- Shuah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ