diff --git a/arm-semi.c b/arm-semi.c
index 0687b03..4c5ab65 100644
--- a/arm-semi.c
+++ b/arm-semi.c
@@ -26,7 +26,7 @@
 #include <stdio.h>
 #include <time.h>
 
-#include "cpu.h"
+#include "config.h"
 #ifdef CONFIG_USER_ONLY
 #include "qemu.h"
 
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 554ff8b..6450571 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -4,6 +4,7 @@
 #include <signal.h>
 #include <string.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 
 #undef DEBUG_REMAP
diff --git a/cpu-exec.c b/cpu-exec.c
index 026980a..e4e0def 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -17,6 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "config.h"
+#include "qemu-common.h"
 #include "exec.h"
 #include "disas.h"
 #include "tcg.h"
diff --git a/darwin-user/qemu.h b/darwin-user/qemu.h
index 462bbda..a5d53ea 100644
--- a/darwin-user/qemu.h
+++ b/darwin-user/qemu.h
@@ -4,6 +4,7 @@
 #include <signal.h>
 #include <string.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 
 #include "thunk.h"
diff --git a/disas.c b/disas.c
index 79a98de..2905459 100644
--- a/disas.c
+++ b/disas.c
@@ -1,5 +1,6 @@
 /* General "disassemble this chunk" code.  Used for debugging. */
 #include "config.h"
+#include "qemu-common.h"
 #include "dis-asm.h"
 #include "elf.h"
 #include <errno.h>
diff --git a/exec.c b/exec.c
index 7f64384..8b61259 100644
--- a/exec.c
+++ b/exec.c
@@ -31,9 +31,9 @@
 #include <unistd.h>
 #include <inttypes.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
-#include "qemu-common.h"
 #include "tcg.h"
 #include "hw/hw.h"
 #include "osdep.h"
diff --git a/linux-user/arm/nwfpe/fpa11.h b/linux-user/arm/nwfpe/fpa11.h
index 07419e2..0e64897 100644
--- a/linux-user/arm/nwfpe/fpa11.h
+++ b/linux-user/arm/nwfpe/fpa11.h
@@ -25,7 +25,8 @@
 #include <stdio.h>
 #include <errno.h>
 
-#include <cpu.h>
+#include "qemu-common.h"
+#include "cpu.h"
 
 #define GET_FPA11() (qemufpa)
 
diff --git a/linux-user/main.c b/linux-user/main.c
index 403c8d3..e0511ee 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -27,7 +27,6 @@
 #include <sys/resource.h>
 
 #include "qemu.h"
-#include "qemu-common.h"
 #include "cache-utils.h"
 /* For tb_lock */
 #include "exec-all.h"
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 1878d5a..e2bd7f8 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -4,6 +4,7 @@
 #include <signal.h>
 #include <string.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 
 #undef DEBUG_REMAP
diff --git a/m68k-semi.c b/m68k-semi.c
index d16bc67..7baa97b 100644
--- a/m68k-semi.c
+++ b/m68k-semi.c
@@ -27,7 +27,7 @@
 #include <sys/time.h>
 #include <time.h>
 
-#include "cpu.h"
+#include "config.h"
 #if defined(CONFIG_USER_ONLY)
 #include "qemu.h"
 #define SEMIHOSTING_HEAP_SIZE (128 * 1024 * 1024)
diff --git a/target-alpha/helper.c b/target-alpha/helper.c
index b6d2160..043dbc1 100644
--- a/target-alpha/helper.c
+++ b/target-alpha/helper.c
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "softfloat.h"
diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c
index ff5ae26..39a6a85 100644
--- a/target-alpha/op_helper.c
+++ b/target-alpha/op_helper.c
@@ -17,6 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu-common.h"
 #include "exec.h"
 #include "host-utils.h"
 #include "softfloat.h"
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index 3a1c625..72eeb09 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -21,12 +21,12 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
 #include "host-utils.h"
 #include "tcg-op.h"
-#include "qemu-common.h"
 
 #include "helper.h"
 #define GEN_HELPER 1
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 63e5dc7..79f5be8 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -2,11 +2,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "gdbstub.h"
 #include "helpers.h"
-#include "qemu-common.h"
 #include "host-utils.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/loader.h"
diff --git a/target-arm/iwmmxt_helper.c b/target-arm/iwmmxt_helper.c
index 3332f70..ec8c456 100644
--- a/target-arm/iwmmxt_helper.c
+++ b/target-arm/iwmmxt_helper.c
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "helpers.h"
diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index 5e6452b..ae9d955 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "helpers.h"
diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
index 9b1a014..6f0f4ce 100644
--- a/target-arm/op_helper.c
+++ b/target-arm/op_helper.c
@@ -16,6 +16,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
+#include "qemu-common.h"
 #include "exec.h"
 #include "helpers.h"
 
diff --git a/target-arm/translate.c b/target-arm/translate.c
index a28e2ff..3c37626 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
diff --git a/target-cris/helper.c b/target-cris/helper.c
index 240bda0..e781aa9 100644
--- a/target-cris/helper.c
+++ b/target-cris/helper.c
@@ -22,6 +22,7 @@
 #include <string.h>
 
 #include "config.h"
+#include "qemu-common.h"
 #include "cpu.h"
 #include "mmu.h"
 #include "exec-all.h"
diff --git a/target-cris/mmu.c b/target-cris/mmu.c
index d09e921..bc6c8da 100644
--- a/target-cris/mmu.c
+++ b/target-cris/mmu.c
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 
 #include "config.h"
+#include "qemu-common.h"
 #include "cpu.h"
 #include "mmu.h"
 #include "exec-all.h"
diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c
index a60da94..9e21799 100644
--- a/target-cris/op_helper.c
+++ b/target-cris/op_helper.c
@@ -18,6 +18,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu-common.h"
 #include "exec.h"
 #include "mmu.h"
 #include "helper.h"
diff --git a/target-cris/translate.c b/target-cris/translate.c
index 45c7682..b4bc99b 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
@@ -36,7 +37,6 @@
 #include "helper.h"
 #include "mmu.h"
 #include "crisv32-decode.h"
-#include "qemu-common.h"
 
 #define GEN_HELPER 1
 #include "helper.h"
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 6a0f7ca..c47518e 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "kvm.h"
 
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 718394c..3eabb44 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -23,9 +23,9 @@
 #include <inttypes.h>
 #include <signal.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
-#include "qemu-common.h"
 #include "kvm.h"
 
 //#define DEBUG_MMU
diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c
index c1256f4..d68be64 100644
--- a/target-i386/op_helper.c
+++ b/target-i386/op_helper.c
@@ -17,6 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 #define CPU_NO_GLOBAL_REGS
+#include "qemu-common.h"
 #include "exec.h"
 #include "exec-all.h"
 #include "host-utils.h"
diff --git a/target-i386/translate.c b/target-i386/translate.c
index 708b0a1..cbc2bcd 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -23,6 +23,7 @@
 #include <inttypes.h>
 #include <signal.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index b4ebb14..a0d1e35 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -22,9 +22,9 @@
 #include <string.h>
 
 #include "config.h"
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
-#include "qemu-common.h"
 #include "gdbstub.h"
 
 #include "helpers.h"
diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c
index 0711107..b98d257 100644
--- a/target-m68k/op_helper.c
+++ b/target-m68k/op_helper.c
@@ -16,6 +16,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
+#include "qemu-common.h"
 #include "exec.h"
 #include "helpers.h"
 
diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index 5351880..234e263 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -24,6 +24,7 @@
 #include <inttypes.h>
 
 #include "config.h"
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
diff --git a/target-microblaze/helper.c b/target-microblaze/helper.c
index 5230b52..e575fe9 100644
--- a/target-microblaze/helper.c
+++ b/target-microblaze/helper.c
@@ -22,6 +22,7 @@
 #include <assert.h>
 
 #include "config.h"
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "host-utils.h"
diff --git a/target-microblaze/mmu.c b/target-microblaze/mmu.c
index b38f7d9..224c2fd 100644
--- a/target-microblaze/mmu.c
+++ b/target-microblaze/mmu.c
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <assert.h>
 
+#include "qemu-common.h"
 #include "config.h"
 #include "cpu.h"
 #include "exec-all.h"
diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c
index be0c829..568fe88 100644
--- a/target-microblaze/op_helper.c
+++ b/target-microblaze/op_helper.c
@@ -18,6 +18,7 @@
  */
 
 #include <assert.h>
+#include "qemu-common.h"
 #include "exec.h"
 #include "helper.h"
 #include "host-utils.h"
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index ca54e2c..f7a01fe 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -24,13 +24,13 @@
 #include <inttypes.h>
 #include <assert.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
 #include "tcg-op.h"
 #include "helper.h"
 #include "microblaze-decode.h"
-#include "qemu-common.h"
 
 #define GEN_HELPER 1
 #include "helper.h"
diff --git a/target-mips/helper.c b/target-mips/helper.c
index ea221ab..84bf8a2 100644
--- a/target-mips/helper.c
+++ b/target-mips/helper.c
@@ -23,6 +23,7 @@
 #include <inttypes.h>
 #include <signal.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 
diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index d09d6ed..c0e56f4 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -17,6 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 #include <stdlib.h>
+#include "qemu-common.h"
 #include "exec.h"
 
 #include "host-utils.h"
diff --git a/target-mips/translate.c b/target-mips/translate.c
index d43d72d..e4d94f6 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -26,11 +26,11 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
 #include "tcg-op.h"
-#include "qemu-common.h"
 
 #include "helper.h"
 #define GEN_HELPER 1
diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index d342b09..a114eb9 100644
--- a/target-ppc/helper.c
+++ b/target-ppc/helper.c
@@ -23,10 +23,10 @@
 #include <inttypes.h>
 #include <signal.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "helper_regs.h"
-#include "qemu-common.h"
 #include "kvm.h"
 
 //#define DEBUG_MMU
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index 3c3aa60..89faf93 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -17,6 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 #include <string.h>
+#include "qemu-common.h"
 #include "exec.h"
 #include "host-utils.h"
 #include "helper.h"
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 66e1c0d..ff6f7c1 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -22,11 +22,11 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
 #include "tcg-op.h"
-#include "qemu-common.h"
 #include "host-utils.h"
 
 #include "helper.h"
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 4a5297b..d474bca 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -21,10 +21,10 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "gdbstub.h"
-#include "qemu-common.h"
 
 #include <linux/kvm.h>
 #include "kvm.h"
diff --git a/target-s390x/op_helper.c b/target-s390x/op_helper.c
index 402df2d..54982f3 100644
--- a/target-s390x/op_helper.c
+++ b/target-s390x/op_helper.c
@@ -17,6 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu-common.h"
 #include "exec.h"
 
 /*****************************************************************************/
diff --git a/target-sh4/helper.c b/target-sh4/helper.c
index 9e70352..63d48c1 100644
--- a/target-sh4/helper.c
+++ b/target-sh4/helper.c
@@ -23,6 +23,7 @@
 #include <inttypes.h>
 #include <signal.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "hw/sh_intc.h"
diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c
index 2e5f555..93d2684 100644
--- a/target-sh4/op_helper.c
+++ b/target-sh4/op_helper.c
@@ -18,6 +18,8 @@
  */
 #include <assert.h>
 #include <stdlib.h>
+
+#include "qemu-common.h"
 #include "exec.h"
 #include "helper.h"
 
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index d0d6c00..3f0393a 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -26,11 +26,11 @@
 #define SH4_DEBUG_DISAS
 //#define SH4_SINGLE_STEP
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
 #include "tcg-op.h"
-#include "qemu-common.h"
 
 #include "helper.h"
 #define GEN_HELPER 1
diff --git a/target-sparc/helper.c b/target-sparc/helper.c
index aa1fd63..1c6319f 100644
--- a/target-sparc/helper.c
+++ b/target-sparc/helper.c
@@ -23,9 +23,9 @@
 #include <inttypes.h>
 #include <signal.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
-#include "qemu-common.h"
 
 //#define DEBUG_MMU
 //#define DEBUG_FEATURES
diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
index be3c1e0..547793f 100644
--- a/target-sparc/op_helper.c
+++ b/target-sparc/op_helper.c
@@ -1,3 +1,4 @@
+#include "qemu-common.h"
 #include "exec.h"
 #include "host-utils.h"
 #include "helper.h"
diff --git a/target-sparc/translate.c b/target-sparc/translate.c
index 23f9519..b91355b 100644
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
diff --git a/translate-all.c b/translate-all.c
index efcfb9a..d9fe23f 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -25,6 +25,7 @@
 #include "config.h"
 
 #define NO_CPU_IO_DEFS
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 #include "disas.h"
