VirtualBox

Changeset 45781 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Apr 26, 2013 3:22:07 PM (12 years ago)
Author:
vboxsync
Message:

VMM/HM: Simplified real/protected mode transition tracking logic.

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r45774 r45781  
    19101910    }
    19111911
    1912     for (VMCPUID i = 0; i < pVM->cCpus; i++)
    1913     {
    1914         PVMCPU pVCpu = &pVM->aCpus[i];
    1915 
    1916         /* Current guest paging mode. */
    1917         pVCpu->hm.s.vmx.enmLastSeenGuestMode = PGMMODE_REAL;
    1918     }
    1919 
    19201912    return VINF_SUCCESS;
    19211913}
     
    33953387        {
    33963388            Assert(pVM->hm.s.vmx.pRealModeTSS);
    3397             PGMMODE enmGuestMode = PGMGetGuestMode(pVCpu);
    3398             if (pVCpu->hm.s.vmx.enmLastSeenGuestMode != enmGuestMode)
     3389            if (   pVCpu->hm.s.vmx.fWasInRealMode
     3390                && PGMGetGuestMode(pVCpu) >= PGMMODE_PROTECTED)
    33993391            {
    3400                 AssertCompile(PGMMODE_REAL < PGMMODE_PROTECTED);
    3401                 if (   pVCpu->hm.s.vmx.enmLastSeenGuestMode == PGMMODE_REAL
    3402                     && enmGuestMode >= PGMMODE_PROTECTED)
    3403                 {
    3404                     /* Signal that recompiler must flush its code-cache as the guest -may- rewrite code it will later execute
    3405                        in real-mode (e.g. OpenBSD 4.0) */
    3406                     REMFlushTBs(pVM);
    3407                     Log(("Load: Switch to protected mode detected!\n"));
    3408                 }
    3409                 pVCpu->hm.s.vmx.enmLastSeenGuestMode = enmGuestMode;
     3392                /* Signal that recompiler must flush its code-cache as the guest -may- rewrite code it will later execute
     3393                   in real-mode (e.g. OpenBSD 4.0) */
     3394                REMFlushTBs(pVM);
     3395                Log(("Load: Switch to protected mode detected!\n"));
     3396                pVCpu->hm.s.vmx.fWasInRealMode = false;
    34103397            }
    34113398        }
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r45739 r45781  
    14871487
    14881488            pVCpu->hm.s.enmShadowMode            = PGMGetShadowMode(pVCpu);
     1489#ifdef VBOX_WITH_OLD_VTX_CODE
    14891490            Assert(pVCpu->hm.s.vmx.enmCurrGuestMode == PGMGetGuestMode(pVCpu));
    14901491            pVCpu->hm.s.vmx.enmCurrGuestMode     = PGMGetGuestMode(pVCpu);
     1492#endif
    14911493        }
    14921494    }
     
    15671569        }
    15681570    }
    1569 #endif
    15701571
    15711572    if (pVCpu->hm.s.vmx.enmCurrGuestMode != enmGuestMode)
     
    15831584        }
    15841585    }
     1586#else
     1587    /* If the guest left protected mode VMX execution, we'll have to be extra
     1588     * careful if/when the guest switches back to protected mode.
     1589     */
     1590    if (enmGuestMode == PGMMODE_REAL)
     1591    {
     1592        Log(("HMR3PagingModeChanged indicates real mode execution\n"));
     1593        pVCpu->hm.s.vmx.fWasInRealMode = true;
     1594    }
     1595#endif
    15851596
    15861597    /** @todo r=ramshankar: Why do we need to do this? Most likely
     
    16691680    pVCpu->hm.s.Event.fPending = false;
    16701681
     1682#ifdef VBOX_WITH_OLD_VTX_CODE
    16711683    /* Reset state information for real-mode emulation in VT-x. */
    16721684    pVCpu->hm.s.vmx.enmLastSeenGuestMode = PGMMODE_REAL;
    16731685    pVCpu->hm.s.vmx.enmPrevGuestMode     = PGMMODE_REAL;
    16741686    pVCpu->hm.s.vmx.enmCurrGuestMode     = PGMMODE_REAL;
     1687#else
     1688    pVCpu->hm.s.vmx.fWasInRealMode = true;
     1689#endif
    16751690
    16761691    /* Reset the contents of the read cache. */
     
    23832398                   mode. VT-x can't handle the CPU state right after a switch
    23842399                   from real to protected mode. (all sorts of RPL & DPL assumptions) */
     2400#if VBOX_WITH_OLD_VTX_CODE
    23852401                if (    pVCpu->hm.s.vmx.enmLastSeenGuestMode == PGMMODE_REAL
    23862402                    &&  enmGuestMode >= PGMMODE_PROTECTED)
     2403#else
     2404                if (pVCpu->hm.s.vmx.fWasInRealMode)
     2405#endif
    23872406                {
    23882407                    if (   (pCtx->cs.Sel & X86_SEL_RPL)
     
    27842803        AssertRCReturn(rc, rc);
    27852804
     2805#if VBOX_WITH_OLD_VTX_CODE
    27862806        rc = SSMR3PutU32(pSSM, pVM->aCpus[i].hm.s.vmx.enmLastSeenGuestMode);
    27872807        AssertRCReturn(rc, rc);
     
    27902810        rc = SSMR3PutU32(pSSM, pVM->aCpus[i].hm.s.vmx.enmPrevGuestMode);
    27912811        AssertRCReturn(rc, rc);
     2812#else
     2813        //@todo: We only need to save pVM->aCpus[i].hm.s.vmx.fWasInRealMode and
     2814        // perhaps not even that (the initial value of 'true' is safe).
     2815        uint32_t u32Dummy = PGMMODE_REAL;
     2816        rc = SSMR3PutU32(pSSM, u32Dummy);
     2817        AssertRCReturn(rc, rc);
     2818        rc = SSMR3PutU32(pSSM, u32Dummy);
     2819        AssertRCReturn(rc, rc);
     2820        rc = SSMR3PutU32(pSSM, u32Dummy);
     2821        AssertRCReturn(rc, rc);
     2822#endif
    27922823    }
    27932824#ifdef VBOX_HM_WITH_GUEST_PATCHING
     
    28822913            uint32_t val;
    28832914
     2915#ifdef VBOX_WITH_OLD_VTX_CODE
    28842916            rc = SSMR3GetU32(pSSM, &val);
    28852917            AssertRCReturn(rc, rc);
     
    28932925            AssertRCReturn(rc, rc);
    28942926            pVM->aCpus[i].hm.s.vmx.enmPrevGuestMode = (PGMMODE)val;
     2927#else
     2928            //@todo: See note above re saving enmLastSeenGuestMode
     2929            rc = SSMR3GetU32(pSSM, &val);
     2930            AssertRCReturn(rc, rc);
     2931            rc = SSMR3GetU32(pSSM, &val);
     2932            AssertRCReturn(rc, rc);
     2933            rc = SSMR3GetU32(pSSM, &val);
     2934            AssertRCReturn(rc, rc);
     2935#endif
    28952936        }
    28962937    }
  • trunk/src/VBox/VMM/include/HMInternal.h

    r45737 r45781  
    688688        } lasterror;
    689689
     690#ifdef VBOX_WITH_OLD_VTX_CODE
    690691        /** The last seen guest paging mode (by VT-x). */
    691692        PGMMODE                     enmLastSeenGuestMode;
     
    694695        /** Previous guest paging mode (as seen by HMR3PagingModeChanged). */
    695696        PGMMODE                     enmPrevGuestMode;
     697#else
     698        /** Set if guest was executing in real mode (extra checks). */
     699        bool                        fWasInRealMode;
     700#endif
    696701    } vmx;
    697702
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