Changeset 20747 in vbox
- Timestamp:
- Jun 21, 2009 8:23:22 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 48863
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/REMInternal.h
r20746 r20747 110 110 uint32_t idxSelf; 111 111 uint32_t volatile idxNext; 112 } REMHANDLERNOTIFICATION, *PREMHANDLERNOTIFICATION; 112 } REMHANDLERNOTIFICATION; 113 /** Pointer to a handler notification record. */ 114 typedef REMHANDLERNOTIFICATION *PREMHANDLERNOTIFICATION; 113 115 114 116 /** -
trunk/src/VBox/VMM/VMMAll/REMAll.cpp
r20746 r20747 93 93 static void remNotifyHandlerInsert(PVM pVM, PREMHANDLERNOTIFICATION pRec) 94 94 { 95 uint32_t idxFree; 96 uint32_t idxNext; 95 /* 96 * Fetch a free record. 97 */ 98 uint32_t cFlushes = 0; 99 uint32_t idxFree; 97 100 PREMHANDLERNOTIFICATION pFree; 98 99 /* Fetch a free record. */100 101 do 101 102 { … … 103 104 if (idxFree == (uint32_t)-1) 104 105 { 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); 107 113 } 108 114 pFree = &pVM->rem.s.aHandlerNotifications[idxFree]; 109 115 } while (!ASMAtomicCmpXchgU32(&pVM->rem.s.idxFreeList, pFree->idxNext, idxFree)); 110 116 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; 124 127 do 125 128 { -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r20689 r20747 739 739 GEN_CHECK_OFF(REM, Env); 740 740 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 741 762 GEN_CHECK_SIZE(SELM); 742 763 GEN_CHECK_OFF(SELM, offVM); -
trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
r20530 r20747 278 278 CHECK_MEMBER_ALIGNMENT(PGMMMIO2RANGE, RamRange, 16); 279 279 280 /* misc*/280 /* rem */ 281 281 CHECK_MEMBER_ALIGNMENT(REM, aGCPtrInvalidatedPages, 8); 282 CHECK_PADDING3(EMCPU, u.FatalLongJump, u.achPaddingFatalLongJump);283 282 CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalRegister, u.padding); 284 283 CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalDeregister, u.padding); 285 284 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); 286 290 CHECK_SIZE_ALIGNMENT(VMMR0JMPBUF, 8); 287 291 CHECK_SIZE_ALIGNMENT(PATCHINFO, 8); -
trunk/src/recompiler/VBoxRecompiler.c
r20746 r20747 2728 2728 if (VM_FF_TESTANDCLEAR(pVM, VM_FF_REM_HANDLER_NOTIFY_BIT)) 2729 2729 { 2730 PREMHANDLERNOTIFICATION pReqsRev; 2731 PREMHANDLERNOTIFICATION pReqs; 2732 uint32_t idxNext; 2733 uint32_t idxReqs; 2734 2730 2735 /* 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) 2733 2738 return; 2734 2735 2739 Assert(idxReqs < RT_ELEMENTS(pVM->rem.s.aHandlerNotifications)); 2736 PREMHANDLERNOTIFICATION pReqs = &pVM->rem.s.aHandlerNotifications[idxReqs];2737 2740 2738 2741 /* 2739 2742 * Reverse the list to process it in FIFO order. 2740 2743 */ 2741 PREMHANDLERNOTIFICATION pReq = pReqs;2742 pReqs = NULL;2743 while (pReq )2744 pReqsRev = &pVM->rem.s.aHandlerNotifications[idxReqs]; 2745 pReqs = NULL; 2746 while (pReqsRev) 2744 2747 { 2745 PREMHANDLERNOTIFICATION pCur = pReq ;2746 2747 if ( pReq->idxNext != -1)2748 PREMHANDLERNOTIFICATION pCur = pReqsRev; 2749 idxNext = pReqsRev->idxNext; 2750 if (idxNext != UINT32_MAX) 2748 2751 { 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]; 2751 2754 } 2752 2755 else 2753 pReq = NULL; 2754 2755 pCur->idxNext = (pReqs) ? pReqs->idxSelf : -1; 2756 pReqsRev = NULL; 2757 pCur->idxNext = idxNext; 2756 2758 pReqs = pCur; 2757 2759 } 2758 2760 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 */ 2759 2765 while (pReqs) 2760 2766 { 2761 PREMHANDLERNOTIFICATION p Rec= pReqs;2762 2763 switch (p Rec->enmKind)2767 PREMHANDLERNOTIFICATION pCur = pReqs; 2768 2769 switch (pCur->enmKind) 2764 2770 { 2765 2771 case REMHANDLERNOTIFICATIONKIND_PHYSICAL_REGISTER: 2766 2772 remR3NotifyHandlerPhysicalRegister(pVM, 2767 p Rec->u.PhysicalRegister.enmType,2768 p Rec->u.PhysicalRegister.GCPhys,2769 p Rec->u.PhysicalRegister.cb,2770 p Rec->u.PhysicalRegister.fHasHCHandler);2773 pCur->u.PhysicalRegister.enmType, 2774 pCur->u.PhysicalRegister.GCPhys, 2775 pCur->u.PhysicalRegister.cb, 2776 pCur->u.PhysicalRegister.fHasHCHandler); 2771 2777 break; 2772 2778 2773 2779 case REMHANDLERNOTIFICATIONKIND_PHYSICAL_DEREGISTER: 2774 2780 remR3NotifyHandlerPhysicalDeregister(pVM, 2775 p Rec->u.PhysicalDeregister.enmType,2776 p Rec->u.PhysicalDeregister.GCPhys,2777 p Rec->u.PhysicalDeregister.cb,2778 p Rec->u.PhysicalDeregister.fHasHCHandler,2779 p Rec->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); 2780 2786 break; 2781 2787 2782 2788 case REMHANDLERNOTIFICATIONKIND_PHYSICAL_MODIFY: 2783 2789 remR3NotifyHandlerPhysicalModify(pVM, 2784 p Rec->u.PhysicalModify.enmType,2785 p Rec->u.PhysicalModify.GCPhysOld,2786 p Rec->u.PhysicalModify.GCPhysNew,2787 p Rec->u.PhysicalModify.cb,2788 p Rec->u.PhysicalModify.fHasHCHandler,2789 p Rec->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); 2790 2796 break; 2791 2797 2792 2798 default: 2793 AssertReleaseMsgFailed(("enmKind=%d\n", p Rec->enmKind));2799 AssertReleaseMsgFailed(("enmKind=%d\n", pCur->enmKind)); 2794 2800 break; 2795 2801 } 2796 if (pReqs->idxNext != -1) 2802 2803 /* 2804 * Advance pReqs. 2805 */ 2806 idxNext = pCur->idxNext; 2807 if (idxNext != UINT32_MAX) 2797 2808 { 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]; 2800 2811 } 2801 2812 else 2802 2813 pReqs = NULL; 2803 2814 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 */ 2807 2818 do 2808 2819 { 2809 2820 idxNext = ASMAtomicUoReadU32(&pVM->rem.s.idxFreeList); 2810 ASMAtomicWriteU32(&p Rec->idxNext, idxNext);2821 ASMAtomicWriteU32(&pCur->idxNext, idxNext); 2811 2822 ASMCompilerBarrier(); 2812 } while (!ASMAtomicCmpXchgU32(&pVM->rem.s.idxFreeList, p Rec->idxSelf, idxNext));2823 } while (!ASMAtomicCmpXchgU32(&pVM->rem.s.idxFreeList, pCur->idxSelf, idxNext)); 2813 2824 } 2814 2825 }
Note:
See TracChangeset
for help on using the changeset viewer.