VirtualBox

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


Ignore:
Timestamp:
Jun 5, 2019 8:55:38 AM (6 years ago)
Author:
vboxsync
Message:

cpum.h: Nested VMX: bugref:9180 Use the inline function to verify VMX non-root mode in all places consistently. Added CPUMIsGuestVmxVirtNmiBlocking for upcoming changes.

File:
1 edited

Legend:

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

    r78976 r78980  
    20092009{
    20102010    RT_NOREF(pVCpu);
    2011     Assert(pCtx->hwvirt.enmHwvirt == CPUMHWVIRT_VMX);
    2012     Assert(pCtx->hwvirt.vmx.fInVmxNonRootMode);
    2013     Assert(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs));
    2014     return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32PinCtls & uPinCtls);
     2011    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
     2012    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
     2013    Assert(pVmcs);
     2014    return RT_BOOL(pVmcs->u32PinCtls & uPinCtls);
    20152015}
    20162016
     
    20302030{
    20312031    RT_NOREF(pVCpu);
    2032     Assert(pCtx->hwvirt.enmHwvirt == CPUMHWVIRT_VMX);
    2033     Assert(pCtx->hwvirt.vmx.fInVmxNonRootMode);
    2034     Assert(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs));
    2035     return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32ProcCtls & uProcCtls);
     2032    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
     2033    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
     2034    Assert(pVmcs);
     2035    return RT_BOOL(pVmcs->u32ProcCtls & uProcCtls);
    20362036}
    20372037
     
    20522052{
    20532053    RT_NOREF(pVCpu);
    2054     Assert(pCtx->hwvirt.enmHwvirt == CPUMHWVIRT_VMX);
    2055     Assert(pCtx->hwvirt.vmx.fInVmxNonRootMode);
    2056     Assert(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs));
    2057     return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32ProcCtls2 & uProcCtls2);
     2054    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
     2055    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
     2056    Assert(pVmcs);
     2057    return RT_BOOL(pVmcs->u32ProcCtls2 & uProcCtls2);
    20582058}
    20592059
     
    20732073{
    20742074    RT_NOREF(pVCpu);
    2075     Assert(pCtx->hwvirt.enmHwvirt == CPUMHWVIRT_VMX);
    2076     Assert(pCtx->hwvirt.vmx.fInVmxNonRootMode);
    2077     Assert(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs));
    2078     return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32ExitCtls & uExitCtls);
     2075    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
     2076    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
     2077    Assert(pVmcs);
     2078    return RT_BOOL(pVmcs->u32ExitCtls & uExitCtls);
    20792079}
    20802080
     
    20942094{
    20952095    RT_NOREF(pVCpu);
    2096     Assert(pCtx->hwvirt.enmHwvirt == CPUMHWVIRT_VMX);
    2097     Assert(pCtx->hwvirt.vmx.fInVmxNonRootMode);
    2098     Assert(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs));
    2099     return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32EntryCtls & uEntryCtls);
     2096    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
     2097    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
     2098    Assert(pVmcs);
     2099    return RT_BOOL(pVmcs->u32EntryCtls & uEntryCtls);
    21002100}
    21012101
     
    21212121
    21222122    RT_NOREF(pVCpu);
     2123    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    21232124    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
    21242125    Assert(pVmcs);
    2125     Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    21262126
    21272127    /* NMIs have a dedicated VM-execution control for causing VM-exits. */
     
    22042204{
    22052205    RT_NOREF(pVCpu);
    2206     Assert(pCtx->hwvirt.enmHwvirt == CPUMHWVIRT_VMX);
    2207     Assert(pCtx->hwvirt.vmx.fInVmxNonRootMode);
    2208     Assert(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs));
    2209     return pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u64AddrApicAccess.u;
     2206    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
     2207    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
     2208    Assert(pVmcs);
     2209    return pVmcs->u64AddrApicAccess.u;
    22102210}
    22112211
     
    22272227     */
    22282228    RT_NOREF(pVCpu);
     2229    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    22292230    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
    22302231    Assert(pVmcs);
    2231     Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    22322232    uint64_t const uGstCr0      = pCtx->cr0;
    22332233    uint64_t const fGstHostMask = pVmcs->u64Cr0Mask.u;
     
    22532253     */
    22542254    RT_NOREF(pVCpu);
     2255    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    22552256    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
    22562257    Assert(pVmcs);
    2257     Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    22582258    uint64_t const uGstCr4      = pCtx->cr4;
    22592259    uint64_t const fGstHostMask = pVmcs->u64Cr4Mask.u;
     
    22792279     */
    22802280    RT_NOREF(pVCpu);
     2281    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    22812282    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
    22822283    Assert(pVmcs);
    2283     Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    22842284
    22852285    uint32_t const fGstHostMask = pVmcs->u64Cr0Mask.u;
     
    23292329     */
    23302330    RT_NOREF(pVCpu);
     2331    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    23312332    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
    23322333    Assert(pVmcs);
    2333     Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    23342334    Assert(iCrReg == 0 || iCrReg == 4);
    23352335
     
    23622362 * interrupts.
    23632363 *
    2364  * @returns VBox status code.
    2365  * @retval  true if it's ready, false otherwise.
    2366  *
     2364 * @returns @c true if it's ready, @c false otherwise.
    23672365 * @param   pVCpu   The cross context virtual CPU structure of the calling EMT.
    23682366 * @param   pCtx    The guest-CPU context.
     
    23812379
    23822380/**
     2381 * Checks whether the VMX nested-guest is blocking virtual-NMIs.
     2382 *
     2383 * @returns @c true if it's blocked, @c false otherwise.
     2384 * @param   pCtx    The guest-CPU context.
     2385 */
     2386DECLINLINE(bool) CPUMIsGuestVmxVirtNmiBlocking(PCVMCPU pVCpu, PCCPUMCTX pCtx)
     2387{
     2388#ifdef IN_RC
     2389    RT_NOREF2(pVCpu, pCtx);
     2390    AssertReleaseFailedReturn(false);
     2391#else
     2392    /*
     2393     * Return the state of virtual-NMI blocking, if we are executing a
     2394     * VMX nested-guest with virtual-NMIs enabled.
     2395     */
     2396    Assert(CPUMIsGuestVmxPinCtlsSet(pVCpu, pCtx, VMX_PIN_CTLS_VIRT_NMI));
     2397    return pCtx->hwvirt.vmx.fVirtNmiBlocking;
     2398#endif
     2399}
     2400
     2401/**
    23832402 * Checks whether the VMX nested-guest is in a state to receive virtual interrupts
    23842403 * (those injected with the "virtual-interrupt delivery" feature).
    23852404 *
    2386  * @returns VBox status code.
    2387  * @retval  true if it's ready, false otherwise.
    2388  *
     2405 * @returns @c true if it's ready, @c false otherwise.
    23892406 * @param   pVCpu   The cross context virtual CPU structure of the calling EMT.
    23902407 * @param   pCtx    The guest-CPU context.
     
    23982415    RT_NOREF(pVCpu);
    23992416    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    2400 
    2401     if (   (pCtx->eflags.u & X86_EFL_IF)
    2402         && !CPUMIsGuestVmxProcCtlsSet(pVCpu, pCtx, VMX_PROC_CTLS_INT_WINDOW_EXIT))
    2403         return true;
    2404     return false;
     2417    return RT_BOOL(pCtx->eflags.u & X86_EFL_IF);
    24052418#endif
    24062419}
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