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]
Date:   Wed, 5 Jun 2019 13:07:04 -0700
From:   Sean Christopherson <sean.j.christopherson@...el.com>
To:     Qian Cai <cai@....pw>
Cc:     tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
        x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/cacheinfo: fix a -Wtype-limits warning

On Wed, Jun 05, 2019 at 03:40:54PM -0400, Qian Cai wrote:
> cpuinfo_x86.x86_model is an unsigned type, so compares it against zero
> will generate a compilation warning,
> 
> arch/x86/kernel/cpu/cacheinfo.c: In function
> 'cacheinfo_amd_init_llc_id':
> arch/x86/kernel/cpu/cacheinfo.c:662:19: warning: comparison is always
> true due to limited range of data type [-Wtype-limits]
> 
> Signed-off-by: Qian Cai <cai@....pw>
> ---
>  arch/x86/kernel/cpu/cacheinfo.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
> index 395d46f78582..c7503be92f35 100644
> --- a/arch/x86/kernel/cpu/cacheinfo.c
> +++ b/arch/x86/kernel/cpu/cacheinfo.c
> @@ -658,8 +658,7 @@ void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, int cpu, u8 node_id)
>  	if (c->x86 < 0x17) {
>  		/* LLC is at the node level. */
>  		per_cpu(cpu_llc_id, cpu) = node_id;
> -	} else if (c->x86 == 0x17 &&
> -		   c->x86_model >= 0 && c->x86_model <= 0x1F) {
> +	} else if (c->x86 == 0x17 && c->x86_model <= 0x1F) {

Might be worth calling out in the changelog that 'c->x86 == 0x17' is true
if and only if c->x86_model was explicitly set by cpu_detect(), i.e. the
patch is correct even if the original intent was a misguided attempt to
check that x86_model has been set.

Fixes: 68091ee7ac3c ("x86/CPU/AMD: Calculate last level cache ID from number of sharing threads")
Reviewed-by: Sean Christopherson <sean.j.christopherson@...el.com>

>  		/*
>  		 * LLC is at the core complex level.
>  		 * Core complex ID is ApicId[3] for these processors.
> -- 
> 1.8.3.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ