X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmx.c;h=d9fc0811cd9c239dfbcb8177622d999d40c2b958;hb=36973b53a5876a555eb59be0b0fb5f1f49686696;hp=b29673f7a6c409a6bf10217264ff3ab0246e68fc;hpb=3500a418f4ab8a5ce38c1480f107b5deb5712bee;p=palacios.git diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index b29673f..d9fc081 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -34,6 +34,7 @@ #include #include #include +#include #ifdef V3_CONFIG_CHECKPOINT #include @@ -399,7 +400,7 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) vmx_ret |= check_vmcs_write(VMCS_CR4_MASK, CR4_VMXE); #define CR0_NE 0x00000020 vmx_ret |= check_vmcs_write(VMCS_CR0_MASK, CR0_NE); - //((struct cr0_32 *)&(core->shdw_pg_state.guest_cr0))->ne = 1; + ((struct cr0_32 *)&(core->shdw_pg_state.guest_cr0))->ne = 1; if (v3_init_ept(core, &hw_info) == -1) { PrintError("Error initializing EPT\n"); @@ -640,9 +641,14 @@ int v3_deinit_vmx_vmcs(struct guest_info * core) { * JRL: This is broken */ int v3_vmx_save_core(struct guest_info * core, void * ctx){ - uint64_t vmcs_ptr = vmcs_store(); + struct vmx_data * vmx_info = (struct vmx_data *)(core->vmm_data); - v3_chkpt_save(ctx, "vmcs_data", PAGE_SIZE, (void *)vmcs_ptr); + // note that the vmcs pointer is an HPA, but we need an HVA + if (v3_chkpt_save(ctx, "vmcs_data", PAGE_SIZE_4KB, + V3_VAddr((void*) (vmx_info->vmcs_ptr_phys))) ==-1) { + PrintError("Could not save vmcs data for VMX\n"); + return -1; + } return 0; } @@ -650,12 +656,27 @@ int v3_vmx_save_core(struct guest_info * core, void * ctx){ int v3_vmx_load_core(struct guest_info * core, void * ctx){ struct vmx_data * vmx_info = (struct vmx_data *)(core->vmm_data); struct cr0_32 * shadow_cr0; - char vmcs[PAGE_SIZE_4KB]; + addr_t vmcs_page_paddr; //HPA - v3_chkpt_load(ctx, "vmcs_data", PAGE_SIZE_4KB, vmcs); + vmcs_page_paddr = (addr_t) V3_AllocPages(1); + + if (!vmcs_page_paddr) { + PrintError("Could not allocate space for a vmcs in VMX\n"); + return -1; + } + + if (v3_chkpt_load(ctx, "vmcs_data", PAGE_SIZE_4KB, + V3_VAddr((void *)vmcs_page_paddr)) == -1) { + PrintError("Could not load vmcs data for VMX\n"); + return -1; + } vmcs_clear(vmx_info->vmcs_ptr_phys); - vmcs_load((addr_t)vmcs); + + // Probably need to delete the old one... + V3_FreePages((void*)(vmx_info->vmcs_ptr_phys),1); + + vmcs_load(vmcs_page_paddr); v3_vmx_save_vmcs(core); @@ -886,7 +907,11 @@ v3_vmx_config_tsc_virtualization(struct guest_info * info) { check_vmcs_write(VMCS_PROC_CTRLS, vmx_info->pri_proc_ctrls.value); } - tsc_offset = v3_tsc_host_offset(&info->time_state); + if (info->time_state.flags & VM_TIME_TSC_PASSTHROUGH) { + tsc_offset = 0; + } else { + tsc_offset = v3_tsc_host_offset(&info->time_state); + } tsc_offset_high = (uint32_t)(( tsc_offset >> 32) & 0xffffffff); tsc_offset_low = (uint32_t)(tsc_offset & 0xffffffff);