Skip to contentSkip to conversation

powerpc/mm/radix: Make the pid unsigned long

PATCH Applied Aneesh Kumar K.V 3 participants 4 messages Jun 2, 2016 – Jun 10, 2016 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/mm/radix: Make the pid unsigned long

Semantic Issue: comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always false.

---
 arch/powerpc/mm/tlb-radix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/mm/tlb-radix.c +4 -4
index 7f2fa82bd155..0484fcdca00a 100644
@@ -115,7 +115,7 @@ static inline void _tlbie_va(unsigned long va, unsigned long pid,
  */
 void radix__local_flush_tlb_mm(struct mm_struct *mm)
 {
-	unsigned int pid;
+	unsigned long pid;
 
 	preempt_disable();
 	pid = mm->context.id;
@@ -128,7 +128,7 @@ EXPORT_SYMBOL(radix__local_flush_tlb_mm);
 void radix___local_flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
 			    unsigned long ap, int nid)
 {
-	unsigned int pid;
+	unsigned long pid;
 
 	preempt_disable();
 	pid = mm ? mm->context.id : 0;
@@ -158,7 +158,7 @@ static int mm_is_core_local(struct mm_struct *mm)
 
 void radix__flush_tlb_mm(struct mm_struct *mm)
 {
-	unsigned int pid;
+	unsigned long pid;
 
 	preempt_disable();
 	pid = mm->context.id;
@@ -207,7 +207,7 @@ EXPORT_SYMBOL(radix__flush_tlb_mm_pwc);
 void radix___flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
 		       unsigned long ap, int nid)
 {
-	unsigned int pid;
+	unsigned long pid;
 
 	preempt_disable();
 	pid = mm ? mm->context.id : 0;
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 41 lines · Aneesh Kumar K.V

Semantic Issue: comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always false.

---
 arch/powerpc/mm/tlb-radix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/mm/tlb-radix.c +3 -3
index 7f2fa82bd155..0484fcdca00a 100644
@@ -115,7 +115,7 @@ static inline void _tlbie_va(unsigned long va, unsigned long pid,
  */
 void radix__local_flush_tlb_mm(struct mm_struct *mm)
 {
-	unsigned int pid;
+	unsigned long pid;
 
 	preempt_disable();
 	pid = mm->context.id;
@@ -128,7 +128,7 @@ EXPORT_SYMBOL(radix__local_flush_tlb_mm);
 void radix___local_flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
 			    unsigned long ap, int nid)
 {
-	unsigned int pid;
+	unsigned long pid;
 
 	preempt_disable();
 	pid = mm ? mm->context.id : 0;
@@ -158,7 +158,7 @@ static int mm_is_core_local(struct mm_struct *mm)
 
 void radix__flush_tlb_mm(struct mm_struct *mm)
 {
-	unsigned int pid;
+	unsigned long pid;
 
 	preempt_disable();
 	pid = mm->context.id;

arch/powerpc/mm/tlb-radix.c EXPORT_SYMBOL(radix__flush_tlb_mm_pwc); · line 213

Quoted 8 lines
arch/powerpc/mm/tlb-radix.c +1 -1
@@ -207,7 +207,7 @@ EXPORT_SYMBOL(radix__flush_tlb_mm_pwc);
 void radix___flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
 		       unsigned long ap, int nid)
 {
-	unsigned int pid;
+	unsigned long pid;
 
 	preempt_disable();
 	pid = mm ? mm->context.id : 0;
reviewer Reviewed-by Balbir Singh on v1 1/1
#2 lore raw
In reply to Aneesh Kumar K.V
Quoted 8 lines · Aneesh Kumar K.V

Semantic Issue: comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always false.

---
 arch/powerpc/mm/tlb-radix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

I'm going to take this as a fix, I rewrote the change log to:

powerpc/mm/radix: Fix always false comparison against MMU_NO_CONTEXT

In some of the radix TLB flush routines, we use a local to store the mm->context.id, AKA the PID.

Currently we use an int, but the PID is unsigned long, so large values of PID will be truncated. In particular MMU_NO_CONTEXT is -1, which means all our comparisons against that value can never be true.

This means we'll issue TLB flushes when we shouldn't on radix enabled machines.

Fix it by using an unsigned long for the local. Discovered by Coverity.

Fixes 1a472c9dba6b ("powerpc/mm/radix: Add tlbflush routines")
[mpe: Write change log]

cheers