linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/mm/radix: Make the pid unsigned long
@ 2016-06-02  9:44 Aneesh Kumar K.V
  2016-06-03  5:28 ` Balbir Singh
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Aneesh Kumar K.V @ 2016-06-02  9:44 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

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

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/mm/tlb-radix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
index 7f2fa82bd155..0484fcdca00a 100644
--- a/arch/powerpc/mm/tlb-radix.c
+++ b/arch/powerpc/mm/tlb-radix.c
@@ -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;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/mm/radix: Make the pid unsigned long
  2016-06-02  9:44 [PATCH] powerpc/mm/radix: Make the pid unsigned long Aneesh Kumar K.V
@ 2016-06-03  5:28 ` Balbir Singh
  2016-06-08  3:58 ` Michael Ellerman
  2016-06-10  3:26 ` Michael Ellerman
  2 siblings, 0 replies; 4+ messages in thread
From: Balbir Singh @ 2016-06-03  5:28 UTC (permalink / raw)
  To: linuxppc-dev



On 02/06/16 19:44, Aneesh Kumar K.V wrote:
> Semantic Issue: comparison of constant 18446744073709551615 with
> expression of type 'unsigned int' is always false.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
>  arch/powerpc/mm/tlb-radix.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
> index 7f2fa82bd155..0484fcdca00a 100644
> --- a/arch/powerpc/mm/tlb-radix.c
> +++ b/arch/powerpc/mm/tlb-radix.c
> @@ -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;
> 

Reviewed-by: Balbir Singh <bsingharora@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: powerpc/mm/radix: Make the pid unsigned long
  2016-06-02  9:44 [PATCH] powerpc/mm/radix: Make the pid unsigned long Aneesh Kumar K.V
  2016-06-03  5:28 ` Balbir Singh
@ 2016-06-08  3:58 ` Michael Ellerman
  2016-06-10  3:26 ` Michael Ellerman
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2016-06-08  3:58 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus; +Cc: linuxppc-dev, Aneesh Kumar K.V

On Thu, 2016-02-06 at 09:44:48 UTC, "Aneesh Kumar K.V" wrote:
> Semantic Issue: comparison of constant 18446744073709551615 with
> expression of type 'unsigned int' is always false.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Reviewed-by: Balbir Singh <bsingharora@gmail.com>
> ---
>  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")
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
    Reviewed-by: Balbir Singh <bsingharora@gmail.com>
    [mpe: Write change log]
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: powerpc/mm/radix: Make the pid unsigned long
  2016-06-02  9:44 [PATCH] powerpc/mm/radix: Make the pid unsigned long Aneesh Kumar K.V
  2016-06-03  5:28 ` Balbir Singh
  2016-06-08  3:58 ` Michael Ellerman
@ 2016-06-10  3:26 ` Michael Ellerman
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2016-06-10  3:26 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus; +Cc: linuxppc-dev, Aneesh Kumar K.V

On Thu, 2016-02-06 at 09:44:48 UTC, "Aneesh Kumar K.V" wrote:
> Semantic Issue: comparison of constant 18446744073709551615 with
> expression of type 'unsigned int' is always false.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Reviewed-by: Balbir Singh <bsingharora@gmail.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/9690c15742688e9cb5ee4aa0b0

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-10  3:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-02  9:44 [PATCH] powerpc/mm/radix: Make the pid unsigned long Aneesh Kumar K.V
2016-06-03  5:28 ` Balbir Singh
2016-06-08  3:58 ` Michael Ellerman
2016-06-10  3:26 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).