aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo A. R. Silva <garsilva@embeddedor.com>2018-02-13 14:22:08 -0500
committerIngo Molnar <mingo@kernel.org>2018-02-14 19:15:53 -0500
commit24dbc6000f4b9b0ef5a9daecb161f1907733765a (patch)
tree52877d24a97802248319ff3525ea151510e3f529
parent9de29eac8d2189424d81c0d840cd0469aa3d41c8 (diff)
x86/cpu: Change type of x86_cache_size variable to unsigned int
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>
-rw-r--r--arch/x86/include/asm/processor.h2
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/cpu/microcode/intel.c2
-rw-r--r--arch/x86/kernel/cpu/proc.c4
4 files changed, 5 insertions, 5 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index b7c8583328c7..44c2c4ec6d60 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -109,7 +109,7 @@ struct cpuinfo_x86 {
109 char x86_vendor_id[16]; 109 char x86_vendor_id[16];
110 char x86_model_id[64]; 110 char x86_model_id[64];
111 /* in KB - valid for CPUS which support this call: */ 111 /* in KB - valid for CPUS which support this call: */
112 int x86_cache_size; 112 unsigned int x86_cache_size;
113 int x86_cache_alignment; /* In bytes */ 113 int x86_cache_alignment; /* In bytes */
114 /* Cache QoS architectural values: */ 114 /* Cache QoS architectural values: */
115 int x86_cache_max_rmid; /* max index */ 115 int x86_cache_max_rmid; /* max index */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index a7d8df641a4c..824aee0117bb 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1184,7 +1184,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
1184 int i; 1184 int i;
1185 1185
1186 c->loops_per_jiffy = loops_per_jiffy; 1186 c->loops_per_jiffy = loops_per_jiffy;
1187 c->x86_cache_size = -1; 1187 c->x86_cache_size = 0;
1188 c->x86_vendor = X86_VENDOR_UNKNOWN; 1188 c->x86_vendor = X86_VENDOR_UNKNOWN;
1189 c->x86_model = c->x86_stepping = 0; /* So far unknown... */ 1189 c->x86_model = c->x86_stepping = 0; /* So far unknown... */
1190 c->x86_vendor_id[0] = '\0'; /* Unset */ 1190 c->x86_vendor_id[0] = '\0'; /* Unset */
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index b94279bb5c04..a15db2b4e0d6 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -982,7 +982,7 @@ static struct microcode_ops microcode_intel_ops = {
982 982
983static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c) 983static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c)
984{ 984{
985 u64 llc_size = c->x86_cache_size * 1024; 985 u64 llc_size = c->x86_cache_size * 1024ULL;
986 986
987 do_div(llc_size, c->x86_max_cores); 987 do_div(llc_size, c->x86_max_cores);
988 988
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index ee4cc388e8d3..2c8522a39ed5 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -91,8 +91,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
91 } 91 }
92 92
93 /* Cache size */ 93 /* Cache size */
94 if (c->x86_cache_size >= 0) 94 if (c->x86_cache_size)
95 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); 95 seq_printf(m, "cache size\t: %u KB\n", c->x86_cache_size);
96 96
97 show_cpuinfo_core(m, c, cpu); 97 show_cpuinfo_core(m, c, cpu);
98 show_cpuinfo_misc(m, c); 98 show_cpuinfo_misc(m, c);