Skip to contentSkip to conversation

x86-64: Simplify cpu_has_invlpg

PATCH In review Brian Gerst 3 participants 6 messages Jul 10, 2011 – Jul 11, 2011 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86-64: Simplify cpu_has_invlpg

Define CONFIG_X86_INVLPG for 64-bit too, which simplifies the code.

---
 arch/x86/Kconfig.cpu              |    2 +-
 arch/x86/include/asm/cpufeature.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/Kconfig.cpu +1 -1
index 6a7cfdf..d801dfe 100644
@@ -350,7 +350,7 @@ config X86_WP_WORKS_OK
 
 config X86_INVLPG
 	def_bool y
-	depends on X86_32 && !M386
+	depends on !M386
 
 config X86_BSWAP
 	def_bool y
arch/x86/include/asm/cpufeature.h +1 -1
index 71cc380..102b6f0 100644
@@ -289,7 +289,7 @@ extern const char * const x86_power_flags[32];
 #define cpu_has_pclmulqdq	boot_cpu_has(X86_FEATURE_PCLMULQDQ)
 #define cpu_has_perfctr_core	boot_cpu_has(X86_FEATURE_PERFCTR_CORE)
 
-#if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64)
+#ifdef CONFIG_X86_INVLPG
 # define cpu_has_invlpg		1
 #else
 # define cpu_has_invlpg		(boot_cpu_data.x86 > 3)
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 2/2 x86: Simplify X86_CMPXCHG, CMPXCHG_LOCAL, and X86_XADD

X86_64 and M386 can never be both set, so reduce the conditional to !M386.

---
 arch/x86/Kconfig.cpu |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
arch/x86/Kconfig.cpu +3 -4
index d801dfe..a913325 100644
@@ -307,10 +307,10 @@ config X86_INTERNODE_CACHE_SHIFT
 	default X86_L1_CACHE_SHIFT
 
 config X86_CMPXCHG
-	def_bool X86_64 || (X86_32 && !M386)
+	def_bool !M386
 
 config CMPXCHG_LOCAL
-	def_bool X86_64 || (X86_32 && !M386)
+	def_bool !M386
 
 config X86_L1_CACHE_SHIFT
 	int
@@ -320,8 +320,7 @@ config X86_L1_CACHE_SHIFT
 	default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
 
 config X86_XADD
-	def_bool y
-	depends on X86_64 || !M386
+	def_bool !M386
 
 config X86_PPRO_FENCE
 	bool "PentiumPro memory ordering errata workaround"
Signature · 1 line
1.7.4.4
#4 lore raw
In reply to Brian Gerst
Quoted 3 lines · Brian Gerst

Define CONFIG_X86_INVLPG for 64-bit too, which simplifies the code.

I think a much better way to do this kind of stuff is to define Linux-specific CPU feature bits (which we already have quite a few of).
That way they fall into the same mechanism as everything else that has
switches on CPU features, we can use alternatives, and so on.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#5 lore raw
Quoted 9 lines · H. Peter Anvin
Quoted 3 lines · Brian Gerst

Define CONFIG_X86_INVLPG for 64-bit too, which simplifies the code.

I think a much better way to do this kind of stuff is to define Linux-specific CPU feature bits (which we already have quite a few of). That way they fall into the same mechanism as everything else that has switches on CPU features, we can use alternatives, and so on.

I don't think it's worth getting too fancy with this. Even if you used alternatives, you'd want the config option to eliminate the alternative when compiling for 486+.

--
Brian Gerst