VirtualBox

Changeset 97183 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Oct 17, 2022 10:27:05 PM (2 years ago)
Author:
vboxsync
Message:

VMM/CPUM,HMVMX,IEM: Use the individual CPUMCTX_INHIBIT_SHADOW_SS and CPUMCTX_INHIBIT_SHADOW_STI flags with IEM (only setting), VT-x and NEM/kvm. bugref:9941

File:
1 edited

Legend:

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

    r97182 r97183  
    19391939
    19401940/**
    1941  * Checks if we're in an "interrupt shadow", i.e. after a STI, POPF or MOV SS,
     1941 * Checks if we're in an "interrupt shadow", i.e. after a STI, POP SS or MOV SS,
    19421942 * updating the state if stale.
    19431943 *
    19441944 * This also inhibit NMIs, except perhaps for nested guests.
    19451945 *
    1946  * @returns true if interrupts are inhibited by interrupt shadow, false if not.
     1946 * @retval  true if interrupts are inhibited by interrupt shadow.
     1947 * @retval  false if not.
    19471948 * @param   pCtx    Current guest CPU context.
    19481949 * @note    Requires pCtx->rip to be up to date.
     
    19621963
    19631964/**
    1964  * Sets the "interrupt shadow" flag, after a STI, POPF or MOV SS instruction.
     1965 * Checks if we're in an "interrupt shadow" due to a POP SS or MOV SS
     1966 * instruction.
     1967 *
     1968 * This also inhibit NMIs, except perhaps for nested guests.
     1969 *
     1970 * @retval  true if interrupts are inhibited due to POP/MOV SS.
     1971 * @retval  false if not.
     1972 * @param   pCtx    Current guest CPU context.
     1973 * @note    Requires pCtx->rip to be up to date.
     1974 * @note    Does not clear fInhibit when CPUMCTX::uRipInhibitInt differs
     1975 *          from CPUMCTX::rip.
     1976 * @note    Both CPUMIsInInterruptShadowAfterSti() and this function may return
     1977 *          true depending on the execution engine being used.
     1978 */
     1979DECLINLINE(bool) CPUMIsInInterruptShadowAfterSs(PCCPUMCTX pCtx)
     1980{
     1981    if (!(pCtx->fInhibit & CPUMCTX_INHIBIT_SHADOW_SS))
     1982        return false;
     1983
     1984    CPUMCTX_ASSERT_NOT_EXTRN(pCtx, CPUMCTX_EXTRN_RIP);
     1985    return pCtx->uRipInhibitInt == pCtx->rip;
     1986}
     1987
     1988/**
     1989 * Checks if we're in an "interrupt shadow" due to an STI instruction.
     1990 *
     1991 * This also inhibit NMIs, except perhaps for nested guests.
     1992 *
     1993 * @retval  true if interrupts are inhibited due to STI.
     1994 * @retval  false if not.
     1995 * @param   pCtx    Current guest CPU context.
     1996 * @note    Requires pCtx->rip to be up to date.
     1997 * @note    Does not clear fInhibit when CPUMCTX::uRipInhibitInt differs
     1998 *          from CPUMCTX::rip.
     1999 * @note    Both CPUMIsInInterruptShadowAfterSs() and this function may return
     2000 *          true depending on the execution engine being used.
     2001 */
     2002DECLINLINE(bool) CPUMIsInInterruptShadowAfterSti(PCCPUMCTX pCtx)
     2003{
     2004    if (!(pCtx->fInhibit & CPUMCTX_INHIBIT_SHADOW_STI))
     2005        return false;
     2006
     2007    CPUMCTX_ASSERT_NOT_EXTRN(pCtx, CPUMCTX_EXTRN_RIP);
     2008    return pCtx->uRipInhibitInt == pCtx->rip;
     2009}
     2010
     2011/**
     2012 * Sets the "interrupt shadow" flag, after a STI, POP SS or MOV SS instruction.
    19652013 *
    19662014 * @param   pCtx    Current guest CPU context.
     
    19752023
    19762024/**
    1977  * Sets the "interrupt shadow" flag, after a STI, POPF or MOV SS instruction,
     2025 * Sets the "interrupt shadow" flag, after a STI, POP SS or MOV SS instruction,
    19782026 * extended version.
    19792027 *
     
    19852033    pCtx->fInhibit |= CPUMCTX_INHIBIT_SHADOW;
    19862034    pCtx->uRipInhibitInt = rip;
     2035}
     2036
     2037/**
     2038 * Sets the "interrupt shadow" flag after a POP SS or MOV SS instruction.
     2039 *
     2040 * @param   pCtx    Current guest CPU context.
     2041 * @note    Requires pCtx->rip to be up to date.
     2042 */
     2043DECLINLINE(void) CPUMSetInInterruptShadowSs(PCPUMCTX pCtx)
     2044{
     2045    CPUMCTX_ASSERT_NOT_EXTRN(pCtx, CPUMCTX_EXTRN_RIP);
     2046    pCtx->fInhibit |= CPUMCTX_INHIBIT_SHADOW_SS;
     2047    pCtx->uRipInhibitInt = pCtx->rip;
     2048}
     2049
     2050/**
     2051 * Sets the "interrupt shadow" flag after an STI instruction.
     2052 *
     2053 * @param   pCtx    Current guest CPU context.
     2054 * @note    Requires pCtx->rip to be up to date.
     2055 */
     2056DECLINLINE(void) CPUMSetInInterruptShadowSti(PCPUMCTX pCtx)
     2057{
     2058    CPUMCTX_ASSERT_NOT_EXTRN(pCtx, CPUMCTX_EXTRN_RIP);
     2059    pCtx->fInhibit |= CPUMCTX_INHIBIT_SHADOW_STI;
     2060    pCtx->uRipInhibitInt = pCtx->rip;
    19872061}
    19882062
     
    20342108    }
    20352109    return fInhibited;
     2110}
     2111
     2112/**
     2113 * Update the two "interrupt shadow" flags separately, extended version.
     2114 *
     2115 * @param   pCtx            Current guest CPU context.
     2116 * @param   fInhibitedBySs  The new state for the MOV SS & POP SS aspect.
     2117 * @param   fInhibitedBySti The new state for the STI aspect.
     2118 * @param   rip             The RIP for which it is inhibited.
     2119 */
     2120DECLINLINE(void) CPUMUpdateInterruptShadowSsStiEx(PCPUMCTX pCtx, bool fInhibitedBySs, bool fInhibitedBySti, uint64_t rip)
     2121{
     2122    if (!(fInhibitedBySs | fInhibitedBySti))
     2123        pCtx->fInhibit &= (uint8_t)~CPUMCTX_INHIBIT_SHADOW;
     2124    else
     2125    {
     2126        pCtx->fInhibit |= (fInhibitedBySs  ? CPUMCTX_INHIBIT_SHADOW_SS  : 0)
     2127                       |  (fInhibitedBySti ? CPUMCTX_INHIBIT_SHADOW_STI : 0);
     2128        pCtx->uRipInhibitInt = rip;
     2129    }
    20362130}
    20372131
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