diff --git a/Makefile.target b/Makefile.target
index 660a855..11a6da8 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -160,9 +160,7 @@ ifeq ($(ARCH),sparc64)
 CPPFLAGS+=-I$(SRC_PATH)/tcg/sparc
 endif
 
-ifeq ($(USE_KVM), 1)
-libobj-y += qemu-kvm.o
-endif
+libobj-$(CONFIG_KVM) += qemu-kvm.o
 ifdef CONFIG_SOFTFLOAT
 libobj-y += fpu/softfloat.o
 else
@@ -173,18 +171,14 @@ libobj-y += op_helper.o helper.o
 
 ifeq ($(TARGET_ARCH), i386)
 libobj-y += helper.o
-ifeq ($(USE_KVM), 1)
-libobj-y += qemu-kvm-x86.o kvm-tpr-opt.o
-libobj-y += qemu-kvm-helper.o
-endif
+libobj-$(CONFIG_KVM) += qemu-kvm-x86.o kvm-tpr-opt.o
+libobj-$(CONFIG_KVM) += qemu-kvm-helper.o
 endif
 
 ifeq ($(TARGET_ARCH), x86_64)
 libobj-y += helper.o
-ifeq ($(USE_KVM), 1)
-libobj-y += qemu-kvm-x86.o kvm-tpr-opt.o
-libobj-y += qemu-kvm-helper.o
-endif
+libobj-$(CONFIG_KVM) += qemu-kvm-x86.o kvm-tpr-opt.o
+libobj-$(CONFIG_KVM) += qemu-kvm-helper.o
 endif
 
 libobj-y += op_helper.o
@@ -203,9 +197,7 @@ endif
 
 ifeq ($(TARGET_BASE_ARCH), ia64)
 libobj-y += op_helper.o firmware.o
-ifeq ($(USE_KVM), 1)
-libobj-y += qemu-kvm-ia64.o
-endif
+libobj-$(CONFIG_KVM) += qemu-kvm-ia64.o
 endif
 
 ifeq ($(TARGET_BASE_ARCH), cris)
diff --git a/configure b/configure
index 3a224d1..fd76259 100755
--- a/configure
+++ b/configure
@@ -2125,8 +2125,8 @@ disable_cpu_emulation() {
 configure_kvm() {
   if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
           \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" -o "$cpu" = "powerpc" \); then
-    echo "#define USE_KVM 1" >> $config_h
-    echo "USE_KVM=1" >> $config_mak
+    echo "#define CONFIG_KVM 1" >> $config_h
+    echo "CONFIG_KVM=y" >> $config_mak
     echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
     if test $kvm_cap_pit = "yes" ; then
 	echo "USE_KVM_PIT=1" >> $config_mak
@@ -2163,9 +2163,9 @@ case "$target_arch2" in
       echo "#define CONFIG_KQEMU 1" >> $config_h
     fi
     if test "$target_kvm" = "yes" ; then
-      echo "USE_KVM=yes" >> $config_mak
+      echo "CONFIG_KVM=y" >> $config_mak
       echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
-      echo "#define USE_KVM 1" >> $config_h
+      echo "#define CONFIG_KVM 1" >> $config_h
     fi
     if test "$xen" = "yes" -a "$target_softmmu" = "yes";
     then
@@ -2187,9 +2187,9 @@ case "$target_arch2" in
     fi
     if [ use_upstream_kvm = yes ]; then
     if test "$target_kvm" = "yes" ; then
-      echo "USE_KVM=yes" >> $config_mak
+      echo "CONFIG_KVM=y" >> $config_mak
       echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
-      echo "#define USE_KVM 1" >> $config_h
+      echo "#define CONFIG_KVM 1" >> $config_h
     fi
     fi
     if test "$xen" = "yes" -a "$target_softmmu" = "yes"
@@ -2284,7 +2284,7 @@ case "$target_arch2" in
     if test "$target_kvm" = "yes" ; then
       echo "CONFIG_KVM=y" >> $config_mak
       echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
-      echo "#define USE_KVM 1" >> $config_h
+      echo "#define CONFIG_KVM 1" >> $config_h
     fi
     fi
     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
diff --git a/kvm-all.c b/kvm-all.c
index 8567ac9..4c2fdf5 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -26,6 +26,7 @@
 #include "gdbstub.h"
 #include "kvm.h"
 
+#ifdef KVM_UPSTREAM
 /* KVM uses PAGE_SIZE in it's definition of COALESCED_MMIO_MAX */
 #define PAGE_SIZE TARGET_PAGE_SIZE
 
@@ -1027,3 +1028,4 @@ void kvm_remove_all_breakpoints(CPUState *current_env)
 {
 }
 #endif /* !KVM_CAP_SET_GUEST_DEBUG */
+#endif
diff --git a/libkvm-all.h b/libkvm-all.h
index e16646c..3e3e1b4 100644
--- a/libkvm-all.h
+++ b/libkvm-all.h
@@ -5,7 +5,7 @@
 #ifndef LIBKVM_H
 #define LIBKVM_H
 
-#ifdef USE_KVM
+#ifdef CONFIG_KVM
 
 #if defined(__s390__)
 #include <asm/ptrace.h>
@@ -952,10 +952,10 @@ int kvm_assign_set_msix_entry(kvm_context_t kvm,
 
 uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function, int reg);
 
-#else /* !USE_KVM */
+#else /* !CONFIG_KVM */
 
 struct kvm_pit_state { };
 
-#endif /* !USE_KVM */
+#endif /* !CONFIG_KVM */
 
 #endif
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 4c185fd..96dc85f 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -136,7 +136,7 @@ void kvm_arch_do_ioperm(void *_data);
 #define ALIGN(x, y)  (((x)+(y)-1) & ~((y)-1))
 #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8)
 
-#ifdef USE_KVM
+#ifdef CONFIG_KVM
 #include "sys-queue.h"
 
 extern int kvm_allowed;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 0af2f55..d26161a 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -24,6 +24,7 @@
 #include "cpu.h"
 #include "gdbstub.h"
 
+#ifdef KVM_UPSTREAM
 //#define DEBUG_KVM
 
 #ifdef DEBUG_KVM
@@ -959,3 +960,4 @@ void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg)
     }
 }
 #endif /* KVM_CAP_SET_GUEST_DEBUG */
+#endif
diff --git a/vl.c b/vl.c
index 5d86e69..ae02ef7 100644
--- a/vl.c
+++ b/vl.c
@@ -5644,14 +5644,14 @@ int main(int argc, char **argv, char **envp)
                 break;
 #endif
 #ifdef CONFIG_KVM
+#ifdef KVM_UPSTREAM
             case QEMU_OPTION_enable_kvm:
                 kvm_allowed = 1;
 #ifdef CONFIG_KQEMU
                 kqemu_allowed = 0;
 #endif
-                break;
 #endif
-#ifdef USE_KVM
+                break;
 	    case QEMU_OPTION_no_kvm:
 		kvm_allowed = 0;
 		break;
@@ -5948,7 +5948,7 @@ int main(int argc, char **argv, char **envp)
         signal(SIGTTIN, SIG_IGN);
     }
 
-#ifdef USE_KVM
+#ifdef CONFIG_KVM
     if (kvm_enabled()) {
 	if (kvm_qemu_init() < 0) {
 	    fprintf(stderr, "Could not initialize KVM, will disable KVM support\n");
