Skip to contentSkip to conversation

i386: Decouple PAE from CONFIG_CMPXCHG64

PATCH In review Avi Kivity 3 participants 3 messages Jul 18, 2007 – Jul 19, 2007 KVM

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 i386: Decouple PAE from CONFIG_CMPXCHG64

Commit 9d9bbd4d247a674deb43565582151acdc22e90d1 makes CONFIG_CMPXCHG64 dependent on CONFIG_HIGHMEM64G, but KVM guest SMP support now also requires CMPXCHG64 while not being tied to PAE. So the effect of that patch is to disable KVM on non-PAE configs.

Untangle those dependencies by:
- having KVM select CMPXCHG64
- having HIGHMEM64G select CMPXCHG64_REQUIRED, a variant that also checks for the feature at early boot

No processors that support KVM exist that also do not support CMPXCHG64, so no additional check is necessary. This setup allows for a single kernel that will boot on i486 and also support KVM if available.

arch/i386/Kconfig +1 -0
index c7c9c2a..d894cb2 100644
@@ -542,6 +542,7 @@ config HIGHMEM4G
 config HIGHMEM64G
 	bool "64GB"
 	depends on !M386 && !M486
+	select X86_CMPXCHG64_REQUIRED
 	help
 	  Select this if you have a 32-bit processor and more than 4
 	  gigabytes of physical RAM.
arch/i386/Kconfig.cpu +5 -2
index 9cbe76c..e11870b 100644
@@ -299,8 +299,11 @@ config X86_POPAD_OK
 
 config X86_CMPXCHG64
 	bool
-	depends on X86_PAE
-	default y
+	depends on !M386 && !M486
+
+config X86_CMPXCHG64_REQUIRED
+	bool
+	select X86_CMPXCHG64
 
 config X86_ALIGNMENT_16
 	bool
drivers/kvm/Kconfig +1 -1
index 33fa28a..6d53316 100644
@@ -11,7 +11,7 @@ if VIRTUALIZATION
 config KVM
 	tristate "Kernel-based Virtual Machine (KVM) support"
 	depends on X86 && EXPERIMENTAL
-	depends on X86_CMPXCHG64 || 64BIT
+	select X86_CMPXCHG64 if X86_32
 	---help---
 	  Support hosting fully virtualized guest machines using hardware
 	  virtualization extensions.  You will need a fairly recent
include/asm-i386/required-features.h +1 -1
index 65848a0..e4746fd 100644
@@ -29,7 +29,7 @@
 # define NEED_CMOV	0
 #endif
 
-#ifdef CONFIG_X86_CMPXCHG64
+#ifdef CONFIG_X86_CMPXCHG64_REQUIRED
 # define NEED_CX8	(1<<(X86_FEATURE_CX8 & 31))
 #else
 # define NEED_CX8	0
#1 lore raw
Quoted 5 lines · Avi Kivity

Commit 9d9bbd4d247a674deb43565582151acdc22e90d1 makes CONFIG_CMPXCHG64 dependent on CONFIG_HIGHMEM64G, but KVM guest SMP support now also requires CMPXCHG64 while not being tied to PAE. So the effect of that patch is to disable KVM on non-PAE configs.

Quoted 8 lines

Untangle those dependencies by:
- having KVM select CMPXCHG64
- having HIGHMEM64G select CMPXCHG64_REQUIRED, a variant that also checks for the feature at early boot

No processors that support KVM exist that also do not support CMPXCHG64, so no additional check is necessary. This setup allows for a single kernel that will boot on i486 and also support KVM if available.

The CONFIG should only control the early CPUID checks, which are needed for PAE kernels.

But for something late like KVM the correct fix is really to drop the ifdefs around the macro and check boot_cpu_has() yourself.

-Andi

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#2 lore raw
Quoted 11 lines · Andi Kleen
Quoted 4 lines

No processors that support KVM exist that also do not support CMPXCHG64, so no additional check is necessary. This setup allows for a single kernel that will boot on i486 and also support KVM if available.

The CONFIG should only control the early CPUID checks, which are needed for PAE kernels.

But for something late like KVM the correct fix is really to drop the ifdefs around the macro and check boot_cpu_has() yourself.

He's checking for the appropriate functionality at runtime. What this does is makes it impossible to select KVM when you have already selected a CPU that doesn't support CX8.

One can, of course, question the utility, since the CPU set that supports KVM all support CX8, but not vice versa...

-hpa

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/