diff options
-rwxr-xr-x | Makefile.target | 9 | ||||
-rwxr-xr-x | configure | 28 | ||||
-rw-r--r-- | cpus.c | 5 | ||||
-rw-r--r-- | hax-stub.c | 51 | ||||
-rw-r--r-- | hax.h | 44 | ||||
-rw-r--r-- | kvm.h | 6 | ||||
-rw-r--r-- | target-i386/hax-all.c | 90 | ||||
-rw-r--r-- | tizen/src/skin/maruskin_operation.c | 2 | ||||
-rw-r--r-- | vl.c | 34 |
9 files changed, 167 insertions, 102 deletions
diff --git a/Makefile.target b/Makefile.target index deb779f107..0c009e01d2 100755 --- a/Makefile.target +++ b/Makefile.target @@ -208,13 +208,8 @@ obj-$(CONFIG_NO_XEN) += xen-stub.o obj-i386-$(CONFIG_XEN) += xen_platform.o xen_apic.o # HAX support -ifeq ($(TARGET_ARCH), i386) -ifdef CONFIG_WIN32 -obj-$(CONFIG_HAX) += \ - hax-all.o \ - hax-windows.o -endif -endif +obj-$(CONFIG_HAX) += hax-all.o hax-windows.o +obj-$(CONFIG_NO_HAX) += hax-stub.o # Inter-VM PCI shared memory CONFIG_IVSHMEM = @@ -3527,6 +3527,13 @@ echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak if test "$trace_default" = "yes"; then echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak fi +if test "$hax" = "yes" ; then + if test "$mingw32" = "yes" ; then + echo "CONFIG_HAX_BACKEND=y" >> $config_host_mak + else + hax="no" + fi +fi echo "TOOLS=$tools" >> $config_host_mak echo "ROMS=$roms" >> $config_host_mak @@ -3853,15 +3860,20 @@ case "$target_arch2" in fi fi esac - -case "$target_arch2" in - i386|x86_64) - if test "$hax" = "yes" ; then - echo "CONFIG_HAX=y" >> $config_target_mak - echo "CONFIG_HAX=y" >> $config_host_mak +if test "$hax" = "yes" ; then + if test "$target_softmmu" = "yes" ; then + case "$target_arch2" in + i386|x86_64) + echo "CONFIG_HAX=y" >> $config_target_mak + ;; + *) + echo "CONFIG_NO_HAX=y" >> $config_target_mak + ;; + esac + else + echo "CONFIG_NO_HAX=y" >> $config_target_mak fi -esac - +fi if test "$ldst_optimization" = "yes" ; then if test "$target_arch2" = "i386" -o "$target_arch2" = "x86_64"; then echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_target_mak @@ -1327,13 +1327,12 @@ void qmp_inject_nmi(Error **errp) #endif } -#ifdef CONFIG_HAX +#ifdef CONFIG_HAX void qemu_notify_hax_event(void) { - CPUState *env = cpu_single_env; + CPUArchState *env = cpu_single_env; if (hax_enabled() && env) hax_raise_event(env); } #endif - diff --git a/hax-stub.c b/hax-stub.c new file mode 100644 index 0000000000..9e200a07b2 --- /dev/null +++ b/hax-stub.c @@ -0,0 +1,51 @@ +/* + * HAX stubs + * + * Copyright (C) 2012 Samsung Electronics Co Ltd. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "hax.h" + +int hax_sync_vcpus(void) +{ + return 0; +} + +int hax_accel_init(void) +{ + return 0; +} + +void hax_disable(int disable) +{ + return; +} + +int hax_pre_init(ram_addr_t ram_size) +{ + return 0; +} + +int hax_enabled(void) +{ + return 0; +} + +void qemu_notify_hax_event(void) +{ + return; +} @@ -9,40 +9,42 @@ #include "hw/hw.h" #include "bitops.h" -extern int hax_disabled; #define dprint printf -#ifdef CONFIG_HAX +#ifdef CONFIG_HAX_BACKEND int hax_enabled(void); +void hax_disable(int disable); int hax_pre_init(ram_addr_t ram_size); -int hax_init(void); +int hax_accel_init(void); int hax_sync_vcpus(void); -#ifdef NEED_CPU_H -int hax_init_vcpu(CPUState *env); -int hax_vcpu_exec(CPUState *env); -void hax_vcpu_sync_state(CPUState *env, int modified); -//extern void hax_cpu_synchronize_state(CPUState *env); -//extern void hax_cpu_synchronize_post_reset(CPUState *env); -//extern void hax_cpu_synchronize_post_init(CPUState *env); +#ifdef CONFIG_HAX +int hax_init_vcpu(CPUArchState *env); +int hax_vcpu_exec(CPUArchState *env); +void hax_vcpu_sync_state(CPUArchState *env, int modified); +//extern void hax_cpu_synchronize_state(CPUArchState *env); +//extern void hax_cpu_synchronize_post_reset(CPUArchState *env); +//extern void hax_cpu_synchronize_post_init(CPUArchState *env); int hax_populate_ram(uint64_t va, uint32_t size); int hax_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t phys_offset); -int hax_vcpu_emulation_mode(CPUState *env); -int hax_stop_emulation(CPUState *env); -int hax_stop_translate(CPUState *env); -int hax_arch_get_registers(CPUState *env); -int hax_vcpu_destroy(CPUState *env); -void hax_raise_event(CPUState *env); -int need_handle_intr_request(CPUState *env); -int hax_handle_io(CPUState *env, uint32_t df, uint16_t port, int direction, +int hax_vcpu_emulation_mode(CPUArchState *env); +int hax_stop_emulation(CPUArchState *env); +int hax_stop_translate(CPUArchState *env); +int hax_arch_get_registers(CPUArchState *env); +int hax_vcpu_destroy(CPUArchState *env); +void hax_raise_event(CPUArchState *env); +int need_handle_intr_request(CPUArchState *env); +int hax_handle_io(CPUArchState *env, uint32_t df, uint16_t port, int direction, int size, int count, void *buffer); void qemu_notify_hax_event(void); -#endif void hax_reset_vcpu_state(void *opaque); - #include "target-i386/hax-interface.h" #include "target-i386/hax-i386.h" +#endif #else -#define hax_enabled() (0) +#define hax_enabled() (0) +#define hax_sync_vcpus() +#define hax_accel_init() (0) +#define hax_pre_init(x) #endif #endif @@ -180,9 +180,9 @@ void kvm_cpu_synchronize_post_init(CPUArchState *env); /* generic hooks - to be moved/refactored once there are more users */ #ifdef CONFIG_HAX -void hax_cpu_synchronize_state(CPUState *env); -void hax_cpu_synchronize_post_reset(CPUState *env); -void hax_cpu_synchronize_post_init(CPUState *env); +void hax_cpu_synchronize_state(CPUArchState *env); +void hax_cpu_synchronize_post_reset(CPUArchState *env); +void hax_cpu_synchronize_post_init(CPUArchState *env); #endif static inline void cpu_synchronize_state(CPUArchState *env) { diff --git a/target-i386/hax-all.c b/target-i386/hax-all.c index 39e43c419c..d25e8b4ec5 100644 --- a/target-i386/hax-all.c +++ b/target-i386/hax-all.c @@ -18,6 +18,8 @@ struct hax_state hax_global; int hax_support = -1; +int ret_hax_init = 0; +static int hax_disabled = 1; /* Called after hax_init */ int hax_enabled(void) @@ -25,13 +27,18 @@ int hax_enabled(void) return (!hax_disabled && hax_support); } +void hax_disable(int disable) +{ + hax_disabled = disable; +} + /* Currently non-PG modes are emulated by QEMU */ -int hax_vcpu_emulation_mode(CPUState *env) +int hax_vcpu_emulation_mode(CPUArchState *env) { return !(env->cr[0] & CR0_PG_MASK); } -static int hax_prepare_emulation(CPUState *env) +static int hax_prepare_emulation(CPUArchState *env) { /* Flush all emulation states */ tlb_flush(env, 1); @@ -45,7 +52,7 @@ static int hax_prepare_emulation(CPUState *env) * Check whether to break the translation block loop * break tbloop after one MMIO emulation, or after finish emulation mode */ -static int hax_stop_tbloop(CPUState *env) +static int hax_stop_tbloop(CPUArchState *env) { switch (env->hax_vcpu->emulation_state) { @@ -66,7 +73,7 @@ static int hax_stop_tbloop(CPUState *env) return 0; } -int hax_stop_emulation(CPUState *env) +int hax_stop_emulation(CPUArchState *env) { if (hax_stop_tbloop(env)) { @@ -82,7 +89,7 @@ int hax_stop_emulation(CPUState *env) return 0; } -int hax_stop_translate(CPUState *env) +int hax_stop_translate(CPUArchState *env) { struct hax_vcpu_state *vstate; @@ -99,7 +106,7 @@ int valid_hax_tunnel_size(uint16_t size) return size >= sizeof(struct hax_tunnel); } -hax_fd hax_vcpu_get_fd(CPUState *env) +hax_fd hax_vcpu_get_fd(CPUArchState *env) { struct hax_vcpu_state *vcpu = env->hax_vcpu; if (!vcpu) @@ -220,7 +227,7 @@ error: return -1; } -int hax_vcpu_destroy(CPUState *env) +int hax_vcpu_destroy(CPUArchState *env) { struct hax_vcpu_state *vcpu = env->hax_vcpu; @@ -243,7 +250,7 @@ int hax_vcpu_destroy(CPUState *env) return 0; } -int hax_init_vcpu(CPUState *env) +int hax_init_vcpu(CPUArchState *env) { int ret; @@ -383,7 +390,7 @@ static CPUPhysMemoryClient hax_cpu_phys_memory_client = { .log_stop = hax_log_stop, }; -static void hax_handle_interrupt(CPUState *env, int mask) +static void hax_handle_interrupt(CPUArchState *env, int mask) { env->interrupt_request |= mask; @@ -406,7 +413,7 @@ int hax_pre_init(ram_addr_t ram_size) return 0; } -int hax_init(void) +static int hax_init(void) { struct hax_state *hax = NULL; int ret; @@ -463,7 +470,26 @@ error: return ret; } -int hax_handle_io(CPUState *env, uint32_t df, uint16_t port, int direction, +int hax_accel_init(void) +{ + if (hax_disabled) { + dprint("HAX is disabled and emulator runs in emulation mode.\n"); + return 0; + } + + ret_hax_init = hax_init(); + if (ret_hax_init && (ret_hax_init != -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; + } +} + +int hax_handle_io(CPUArchState *env, uint32_t df, uint16_t port, int direction, int size, int count, void *buffer) { uint8_t *ptr; @@ -509,7 +535,7 @@ int hax_handle_io(CPUState *env, uint32_t df, uint16_t port, int direction, return 0; } -static int hax_vcpu_interrupt(CPUState *env) +static int hax_vcpu_interrupt(CPUArchState *env) { struct hax_vcpu_state *vcpu = env->hax_vcpu; struct hax_tunnel *ht = vcpu->tunnel; @@ -541,7 +567,7 @@ static int hax_vcpu_interrupt(CPUState *env) return 0; } -void hax_raise_event(CPUState *env) +void hax_raise_event(CPUArchState *env) { struct hax_vcpu_state *vcpu = env->hax_vcpu; @@ -560,7 +586,7 @@ void hax_raise_event(CPUState *env) * 5. An unknown VMX exit happens */ extern void qemu_system_reset_request(void); -static int hax_vcpu_hax_exec(CPUState *env) +static int hax_vcpu_hax_exec(CPUArchState *env) { int ret = 0; struct hax_vcpu_state *vcpu = env->hax_vcpu; @@ -669,27 +695,27 @@ static int hax_vcpu_hax_exec(CPUState *env) static void do_hax_cpu_synchronize_state(void *_env) { - CPUState *env = _env; + CPUArchState *env = _env; if (!env->hax_vcpu_dirty) { hax_vcpu_sync_state(env, 0); env->hax_vcpu_dirty = 1; } } -void hax_cpu_synchronize_state(CPUState *env) +void hax_cpu_synchronize_state(CPUArchState *env) { if (!env->hax_vcpu_dirty) { run_on_cpu(env, do_hax_cpu_synchronize_state, env); } } -void hax_cpu_synchronize_post_reset(CPUState *env) +void hax_cpu_synchronize_post_reset(CPUArchState *env) { hax_vcpu_sync_state(env, 1); env->hax_vcpu_dirty = 0; } -void hax_cpu_synchronize_post_init(CPUState *env) +void hax_cpu_synchronize_post_init(CPUArchState *env) { hax_vcpu_sync_state(env, 1); env->hax_vcpu_dirty = 0; @@ -698,7 +724,7 @@ void hax_cpu_synchronize_post_init(CPUState *env) /* * return 1 when need emulate, 0 when need exit loop */ -int hax_vcpu_exec(CPUState *env) +int hax_vcpu_exec(CPUArchState *env) { int next = 0, ret = 0; struct hax_vcpu_state *vcpu; @@ -795,7 +821,7 @@ static void hax_getput_reg(uint64_t *hax_reg, target_ulong *qemu_reg, int set) } /* The sregs has been synced with HAX kernel already before this call */ -static int hax_get_segments(CPUState *env, struct vcpu_state_t *sregs) +static int hax_get_segments(CPUArchState *env, struct vcpu_state_t *sregs) { get_seg(&env->segs[R_CS], &sregs->_cs); get_seg(&env->segs[R_DS], &sregs->_ds); @@ -813,7 +839,7 @@ static int hax_get_segments(CPUState *env, struct vcpu_state_t *sregs) return 0; } -static int hax_set_segments(CPUState *env, struct vcpu_state_t *sregs) +static int hax_set_segments(CPUArchState *env, struct vcpu_state_t *sregs) { if ((env->eflags & VM_MASK)) { set_v8086_seg(&sregs->_cs, &env->segs[R_CS]); @@ -851,7 +877,7 @@ static int hax_set_segments(CPUState *env, struct vcpu_state_t *sregs) * After get the state from the kernel module, some * qemu emulator state need be updated also */ -static int hax_setup_qemu_emulator(CPUState *env) +static int hax_setup_qemu_emulator(CPUArchState *env) { #define HFLAG_COPY_MASK ~( \ @@ -896,7 +922,7 @@ static int hax_setup_qemu_emulator(CPUState *env) return 0; } -static int hax_sync_vcpu_register(CPUState *env, int set) +static int hax_sync_vcpu_register(CPUArchState *env, int set) { struct vcpu_state_t regs; int ret; @@ -958,7 +984,7 @@ static void hax_msr_entry_set(struct vmx_msr *item, item->value = value; } -static int hax_get_msrs(CPUState *env) +static int hax_get_msrs(CPUArchState *env) { struct hax_msr_data md; struct vmx_msr *msrs = md.entries; @@ -994,7 +1020,7 @@ static int hax_get_msrs(CPUState *env) return 0; } -static int hax_set_msrs(CPUState *env) +static int hax_set_msrs(CPUArchState *env) { struct hax_msr_data md; struct vmx_msr *msrs; @@ -1013,7 +1039,7 @@ static int hax_set_msrs(CPUState *env) } -static int hax_get_fpu(CPUState *env) +static int hax_get_fpu(CPUArchState *env) { struct fx_layout fpu; int i, ret; @@ -1036,7 +1062,7 @@ static int hax_get_fpu(CPUState *env) return 0; } -static int hax_set_fpu(CPUState *env) +static int hax_set_fpu(CPUArchState *env) { struct fx_layout fpu; int i; @@ -1058,7 +1084,7 @@ static int hax_set_fpu(CPUState *env) return hax_sync_fpu(env, &fpu, 1); } -int hax_arch_get_registers(CPUState *env) +int hax_arch_get_registers(CPUArchState *env) { int ret; @@ -1077,7 +1103,7 @@ int hax_arch_get_registers(CPUState *env) return 0; } -static int hax_arch_set_registers(CPUState *env) +static int hax_arch_set_registers(CPUArchState *env) { int ret; ret = hax_sync_vcpu_register(env, 1); @@ -1103,7 +1129,7 @@ static int hax_arch_set_registers(CPUState *env) return 0; } -void hax_vcpu_sync_state(CPUState *env, int modified) +void hax_vcpu_sync_state(CPUArchState *env, int modified) { if (hax_enabled()) { if (modified) @@ -1122,7 +1148,7 @@ int hax_sync_vcpus(void) { if (hax_enabled()) { - CPUState *env; + CPUArchState *env; env = first_cpu; if (!env) @@ -1144,7 +1170,7 @@ int hax_sync_vcpus(void) } void hax_reset_vcpu_state(void *opaque) { - CPUState *env = opaque; + CPUArchState *env = opaque; for (env = first_cpu; env != NULL; env = env->next_cpu) { dprint("*********ReSet hax_vcpu->emulation_state \n"); diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index e38511b19b..e353cce8c8 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -44,7 +44,7 @@ #include "hw/maru_pm.h" #include "sysemu.h" -#ifdef _WIN32 +#ifdef CONFIG_HAX #include "target-i386/hax-i386.h" #endif @@ -199,8 +199,6 @@ extern int tizen_base_port; int skin_disabled = 0; #endif -int ret_hax_init = 0; - static const char *data_dir; const char *bios_name = NULL; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; @@ -239,7 +237,6 @@ const char *vnc_display; #endif int acpi_enabled = 1; int no_hpet = 0; -int hax_disabled = 1; int fd_bootchk = 1; int no_reboot = 0; int no_shutdown = 0; @@ -1604,9 +1601,7 @@ static void main_loop(void) int64_t ti; #endif -#ifdef CONFIG_HAX hax_sync_vcpus(); -#endif do { nonblocking = !(kvm_enabled()|| hax_enabled()) && last_io > 0; @@ -2174,23 +2169,7 @@ static int tcg_init(void) { int ret = 0; tcg_exec_init(tcg_tb_size * 1024 * 1024); -#ifdef CONFIG_HAX - if (!hax_disabled) - { - ret = hax_init(); - ret_hax_init = ret; - if (ret && (ret != -ENOSPC)) - dprint("No accelerator found.\n"); - else { - dprint("HAX is %s and emulator runs in %s mode.\n", - !ret ? "working" : "not working", - !ret ? "fast virt" : "emulation"); - return 0; - } - - } else - dprint("HAX is disabled and emulator runs in emulation mode.\n"); -#endif + ret = hax_accel_init(); return ret; } @@ -3352,10 +3331,15 @@ int main(int argc, char **argv, char **envp) qtest_log = optarg; break; case QEMU_OPTION_enable_hax: +#ifdef CONFIG_HAX_BACKEND olist = qemu_find_opts("machine"); qemu_opts_reset(olist); - hax_disabled = 0; + hax_disable(0); //qemu_opts_parse(olist, "accel=hax", 0); +#else + fprintf(stderr, + "HAX support is disabled, ignoring -enable-hax\n"); +#endif break; #ifdef CONFIG_MARU case QEMU_OPTION_max_touch_point: @@ -3536,9 +3520,7 @@ int main(int argc, char **argv, char **envp) ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; } -#ifdef CONFIG_HAX hax_pre_init(ram_size); -#endif configure_accelerator(); @@ -3723,10 +3705,8 @@ int main(int argc, char **argv, char **envp) current_machine = machine; -#ifdef CONFIG_HAX if (hax_enabled()) hax_sync_vcpus(); -#endif /* init USB devices */ if (usb_enabled) { |