From: syeon.hwang Date: Mon, 29 Oct 2012 10:39:12 +0000 (+0900) Subject: HAX: Apply HAX patch from intel X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1405^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd3025afa216f149763239082dcfaa3023daad08;p=sdk%2Femulator%2Fqemu.git HAX: Apply HAX patch from intel --- diff --git a/configure b/configure index 10221ce33a..8ac06fee29 100755 --- a/configure +++ b/configure @@ -3691,6 +3691,8 @@ fi if test "$hax" = "yes" ; then if test "$mingw32" = "yes" ; then echo "CONFIG_HAX_BACKEND=y" >> $config_host_mak + elif test "$darwin" = "yes" ; then + echo "CONFIG_HAX_BACKEND=y" >> $config_host_mak else hax="no" fi diff --git a/cpu-exec.c b/cpu-exec.c index d7bcde0734..0a0858279d 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -324,16 +324,21 @@ int cpu_exec(CPUArchState *env) cpu_loop_exit(env); } else if (interrupt_request & CPU_INTERRUPT_SIPI) { do_cpu_sipi(x86_env_get_cpu(env)); + } else if (env->hflags2 & HF2_GIF_MASK) { if ((interrupt_request & CPU_INTERRUPT_SMI) && !(env->hflags & HF_SMM_MASK)) { cpu_svm_check_intercept_param(env, SVM_EXIT_SMI, 0); env->interrupt_request &= ~CPU_INTERRUPT_SMI; +#ifdef CONFIG_HAX + if (hax_enabled()) + env->hax_vcpu->resync = 1; +#endif do_smm_enter(env); next_tb = 0; } else if ((interrupt_request & CPU_INTERRUPT_NMI) && - !(env->hflags2 & HF2_NMI_MASK)) { + !(env->hflags2 & HF2_NMI_MASK)) { env->interrupt_request &= ~CPU_INTERRUPT_NMI; env->hflags2 |= HF2_NMI_MASK; do_interrupt_x86_hardirq(env, EXCP02_NMI, 1); diff --git a/target-i386/hax-all.c b/target-i386/hax-all.c index 844926e10b..a60065f185 100644 --- a/target-i386/hax-all.c +++ b/target-i386/hax-all.c @@ -54,15 +54,20 @@ static int hax_prepare_emulation(CPUArchState *env) */ static int hax_stop_tbloop(CPUArchState *env) { - switch (env->hax_vcpu->emulation_state) - { - case HAX_EMULATE_STATE_MMIO: - return 1; - break; - case HAX_EMULATE_STATE_INITIAL: + switch (env->hax_vcpu->emulation_state) + { + case HAX_EMULATE_STATE_MMIO: + if (env->hax_vcpu->resync) { + hax_prepare_emulation(env); + env->hax_vcpu->resync = 0; + return 0; + } + return 1; + break; + case HAX_EMULATE_STATE_INITIAL: case HAX_EMULATE_STATE_REAL: - if (!hax_vcpu_emulation_mode(env)) - return 1; + if (!hax_vcpu_emulation_mode(env)) + return 1; break; default: dprint("Invalid emulation state in hax_sto_tbloop state %x\n", @@ -377,10 +382,25 @@ static void hax_log_stop(MemoryListener *listener, { } +static void hax_begin(MemoryListener *listener) +{ +} + +static void hax_commit(MemoryListener *listener) +{ +} + +static void hax_region_nop(MemoryListener *listener, + MemoryRegionSection *section) +{ +} static MemoryListener hax_memory_listener = { + .begin = hax_begin, + .commit = hax_commit, .region_add = hax_region_add, .region_del = hax_region_del, + .region_nop = hax_region_nop, .log_start = hax_log_start, .log_stop = hax_log_stop, .log_sync = hax_log_sync, diff --git a/target-i386/hax-darwin.c b/target-i386/hax-darwin.c index c083034ac6..b3127f6619 100644 --- a/target-i386/hax-darwin.c +++ b/target-i386/hax-darwin.c @@ -52,16 +52,18 @@ int hax_populate_ram(uint64_t va, uint32_t size) return 0; } -int hax_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t phys_offset) +int hax_set_phys_mem(MemoryRegionSection *section) { - struct hax_set_ram_info info, *pinfo = &info; + struct hax_set_ram_info info, *pinfo = &info; + MemoryRegionSection *mr = section->mr; + target_phys_addr_t start_addr = section->offset_within_address_space; + ram_addr_t size = section->size; int ret; - ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK; - - /* We only care for the RAM and ROM */ - if (flags >= IO_MEM_UNASSIGNED) - return 0; + /*We only care for the RAM and ROM*/ + if(!memory_region_is_ram(mr)) + return 0; + if ( (start_addr & ~TARGET_PAGE_MASK) || (size & ~TARGET_PAGE_MASK)) { dprint("set_phys_mem %x %lx requires page aligned addr and size\n", start_addr, size); @@ -71,8 +73,8 @@ int hax_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t info.pa_start = start_addr; info.size = size; - info.va = (uint64_t)qemu_get_ram_ptr(phys_offset); - info.flags = (flags & IO_MEM_ROM) ? 1 : 0; + info.va = (uint64_t)(memory_region_get_ram_ptr(mr) + section->offset_within_region); + info.flags = memory_region_is_rom(mr) ? 1 : 0; ret = ioctl(hax_global.vm->fd, HAX_VM_IOCTL_SET_RAM, pinfo); if (ret < 0) @@ -80,9 +82,13 @@ int hax_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t dprint("has set phys mem failed\n"); exit(1); } + return ret; + } + + int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap) { int ret; @@ -244,7 +250,7 @@ int hax_vcpu_run(struct hax_vcpu_state* vcpu) return ret; } -int hax_sync_fpu(CPUState *env, struct fx_layout *fl, int set) +int hax_sync_fpu(CPUArchState *env, struct fx_layout *fl, int set) { int ret, fd; @@ -259,7 +265,7 @@ int hax_sync_fpu(CPUState *env, struct fx_layout *fl, int set) return ret; } -int hax_sync_msr(CPUState *env, struct hax_msr_data *msrs, int set) +int hax_sync_msr(CPUArchState *env, struct hax_msr_data *msrs, int set) { int ret, fd; @@ -273,7 +279,7 @@ int hax_sync_msr(CPUState *env, struct hax_msr_data *msrs, int set) return ret; } -int hax_sync_vcpu_state(CPUState *env, struct vcpu_state_t *state, int set) +int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state, int set) { int ret, fd; @@ -288,7 +294,7 @@ int hax_sync_vcpu_state(CPUState *env, struct vcpu_state_t *state, int set) return ret; } -int hax_inject_interrupt(CPUState *env, int vector) +int hax_inject_interrupt(CPUArchState *env, int vector) { int ret, fd; diff --git a/target-i386/hax-i386.h b/target-i386/hax-i386.h index 9fa93c0c55..29415652fd 100644 --- a/target-i386/hax-i386.h +++ b/target-i386/hax-i386.h @@ -17,6 +17,7 @@ struct hax_vcpu_state { hax_fd fd; int vcpu_id; + int resync; int emulation_state; struct hax_tunnel *tunnel; unsigned char *iobuf; diff --git a/target-i386/hax-windows.c b/target-i386/hax-windows.c index a4ff52d0aa..c510cac214 100644 --- a/target-i386/hax-windows.c +++ b/target-i386/hax-windows.c @@ -110,7 +110,8 @@ int hax_set_phys_mem(MemoryRegionSection *section) info.pa_start = start_addr; info.size = size; - info.va = (uint64_t)memory_region_get_ram_ptr(mr); + info.va = (uint64_t)(memory_region_get_ram_ptr(mr) + + section->offset_within_region); info.flags = memory_region_is_rom(mr) ? 1 : 0; hDeviceVM = hax_global.vm->fd; diff --git a/tizen/src/Makefile.tizen.arm b/tizen/src/Makefile.tizen.arm index c5c01727fa..e93bd3aa8e 100755 --- a/tizen/src/Makefile.tizen.arm +++ b/tizen/src/Makefile.tizen.arm @@ -2,6 +2,10 @@ # for TIZEN-maru board obj-y += maru_arm_soc.o + +ifndef CONFIG_DARWIN obj-y += maru_arm_board.o +endif + obj-y += maru_arm_vpci.o -obj-y += maru_arm_pmu.o \ No newline at end of file +obj-y += maru_arm_pmu.o diff --git a/tizen/src/hw/maru_camera_win32_pci.c b/tizen/src/hw/maru_camera_win32_pci.c index 14f0c203e1..bd97217088 100644 --- a/tizen/src/hw/maru_camera_win32_pci.c +++ b/tizen/src/hw/maru_camera_win32_pci.c @@ -1506,6 +1506,7 @@ static STDMETHODIMP SetFormat(uint32_t dwWidth, uint32_t dwHeight, { /* use minimum FPS(maximum frameinterval) with non-VT system */ +#ifdef CONFIG_HAX if (!hax_enabled()) { pvi->AvgTimePerFrame = (REFERENCE_TIME)scc.MaxFrameInterval; @@ -1513,6 +1514,10 @@ static STDMETHODIMP SetFormat(uint32_t dwWidth, uint32_t dwHeight, pvi->AvgTimePerFrame = (REFERENCE_TIME)MARUCAM_DEFAULT_FRAMEINTERVAL; } +#else + pvi->AvgTimePerFrame = + (REFERENCE_TIME)scc.MaxFrameInterval; +#endif hr = pSConfig->lpVtbl->SetFormat(pSConfig, pmtConfig); DeleteMediaType(pmtConfig); break;