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: <e364b4f9-ce92-43a9-ab06-a0391c5dcc5f@arm.com>
Date: Fri, 1 Mar 2024 13:46:36 -0600
From: Jeremy Linton <jeremy.linton@....com>
To: Liao Chang <liaochang1@...wei.com>, catalin.marinas@....com,
 will@...nel.org, broonie@...nel.org, mark.rutland@....com, maz@...nel.org,
 joey.gouly@....com, kristina.martsenko@....com, ryan.roberts@....com
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arm64: cpufeatures: Clean up temporary variable to
 simplify code

Hi,

On 2/29/24 04:52, Liao Chang wrote:
> Clean up one temporary variable to simplifiy code in capability
> detection.
> 
> Signed-off-by: Liao Chang <liaochang1@...wei.com>
> ---
>   arch/arm64/kernel/cpufeature.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 8d1a634a403e..0e900b23f7ab 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -3052,13 +3052,9 @@ static void __init enable_cpu_capabilities(u16 scope_mask)
>   	boot_scope = !!(scope_mask & SCOPE_BOOT_CPU);
>   
>   	for (i = 0; i < ARM64_NCAPS; i++) {
> -		unsigned int num;
> -
>   		caps = cpucap_ptrs[i];
> -		if (!caps || !(caps->type & scope_mask))
> -			continue;
> -		num = caps->capability;
> -		if (!cpus_have_cap(num))
> +		if (!caps || !(caps->type & scope_mask) ||
> +		    !cpus_have_cap(caps->capability))
>   			continue;
>   
>   		if (boot_scope && caps->cpu_enable)

Looks functionality equivalent to me, and just to see if it makes a 
binary difference I compiled both variations (gcc 14.0.1) and they do 
result in the same instruction sequence. Meaning gcc is smart enough to 
drop the tmp, its also smart enough equate/apply de Morgan's law. The 
latter might make it more readable too, but I guess its all a matter of 
taste.


Reviewed-by: Jeremy Linton <jeremy.linton@....com>



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ