VirtualBox

Changeset 78775 in vbox for trunk/include/VBox/vmm


Ignore:
Timestamp:
May 27, 2019 8:48:18 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
130862
Message:

cpum.h: Nested VMX: bugref:9180 Add CPUMIsGuestVmxMovToCr0Cr4InterceptSet for upcoming changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/cpum.h

    r78715 r78775  
    22452245}
    22462246
     2247
     2248/**
     2249 * Checks whether the Mov-to-CR0/CR4 access causes a VM-exit or not.
     2250 *
     2251 * @returns @c true if the Mov CRX access causes a VM-exit, @c false otherwise.
     2252 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
     2253 * @param   pCtx        Pointer to the context.
     2254 * @param   iCrReg      The control register number (must be 0 or 4).
     2255 * @param   uNewCrX     The CR0/CR4 value being written.
     2256 */
     2257DECLINLINE(bool) CPUMIsGuestVmxMovToCr0Cr4InterceptSet(PVMCPU pVCpu, PCCPUMCTX pCtx, uint8_t iCrReg, uint64_t uNewCrX)
     2258{
     2259    /*
     2260     * For any CR0/CR4 bit owned by the host (in the CR0/CR4 guest/host mask), if the
     2261     * corresponding bits differ between the source operand and the read-shadow,
     2262     * we must cause a VM-exit.
     2263     *
     2264     * See Intel spec. 25.1.3 "Instructions That Cause VM Exits Conditionally".
     2265     */
     2266    RT_NOREF(pVCpu);
     2267    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
     2268    Assert(pVmcs);
     2269    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
     2270    Assert(iCrReg == 0 || iCrReg == 4);
     2271
     2272    uint64_t fGstHostMask;
     2273    uint64_t fReadShadow;
     2274    if (iCrReg == 0)
     2275    {
     2276        fGstHostMask = pVmcs->u64Cr0Mask.u;
     2277        fReadShadow  = pVmcs->u64Cr0ReadShadow.u;
     2278    }
     2279    else
     2280    {
     2281        fGstHostMask = pVmcs->u64Cr4Mask.u;
     2282        fReadShadow  = pVmcs->u64Cr4ReadShadow.u;
     2283    }
     2284
     2285    if ((fReadShadow & fGstHostMask) != (uNewCrX & fGstHostMask))
     2286    {
     2287        Assert(fGstHostMask != 0);
     2288        return true;
     2289    }
     2290
     2291    return false;
     2292}
     2293
    22472294# endif /* !IN_RC */
    22482295
Note: See TracChangeset for help on using the changeset viewer.

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