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] [thread-next>] [day] [month] [year] [list]
Message-ID: <py4463oypehjew7u3hlfnj4zrsnts2564qxyimgxvo4zmkma57@dnerxgzi5c3k>
Date: Wed, 27 Nov 2024 14:15:47 +0100
From: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
To: "Kirill A. Shutemov" <kirill@...temov.name>
CC: <shuah@...nel.org>, <hpa@...or.com>, <x86@...nel.org>,
	<dave.hansen@...ux.intel.com>, <bp@...en8.de>, <mingo@...hat.com>,
	<tglx@...utronix.de>, <linux-kernel@...r.kernel.org>,
	<linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH v4 1/3] selftests/lam: Move cpu_has_la57() to use cpuinfo
 flag

On 2024-11-27 at 14:11:38 +0200, Kirill A. Shutemov wrote:
>On Tue, Nov 26, 2024 at 02:34:48PM +0100, Maciej Wieczor-Retman wrote:
>> In current form cpu_has_la57() reports platform's support for LA57
>> through reading the output of cpuid. A much more useful information is
>> whether 5-level paging is actually enabled on the running system.
>> 
>> Presence of the la57 flag in /proc/cpuinfo signifies that 5-level paging
>> was compiled into the kernel, is supported by the platform and wasn't
>> disabled by kernel command line argument.
>> 
>> Use system() with cat and grep to figure out if la57 is enabled on the
>> running system.
>> 
>> Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
>> ---
>> Changelog v4:
>> - Add this patch to the series.
>> 
>>  tools/testing/selftests/x86/lam.c | 7 ++-----
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>> 
>> diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c
>> index 0ea4f6813930..0ac805125ab2 100644
>> --- a/tools/testing/selftests/x86/lam.c
>> +++ b/tools/testing/selftests/x86/lam.c
>> @@ -124,14 +124,11 @@ static inline int cpu_has_lam(void)
>>  	return (cpuinfo[0] & (1 << 26));
>>  }
>>  
>> -/* Check 5-level page table feature in CPUID.(EAX=07H, ECX=00H):ECX.[bit 16] */
>>  static inline int cpu_has_la57(void)
>>  {
>> -	unsigned int cpuinfo[4];
>> -
>> -	__cpuid_count(0x7, 0, cpuinfo[0], cpuinfo[1], cpuinfo[2], cpuinfo[3]);
>> +	int ret = !!system("cat /proc/cpuinfo | grep -wq la57\n");
>
>Heh. grep can read files on its own :P
>
>	return !system("grep -wq la57 /proc/cpuinfo");
>

Oh, thanks, missed this :)
I'll resend after fixing it.

>>  
>> -	return (cpuinfo[2] & (1 << 16));
>> +	return !ret;
>>  }
>>  
>>  /*
>> -- 
>> 2.47.1
>> 
>
>-- 
>  Kiryl Shutsemau / Kirill A. Shutemov

-- 
Kind regards
Maciej Wieczór-Retman

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ