VirtualBox

Changeset 20747 in vbox


Ignore:
Timestamp:
Jun 21, 2009 8:23:22 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
48863
Message:

REM: Don't drop handler reply records. More handler replay paranoia and massaging.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/REMInternal.h

    r20746 r20747  
    110110    uint32_t                    idxSelf;
    111111    uint32_t volatile           idxNext;
    112 } REMHANDLERNOTIFICATION, *PREMHANDLERNOTIFICATION;
     112} REMHANDLERNOTIFICATION;
     113/** Pointer to a handler notification record. */
     114typedef REMHANDLERNOTIFICATION *PREMHANDLERNOTIFICATION;
    113115
    114116/**
  • trunk/src/VBox/VMM/VMMAll/REMAll.cpp

    r20746 r20747  
    9393static void remNotifyHandlerInsert(PVM pVM, PREMHANDLERNOTIFICATION pRec)
    9494{
    95     uint32_t idxFree;
    96     uint32_t idxNext;
     95    /*
     96     * Fetch a free record.
     97     */
     98    uint32_t                cFlushes = 0;
     99    uint32_t                idxFree;
    97100    PREMHANDLERNOTIFICATION pFree;
    98 
    99     /* Fetch a free record. */
    100101    do
    101102    {
     
    103104        if (idxFree == (uint32_t)-1)
    104105        {
    105             pFree = NULL;
    106             break;
     106            do
     107            {
     108                Assert(cFlushes++ != 128);
     109                AssertFatal(cFlushes < _1M);
     110                remFlushHandlerNotifications(pVM);
     111                idxFree = ASMAtomicUoReadU32(&pVM->rem.s.idxFreeList);
     112            } while (idxFree == (uint32_t)-1);
    107113        }
    108114        pFree = &pVM->rem.s.aHandlerNotifications[idxFree];
    109115    } while (!ASMAtomicCmpXchgU32(&pVM->rem.s.idxFreeList, pFree->idxNext, idxFree));
    110116
    111     if (!pFree)
    112     {
    113         remFlushHandlerNotifications(pVM);
    114         /** @todo why are we dropping the pReq here without a fight? If we can drop
    115          *        one, we can drop all... */
    116         return;
    117     }
    118 
    119     /* Copy the record. */
    120     *pFree = *pRec;
    121     pFree->idxSelf = idxFree; /* was trashed */
    122 
    123     /* Insert it into the pending list. */
     117    /*
     118     * Copy the record.
     119     */
     120    pFree->enmKind = pRec->enmKind;
     121    pFree->u = pRec->u;
     122
     123    /*
     124     * Insert it into the pending list.
     125     */
     126    uint32_t idxNext;
    124127    do
    125128    {
  • trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp

    r20689 r20747  
    739739    GEN_CHECK_OFF(REM, Env);
    740740
     741    GEN_CHECK_SIZE(REMHANDLERNOTIFICATION);
     742    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, enmKind);
     743    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u);
     744    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalRegister.GCPhys);
     745    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalRegister.cb);
     746    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalRegister.enmType);
     747    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalRegister.fHasHCHandler);
     748    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalDeregister.GCPhys);
     749    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalDeregister.cb);
     750    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalDeregister.enmType);
     751    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalDeregister.fHasHCHandler);
     752    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalDeregister.fRestoreAsRAM);
     753    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalModify.GCPhysOld);
     754    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalModify.GCPhysNew);
     755    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalModify.cb);
     756    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalModify.enmType);
     757    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalModify.fHasHCHandler);
     758    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, u.PhysicalModify.fRestoreAsRAM);
     759    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, idxSelf);
     760    GEN_CHECK_OFF(REMHANDLERNOTIFICATION, idxNext);
     761
    741762    GEN_CHECK_SIZE(SELM);
    742763    GEN_CHECK_OFF(SELM, offVM);
  • trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp

    r20530 r20747  
    278278    CHECK_MEMBER_ALIGNMENT(PGMMMIO2RANGE, RamRange, 16);
    279279
    280     /* misc */
     280    /* rem */
    281281    CHECK_MEMBER_ALIGNMENT(REM, aGCPtrInvalidatedPages, 8);
    282     CHECK_PADDING3(EMCPU, u.FatalLongJump, u.achPaddingFatalLongJump);
    283282    CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalRegister, u.padding);
    284283    CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalDeregister, u.padding);
    285284    CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalModify, u.padding);
     285    CHECK_SIZE_ALIGNMENT(REMHANDLERNOTIFICATION, 8);
     286    CHECK_MEMBER_ALIGNMENT(REMHANDLERNOTIFICATION, u.PhysicalDeregister.GCPhys, 8);
     287
     288    /* misc */
     289    CHECK_PADDING3(EMCPU, u.FatalLongJump, u.achPaddingFatalLongJump);
    286290    CHECK_SIZE_ALIGNMENT(VMMR0JMPBUF, 8);
    287291    CHECK_SIZE_ALIGNMENT(PATCHINFO, 8);
  • trunk/src/recompiler/VBoxRecompiler.c

    r20746 r20747  
    27282728    if (VM_FF_TESTANDCLEAR(pVM, VM_FF_REM_HANDLER_NOTIFY_BIT))
    27292729    {
     2730        PREMHANDLERNOTIFICATION pReqsRev;
     2731        PREMHANDLERNOTIFICATION pReqs;
     2732        uint32_t                idxNext;
     2733        uint32_t                idxReqs;
     2734
    27302735        /* Lockless purging of pending notifications. */
    2731         uint32_t idxReqs = ASMAtomicXchgU32(&pVM->rem.s.idxPendingList, -1);
    2732         if (idxReqs == -1)
     2736        idxReqs = ASMAtomicXchgU32(&pVM->rem.s.idxPendingList, UINT32_MAX);
     2737        if (idxReqs == UINT32_MAX)
    27332738            return;
    2734 
    27352739        Assert(idxReqs < RT_ELEMENTS(pVM->rem.s.aHandlerNotifications));
    2736         PREMHANDLERNOTIFICATION pReqs = &pVM->rem.s.aHandlerNotifications[idxReqs];
    27372740
    27382741        /*
    27392742         * Reverse the list to process it in FIFO order.
    27402743         */
    2741         PREMHANDLERNOTIFICATION pReq = pReqs;
    2742         pReqs = NULL;
    2743         while (pReq)
     2744        pReqsRev = &pVM->rem.s.aHandlerNotifications[idxReqs];
     2745        pReqs    = NULL;
     2746        while (pReqsRev)
    27442747        {
    2745             PREMHANDLERNOTIFICATION pCur = pReq;
    2746 
    2747             if (pReq->idxNext != -1)
     2748            PREMHANDLERNOTIFICATION pCur = pReqsRev;
     2749            idxNext = pReqsRev->idxNext;
     2750            if (idxNext != UINT32_MAX)
    27482751            {
    2749                 Assert(pReq->idxNext < RT_ELEMENTS(pVM->rem.s.aHandlerNotifications));
    2750                 pReq = &pVM->rem.s.aHandlerNotifications[pReq->idxNext];
     2752                Assert(idxNext < RT_ELEMENTS(pVM->rem.s.aHandlerNotifications));
     2753                pReqsRev = &pVM->rem.s.aHandlerNotifications[idxNext];
    27512754            }
    27522755            else
    2753                 pReq = NULL;
    2754 
    2755             pCur->idxNext = (pReqs) ? pReqs->idxSelf : -1;
     2756                pReqsRev = NULL;
     2757            pCur->idxNext = idxNext;
    27562758            pReqs = pCur;
    27572759        }
    27582760
     2761        /*
     2762         * Loop thru the list, reinserting the record into the free list as they are
     2763         * processed to avoid having other EMTs running out of entries while we're flushing.
     2764         */
    27592765        while (pReqs)
    27602766        {
    2761             PREMHANDLERNOTIFICATION pRec = pReqs;
    2762 
    2763             switch (pRec->enmKind)
     2767            PREMHANDLERNOTIFICATION pCur = pReqs;
     2768
     2769            switch (pCur->enmKind)
    27642770            {
    27652771                case REMHANDLERNOTIFICATIONKIND_PHYSICAL_REGISTER:
    27662772                    remR3NotifyHandlerPhysicalRegister(pVM,
    2767                                                        pRec->u.PhysicalRegister.enmType,
    2768                                                        pRec->u.PhysicalRegister.GCPhys,
    2769                                                        pRec->u.PhysicalRegister.cb,
    2770                                                        pRec->u.PhysicalRegister.fHasHCHandler);
     2773                                                       pCur->u.PhysicalRegister.enmType,
     2774                                                       pCur->u.PhysicalRegister.GCPhys,
     2775                                                       pCur->u.PhysicalRegister.cb,
     2776                                                       pCur->u.PhysicalRegister.fHasHCHandler);
    27712777                    break;
    27722778
    27732779                case REMHANDLERNOTIFICATIONKIND_PHYSICAL_DEREGISTER:
    27742780                    remR3NotifyHandlerPhysicalDeregister(pVM,
    2775                                                          pRec->u.PhysicalDeregister.enmType,
    2776                                                          pRec->u.PhysicalDeregister.GCPhys,
    2777                                                          pRec->u.PhysicalDeregister.cb,
    2778                                                          pRec->u.PhysicalDeregister.fHasHCHandler,
    2779                                                          pRec->u.PhysicalDeregister.fRestoreAsRAM);
     2781                                                         pCur->u.PhysicalDeregister.enmType,
     2782                                                         pCur->u.PhysicalDeregister.GCPhys,
     2783                                                         pCur->u.PhysicalDeregister.cb,
     2784                                                         pCur->u.PhysicalDeregister.fHasHCHandler,
     2785                                                         pCur->u.PhysicalDeregister.fRestoreAsRAM);
    27802786                    break;
    27812787
    27822788                case REMHANDLERNOTIFICATIONKIND_PHYSICAL_MODIFY:
    27832789                    remR3NotifyHandlerPhysicalModify(pVM,
    2784                                                      pRec->u.PhysicalModify.enmType,
    2785                                                      pRec->u.PhysicalModify.GCPhysOld,
    2786                                                      pRec->u.PhysicalModify.GCPhysNew,
    2787                                                      pRec->u.PhysicalModify.cb,
    2788                                                      pRec->u.PhysicalModify.fHasHCHandler,
    2789                                                      pRec->u.PhysicalModify.fRestoreAsRAM);
     2790                                                     pCur->u.PhysicalModify.enmType,
     2791                                                     pCur->u.PhysicalModify.GCPhysOld,
     2792                                                     pCur->u.PhysicalModify.GCPhysNew,
     2793                                                     pCur->u.PhysicalModify.cb,
     2794                                                     pCur->u.PhysicalModify.fHasHCHandler,
     2795                                                     pCur->u.PhysicalModify.fRestoreAsRAM);
    27902796                    break;
    27912797
    27922798                default:
    2793                     AssertReleaseMsgFailed(("enmKind=%d\n", pRec->enmKind));
     2799                    AssertReleaseMsgFailed(("enmKind=%d\n", pCur->enmKind));
    27942800                    break;
    27952801            }
    2796             if (pReqs->idxNext != -1)
     2802
     2803            /*
     2804             * Advance pReqs.
     2805             */
     2806            idxNext = pCur->idxNext;
     2807            if (idxNext != UINT32_MAX)
    27972808            {
    2798                 AssertMsg(pReqs->idxNext < RT_ELEMENTS(pVM->rem.s.aHandlerNotifications), ("pReqs->idxNext=%d\n", pReqs->idxNext));
    2799                 pReqs = &pVM->rem.s.aHandlerNotifications[pReqs->idxNext];
     2809                AssertMsg(idxNext < RT_ELEMENTS(pVM->rem.s.aHandlerNotifications), ("idxNext=%d\n", idxNext));
     2810                pReqs = &pVM->rem.s.aHandlerNotifications[idxNext];
    28002811            }
    28012812            else
    28022813                pReqs = NULL;
    28032814
    2804             /* Put the record back into the free list */
    2805             uint32_t idxNext;
    2806 
     2815            /*
     2816             * Put the record back into the free list.
     2817             */
    28072818            do
    28082819            {
    28092820                idxNext = ASMAtomicUoReadU32(&pVM->rem.s.idxFreeList);
    2810                 ASMAtomicWriteU32(&pRec->idxNext, idxNext);
     2821                ASMAtomicWriteU32(&pCur->idxNext, idxNext);
    28112822                ASMCompilerBarrier();
    2812             } while (!ASMAtomicCmpXchgU32(&pVM->rem.s.idxFreeList, pRec->idxSelf, idxNext));
     2823            } while (!ASMAtomicCmpXchgU32(&pVM->rem.s.idxFreeList, pCur->idxSelf, idxNext));
    28132824        }
    28142825    }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette