X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=c98a48b4f381a4d7c5279e66a15f3719c2280bc2;hb=4d17b20a86eb8102a287263372458fcb9019c232;hp=b4f692cf0c23666db477db43ed8b6762ecc0ca09;hpb=a686a57429dcd9fa2f701228227dadcd096df8ed;p=palacios.git diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index b4f692c..c98a48b 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -36,6 +36,7 @@ #include #include +#include #ifdef V3_CONFIG_CHECKPOINT #include @@ -368,15 +369,25 @@ int v3_deinit_svm_vmcb(struct guest_info * core) { #ifdef V3_CONFIG_CHECKPOINT int v3_svm_save_core(struct guest_info * core, void * ctx){ - v3_chkpt_save_8(ctx, "cpl", &(core->cpl)); - v3_chkpt_save(ctx, "vmcb_data", PAGE_SIZE, core->vmm_data); + if (v3_chkpt_save_8(ctx, "cpl", &(core->cpl)) == -1) { + PrintError("Could not save SVM cpl\n"); + return -1; + } + + if (v3_chkpt_save(ctx, "vmcb_data", PAGE_SIZE, core->vmm_data) == -1) { + PrintError("Could not save SVM vmcb\n"); + return -1; + } return 0; } int v3_svm_load_core(struct guest_info * core, void * ctx){ - v3_chkpt_load_8(ctx, "cpl", &(core->cpl)); + if (v3_chkpt_load_8(ctx, "cpl", &(core->cpl)) == -1) { + PrintError("Could not load SVM cpl\n"); + return -1; + } if (v3_chkpt_load(ctx, "vmcb_data", PAGE_SIZE, core->vmm_data) == -1) { return -1; @@ -523,13 +534,17 @@ int v3_svm_config_tsc_virtualization(struct guest_info * info) { vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data)); - if (info->time_state.time_flags & V3_TIME_TRAP_RDTSC) { + if (info->time_state.flags & VM_TIME_TRAP_RDTSC) { ctrl_area->instrs.RDTSC = 1; ctrl_area->svm_instrs.RDTSCP = 1; } else { ctrl_area->instrs.RDTSC = 0; ctrl_area->svm_instrs.RDTSCP = 0; - ctrl_area->TSC_OFFSET = v3_tsc_host_offset(&info->time_state); + if (info->time_state.flags & VM_TIME_TSC_PASSTHROUGH) { + ctrl_area->TSC_OFFSET = 0; + } else { + ctrl_area->TSC_OFFSET = v3_tsc_host_offset(&info->time_state); + } } return 0; } @@ -551,15 +566,15 @@ int v3_svm_enter(struct guest_info * info) { // Conditionally yield the CPU if the timeslice has expired v3_yield_cond(info); + // Update timer devices after being in the VM before doing + // IRQ updates, so that any interrupts they raise get seen + // immediately. + v3_advance_time(info, NULL); + v3_update_timers(info); + // disable global interrupts for vm state transition v3_clgi(); - // Update timer devices after being in the VM, with interupts - // disabled, but before doing IRQ updates, so that any interrupts they - //raise get seen immediately. - v3_advance_time(info); - v3_update_timers(info); - // Synchronize the guest state to the VMCB guest_state->cr0 = info->ctrl_regs.cr0; guest_state->cr2 = info->ctrl_regs.cr2; @@ -610,7 +625,6 @@ int v3_svm_enter(struct guest_info * info) { } #endif - v3_time_enter_vm(info); v3_svm_config_tsc_virtualization(info); //V3_Print("Calling v3_svm_launch\n"); @@ -632,8 +646,7 @@ int v3_svm_enter(struct guest_info * info) { v3_last_exit = (uint32_t)(guest_ctrl->exit_code); - // Immediate exit from VM time bookkeeping - v3_time_exit_vm(info, &guest_cycles); + v3_advance_time(info, &guest_cycles); info->num_exits++; @@ -684,6 +697,11 @@ int v3_svm_enter(struct guest_info * info) { // Conditionally yield the CPU if the timeslice has expired v3_yield_cond(info); + // This update timers is for time-dependent handlers + // if we're slaved to host time + v3_advance_time(info, NULL); + v3_update_timers(info); + { int ret = v3_handle_svm_exit(info, exit_code, exit_info1, exit_info2);