VirtualBox

Changeset 79235 in vbox


Ignore:
Timestamp:
Jun 19, 2019 8:42:11 AM (6 years ago)
Author:
vboxsync
Message:

VMM/IEM: Nested VMX: bugref:9180 Some symmetry with regards to clearing and loading the current VMCS. Renamed iemVmxCommitCurrentVmcsToMemory to iemVmxWriteCurrentVmcsToGstMem and added iemVmxReadCurrentVmcsFromGstMem. Will make it easier to add HM hooks in the right places with clearer names. Also the VMCS read/write functions do not set/clear the current VMCS ptr anymore, let the callers do this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r79233 r79235  
    864864 * @param   pVCpu   The cross context virtual CPU structure.
    865865 */
    866 DECL_FORCE_INLINE(int) iemVmxCommitCurrentVmcsToMemory(PVMCPU pVCpu)
    867 {
     866DECL_FORCE_INLINE(int) iemVmxWriteCurrentVmcsToGstMem(PVMCPU pVCpu)
     867{
     868    Assert(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs));
    868869    Assert(IEM_VMX_HAS_CURRENT_VMCS(pVCpu));
    869     Assert(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs));
    870870    int rc = PGMPhysSimpleWriteGCPhys(pVCpu->CTX_SUFF(pVM), IEM_VMX_GET_CURRENT_VMCS(pVCpu),
    871871                                      pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs), sizeof(VMXVVMCS));
    872     IEM_VMX_CLEAR_CURRENT_VMCS(pVCpu);
     872    return rc;
     873}
     874
     875
     876/**
     877 * Populates the current VMCS contents from guest memory.
     878 *
     879 * @returns VBox status code.
     880 * @param   pVCpu   The cross context virtual CPU structure.
     881 */
     882DECL_FORCE_INLINE(int) iemVmxReadCurrentVmcsFromGstMem(PVMCPU pVCpu)
     883{
     884    Assert(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs));
     885    Assert(IEM_VMX_HAS_CURRENT_VMCS(pVCpu));
     886    int rc = PGMPhysSimpleReadGCPhys(pVCpu->CTX_SUFF(pVM), (void *)pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs),
     887                                     IEM_VMX_GET_CURRENT_VMCS(pVCpu), sizeof(VMXVVMCS));
    873888    return rc;
    874889}
     
    79938008    {
    79948009        pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs)->fVmcsState = fVmcsLaunchStateClear;
    7995         iemVmxCommitCurrentVmcsToMemory(pVCpu);
    7996         Assert(!IEM_VMX_HAS_CURRENT_VMCS(pVCpu));
     8010        iemVmxWriteCurrentVmcsToGstMem(pVCpu);
     8011        IEM_VMX_CLEAR_CURRENT_VMCS(pVCpu);
    79978012    }
    79988013    else
     
    82088223        if (IEM_VMX_HAS_CURRENT_VMCS(pVCpu))
    82098224        {
    8210             iemVmxCommitCurrentVmcsToMemory(pVCpu);
    8211             Assert(!IEM_VMX_HAS_CURRENT_VMCS(pVCpu));
    8212         }
    8213 
    8214         /* Finally, cache the new VMCS from guest memory and mark it as the current VMCS. */
    8215         rc = PGMPhysSimpleReadGCPhys(pVCpu->CTX_SUFF(pVM), (void *)pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs), GCPhysVmcs,
    8216                                      sizeof(VMXVVMCS));
     8225            iemVmxWriteCurrentVmcsToGstMem(pVCpu);
     8226            IEM_VMX_CLEAR_CURRENT_VMCS(pVCpu);
     8227        }
     8228
     8229        /* Set the new VMCS as the current VMCS and read it from guest memory. */
     8230        IEM_VMX_SET_CURRENT_VMCS(pVCpu, GCPhysVmcs);
     8231        rc = iemVmxReadCurrentVmcsFromGstMem(pVCpu);
    82178232        if (RT_SUCCESS(rc))
    82188233        { /* likely */ }
     
    82238238            return rc;
    82248239        }
    8225         IEM_VMX_SET_CURRENT_VMCS(pVCpu, GCPhysVmcs);
    82268240    }
    82278241
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette