Skip to content

Commit aa72eec

Browse files
GustavoARSilvagregkh
authored andcommitted
x86/cpu: Change type of x86_cache_size variable to unsigned int
commit 24dbc60 upstream. Currently, x86_cache_size is of type int, which makes no sense as we will never have a valid cache size equal or less than 0. So instead of initializing this variable to -1, it can perfectly be initialized to 0 and use it as an unsigned variable instead. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Addresses-Coverity-ID: 1464429 Link: http://lkml.kernel.org/r/20180213192208.GA26414@embeddedor.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 14eb413 commit aa72eec

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

arch/x86/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct cpuinfo_x86 {
113113
char x86_vendor_id[16];
114114
char x86_model_id[64];
115115
/* in KB - valid for CPUS which support this call: */
116-
int x86_cache_size;
116+
unsigned int x86_cache_size;
117117
int x86_cache_alignment; /* In bytes */
118118
/* Cache QoS architectural values: */
119119
int x86_cache_max_rmid; /* max index */

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
11441144
int i;
11451145

11461146
c->loops_per_jiffy = loops_per_jiffy;
1147-
c->x86_cache_size = -1;
1147+
c->x86_cache_size = 0;
11481148
c->x86_vendor = X86_VENDOR_UNKNOWN;
11491149
c->x86_model = c->x86_stepping = 0; /* So far unknown... */
11501150
c->x86_vendor_id[0] = '\0'; /* Unset */

arch/x86/kernel/cpu/microcode/intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ static struct microcode_ops microcode_intel_ops = {
11321132

11331133
static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c)
11341134
{
1135-
u64 llc_size = c->x86_cache_size * 1024;
1135+
u64 llc_size = c->x86_cache_size * 1024ULL;
11361136

11371137
do_div(llc_size, c->x86_max_cores);
11381138

arch/x86/kernel/cpu/proc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
8787
}
8888

8989
/* Cache size */
90-
if (c->x86_cache_size >= 0)
91-
seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
90+
if (c->x86_cache_size)
91+
seq_printf(m, "cache size\t: %u KB\n", c->x86_cache_size);
9292

9393
show_cpuinfo_core(m, c, cpu);
9494
show_cpuinfo_misc(m, c);

0 commit comments

Comments
 (0)