X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=9f725143caf6ba86d5129d01fa68e2bdab3a9741;hp=09fe744ec0abd05e1c67d607ad0846c8f823b1e1;hb=87b1679efe8bee960b65cfd730188ccc94966b71;hpb=123a1ba27ea09c8fa77a1b36ce625b43d7c48b14 diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 09fe744..9f72514 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -44,6 +44,8 @@ #include +uint32_t v3_last_exit; + // This is a global pointer to the host's VMCB static addr_t host_vmcbs[CONFIG_MAX_CPUS] = { [0 ... CONFIG_MAX_CPUS - 1] = 0}; @@ -284,7 +286,7 @@ int v3_init_svm_vmcb(struct guest_info * info, v3_vm_class_t vm_class) { -static int update_irq_state_atomic(struct guest_info * info) { +static int update_irq_exit_state(struct guest_info * info) { vmcb_ctrl_t * guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data)); if ((info->intr_state.irq_pending == 1) && (guest_ctrl->guest_ctrl.V_IRQ == 0)) { @@ -317,7 +319,7 @@ static int update_irq_state_atomic(struct guest_info * info) { } -static int update_irq_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 (v3_excp_pending(info)) { @@ -417,6 +419,8 @@ int v3_svm_enter(struct guest_info * info) { // disable global interrupts for vm state transition v3_clgi(); + /// checkpoint + // Synchronize the guest state to the VMCB guest_state->cr0 = info->ctrl_regs.cr0; guest_state->cr2 = info->ctrl_regs.cr2; @@ -435,6 +439,16 @@ int v3_svm_enter(struct guest_info * info) { guest_state->rax = info->vm_regs.rax; guest_state->rip = info->rip; guest_state->rsp = info->vm_regs.rsp; + +#ifdef CONFIG_SYMBIOTIC + if (info->sym_state.sym_call_active == 0) { + update_irq_entry_state(info); + } +#else + update_irq_entry_state(info); +#endif + + /* ** */ /* @@ -453,10 +467,15 @@ int v3_svm_enter(struct guest_info * info) { 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_svm_launch((vmcb_t *)V3_PAddr(info->vmm_data), &(info->vm_regs), (vmcb_t *)host_vmcbs[info->cpu_id]); + + v3_last_exit = (uint32_t)(guest_ctrl->exit_code); + + // v3_print_cond("SVM Returned: Exit Code: %x\n", (uint32_t)(guest_ctrl->exit_code)); + rdtscll(tmp_tsc); //PrintDebug("SVM Returned\n"); @@ -497,10 +516,10 @@ int v3_svm_enter(struct guest_info * info) { #ifdef CONFIG_SYMBIOTIC if (info->sym_state.sym_call_active == 0) { - update_irq_state_atomic(info); + update_irq_exit_state(info); } #else - update_irq_state_atomic(info); + update_irq_exit_state(info); #endif @@ -517,13 +536,6 @@ int v3_svm_enter(struct guest_info * info) { return -1; } -#ifdef CONFIG_SYMBIOTIC - if (info->sym_state.sym_call_active == 0) { - update_irq_state(info); - } -#else - update_irq_state(info); -#endif return 0; } @@ -580,13 +592,12 @@ int v3_start_svm_guest(struct guest_info *info) { break; } +/* if ((info->num_exits % 5000) == 0) { V3_Print("SVM Exit number %d\n", (uint32_t)info->num_exits); } - - +*/ - } return 0; }