VirtualBox

Changeset 72252 in vbox


Ignore:
Timestamp:
May 17, 2018 5:39:28 PM (7 years ago)
Author:
vboxsync
Message:

NEMR3Native-win.cpp: Loop optimization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp

    r72207 r72252  
    20192019    return nemHCWinRunGC(pVM, pVCpu, NULL /*pGVM*/, NULL /*pGVCpu*/);
    20202020#else
    2021     VBOXSTRICTRC rcStrict = VMMR3CallR0EmtFast(pVM, pVCpu, VMMR0_DO_NEM_RUN);
    2022     if (RT_SUCCESS(rcStrict))
    2023     {
    2024         /* We deal wtih VINF_NEM_CHANGE_PGM_MODE and VINF_NEM_FLUSH_TLB here, since we're running
    2025            the risk of getting these while we already got another RC (I/O ports). */
    2026         VBOXSTRICTRC rcPgmPending = pVCpu->nem.s.rcPgmPending;
    2027         pVCpu->nem.s.rcPgmPending = VINF_SUCCESS;
    2028         if (   rcStrict == VINF_NEM_CHANGE_PGM_MODE
    2029             || rcStrict == VINF_PGM_CHANGE_MODE
    2030             || rcPgmPending == VINF_NEM_CHANGE_PGM_MODE )
    2031         {
    2032             LogFlow(("nemR3NativeRunGC: calling PGMChangeMode...\n"));
    2033             int rc = PGMChangeMode(pVCpu, CPUMGetGuestCR0(pVCpu), CPUMGetGuestCR4(pVCpu), CPUMGetGuestEFER(pVCpu));
    2034             AssertRCReturn(rc, rc);
    2035             if (rcStrict == VINF_NEM_CHANGE_PGM_MODE || rcStrict == VINF_NEM_FLUSH_TLB)
    2036                 rcStrict = VINF_SUCCESS;
     2021    for (;;)
     2022    {
     2023        VBOXSTRICTRC rcStrict = VMMR3CallR0EmtFast(pVM, pVCpu, VMMR0_DO_NEM_RUN);
     2024        if (RT_SUCCESS(rcStrict))
     2025        {
     2026            /* We deal with VINF_NEM_CHANGE_PGM_MODE and VINF_NEM_FLUSH_TLB here, since we're running
     2027               the risk of getting these while we already got another RC (I/O ports). */
     2028            VBOXSTRICTRC rcPgmPending = pVCpu->nem.s.rcPgmPending;
     2029            pVCpu->nem.s.rcPgmPending = VINF_SUCCESS;
     2030            if (   rcStrict == VINF_NEM_CHANGE_PGM_MODE
     2031                || rcStrict == VINF_PGM_CHANGE_MODE
     2032                || rcPgmPending == VINF_NEM_CHANGE_PGM_MODE )
     2033            {
     2034                LogFlow(("nemR3NativeRunGC: calling PGMChangeMode...\n"));
     2035                int rc = PGMChangeMode(pVCpu, CPUMGetGuestCR0(pVCpu), CPUMGetGuestCR4(pVCpu), CPUMGetGuestEFER(pVCpu));
     2036                AssertRCReturn(rc, rc);
     2037                if (rcStrict == VINF_NEM_CHANGE_PGM_MODE || rcStrict == VINF_NEM_FLUSH_TLB)
     2038                {
     2039                    if (   !VM_FF_IS_PENDING(pVM, VM_FF_HIGH_PRIORITY_POST_MASK | VM_FF_HP_R0_PRE_HM_MASK)
     2040                        && !VMCPU_FF_IS_PENDING(pVCpu,   (VMCPU_FF_HIGH_PRIORITY_POST_MASK | VMCPU_FF_HP_R0_PRE_HM_MASK)
     2041                                                       & ~VMCPU_FF_RESUME_GUEST_MASK))
     2042                    {
     2043                        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
     2044                        continue;
     2045                    }
     2046                    rcStrict = VINF_SUCCESS;
     2047                }
     2048            }
     2049            else if (rcStrict == VINF_NEM_FLUSH_TLB || rcPgmPending == VINF_NEM_FLUSH_TLB)
     2050            {
     2051                LogFlow(("nemR3NativeRunGC: calling PGMFlushTLB...\n"));
     2052                int rc = PGMFlushTLB(pVCpu, CPUMGetGuestCR3(pVCpu), true);
     2053                AssertRCReturn(rc, rc);
     2054                if (rcStrict == VINF_NEM_FLUSH_TLB || rcStrict == VINF_NEM_CHANGE_PGM_MODE)
     2055                {
     2056                    if (   !VM_FF_IS_PENDING(pVM, VM_FF_HIGH_PRIORITY_POST_MASK | VM_FF_HP_R0_PRE_HM_MASK)
     2057                        && !VMCPU_FF_IS_PENDING(pVCpu,   (VMCPU_FF_HIGH_PRIORITY_POST_MASK | VMCPU_FF_HP_R0_PRE_HM_MASK)
     2058                                                       & ~VMCPU_FF_RESUME_GUEST_MASK))
     2059                    {
     2060                        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
     2061                        continue;
     2062                    }
     2063                    rcStrict = VINF_SUCCESS;
     2064                }
     2065            }
     2066            else
     2067                AssertMsg(rcPgmPending == VINF_SUCCESS, ("rcPgmPending=%Rrc\n", VBOXSTRICTRC_VAL(rcPgmPending) ));
    20372068        }
    2038         else if (rcStrict == VINF_NEM_FLUSH_TLB || rcPgmPending == VINF_NEM_FLUSH_TLB)
    2039         {
    2040             LogFlow(("nemR3NativeRunGC: calling PGMFlushTLB...\n"));
    2041             int rc = PGMFlushTLB(pVCpu, CPUMGetGuestCR3(pVCpu), true);
    2042             AssertRCReturn(rc, rc);
    2043             if (rcStrict == VINF_NEM_FLUSH_TLB || rcStrict == VINF_NEM_CHANGE_PGM_MODE)
    2044                 rcStrict = VINF_SUCCESS;
    2045         }
    2046         else
    2047             AssertMsg(rcPgmPending == VINF_SUCCESS, ("rcPgmPending=%Rrc\n", VBOXSTRICTRC_VAL(rcPgmPending) ));
    2048     }
    2049     LogFlow(("nemR3NativeRunGC: returns %Rrc\n", VBOXSTRICTRC_VAL(rcStrict) ));
    2050     return rcStrict;
     2069        LogFlow(("nemR3NativeRunGC: returns %Rrc\n", VBOXSTRICTRC_VAL(rcStrict) ));
     2070        return rcStrict;
     2071    }
    20512072#endif
    20522073}
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