VirtualBox

Changeset 74790 in vbox for trunk


Ignore:
Timestamp:
Oct 12, 2018 10:42:58 AM (6 years ago)
Author:
vboxsync
Message:

vm.h,VMM: Use VM_FF_IS_SET instead of VM_FF_IS_PENDING when checking a single flag. Added compile time assertion on single flag. bugref:9180

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/vm.h

    r74789 r74790  
    692692
    693693/** @def VM_FF_IS_SET
    694  * Checks if a force action flag is set.
     694 * Checks if single a force action flag is set.
    695695 *
    696696 * @param   pVM     The cross context VM structure.
    697697 * @param   fFlag   The flag to check.
    698  */
    699 #define VM_FF_IS_SET(pVM, fFlag)            (((pVM)->fGlobalForcedActions & (fFlag)) == (fFlag))
    700 
     698 * @sa      VM_FF_IS_ANY_SET
     699 */
     700#if !defined(VBOX_STRICT) || !defined(RT_COMPILER_SUPPORTS_LAMBDA)
     701# define VM_FF_IS_SET(pVM, fFlag)           (((pVM)->fGlobalForcedActions & (fFlag)) == (fFlag))
     702#else
     703# define VM_FF_IS_SET(pVM, fFlag) \
     704    ([](PVM a_pVM) -> bool \
     705    { \
     706        AssertCompile(RT_IS_POWER_OF_TWO(fFlag)); \
     707        return (a_pVM->fGlobalForcedActions & (fFlag)) == (fFlag); \
     708    }(pVM))
     709#endif
    701710
    702711/** @def VMCPU_FF_IS_SET
    703  * Checks if a force action flag is set for the given VCPU.
     712 * Checks if a single force action flag is set for the given VCPU.
    704713 *
    705714 * @param   pVCpu   The cross context virtual CPU structure.
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r73324 r74790  
    10801080                    return rc;
    10811081                }
    1082                 if (RT_UNLIKELY(VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY)))
     1082                if (RT_UNLIKELY(VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY)))
    10831083                    return VINF_EM_NO_MEMORY;
    10841084            }
     
    21622162                    if (    cPages > 1
    21632163                        &&  !(uErr & X86_TRAP_PF_P)
    2164                         &&  !VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     2164                        &&  !VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    21652165                    {
    21662166                        /*
     
    24342434    if (    cPages > 1
    24352435        &&  !(uErr & X86_TRAP_PF_P)
    2436         &&  !VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     2436        &&  !VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    24372437    {
    24382438        /*
     
    24622462                      SHW_PTE_IS_TRACK_DIRTY(pPTDst->a[iPTDst]) ? " Track-Dirty" : ""));
    24632463
    2464                 if (RT_UNLIKELY(VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY)))
     2464                if (RT_UNLIKELY(VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY)))
    24652465                    break;
    24662466            }
     
    31163116            unsigned        iPTDst = 0;
    31173117            while (     iPTDst < RT_ELEMENTS(pPTDst->a)
    3118                    &&   !VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     3118                   &&   !VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    31193119            {
    31203120                if (pRam && GCPhys >= pRam->GCPhys)
     
    31513151                            rc = pgmPhysPageMakeWritable(pVM, pPage, GCPhys);
    31523152                            AssertRCReturn(rc, rc);
    3153                             if (VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     3153                            if (VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    31543154                                break;
    31553155                        }
     
    34263426                  SHW_PTE_IS_TRACK_DIRTY(pPTDst->a[iPTDst]) ? " Track-Dirty" : ""));
    34273427
    3428             if (RT_UNLIKELY(VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY)))
     3428            if (RT_UNLIKELY(VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY)))
    34293429                break;
    34303430        }
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r74789 r74790  
    42434243        {
    42444244            STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchHmToR3FF);
    4245             int rc = RT_UNLIKELY(VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY)) ? VINF_EM_NO_MEMORY : VINF_EM_RAW_TO_R3;
     4245            int rc = RT_LIKELY(!VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY)) ? VINF_EM_RAW_TO_R3 : VINF_EM_NO_MEMORY;
    42464246            Log4Func(("HM_TO_R3 forcing us back to ring-3. rc=%d\n", rc));
    42474247            return rc;
     
    42574257
    42584258        /* Pending PGM pool flushes. */
    4259         if (VM_FF_IS_PENDING(pVM, VM_FF_PGM_POOL_FLUSH_PENDING))
     4259        if (VM_FF_IS_SET(pVM, VM_FF_PGM_POOL_FLUSH_PENDING))
    42604260        {
    42614261            Log4Func(("PGM pool flush pending forcing us back to ring-3\n"));
     
    42644264
    42654265        /* Pending DMA requests. */
    4266         if (VM_FF_IS_PENDING(pVM, VM_FF_PDM_DMA))
     4266        if (VM_FF_IS_SET(pVM, VM_FF_PDM_DMA))
    42674267        {
    42684268            Log4Func(("Pending DMA request forcing us back to ring-3\n"));
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r74789 r74790  
    69266926    {
    69276927        STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchHmToR3FF);
    6928         int rc2 = RT_UNLIKELY(VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY)) ? VINF_EM_NO_MEMORY : VINF_EM_RAW_TO_R3;
     6928        int rc2 = RT_LIKELY(!VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY)) ? VINF_EM_RAW_TO_R3 : VINF_EM_NO_MEMORY;
    69296929        Log4Func(("HM_TO_R3 forcing us back to ring-3. rc=%d\n", rc2));
    69306930        return rc2;
     
    69326932
    69336933    /* Pending VM request packets, such as hardware interrupts. */
    6934     if (   VM_FF_IS_PENDING(pVM, VM_FF_REQUEST)
     6934    if (   VM_FF_IS_SET(pVM, VM_FF_REQUEST)
    69356935        || VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_REQUEST))
    69366936    {
     
    69406940
    69416941    /* Pending PGM pool flushes. */
    6942     if (VM_FF_IS_PENDING(pVM, VM_FF_PGM_POOL_FLUSH_PENDING))
     6942    if (VM_FF_IS_SET(pVM, VM_FF_PGM_POOL_FLUSH_PENDING))
    69436943    {
    69446944        Log4Func(("PGM pool flush pending forcing us back to ring-3\n"));
     
    69476947
    69486948    /* Pending DMA requests. */
    6949     if (VM_FF_IS_PENDING(pVM, VM_FF_PDM_DMA))
     6949    if (VM_FF_IS_SET(pVM, VM_FF_PDM_DMA))
    69506950    {
    69516951        Log4Func(("Pending DMA request forcing us back to ring-3\n"));
  • trunk/src/VBox/VMM/VMMR3/DBGF.cpp

    r74785 r74790  
    298298                       first.  The request processing is a bit crazy, but
    299299                       unfortunately required by plugin unloading. */
    300                     if (   VM_FF_IS_PENDING(pVM, VM_FF_REQUEST)
     300                    if (   VM_FF_IS_SET(pVM, VM_FF_REQUEST)
    301301                        || VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_REQUEST))
    302302                    {
     
    309309                    }
    310310                    /* Need to handle rendezvous too, for generic debug event management. */
    311                     else if (VM_FF_IS_PENDING(pVM, VM_FF_EMT_RENDEZVOUS))
     311                    else if (VM_FF_IS_SET(pVM, VM_FF_EMT_RENDEZVOUS))
    312312                    {
    313313                        rc = VMMR3EmtRendezvousFF(pVM, pVCpu);
     
    391391
    392392        /* Process priority stuff. */
    393         if (   VM_FF_IS_PENDING(pVM, VM_FF_REQUEST)
     393        if (   VM_FF_IS_SET(pVM, VM_FF_REQUEST)
    394394            || VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_REQUEST))
    395395        {
     
    847847            }
    848848
    849             if (VM_FF_IS_PENDING(pVM, VM_FF_EMT_RENDEZVOUS))
     849            if (VM_FF_IS_SET(pVM, VM_FF_EMT_RENDEZVOUS))
    850850            {
    851851                rc = VMMR3EmtRendezvousFF(pVM, pVCpu);
    852852                cPollHack = 1;
    853853            }
    854             else if (   VM_FF_IS_PENDING(pVM, VM_FF_REQUEST)
     854            else if (   VM_FF_IS_SET(pVM, VM_FF_REQUEST)
    855855                     || VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_REQUEST))
    856856            {
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r74789 r74790  
    17001700#endif
    17011701
    1702     if (VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     1702    if (VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    17031703    {
    17041704        if (    rc > VINF_EM_NO_MEMORY
     
    18691869         * EMT Rendezvous (must be serviced before termination).
    18701870         */
    1871         if (VM_FF_IS_PENDING(pVM, VM_FF_EMT_RENDEZVOUS))
     1871        if (VM_FF_IS_SET(pVM, VM_FF_EMT_RENDEZVOUS))
    18721872        {
    18731873            CPUM_IMPORT_EXTRN_RCSTRICT(pVCpu, ~CPUMCTX_EXTRN_KEEPER_MASK, rc);
     
    18901890         * State change request (cleared by vmR3SetStateLocked).
    18911891         */
    1892         if (VM_FF_IS_PENDING(pVM, VM_FF_CHECK_VM_STATE))
     1892        if (VM_FF_IS_SET(pVM, VM_FF_CHECK_VM_STATE))
    18931893        {
    18941894            VMSTATE enmState = VMR3GetState(pVM);
     
    19521952         * Out of memory? Putting this after CSAM as it may in theory cause us to run out of memory.
    19531953         */
    1954         if (VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     1954        if (VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    19551955        {
    19561956            rc2 = PGMR3PhysAllocateHandyPages(pVM);
     
    19861986         * EMT Rendezvous (make sure they are handled before the requests).
    19871987         */
    1988         if (VM_FF_IS_PENDING(pVM, VM_FF_EMT_RENDEZVOUS))
     1988        if (VM_FF_IS_SET(pVM, VM_FF_EMT_RENDEZVOUS))
    19891989        {
    19901990            CPUM_IMPORT_EXTRN_RCSTRICT(pVCpu, ~CPUMCTX_EXTRN_KEEPER_MASK, rc);
     
    21002100         * Timers before interrupts.
    21012101         */
    2102         if (    VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_TIMER)
    2103             &&  !VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     2102        if (   VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_TIMER)
     2103            && !VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    21042104            TMR3TimerQueuesDo(pVM);
    21052105
     
    21222122         *       you might think.
    21232123         */
    2124         if (    VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)
    2125             &&  !VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     2124        if (   VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)
     2125            && !VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    21262126        {
    21272127            CPUM_ASSERT_NOT_EXTRN(pVCpu, CPUMCTX_EXTRN_RIP);
     
    21392139         */
    21402140        bool fWakeupPending = false;
    2141         if (    !VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY)
    2142             &&  (!rc || rc >= VINF_EM_RESCHEDULE_HM))
     2141        if (   !VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY)
     2142            && (!rc || rc >= VINF_EM_RESCHEDULE_HM))
    21432143        {
    21442144            if (   !VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)
     
    22092209         * Debugger Facility request.
    22102210         */
    2211         if (   (   VM_FF_IS_PENDING(pVM, VM_FF_DBGF)
     2211        if (   (   VM_FF_IS_SET(pVM, VM_FF_DBGF)
    22122212                || VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_DBGF) )
    2213             && !VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY) )
     2213            && !VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY) )
    22142214        {
    22152215            CPUM_IMPORT_EXTRN_RCSTRICT(pVCpu, ~CPUMCTX_EXTRN_KEEPER_MASK, rc);
     
    22222222         */
    22232223        if (   !fWakeupPending /* don't miss the wakeup from EMSTATE_HALTED! */
    2224             && VM_FF_IS_PENDING(pVM, VM_FF_EMT_RENDEZVOUS))
     2224            && VM_FF_IS_SET(pVM, VM_FF_EMT_RENDEZVOUS))
    22252225        {
    22262226            CPUM_IMPORT_EXTRN_RCSTRICT(pVCpu, ~CPUMCTX_EXTRN_KEEPER_MASK, rc);
     
    22432243         */
    22442244        if (   !fWakeupPending /* don't miss the wakeup from EMSTATE_HALTED! */
    2245             && VM_FF_IS_PENDING(pVM, VM_FF_CHECK_VM_STATE))
     2245            && VM_FF_IS_SET(pVM, VM_FF_CHECK_VM_STATE))
    22462246        {
    22472247            VMSTATE enmState = VMR3GetState(pVM);
     
    22722272         * than us since we can terminate without allocating more memory.
    22732273         */
    2274         if (VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     2274        if (VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    22752275        {
    22762276            rc2 = PGMR3PhysAllocateHandyPages(pVM);
     
    22832283         * If the virtual sync clock is still stopped, make TM restart it.
    22842284         */
    2285         if (VM_FF_IS_PENDING(pVM, VM_FF_TM_VIRTUAL_SYNC))
     2285        if (VM_FF_IS_SET(pVM, VM_FF_TM_VIRTUAL_SYNC))
    22862286            TMR3VirtualSyncFF(pVM, pVCpu);
    22872287
     
    22902290         * Debug, pause the VM.
    22912291         */
    2292         if (VM_FF_IS_PENDING(pVM, VM_FF_DEBUG_SUSPEND))
     2292        if (VM_FF_IS_SET(pVM, VM_FF_DEBUG_SUSPEND))
    22932293        {
    22942294            VM_FF_CLEAR(pVM, VM_FF_DEBUG_SUSPEND);
  • trunk/src/VBox/VMM/VMMR3/EMHM.cpp

    r74789 r74790  
    354354     * this check.
    355355     */
    356     if (VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     356    if (VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    357357        return VINF_EM_NO_MEMORY;
    358358
  • trunk/src/VBox/VMM/VMMR3/EMR3Nem.cpp

    r74789 r74790  
    330330     * this check.
    331331     */
    332     if (VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     332    if (VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    333333        return VINF_EM_NO_MEMORY;
    334334
  • trunk/src/VBox/VMM/VMMR3/EMRaw.cpp

    r74789 r74790  
    12551255     * this check.
    12561256     */
    1257     if (VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY))
     1257    if (VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY))
    12581258        return VINF_EM_NO_MEMORY;
    12591259
  • trunk/src/VBox/VMM/VMMR3/FTM.cpp

    r69111 r74790  
    13381338        while ((rc = PDMCritSectTryEnter(&pVM->ftm.s.CritSect)) == VERR_SEM_BUSY)
    13391339        {
    1340             if (VM_FF_IS_PENDING(pVM, VM_FF_EMT_RENDEZVOUS))
     1340            if (VM_FF_IS_SET(pVM, VM_FF_EMT_RENDEZVOUS))
    13411341            {
    13421342                rc = VMMR3EmtRendezvousFF(pVM, pVCpu);
     
    13441344            }
    13451345
    1346             if (VM_FF_IS_PENDING(pVM, VM_FF_REQUEST))
     1346            if (VM_FF_IS_SET(pVM, VM_FF_REQUEST))
    13471347            {
    13481348                rc = VMR3ReqProcessU(pVM->pUVM, VMCPUID_ANY, true /*fPriorityOnly*/);
  • trunk/src/VBox/VMM/VMMR3/PDMQueue.cpp

    r73097 r74790  
    663663        /* We're done if there were no inserts while we were busy. */
    664664        if (   !ASMBitTest(&pVM->pdm.s.fQueueFlushing, PDM_QUEUE_FLUSH_FLAG_PENDING_BIT)
    665             && !VM_FF_IS_PENDING(pVM, VM_FF_PDM_QUEUES))
     665            && !VM_FF_IS_SET(pVM, VM_FF_PDM_QUEUES))
    666666            break;
    667667        VM_FF_CLEAR(pVM, VM_FF_PDM_QUEUES);
  • trunk/src/VBox/VMM/VMMR3/VMEmt.cpp

    r74789 r74790  
    165165            }
    166166
    167             if (VM_FF_IS_PENDING(pVM, VM_FF_EMT_RENDEZVOUS))
     167            if (VM_FF_IS_SET(pVM, VM_FF_EMT_RENDEZVOUS))
    168168            {
    169169                rc = VMMR3EmtRendezvousFF(pVM, &pVM->aCpus[idCpu]);
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r74785 r74790  
    23612361            while (!ASMAtomicCmpXchgU32(&pVM->vmm.s.u32RendezvousLock, 0x77778888, 0))
    23622362            {
    2363                 if (VM_FF_IS_PENDING(pVM, VM_FF_EMT_RENDEZVOUS))
     2363                if (VM_FF_IS_SET(pVM, VM_FF_EMT_RENDEZVOUS))
    23642364                {
    23652365                    rc = VMMR3EmtRendezvousFF(pVM, pVCpu);
     
    23752375
    23762376        Log(("VMMR3EmtRendezvous: %#x EMT#%u\n", fFlags, pVCpu->idCpu));
    2377         Assert(!VM_FF_IS_PENDING(pVM, VM_FF_EMT_RENDEZVOUS));
     2377        Assert(!VM_FF_IS_SET(pVM, VM_FF_EMT_RENDEZVOUS));
    23782378        Assert(!pVCpu->vmm.s.fInRendezvous);
    23792379        pVCpu->vmm.s.fInRendezvous = true;
  • trunk/src/VBox/VMM/VMMRC/TRPMRCHandlers.cpp

    r74789 r74790  
    184184            TMTimerPollVoid(pVM, pVCpu);
    185185            Log2(("TMTimerPoll at %08RX32 - VM_FF_TM_VIRTUAL_SYNC=%d VM_FF_TM_VIRTUAL_SYNC=%d\n", pRegFrame->eip,
    186                   VM_FF_IS_PENDING(pVM, VM_FF_TM_VIRTUAL_SYNC), VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_TIMER)));
     186                  VM_FF_IS_SET(pVM, VM_FF_TM_VIRTUAL_SYNC), VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_TIMER)));
    187187        }
    188188    }
     
    223223    {
    224224        /* The out of memory condition naturally outranks the others. */
    225         if (RT_UNLIKELY(VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY)))
     225        if (RT_UNLIKELY(VM_FF_IS_SET(pVM, VM_FF_PGM_NO_MEMORY)))
    226226            rc = VINF_EM_NO_MEMORY;
    227227        else
     
    244244                rc = VINF_EM_RAW_TIMER_PENDING;
    245245            /* The Virtual Sync clock has stopped. */
    246             else if (VM_FF_IS_PENDING(pVM, VM_FF_TM_VIRTUAL_SYNC))
     246            else if (VM_FF_IS_SET(pVM, VM_FF_TM_VIRTUAL_SYNC))
    247247                rc = VINF_EM_RAW_TO_R3;
    248248            /* DMA work pending? */
    249             else if (VM_FF_IS_PENDING(pVM, VM_FF_PDM_DMA))
     249            else if (VM_FF_IS_SET(pVM, VM_FF_PDM_DMA))
    250250                rc = VINF_EM_RAW_TO_R3;
    251251            /* Pending request packets might contain actions that need immediate
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