Skip to contentSkip to conversation

i386: fix early usage of atomic_add_return and local_add_return on real i386

PATCH In review Thomas Gleixner 2 participants 3 messages May 22, 2007 Atomic infrastructure

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386: fix early usage of atomic_add_return and local_add_return on real i386

The check (boot_cpu_data.x86 == 3) in atomic_add_return() and local_add_return() fails, when those operations are used before boot_cpu_data is filled in.

Change the check to (boot_cpu_data.x86 <= 3) to fix this.

include/asm-i386/atomic.h +1 -1
Index: linux-2.6/include/asm-i386/atomic.h
===================================================================
@@ -182,7 +182,7 @@ static __inline__ int atomic_add_return(
 	int __i;
 #ifdef CONFIG_M386
 	unsigned long flags;
-	if(unlikely(boot_cpu_data.x86==3))
+	if(unlikely(boot_cpu_data.x86 <= 3))
 		goto no_xadd;
 #endif
 	/* Modern 486+ processor */
include/asm-i386/local.h +1 -1
Index: linux-2.6/include/asm-i386/local.h
===================================================================
@@ -135,7 +135,7 @@ static __inline__ long local_add_return(
 	long __i;
 #ifdef CONFIG_M386
 	unsigned long flags;
-	if(unlikely(boot_cpu_data.x86==3))
+	if(unlikely(boot_cpu_data.x86 <= 3))
 		goto no_xadd;
 #endif
 	/* Modern 486+ processor */
#1 lore raw
Quoted 5 lines · Thomas Gleixner

The check (boot_cpu_data.x86 == 3) in atomic_add_return() and local_add_return() fails, when those operations are used before boot_cpu_data is filled in.

Change the check to (boot_cpu_data.x86 <= 3) to fix this.

That's a critical boot fix for 386, right?

-Andi

#2 lore raw
Quoted 8 lines · Andi Kleen
Quoted 5 lines · Thomas Gleixner

The check (boot_cpu_data.x86 == 3) in atomic_add_return() and local_add_return() fails, when those operations are used before boot_cpu_data is filled in.

Change the check to (boot_cpu_data.x86 <= 3) to fix this.

That's a critical boot fix for 386, right?

Yup. Hit me with some debug option enabled, but might happen anywhere else too.

tglx