Did not bother TCG initialization.
Removed redundant condition fields.(hax_disabled, hax_support)
Used small TB buffer for non-UG platform.
Change-Id: I6e0a9af12abf7e9399198440bc485f70453ce9c8
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
#include "sysemu/hax.h"
+bool hax_allowed;
+
int hax_sync_vcpus(void)
{
return 0;
}
-int hax_accel_init(void)
-{
- return 0;
-}
-
-void hax_disable(int disable)
+int hax_accel_init(uint64_t ram_size)
{
- return;
-}
-
-int hax_pre_init(uint64_t ram_size)
-{
- return 0;
-}
-
-int hax_enabled(void)
-{
- return 0;
+ return -ENOSYS;
}
int hax_ug_platform(void)
{
return 0;
}
-
#include "config-host.h"
#include "qemu-common.h"
+extern bool hax_allowed;
-// This needs to be fixed for vl.c, ich9.c, piix4.c.
-// Those files do not include config.h and will not have CONFIG_HAX defined.
-
-int hax_enabled(void);
-void hax_disable(int disable);
int hax_ug_platform(void);
-int hax_pre_init(uint64_t ram_size);
-int hax_accel_init(void);
+int hax_accel_init(uint64_t ram_size);
int hax_sync_vcpus(void);
+// called after hax_init
+#define hax_enabled() hax_allowed
+
#ifdef CONFIG_HAX
#define dprint printf
static int hax_handle_fastmmio(CPUArchState *env, struct hax_fastmmio *hft);
struct hax_state hax_global;
-int ret_hax_init = 0;
-static int hax_disabled = 1;
-int hax_support = -1;
int ug_support = 0;
-/* Called after hax_init */
-int hax_enabled(void)
-{
- return (!hax_disabled && hax_support);
-}
-
-void hax_disable(int disable)
-{
- hax_disabled = disable;
-}
+bool hax_allowed;
-/* Called after hax_init */
+/* Called after hax_init_internal */
int hax_ug_platform(void)
{
return (ug_support);
{
case HAX_EMULATE_STATE_MMIO:
if (cpu->hax_vcpu->resync) {
- hax_prepare_emulation(env);
+ hax_prepare_emulation(env);
cpu->hax_vcpu->resync = 0;
return 0;
}
}
}
-int hax_pre_init(uint64_t ram_size)
-{
- struct hax_state *hax = NULL;
-
- dprint("hax_disabled %d\n", hax_disabled);
- if (hax_disabled)
- return 0;
- hax = &hax_global;
- memset(hax, 0, sizeof(struct hax_state));
- hax->mem_quota = ram_size;
- dprint("ram_size %lx\n", ram_size);
-
- return 0;
-}
-
-static int hax_init(void)
+static int hax_init_internal(void)
{
struct hax_state *hax = NULL;
struct hax_qemu_version qversion;
int ret;
- hax_support = 0;
-
hax = &hax_global;
qversion.least_version = hax_lest_version;
hax_notify_qemu_version(hax->vm->fd, &qversion);
cpu_interrupt_handler = hax_handle_interrupt;
- hax_support = 1;
return ret;
error:
return ret;
}
-int hax_accel_init(void)
+int hax_accel_init(uint64_t ram_size)
{
- if (hax_disabled) {
- dprint("HAX is disabled and emulator runs in emulation mode.\n");
- return 0;
- }
+ struct hax_state *hax = NULL;
+ int ret = 0;
+
+ hax = &hax_global;
+ memset(hax, 0, sizeof(struct hax_state));
+ hax->mem_quota = ram_size;
+ dprint("ram_size %lx\n", ram_size);
- ret_hax_init = hax_init();
- if (ret_hax_init && (ret_hax_init != -ENOSPC)) {
+ ret = hax_init_internal();
+ // It is better to fail than to transit implicitly.
+ /*
+ if (ret && (ret != -ENOSPC)) {
dprint("No accelerator found.\n");
- return ret_hax_init;
} else {
dprint("HAX is %s and emulator runs in %s mode.\n",
- !ret_hax_init ? "working" : "not working",
- !ret_hax_init ? "fast virt" : "emulation");
- return 0;
+ !ret ? "working" : "not working",
+ !ret ? "fast virt" : "emulation");
}
+ */
+
+ return ret;
}
static int hax_handle_fastmmio(CPUArchState *env, struct hax_fastmmio *hft)
hax_err_len = sprintf( hax_error + hax_err_len, "%s", "hax_error=" );
int error = 0;
+// FIXME: ret_hax_init is no longer exist...
if ( !ret_hax_init ) {
if ( -ENOSPC == ret_hax_init ) {
error = 1;
static bool tcg_allowed = true;
bool xen_allowed;
-// FIXME: ??
-int hax_allowed = 0;
-//
uint32_t xen_domid;
enum xen_mode xen_mode = XEN_EMULATE;
static int tcg_tb_size;
static int tcg_init(QEMUMachine *machine)
{
- int ret = 0;
- ret = hax_accel_init();
- if (!(hax_enabled() && hax_ug_platform()))
- tcg_exec_init(tcg_tb_size * 1024 * 1024);
+ tcg_exec_init(tcg_tb_size * 1024 * 1024);
+ return 0;
+}
+
+static int hax_init(QEMUMachine *machine)
+{
+ int ret = hax_accel_init(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;
}
{ "xen", "Xen", xen_available, xen_init, &xen_allowed },
{ "kvm", "KVM", kvm_available, kvm_init, &kvm_allowed },
{ "qtest", "QTest", qtest_available, qtest_init_accel, &qtest_allowed },
+ { "hax", "HAX", hax_available, hax_init, &hax_allowed },
};
static int configure_accelerator(QEMUMachine *machine)
break;
case QEMU_OPTION_enable_hax:
olist = qemu_find_opts("machine");
- //qemu_opts_reset(olist);
- hax_disable(0);
- //qemu_opts_parse(olist, "accel=hax", 0);
+ qemu_opts_parse(olist, "accel=hax", 0);
break;
case QEMU_OPTION_add_fd:
#ifndef _WIN32
ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
}
- hax_pre_init(ram_size);
-
if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0)
!= 0) {
exit(0);