kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] x86, UV: integer wrap bug in uv_hub_ipi_value()
@ 2012-11-17 15:16 Dan Carpenter
  2012-11-20  0:48 ` Russ Anderson
  0 siblings, 1 reply; 14+ messages in thread
From: Dan Carpenter @ 2012-11-17 15:16 UTC (permalink / raw)
  To: Thomas Gleixner, Jack Steiner, Dimitri Sivanich
  Cc: Ingo Molnar, H. Peter Anvin, x86, Russ Anderson, linux-kernel,
	kernel-janitors

This is a static checker fix.  The problem is that we store the bits
from "uv_apicid_hibits" into "apicid" (the high 16 bits) but then we
shift it 16 bit to the left.  "apicid" is an int so it wraps and we lose
them.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is for an SGI product, and I can't test it.

diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h
index 21f7385..f3a0f91 100644
--- a/arch/x86/include/asm/uv/uv_hub.h
+++ b/arch/x86/include/asm/uv/uv_hub.h
@@ -573,7 +573,7 @@ static inline void uv_set_cpu_scir_bits(int cpu, unsigned char value)
 }
 
 extern unsigned int uv_apicid_hibits;
-static unsigned long uv_hub_ipi_value(int apicid, int vector, int mode)
+static unsigned long uv_hub_ipi_value(ulong apicid, ulong vector, ulong mode)
 {
 	apicid |= uv_apicid_hibits;
 	return (1UL << UVH_IPI_INT_SEND_SHFT) |
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index 8cfade9..6d93b2f 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -194,13 +194,13 @@ static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_ri
 	pnode = uv_apicid_to_pnode(phys_apicid);
 	phys_apicid |= uv_apicid_hibits;
 	val = (1UL << UVH_IPI_INT_SEND_SHFT) |
-	    (phys_apicid << UVH_IPI_INT_APIC_ID_SHFT) |
+	    ((unsigned long)phys_apicid << UVH_IPI_INT_APIC_ID_SHFT) |
 	    ((start_rip << UVH_IPI_INT_VECTOR_SHFT) >> 12) |
 	    APIC_DM_INIT;
 	uv_write_global_mmr64(pnode, UVH_IPI_INT, val);
 
 	val = (1UL << UVH_IPI_INT_SEND_SHFT) |
-	    (phys_apicid << UVH_IPI_INT_APIC_ID_SHFT) |
+	    ((unsigned long)phys_apicid << UVH_IPI_INT_APIC_ID_SHFT) |
 	    ((start_rip << UVH_IPI_INT_VECTOR_SHFT) >> 12) |
 	    APIC_DM_STARTUP;
 	uv_write_global_mmr64(pnode, UVH_IPI_INT, val);

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

end of thread, other threads:[~2012-12-03  7:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-17 15:16 [patch] x86, UV: integer wrap bug in uv_hub_ipi_value() Dan Carpenter
2012-11-20  0:48 ` Russ Anderson
2012-11-20  4:28   ` Dan Carpenter
2012-11-20  4:55     ` H. Peter Anvin
2012-11-20 11:10     ` Alan Cox
2012-11-20 16:27       ` Russ Anderson
2012-11-20 17:09         ` H. Peter Anvin
2012-11-20 17:07     ` Russ Anderson
2012-11-21  7:39       ` Dan Carpenter
2012-12-02 10:44         ` [patch v2] " Dan Carpenter
2012-12-02 15:33           ` walter harms
2012-12-02 17:28             ` [patch v3] " Dan Carpenter
2012-12-02 17:35               ` Dan Carpenter
2012-12-03  7:58                 ` [patch v4] " Dan Carpenter

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).