VirtualBox

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


Ignore:
Timestamp:
Jun 9, 2009 9:34:53 AM (16 years ago)
Author:
vboxsync
Message:

Rewrote rem notification handling.

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

Legend:

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

    r19660 r20421  
    107107        uint64_t                padding[5];
    108108    } u;
     109    uint32_t                    idxSelf;
     110    uint32_t                    idxNext;
    109111} REMHANDLERNOTIFICATION, *PREMHANDLERNOTIFICATION;
    110112
     
    166168     * These instructions are replayed when entering REM. */
    167169    RTGCPTR                 aGCPtrInvalidatedPages[48];
    168     /** The number of recorded handler notifications. */
    169     RTUINT volatile         cHandlerNotifications;
    170     RTUINT                  padding0; /**< Padding. */
     170
    171171    /** Array of recorded handler noticications.
    172172     * These are replayed when entering REM. */
    173173    REMHANDLERNOTIFICATION  aHandlerNotifications[32];
     174    volatile uint32_t       idxPendingList;
     175    volatile uint32_t       idxFreeList;
    174176
    175177    /** MMIO memory type.
     
    211213    uint32_t                abPadding[HC_ARCH_BITS == 32 ? 6 : 4];
    212214
    213 #if GC_ARCH_BITS == 32
    214 # define REM_ENV_SIZE        (HC_ARCH_BITS == 32 ? 0xff00 : 0xff00)
    215 #else
    216 # define REM_ENV_SIZE        (HC_ARCH_BITS == 32 ? 0xff00 : 0xff00)
    217 #endif
     215# define REM_ENV_SIZE       0xff00
    218216
    219217    /** Recompiler CPU state. */
  • trunk/src/VBox/VMM/VMMAll/REMAll.cpp

    r20410 r20421  
    8282    AssertReleaseMsgFailed(("Ring 3 call????.\n"));
    8383#endif
    84     Assert(pVM->rem.s.cHandlerNotifications == 0);
    85 }
    86 
     84}
     85
     86
     87/**
     88 * Insert pending notification
     89 *
     90 * @param   pVM             VM Handle.
     91 * @param   pRec            Notification record to insert
     92 */
     93static void remNotifyHandlerInsert(PVM pVM, PREMHANDLERNOTIFICATION pRec)
     94{
     95    uint32_t idxFree;
     96    uint32_t idxNext;
     97    PREMHANDLERNOTIFICATION pFree;
     98
     99    /* Fetch a free record. */
     100    do
     101    {
     102        idxFree = pVM->rem.s.idxFreeList;
     103        if (idxFree == -1)
     104        {
     105            pFree = NULL;
     106            break;
     107        }
     108        pFree = &pVM->rem.s.aHandlerNotifications[idxFree]; 
     109    } while (!ASMAtomicCmpXchgU32(&pVM->rem.s.idxFreeList, pFree->idxNext, idxFree));
     110
     111    if (!pFree)
     112    {
     113        remFlushHandlerNotifications(pVM);
     114        return;
     115    }
     116
     117    /* Copy the record. */
     118    *pFree = *pRec;
     119    pFree->idxSelf = idxFree; /* was trashed */
     120
     121    /* Insert it into the pending list. */
     122    do
     123    {
     124        idxNext = pVM->rem.s.idxPendingList;
     125        pFree->idxNext = idxNext;
     126    } while (!ASMAtomicCmpXchgU32(&pVM->rem.s.idxPendingList, idxFree, idxNext));
     127
     128    VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
     129}
    87130
    88131/**
     
    97140VMMDECL(void) REMNotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler)
    98141{
    99     if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
    100         remFlushHandlerNotifications(pVM);
    101     PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
    102     pRec->enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_REGISTER;
    103     pRec->u.PhysicalRegister.enmType = enmType;
    104     pRec->u.PhysicalRegister.GCPhys = GCPhys;
    105     pRec->u.PhysicalRegister.cb = cb;
    106     pRec->u.PhysicalRegister.fHasHCHandler = fHasHCHandler;
    107     VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
     142    REMHANDLERNOTIFICATION Rec;
     143    Rec.enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_REGISTER;
     144    Rec.u.PhysicalRegister.enmType = enmType;
     145    Rec.u.PhysicalRegister.GCPhys = GCPhys;
     146    Rec.u.PhysicalRegister.cb = cb;
     147    Rec.u.PhysicalRegister.fHasHCHandler = fHasHCHandler;
     148    remNotifyHandlerInsert(pVM, &Rec);
    108149}
    109150
     
    121162VMMDECL(void) REMNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
    122163{
    123     if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
    124         remFlushHandlerNotifications(pVM);
    125     PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
    126     pRec->enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_DEREGISTER;
    127     pRec->u.PhysicalDeregister.enmType = enmType;
    128     pRec->u.PhysicalDeregister.GCPhys = GCPhys;
    129     pRec->u.PhysicalDeregister.cb = cb;
    130     pRec->u.PhysicalDeregister.fHasHCHandler = fHasHCHandler;
    131     pRec->u.PhysicalDeregister.fRestoreAsRAM = fRestoreAsRAM;
    132     VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
     164    REMHANDLERNOTIFICATION Rec;
     165    Rec.enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_DEREGISTER;
     166    Rec.u.PhysicalDeregister.enmType = enmType;
     167    Rec.u.PhysicalDeregister.GCPhys = GCPhys;
     168    Rec.u.PhysicalDeregister.cb = cb;
     169    Rec.u.PhysicalDeregister.fHasHCHandler = fHasHCHandler;
     170    Rec.u.PhysicalDeregister.fRestoreAsRAM = fRestoreAsRAM;
     171    remNotifyHandlerInsert(pVM, &Rec);
    133172}
    134173
     
    147186VMMDECL(void) REMNotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
    148187{
    149     if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
    150         remFlushHandlerNotifications(pVM);
    151     PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
    152     pRec->enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_MODIFY;
    153     pRec->u.PhysicalModify.enmType = enmType;
    154     pRec->u.PhysicalModify.GCPhysOld = GCPhysOld;
    155     pRec->u.PhysicalModify.GCPhysNew = GCPhysNew;
    156     pRec->u.PhysicalModify.cb = cb;
    157     pRec->u.PhysicalModify.fHasHCHandler = fHasHCHandler;
    158     pRec->u.PhysicalModify.fRestoreAsRAM = fRestoreAsRAM;
    159     VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
     188    REMHANDLERNOTIFICATION Rec;
     189    Rec.enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_MODIFY;
     190    Rec.u.PhysicalModify.enmType = enmType;
     191    Rec.u.PhysicalModify.GCPhysOld = GCPhysOld;
     192    Rec.u.PhysicalModify.GCPhysNew = GCPhysNew;
     193    Rec.u.PhysicalModify.cb = cb;
     194    Rec.u.PhysicalModify.fHasHCHandler = fHasHCHandler;
     195    Rec.u.PhysicalModify.fRestoreAsRAM = fRestoreAsRAM;
     196    remNotifyHandlerInsert(pVM, &Rec);
    160197}
    161198
  • trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp

    r20151 r20421  
    725725    GEN_CHECK_OFF(REM, cCanExecuteRaw);
    726726    GEN_CHECK_OFF(REM, aGCPtrInvalidatedPages);
    727     GEN_CHECK_OFF(REM, cHandlerNotifications);
     727    GEN_CHECK_OFF(REM, idxPendingList);
    728728    GEN_CHECK_OFF(REM, aHandlerNotifications);
     729    GEN_CHECK_OFF(REM, idxFreeList);
    729730    GEN_CHECK_OFF(REM, rc);
    730731    GEN_CHECK_OFF(REM, StatsInQEMU);
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