X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=752e2490866760f0e1e22eb0c632f68fb275f378;hb=8300df0450154d7a2db08a7afbd2aca32ce38f70;hp=804e5c91e2289ec22b9f481c439e4ea228e52dd5;hpb=2af24dee6386a5fc694d74fa4281dff8b8e2f148;p=palacios.releases.git diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 804e5c9..752e249 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -189,15 +189,11 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) { core->dbg_regs.dr7 = 0x0000000000000400LL; - /** THESE NEED TO BE MOVED TO GLOBAL LOCATION **/ - v3_init_svm_io_map(core->vm_info); ctrl_area->IOPM_BASE_PA = (addr_t)V3_PAddr(core->vm_info->io_map.arch_data); ctrl_area->instrs.IOIO_PROT = 1; - - v3_init_svm_msr_map(core->vm_info); + ctrl_area->MSRPM_BASE_PA = (addr_t)V3_PAddr(core->vm_info->msr_map.arch_data); - ctrl_area->instrs.MSR_PROT = 1; - /** *** **/ + ctrl_area->instrs.MSR_PROT = 1; PrintDebug("Exiting on interrupts\n"); @@ -290,6 +286,9 @@ int v3_init_svm_vmcb(struct guest_info * info, v3_vm_class_t vm_class) { static int update_irq_exit_state(struct guest_info * info) { vmcb_ctrl_t * guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data)); + // Fix for QEMU bug using EVENTINJ as an internal cache + guest_ctrl->EVENTINJ.valid = 0; + if ((info->intr_core_state.irq_pending == 1) && (guest_ctrl->guest_ctrl.V_IRQ == 0)) { #ifdef CONFIG_DEBUG_INTERRUPTS @@ -310,7 +309,7 @@ static int update_irq_exit_state(struct guest_info * info) { // Interrupt was taken fully vectored info->intr_core_state.irq_started = 0; - } else { + } else if ((info->intr_core_state.irq_started == 1) && (guest_ctrl->exit_int_info.valid == 1)) { #ifdef CONFIG_DEBUG_INTERRUPTS PrintDebug("EXIT INT INFO is set (vec=%d)\n", guest_ctrl->exit_int_info.vector); #endif @@ -323,6 +322,12 @@ static int update_irq_exit_state(struct guest_info * info) { static int update_irq_entry_state(struct guest_info * info) { vmcb_ctrl_t * guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data)); + + if (info->intr_core_state.irq_pending == 0) { + guest_ctrl->guest_ctrl.V_IRQ = 0; + guest_ctrl->guest_ctrl.V_INTR_VECTOR = 0; + } + if (v3_excp_pending(info)) { uint_t excp = v3_get_excp_number(info); @@ -439,8 +444,8 @@ int v3_svm_enter(struct guest_info * info) { guest_state->rip = info->rip; guest_state->rsp = info->vm_regs.rsp; -#ifdef CONFIG_SYMBIOTIC - if (info->vm_info->sym_state.symcalls[info->cpu_id].sym_call_active == 0) { +#ifdef CONFIG_SYMCALL + if (info->sym_core_state.symcall_state.sym_call_active == 0) { update_irq_entry_state(info); } #else @@ -456,8 +461,8 @@ int v3_svm_enter(struct guest_info * info) { (void *)(addr_t)info->rip); */ -#ifdef CONFIG_SYMBIOTIC - if (info->vm_info->sym_state.symcalls[info->cpu_id].sym_call_active == 1) { +#ifdef CONFIG_SYMCALL + if (info->sym_core_state.symcall_state.sym_call_active == 1) { if (guest_ctrl->guest_ctrl.V_IRQ == 1) { V3_Print("!!! Injecting Interrupt during Sym call !!!\n"); } @@ -465,8 +470,10 @@ int v3_svm_enter(struct guest_info * info) { #endif + rdtscll(tmp_tsc); + v3_update_time(info, (tmp_tsc - info->time_state.cached_host_tsc)); rdtscll(info->time_state.cached_host_tsc); - guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc; + // guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc; //V3_Print("Calling v3_svm_launch\n"); @@ -477,13 +484,14 @@ int v3_svm_enter(struct guest_info * info) { v3_last_exit = (uint32_t)(guest_ctrl->exit_code); - rdtscll(tmp_tsc); + //rdtscll(tmp_tsc); + // v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc); //PrintDebug("SVM Returned\n"); info->num_exits++; - v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc); + // Save Guest state from VMCB @@ -515,8 +523,8 @@ int v3_svm_enter(struct guest_info * info) { exit_info2 = guest_ctrl->exit_info2; -#ifdef CONFIG_SYMBIOTIC - if (info->vm_info->sym_state.symcalls[info->cpu_id].sym_call_active == 0) { +#ifdef CONFIG_SYMCALL + if (info->sym_core_state.symcall_state.sym_call_active == 0) { update_irq_exit_state(info); } #else @@ -578,9 +586,9 @@ int v3_start_svm_guest(struct guest_info *info) { linear_addr = get_addr_linear(info, info->rip, &(info->segments.cs)); if (info->mem_mode == PHYSICAL_MEM) { - guest_pa_to_host_va(info, linear_addr, &host_addr); + v3_gpa_to_hva(info, linear_addr, &host_addr); } else if (info->mem_mode == VIRTUAL_MEM) { - guest_va_to_host_va(info, linear_addr, &host_addr); + v3_gva_to_hva(info, linear_addr, &host_addr); } V3_Print("Host Address of rip = 0x%p\n", (void *)host_addr);