
From: Zwane Mwaikambo <zwane@linuxpower.ca>

This patch is for the following bug, thanks to Ondrej Zary for reporting,
testing and submitting a patch.

http://bugzilla.kernel.org/show_bug.cgi?id=3767

It appears that the Cyrix MII won't touch %ecx at all resulting in stale
data being returned as extended attributes, so clear ecx before issuing the
cpuid.  I have also made the capability print code display all the
capability words for easier debugging in future.

Signed-off-by: Zwane Mwaikambo <zwane@linuxpower.ca>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/kernel/cpu/common.c |   29 +++++++++++++----------------
 25-akpm/include/asm-i386/processor.h  |    4 +++-
 2 files changed, 16 insertions(+), 17 deletions(-)

diff -puN arch/i386/kernel/cpu/common.c~cyrix-mii-cpuid-returns-stale-%ecx arch/i386/kernel/cpu/common.c
--- 25/arch/i386/kernel/cpu/common.c~cyrix-mii-cpuid-returns-stale-%ecx	2004-11-30 21:48:29.416596704 -0800
+++ 25-akpm/arch/i386/kernel/cpu/common.c	2004-11-30 21:48:29.422595792 -0800
@@ -334,21 +334,19 @@ void __init identify_cpu(struct cpuinfo_
 
 	generic_identify(c);
 
-	printk(KERN_DEBUG "CPU: After generic identify, caps: %08lx %08lx %08lx %08lx\n",
-		c->x86_capability[0],
-		c->x86_capability[1],
-		c->x86_capability[2],
-		c->x86_capability[3]);
+	printk(KERN_DEBUG "CPU: After generic identify, caps:");
+	for (i = 0; i < NCAPINTS; i++)
+		printk(" %08lx", c->x86_capability[i]);
+	printk("\n");
 
 	if (this_cpu->c_identify) {
 		this_cpu->c_identify(c);
 
-	printk(KERN_DEBUG "CPU: After vendor identify, caps:  %08lx %08lx %08lx %08lx\n",
-		c->x86_capability[0],
-		c->x86_capability[1],
-		c->x86_capability[2],
-		c->x86_capability[3]);
-}
+		printk(KERN_DEBUG "CPU: After vendor identify, caps:");
+		for (i = 0; i < NCAPINTS; i++)
+			printk(" %08lx", c->x86_capability[i]);
+		printk("\n");
+	}
 
 	/*
 	 * Vendor-specific initialization.  In this section we
@@ -398,11 +396,10 @@ void __init identify_cpu(struct cpuinfo_
 
 	/* Now the feature flags better reflect actual CPU features! */
 
-	printk(KERN_DEBUG "CPU: After all inits, caps:        %08lx %08lx %08lx %08lx\n",
-	       c->x86_capability[0],
-	       c->x86_capability[1],
-	       c->x86_capability[2],
-	       c->x86_capability[3]);
+	printk(KERN_DEBUG "CPU: After all inits, caps:");
+	for (i = 0; i < NCAPINTS; i++)
+		printk(" %08lx", c->x86_capability[i]);
+	printk("\n");
 
 	/*
 	 * On SMP, boot_cpu_data holds the common feature set between
diff -puN include/asm-i386/processor.h~cyrix-mii-cpuid-returns-stale-%ecx include/asm-i386/processor.h
--- 25/include/asm-i386/processor.h~cyrix-mii-cpuid-returns-stale-%ecx	2004-11-30 21:48:29.417596552 -0800
+++ 25-akpm/include/asm-i386/processor.h	2004-11-30 21:48:29.421595944 -0800
@@ -126,6 +126,8 @@ extern void dodgy_tsc(void);
 
 /*
  * Generic CPUID function
+ * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
+ * resulting in stale register contents being returned.
  */
 static inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx)
 {
@@ -134,7 +136,7 @@ static inline void cpuid(int op, int *ea
 		  "=b" (*ebx),
 		  "=c" (*ecx),
 		  "=d" (*edx)
-		: "0" (op));
+		: "0" (op), "c"(0));
 }
 
 /*
_
