X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmx.c;h=20c0c5f9ac3e56f6abe648cde0047f5c677ed3e6;hb=cf780b903a02efc700d51dbadcc90115f016256c;hp=f26a1eae40cd2154b5878e9b6ef48bb6239cb701;hpb=5d67a000f2d9e0043237af7c86eecd034119fe93;p=palacios.releases.git diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index f26a1ea..20c0c5f 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -212,23 +212,25 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) #ifdef __V3_64BIT__ + // Ensure host runs in 64-bit mode at each VM EXIT vmx_state->exit_ctrls.host_64_on = 1; #endif - - /* Not sure how exactly to handle this... */ + // Hook all accesses to EFER register v3_hook_msr(core->vm_info, EFER_MSR, &v3_handle_efer_read, &v3_handle_efer_write, core); - // Or is it this??? - vmx_state->entry_ctrls.ld_efer = 1; + // Restore host's EFER register on each VM EXIT vmx_state->exit_ctrls.ld_efer = 1; + + // Save/restore guest's EFER register to/from VMCS on VM EXIT/ENTRY vmx_state->exit_ctrls.save_efer = 1; - /* *** */ + vmx_state->entry_ctrls.ld_efer = 1; - vmx_ret |= check_vmcs_write(VMCS_CR4_MASK, CR4_VMXE); + // Cause VM_EXIT whenever CR4.VMXE or CR4.PAE bits are written + vmx_ret |= check_vmcs_write(VMCS_CR4_MASK, CR4_VMXE | CR4_PAE); /* Setup paging */ @@ -749,9 +751,10 @@ int v3_vmx_enter(struct guest_info * info) { // disable global interrupts for vm state transition v3_disable_ints(); - // Update timer devices prior to entering VM. Doing it here - // makes sure the guest sees any timers that fired while it - // was in the VMM + // Update timer devices late after being in the VM so that as much + // of hte time in the VM is accounted for as possible. Also do it before + // updating IRQ entry state so that any interrupts the timers raise get + // handled on the next VM entry. Must be done with interrupts disabled. v3_update_timers(info); if (vmcs_store() != vmx_info->vmcs_ptr_phys) { @@ -842,7 +845,6 @@ int v3_vmx_enter(struct guest_info * info) { exit_log[info->num_exits % 10] = exit_info; - #ifdef V3_CONFIG_SYMCALL if (info->sym_core_state.symcall_state.sym_call_active == 0) { update_irq_exit_state(info);