VirtualBox

Changeset 78976 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Jun 5, 2019 6:22:44 AM (6 years ago)
Author:
vboxsync
Message:

cpum.h: Nested VMX: bugref:9180 Add CPUMIsGuestVmxXcptInterceptSet.

File:
1 edited

Legend:

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

    r78869 r78976  
    21012101
    21022102/**
     2103 * Checks whether the given exception causes a VM-exit.
     2104 *
     2105 * The exception type include hardware exceptions, software exceptions (#BP, #OF)
     2106 * and privileged software exceptions (#DB generated by INT1/ICEBP).
     2107 *
     2108 * Software interrupts do -not- cause VM-exits and hence must not be used with this
     2109 * function.
     2110 *
     2111 * @returns @c true if the exception causes a VM-exit, @c false otherwise.
     2112 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
     2113 * @param   pCtx        Pointer to the context.
     2114 * @param   uVector     The exception vector.
     2115 * @param   uErrCode    The error code associated with the exception. Pass 0 if not
     2116 *                      applicable.
     2117 */
     2118DECLINLINE(bool) CPUMIsGuestVmxXcptInterceptSet(PCVMCPU pVCpu, PCCPUMCTX pCtx, uint8_t uVector, uint32_t uErrCode)
     2119{
     2120    Assert(uVector <= X86_XCPT_LAST);
     2121
     2122    RT_NOREF(pVCpu);
     2123    PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs);
     2124    Assert(pVmcs);
     2125    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
     2126
     2127    /* NMIs have a dedicated VM-execution control for causing VM-exits. */
     2128    if (uVector == X86_XCPT_NMI)
     2129        return RT_BOOL(pVmcs->u32PinCtls & VMX_PIN_CTLS_NMI_EXIT);
     2130
     2131    /* Page-faults are subject to masking using its error code. */
     2132    uint32_t fXcptBitmap = pVmcs->u32XcptBitmap;
     2133    if (uVector == X86_XCPT_PF)
     2134    {
     2135        uint32_t const fXcptPFMask  = pVmcs->u32XcptPFMask;
     2136        uint32_t const fXcptPFMatch = pVmcs->u32XcptPFMatch;
     2137        if ((uErrCode & fXcptPFMask) != fXcptPFMatch)
     2138            fXcptBitmap ^= RT_BIT(X86_XCPT_PF);
     2139    }
     2140
     2141    /* Consult the exception bitmap for all other exceptions. */
     2142    if (fXcptBitmap & RT_BIT(uVector))
     2143        return true;
     2144    return false;
     2145}
     2146
     2147/**
    21032148 * Implements VMSucceed for VMX instruction success.
    21042149 *
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