cpu_interrupt: integrate upstream version.

Change-Id: Ia310315c78fc26dce492f01449f34e7cd6e4182b
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 4750de9..6a6fe92 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -97,7 +97,6 @@
     int numa_node;
 
     struct QemuThread *thread;
-
     uint32_t host_tid; /* host thread ID */
     bool running;
     struct QemuCond *halt_cond;
@@ -215,6 +214,7 @@
  */
 void cpu_reset(CPUState *cpu);
 
+
 /**
  * qemu_cpu_has_work:
  * @cpu: The vCPU to check.
@@ -274,6 +274,12 @@
  */
 CPUState *qemu_get_cpu(int index);
 
+#ifndef CONFIG_USER_ONLY
+
+typedef void (*CPUInterruptHandler)(CPUState *, int);
+
+extern CPUInterruptHandler cpu_interrupt_handler;
+
 /**
  * cpu_interrupt:
  * @cpu: The CPU to set an interrupt on.
@@ -281,7 +287,14 @@
  *
  * Invokes the interrupt handler.
  */
+static inline void cpu_interrupt(CPUState *cpu, int mask)
+{
+    cpu_interrupt_handler(cpu, mask);
+}
+
+#else /* USER_ONLY */
 void cpu_interrupt(CPUState *cpu, int mask);
+#endif /* USER_ONLY */
 
 /**
  * cpu_reset_interrupt:
diff --git a/translate-all.c b/translate-all.c
index 30a270d..68b9c65 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -1470,7 +1470,7 @@
 
 #ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
-void cpu_interrupt(CPUState *cpu, int mask)
+static void tcg_handle_interrupt(CPUState *cpu, int mask)
 {
     int old_mask;
 
@@ -1498,6 +1498,8 @@
     }
 }
 
+CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
+
 static inline void tb_reset_jump_recursive2(TranslationBlock *tb, int n)
 {
     TranslationBlock *tb1, *tb_next, **ptb;