Skip to content

Commit

Permalink
powerpc/mm/radix: Fix always false comparison against MMU_NO_CONTEXT
Browse files Browse the repository at this point in the history
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: 1a472c9 ("powerpc/mm/radix: Add tlbflush routines")
Signed-off-by: Aneesh Kumar K.V <[email protected]>
Reviewed-by: Balbir Singh <[email protected]>
[mpe: Write change log]
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
kvaneesh authored and mpe committed Jun 8, 2016
1 parent b3c0a4d commit 9690c15
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions arch/powerpc/mm/tlb-radix.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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;
Expand All @@ -130,7 +130,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;
Expand Down Expand Up @@ -160,7 +160,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;
Expand All @@ -185,7 +185,7 @@ EXPORT_SYMBOL(radix__flush_tlb_mm);
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;
Expand Down

0 comments on commit 9690c15

Please sign in to comment.