Merge 'v2.2.0' into tizen_next_qemu_2.2
[sdk/emulator/qemu.git] / target-i386 / hax-all.c
index 7069be9..62e4ffa 100644 (file)
@@ -513,10 +513,12 @@ error:
     return ret;
 }
 
-int hax_accel_init(uint64_t ram_size)
+static int hax_init(MachineState *ms)
 {
     struct hax_state *hax = NULL;
     int ret = 0;
+    uint64_t ram_size =
+        qemu_opt_get_number(qemu_find_opts_singleton("memory"), "size");
 
     hax = &hax_global;
     memset(hax, 0, sizeof(struct hax_state));
@@ -535,6 +537,12 @@ int hax_accel_init(uint64_t ram_size)
     }
     */
 
+    if (!ret && !hax_ug_platform()) {
+        // TCG is used for very limited purpose under HAX.
+        // so we can allocate small TB buffer.
+        tcg_exec_init(16 * 1024 * 1024);
+    }
+
     return ret;
 }
 
@@ -1337,3 +1345,26 @@ void hax_reset_vcpu_state(void *opaque)
     }
 }
 
+#define TYPE_HAX_ACCEL ACCEL_CLASS_NAME("hax")
+
+static void hax_accel_class_init(ObjectClass *oc, void *data)
+{
+    AccelClass *ac = ACCEL_CLASS(oc);
+    ac->name = "HAX";
+    ac->init_machine = hax_init;
+    ac->allowed = &hax_allowed;
+}
+
+static const TypeInfo hax_accel_type = {
+    .name = TYPE_HAX_ACCEL,
+    .parent = TYPE_ACCEL,
+    .class_init = hax_accel_class_init,
+//    .instance_size = sizeof(hax_state),
+};
+
+static void hax_type_init(void)
+{
+    type_register_static(&hax_accel_type);
+}
+
+type_init(hax_type_init);