From 4b3250c5073149c59c5c11e06c2c0d93b6a9f5ff Mon Sep 17 00:00:00 2001
From: Timothy Pearson <tpearson@raptorengineering.com>
Date: Fri, 29 Nov 2019 19:00:14 -0600
Subject: Initial overlay of HQEMU 2.5.2 changes onto underlying 2.5.1 QEMU GIT
 tree

---
 cpus.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

(limited to 'cpus.c')

diff --git a/cpus.c b/cpus.c
index 747f14d..04da0ad 100644
--- a/cpus.c
+++ b/cpus.c
@@ -66,6 +66,9 @@
 
 #endif /* CONFIG_LINUX */
 
+#include "tcg.h"
+#include "hqemu.h"
+
 static CPUState *next_cpu;
 int64_t max_delay;
 int64_t max_advance;
@@ -892,6 +895,18 @@ void qemu_init_cpu_loop(void)
     qemu_thread_get_self(&io_thread);
 }
 
+void qemu_end_cpu_loop(void)
+{
+    CPUState *cpu;
+
+    CPU_FOREACH(cpu)
+        optimization_finalize(cpu->env_ptr);
+
+#if defined(CONFIG_LLVM)
+    llvm_finalize();
+#endif
+}
+
 void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data)
 {
     struct qemu_work_item wi;
@@ -1134,6 +1149,16 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
     /* process any pending work */
     atomic_mb_set(&exit_request, 1);
 
+#if defined(CONFIG_LLVM)
+    llvm_init();
+#endif
+    /* we can safely initialize optimization resources after
+     * the setup of CPUArchState is completed. */
+    CPU_FOREACH(cpu) {
+        copy_tcg_context();
+        optimization_init(cpu->env_ptr);
+    }
+
     while (1) {
         tcg_exec_all();
 
-- 
cgit v1.1