linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] microcode_amd: fix shift warning
@ 2008-08-21 20:43 Randy Dunlap
  2008-08-22  4:55 ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: Randy Dunlap @ 2008-08-21 20:43 UTC (permalink / raw)
  To: Peter Oruba; +Cc: x86, linux-next, akpm

From: Randy Dunlap <randy.dunlap@oracle.com>

microcode_amd.c uses ">> 32" on a 32-bit value, so gcc warns about that.
The code could use something like this *untested* patch.

linux-next-20080821/arch/x86/kernel/microcode_amd.c:229: warning: right shift count >= width of type

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
 arch/x86/kernel/microcode_amd.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- linux-next-20080821.orig/arch/x86/kernel/microcode_amd.c
+++ linux-next-20080821/arch/x86/kernel/microcode_amd.c
@@ -216,6 +216,7 @@ static void apply_microcode_amd(int cpu)
 	unsigned int rev;
 	int cpu_num = raw_smp_processor_id();
 	struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
+	unsigned long addr;
 
 	/* We should bind the task to the CPU */
 	BUG_ON(cpu_num != cpu);
@@ -225,10 +226,9 @@ static void apply_microcode_amd(int cpu)
 
 	spin_lock_irqsave(&microcode_update_lock, flags);
 
-	edx = (unsigned int)(((unsigned long)
-			      &(uci->mc.mc_amd->hdr.data_code)) >> 32);
-	eax = (unsigned int)(((unsigned long)
-			      &(uci->mc.mc_amd->hdr.data_code)) & 0xffffffffL);
+	addr = (unsigned long)&uci->mc.mc_amd->hdr.data_code;
+	edx = (unsigned int)(((unsigned long)upper_32_bits(addr)));
+	eax = (unsigned int)(((unsigned long)lower_32_bits(addr)));
 
 	asm volatile("movl %0, %%ecx; wrmsr" :
 		     : "i" (0xc0010020), "a" (eax), "d" (edx) : "ecx");


---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/

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

* Re: [PATCH -next] microcode_amd: fix shift warning
  2008-08-21 20:43 [PATCH -next] microcode_amd: fix shift warning Randy Dunlap
@ 2008-08-22  4:55 ` Ingo Molnar
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2008-08-22  4:55 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: Peter Oruba, x86, linux-next, akpm


* Randy Dunlap <randy.dunlap@oracle.com> wrote:

> From: Randy Dunlap <randy.dunlap@oracle.com>
> 
> microcode_amd.c uses ">> 32" on a 32-bit value, so gcc warns about that.
> The code could use something like this *untested* patch.
> 
> linux-next-20080821/arch/x86/kernel/microcode_amd.c:229: warning: right shift count >= width of type
> 
> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>

applied to tip/x86/microcode - thanks Randy!

	Ingo

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

end of thread, other threads:[~2008-08-22  4:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-21 20:43 [PATCH -next] microcode_amd: fix shift warning Randy Dunlap
2008-08-22  4:55 ` Ingo Molnar

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