VirtualBox

Changeset 74608 in vbox for trunk


Ignore:
Timestamp:
Oct 4, 2018 10:56:05 AM (6 years ago)
Author:
vboxsync
Message:

VMM/IEM: Nested VMX: bugref:9180 Added CR0 guest/host and read-shadow masking for Mov-from-CR0 instructions.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

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

    r74607 r74608  
    52085208        IEM_NOT_REACHED_DEFAULT_CASE_RET(); /* call checks */
    52095209    }
     5210
     5211#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
     5212    if (IEM_VMX_IS_NON_ROOT_MODE(pVCpu))
     5213    {
     5214        if (iCrReg == 0)
     5215            crX = iemVmxGetMaskedCr0(pVCpu, crX);
     5216    }
     5217#endif
    52105218
    52115219    /* store it */
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r74607 r74608  
    901901
    902902/**
     903 * Gets the nested-guest CR0 mask subjected to the CR0 guest/host mask and the CR0
     904 * read-shadow.
     905 *
     906 * @returns The masked CR0.
     907 * @param   pVCpu       The cross context virtual CPU structure.
     908 * @param   uGuestCr0   The guest CR0.
     909 */
     910IEM_STATIC uint64_t iemVmxGetMaskedCr0(PVMCPU pVCpu, uint64_t uGuestCr0)
     911{
     912    PCVMXVVMCS pVmcs = pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs);
     913    Assert(pVmcs);
     914    Assert(IEM_VMX_IS_NON_ROOT_MODE(pVCpu));
     915
     916    /*
     917     * For each CR0 bit owned by the host, the corresponding bit is loaded from the
     918     * CR0-read shadow. For each CR0 bit that is not owned by the host, the corresponding
     919     * bit from the guest CR0 is loaded.
     920     *
     921     * See Intel Spec. 25.3 "Changes To Instruction Behavior In VMX Non-root Operation".
     922     */
     923    uint64_t const fGstHostMask = pVmcs->u64Cr0Mask.u;
     924    uint64_t const fReadShadow  = pVmcs->u64Cr0ReadShadow.u;
     925    uint64_t const fMaskedCr0   = (fReadShadow & fGstHostMask) | (uGuestCr0 & ~fGstHostMask);
     926
     927    return fMaskedCr0;
     928}
     929
     930
     931/**
    903932 * Gets VM-exit instruction information along with any displacement for an
    904933 * instruction VM-exit.
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