VirtualBox

Changeset 19015 in vbox for trunk/src/VBox/VMM/TRPM.cpp


Ignore:
Timestamp:
Apr 20, 2009 7:54:29 AM (16 years ago)
Author:
vboxsync
Message:

Split up TRPM. (guest SMP)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/TRPM.cpp

    r18927 r19015  
    431431
    432432/** TRPM saved state version. */
    433 #define TRPM_SAVED_STATE_VERSION    8
     433#define TRPM_SAVED_STATE_VERSION        9
     434#define TRPM_SAVED_STATE_VERSION_UNI    8   /* SMP support bumped the version */
    434435
    435436
     
    464465     */
    465466    pVM->trpm.s.offVM              = RT_OFFSETOF(VM, trpm);
    466     pVM->trpm.s.uActiveVector      = ~0;
     467    pVM->trpm.s.offTRPMCPU         = RT_OFFSETOF(VM, aCpus[0].trpm) - RT_OFFSETOF(VM, trpm);
     468
     469    for (unsigned i=0;i<pVM->cCPUs;i++)
     470    {
     471        PVMCPU pVCpu = &pVM->aCpus[i];
     472
     473        pVCpu->trpm.s.offVM         = RT_OFFSETOF(VM, aCpus[i].trpm);
     474        pVCpu->trpm.s.uActiveVector = ~0;
     475    }
     476
    467477    pVM->trpm.s.GuestIdtr.pIdt     = RTRCPTR_MAX;
    468478    pVM->trpm.s.pvMonShwIdtRC            = RTRCPTR_MAX;
     
    731741     * Reinitialize other members calling the relocator to get things right.
    732742     */
    733     pVM->trpm.s.uActiveVector  = ~0;
     743    for (unsigned i=0;i<pVM->cCPUs;i++)
     744    {
     745        PVMCPU pVCpu = &pVM->aCpus[i];
     746        pVCpu->trpm.s.uActiveVector = ~0;
     747    }
    734748    memcpy(&pVM->trpm.s.aIdt[0], &g_aIdt[0], sizeof(pVM->trpm.s.aIdt));
    735749    memset(pVM->trpm.s.aGuestTrapHandler, 0, sizeof(pVM->trpm.s.aGuestTrapHandler));
     
    752766static DECLCALLBACK(int) trpmR3Save(PVM pVM, PSSMHANDLE pSSM)
    753767{
     768    PTRPM pTrpm = &pVM->trpm.s;
    754769    LogFlow(("trpmR3Save:\n"));
    755770
     
    757772     * Active and saved traps.
    758773     */
    759     PTRPM pTrpm = &pVM->trpm.s;
    760     SSMR3PutUInt(pSSM,      pTrpm->uActiveVector);
    761     SSMR3PutUInt(pSSM,      pTrpm->enmActiveType);
    762     SSMR3PutGCUInt(pSSM,    pTrpm->uActiveErrorCode);
    763     SSMR3PutGCUIntPtr(pSSM, pTrpm->uActiveCR2);
    764     SSMR3PutGCUInt(pSSM,    pTrpm->uSavedVector);
    765     SSMR3PutUInt(pSSM,      pTrpm->enmSavedType);
    766     SSMR3PutGCUInt(pSSM,    pTrpm->uSavedErrorCode);
    767     SSMR3PutGCUIntPtr(pSSM, pTrpm->uSavedCR2);
    768     SSMR3PutGCUInt(pSSM,    pTrpm->uPrevVector);
    769 #if 0  /** @todo Enable this (+ load change) on the next version change. */
     774    for (unsigned i=0;i<pVM->cCPUs;i++)
     775    {
     776        PTRPMCPU pTrpmCpu = &pVM->aCpus[i].trpm.s;
     777
     778        SSMR3PutUInt(pSSM,      pTrpmCpu->uActiveVector);
     779        SSMR3PutUInt(pSSM,      pTrpmCpu->enmActiveType);
     780        SSMR3PutGCUInt(pSSM,    pTrpmCpu->uActiveErrorCode);
     781        SSMR3PutGCUIntPtr(pSSM, pTrpmCpu->uActiveCR2);
     782        SSMR3PutGCUInt(pSSM,    pTrpmCpu->uSavedVector);
     783        SSMR3PutUInt(pSSM,      pTrpmCpu->enmSavedType);
     784        SSMR3PutGCUInt(pSSM,    pTrpmCpu->uSavedErrorCode);
     785        SSMR3PutGCUIntPtr(pSSM, pTrpmCpu->uSavedCR2);
     786        SSMR3PutGCUInt(pSSM,    pTrpmCpu->uPrevVector);
     787    }
    770788    SSMR3PutBool(pSSM,      pTrpm->fDisableMonitoring);
    771 #else
    772     SSMR3PutGCUInt(pSSM,    pTrpm->fDisableMonitoring);
    773 #endif
    774789    SSMR3PutUInt(pSSM,      VM_FF_ISSET(pVM, VM_FF_TRPM_SYNC_IDT));
    775790    SSMR3PutMem(pSSM,       &pTrpm->au32IdtPatched[0], sizeof(pTrpm->au32IdtPatched));
     
    808823     * Validate version.
    809824     */
    810     if (u32Version != TRPM_SAVED_STATE_VERSION)
     825    if (    u32Version != TRPM_SAVED_STATE_VERSION
     826        &&  u32Version != TRPM_SAVED_STATE_VERSION_UNI)
    811827    {
    812828        AssertMsgFailed(("trpmR3Load: Invalid version u32Version=%d!\n", u32Version));
     
    823839     */
    824840    PTRPM pTrpm = &pVM->trpm.s;
    825     SSMR3GetUInt(pSSM,      &pTrpm->uActiveVector);
    826     SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpm->enmActiveType);
    827     SSMR3GetGCUInt(pSSM,    &pTrpm->uActiveErrorCode);
    828     SSMR3GetGCUIntPtr(pSSM, &pTrpm->uActiveCR2);
    829     SSMR3GetGCUInt(pSSM,    &pTrpm->uSavedVector);
    830     SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpm->enmSavedType);
    831     SSMR3GetGCUInt(pSSM,    &pTrpm->uSavedErrorCode);
    832     SSMR3GetGCUIntPtr(pSSM, &pTrpm->uSavedCR2);
    833     SSMR3GetGCUInt(pSSM,    &pTrpm->uPrevVector);
    834 #if 0 /** @todo Enable this + the corresponding save code on the next version change. */
    835     SSMR3GetBool(pSSM,      &pTrpm->fDisableMonitoring);
    836 #else
    837     RTGCUINT fDisableMonitoring;
    838     SSMR3GetGCUInt(pSSM,    &fDisableMonitoring);
    839     pTrpm->fDisableMonitoring = !!fDisableMonitoring;
    840 #endif
     841
     842    if (u32Version == TRPM_SAVED_STATE_VERSION)
     843    {
     844        for (unsigned i=0;i<pVM->cCPUs;i++)
     845        {
     846            PTRPMCPU pTrpmCpu = &pVM->aCpus[i].trpm.s;
     847            SSMR3GetUInt(pSSM,      &pTrpmCpu->uActiveVector);
     848            SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpmCpu->enmActiveType);
     849            SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uActiveErrorCode);
     850            SSMR3GetGCUIntPtr(pSSM, &pTrpmCpu->uActiveCR2);
     851            SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uSavedVector);
     852            SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpmCpu->enmSavedType);
     853            SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uSavedErrorCode);
     854            SSMR3GetGCUIntPtr(pSSM, &pTrpmCpu->uSavedCR2);
     855            SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uPrevVector);
     856        }
     857
     858        SSMR3GetBool(pSSM,      &pVM->trpm.s.fDisableMonitoring);
     859    }
     860    else
     861    {
     862        PTRPMCPU pTrpmCpu = &pVM->aCpus[0].trpm.s;
     863        SSMR3GetUInt(pSSM,      &pTrpmCpu->uActiveVector);
     864        SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpmCpu->enmActiveType);
     865        SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uActiveErrorCode);
     866        SSMR3GetGCUIntPtr(pSSM, &pTrpmCpu->uActiveCR2);
     867        SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uSavedVector);
     868        SSMR3GetUInt(pSSM,      (uint32_t *)&pTrpmCpu->enmSavedType);
     869        SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uSavedErrorCode);
     870        SSMR3GetGCUIntPtr(pSSM, &pTrpmCpu->uSavedCR2);
     871        SSMR3GetGCUInt(pSSM,    &pTrpmCpu->uPrevVector);
     872
     873        RTGCUINT fDisableMonitoring;
     874        SSMR3GetGCUInt(pSSM,    &fDisableMonitoring);
     875        pTrpm->fDisableMonitoring = !!fDisableMonitoring;
     876    }
    841877
    842878    RTUINT fSyncIDT;
     
    14171453            if (HWACCMR3IsActive(pVM))
    14181454            {
    1419                 rc = TRPMAssertTrap(pVM, u8Interrupt, enmEvent);
     1455                rc = TRPMAssertTrap(pVCpu, u8Interrupt, enmEvent);
    14201456                AssertRC(rc);
    14211457                STAM_COUNTER_INC(&pVM->trpm.s.paStatForwardedIRQR3[u8Interrupt]);
     
    14361472                {
    14371473                    /* There's a handler -> let's execute it in raw mode */
    1438                     rc = TRPMForwardTrap(pVM, CPUMCTX2CORE(pCtx), u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, enmEvent, -1);
     1474                    rc = TRPMForwardTrap(pVCpu, CPUMCTX2CORE(pCtx), u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, enmEvent, -1);
    14391475                    if (rc == VINF_SUCCESS /* Don't use RT_SUCCESS */)
    14401476                    {
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