X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmx.c;h=de81dfc9df654f5b3e731765819ffbc2e4ba0161;hb=ed72a7fb6a7ccbf370dbfa7900d2548ab34f3d63;hp=2653af0745fb3b1798c03ea3c202bf8f5886a855;hpb=e0711262cc7bef8962813f713d36cc8cabf80cb4;p=palacios.git diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index 2653af0..de81dfc 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -97,7 +97,7 @@ static addr_t allocate_vmcs() { PrintDebug(VM_NONE, VCORE_NONE, "Allocating page\n"); - temp = V3_AllocPages(1); + temp = V3_AllocPages(1); // need not be shadow-safe, not exposed to guest if (!temp) { PrintError(VM_NONE, VCORE_NONE, "Cannot allocate VMCS\n"); return -1; @@ -456,7 +456,7 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) return -1; } - vmx_state->msr_area_paddr = (addr_t)V3_AllocPages(1); + vmx_state->msr_area_paddr = (addr_t)V3_AllocPages(1); // need not be shadow-safe, not exposed to guest if (vmx_state->msr_area_paddr == (addr_t)NULL) { PrintError(core->vm_info, core, "could not allocate msr load/store area\n"); @@ -687,7 +687,7 @@ int v3_vmx_load_core(struct guest_info * core, void * ctx){ struct cr0_32 * shadow_cr0; addr_t vmcs_page_paddr; //HPA - vmcs_page_paddr = (addr_t) V3_AllocPages(1); + vmcs_page_paddr = (addr_t) V3_AllocPages(1); // need not be shadow-safe, not exposed to guest if (!vmcs_page_paddr) { PrintError(core->vm_info, core, "Could not allocate space for a vmcs in VMX\n"); @@ -1028,7 +1028,8 @@ int v3_vmx_enter(struct guest_info * info) { check_vmcs_write(VMCS_PREEMPT_TIMER, preempt_window); } - + + V3_FP_ENTRY_RESTORE(info); { uint64_t entry_tsc = 0; @@ -1081,6 +1082,8 @@ int v3_vmx_enter(struct guest_info * info) { info->num_exits++; + V3_FP_EXIT_SAVE(info); + /* If we have the preemption time, then use it to get more accurate guest time */ if (vmx_info->pin_ctrls.active_preempt_timer) { uint32_t cycles_left = 0; @@ -1180,56 +1183,64 @@ int v3_start_vmx_guest(struct guest_info * info) { PrintDebug(info->vm_info, info, "Starting VMX core %u\n", info->vcpu_id); - if (info->vcpu_id == 0) { - info->core_run_state = CORE_RUNNING; - } else { + while (1) { + if (info->core_run_state == CORE_STOPPED) { + if (info->vcpu_id == 0) { + info->core_run_state = CORE_RUNNING; + } else { + + PrintDebug(info->vm_info, info, "VMX core %u: Waiting for core initialization\n", info->vcpu_id); + + V3_NO_WORK(info); + + while (info->core_run_state == CORE_STOPPED) { + + if (info->vm_info->run_state == VM_STOPPED) { + // The VM was stopped before this core was initialized. + return 0; + } - PrintDebug(info->vm_info, info, "VMX core %u: Waiting for core initialization\n", info->vcpu_id); + V3_STILL_NO_WORK(info); + //PrintDebug(info->vm_info, info, "VMX core %u: still waiting for INIT\n",info->vcpu_id); + } - while (info->core_run_state == CORE_STOPPED) { + V3_HAVE_WORK_AGAIN(info); + PrintDebug(info->vm_info, info, "VMX core %u initialized\n", info->vcpu_id); + + // We'll be paranoid about race conditions here + v3_wait_at_barrier(info); + } + + + PrintDebug(info->vm_info, info, "VMX core %u: I am starting at CS=0x%x (base=0x%p, limit=0x%x), RIP=0x%p\n", + info->vcpu_id, info->segments.cs.selector, (void *)(info->segments.cs.base), + info->segments.cs.limit, (void *)(info->rip)); + + + PrintDebug(info->vm_info, info, "VMX core %u: Launching VMX VM on logical core %u\n", info->vcpu_id, info->pcpu_id); + + v3_start_time(info); + + if (info->vm_info->run_state == VM_STOPPED) { - // The VM was stopped before this core was initialized. - return 0; + info->core_run_state = CORE_STOPPED; + break; } - - v3_yield(info,-1); - //PrintDebug(info->vm_info, info, "VMX core %u: still waiting for INIT\n",info->vcpu_id); - } + } + - PrintDebug(info->vm_info, info, "VMX core %u initialized\n", info->vcpu_id); - - // We'll be paranoid about race conditions here - v3_wait_at_barrier(info); - } - - - PrintDebug(info->vm_info, info, "VMX core %u: I am starting at CS=0x%x (base=0x%p, limit=0x%x), RIP=0x%p\n", - info->vcpu_id, info->segments.cs.selector, (void *)(info->segments.cs.base), - info->segments.cs.limit, (void *)(info->rip)); - - - PrintDebug(info->vm_info, info, "VMX core %u: Launching VMX VM on logical core %u\n", info->vcpu_id, info->pcpu_id); - - v3_start_time(info); - #ifdef V3_CONFIG_PMU_TELEMETRY - v3_pmu_telemetry_start(info); + v3_pmu_telemetry_start(info); #endif - + #ifdef V3_CONFIG_PWRSTAT_TELEMETRY - v3_pwrstat_telemetry_start(info); + v3_pwrstat_telemetry_start(info); #endif - - while (1) { - - if (info->vm_info->run_state == VM_STOPPED) { - info->core_run_state = CORE_STOPPED; - break; - } - + + if (v3_vmx_enter(info) == -1) { - + addr_t host_addr; addr_t linear_addr = 0;