kernel: add MIPS kernel fix for an uninitialized CPU map
[openwrt/openwrt.git] / target / linux / generic / patches-4.4 / 103-MIPS-smp.c-Fix-uninitialised-temp_foreign_map.patch
1 From: James Hogan <james.hogan@imgtec.com>
2 Date: Fri, 4 Mar 2016 10:10:51 +0000
3 Subject: [PATCH] MIPS: smp.c: Fix uninitialised temp_foreign_map
4
5 When calculate_cpu_foreign_map() recalculates the cpu_foreign_map
6 cpumask it uses the local variable temp_foreign_map without initialising
7 it to zero. Since the calculation only ever sets bits in this cpumask
8 any existing bits at that memory location will remain set and find their
9 way into cpu_foreign_map too. This could potentially lead to cache
10 operations suboptimally doing smp calls to multiple VPEs in the same
11 core, even though the VPEs share primary caches.
12
13 Therefore initialise temp_foreign_map using cpumask_clear() before use.
14
15 Fixes: cccf34e9411c ("MIPS: c-r4k: Fix cache flushing for MT cores")
16 Signed-off-by: James Hogan <james.hogan@imgtec.com>
17 Cc: Ralf Baechle <ralf@linux-mips.org>
18 Cc: Paul Burton <paul.burton@imgtec.com>
19 Cc: linux-mips@linux-mips.org
20 ---
21
22 --- a/arch/mips/kernel/smp.c
23 +++ b/arch/mips/kernel/smp.c
24 @@ -121,6 +121,7 @@ static inline void calculate_cpu_foreign
25 cpumask_t temp_foreign_map;
26
27 /* Re-calculate the mask */
28 + cpumask_clear(&temp_foreign_map);
29 for_each_online_cpu(i) {
30 core_present = 0;
31 for_each_cpu(k, &temp_foreign_map)