Skip to contentSkip to conversation

MIPS: smp.c: Fix uninitialised temp_foreign_map

PATCH In review [email protected] 2 participants 2 messages Mar 14, 2016 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: smp.c: Fix uninitialised temp_foreign_map

From: James Hogan <[email protected]>

When calculate_cpu_foreign_map() recalculates the cpu_foreign_map cpumask it uses the local variable temp_foreign_map without initialising it to zero. Since the calculation only ever sets bits in this cpumask any existing bits at that memory location will remain set and find their way into cpu_foreign_map too. This could potentially lead to cache operations suboptimally doing smp calls to multiple VPEs in the same core, even though the VPEs share primary caches.

Therefore initialise temp_foreign_map using cpumask_clear() before use.

Fixes cccf34e9411c ("MIPS: c-r4k: Fix cache flushing for MT cores")
Cc Paul Burton <[email protected]>

Patchwork: https://patchwork.linux-mips.org/patch/12759/

---
 arch/mips/kernel/smp.c | 1 +
 1 file changed, 1 insertion(+)
arch/mips/kernel/smp.c +1 -0
index bd4385a..2b521e0 100644
@@ -121,6 +121,7 @@ static inline void calculate_cpu_foreign_map(void)
 	cpumask_t temp_foreign_map;
 
 	/* Re-calculate the mask */
+	cpumask_clear(&temp_foreign_map);
 	for_each_online_cpu(i) {
 		core_present = 0;
 		for_each_cpu(k, &temp_foreign_map)
Signature · 1 line
1.9.1
#1 lore raw

Please fix your scripts to not repost patches.

Ralf

Quoted 44 lines · On Mon, Mar 14, 2016 at 02:12:58PM +0800, [email protected] wrote:

From: [email protected]
To: Miles <[email protected]>
CC: James Hogan <[email protected]>, Paul Burton
<[email protected]>, [email protected], Ralf Baechle <[email protected]>
Subject: [PATCH] MIPS: smp.c: Fix uninitialised temp_foreign_map
Content-Type: text/plain

From: James Hogan <[email protected]>

When calculate_cpu_foreign_map() recalculates the cpu_foreign_map cpumask it uses the local variable temp_foreign_map without initialising it to zero. Since the calculation only ever sets bits in this cpumask any existing bits at that memory location will remain set and find their way into cpu_foreign_map too. This could potentially lead to cache operations suboptimally doing smp calls to multiple VPEs in the same core, even though the VPEs share primary caches.

Therefore initialise temp_foreign_map using cpumask_clear() before use.

Fixes cccf34e9411c ("MIPS: c-r4k: Fix cache flushing for MT cores")
Cc Paul Burton <[email protected]>

Patchwork: https://patchwork.linux-mips.org/patch/12759/

---
 arch/mips/kernel/smp.c | 1 +
 1 file changed, 1 insertion(+)
arch/mips/kernel/smp.c +1 -0
index bd4385a..2b521e0 100644
@@ -121,6 +121,7 @@ static inline void calculate_cpu_foreign_map(void)
 	cpumask_t temp_foreign_map;
 
 	/* Re-calculate the mask */
+	cpumask_clear(&temp_foreign_map);
 	for_each_online_cpu(i) {
 		core_present = 0;
 		for_each_cpu(k, &temp_foreign_map)
Signature · 1 line
1.9.1

Ralf