VirtualBox

Changeset 19278 in vbox for trunk


Ignore:
Timestamp:
Apr 30, 2009 3:55:16 PM (16 years ago)
Author:
vboxsync
Message:

Critical section for REM execution added

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/EM.cpp

    r19241 r19278  
    109109static int emR3SingleStepExecRem(PVM pVM, uint32_t cIterations);
    110110static EMSTATE emR3Reschedule(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
     111static void emR3RemLock(PVM pVM);
     112static void emR3RemUnlock(PVM pVM);
    111113
    112114/**
     
    138140        pVM->fRawR0Enabled = true;
    139141    Log(("EMR3Init: fRawR3Enabled=%d fRawR0Enabled=%d\n", pVM->fRawR3Enabled, pVM->fRawR0Enabled));
     142
     143    /*
     144     * Initialize the REM critical section.
     145     */
     146    rc = PDMR3CritSectInit(pVM, &pVM->em.s.CritSectREM, "EM-REM");
     147    AssertRCReturn(rc, rc);
    140148
    141149    /*
     
    476484{
    477485    AssertMsg(pVM->em.s.offVM, ("bad init order!\n"));
     486
     487    PDMR3CritSectDelete(&pVM->em.s.CritSectREM);
    478488    return VINF_SUCCESS;
    479489}
     
    837847}
    838848
     849/**
     850 * Locks REM execution to a single VCpu
     851 *
     852 * @param   pVM         VM handle.
     853 */
     854static void emR3RemLock(PVM pVM)
     855{
     856    int rc = PDMCritSectEnter(&pVM->em.s.CritSectREM, VERR_SEM_BUSY);
     857    AssertMsg(rc == VINF_SUCCESS, ("%Rrc\n", rc));
     858}
     859
     860/**
     861 * Unlocks REM execution
     862 *
     863 * @param   pVM         VM handle.
     864 */
     865static void emR3RemUnlock(PVM pVM)
     866{
     867    PDMCritSectLeave(&pVM->em.s.CritSectREM);
     868}
    839869
    840870/**
     
    851881    LogFlow(("emR3RemStep: cs:eip=%04x:%08x\n", CPUMGetGuestCS(pVCpu),  CPUMGetGuestEIP(pVCpu)));
    852882
     883    emR3RemLock(pVM);
     884
    853885    /*
    854886     * Switch to REM, step instruction, switch back.
     
    860892        REMR3StateBack(pVM, pVCpu);
    861893    }
     894    emR3RemUnlock(pVM);
     895
    862896    LogFlow(("emR3RemStep: returns %Rrc cs:eip=%04x:%08x\n", rc, CPUMGetGuestCS(pVCpu),  CPUMGetGuestEIP(pVCpu)));
    863897    return rc;
     
    899933#endif
    900934
     935    /* Big lock, but you are not supposed to own any lock when coming in here. */
     936    emR3RemLock(pVM);
     937
    901938    /*
    902939     * Spin till we get a forced action which returns anything but VINF_SUCCESS
     
    906943    bool    fInREMState = false;
    907944    int     rc = VINF_SUCCESS;
     945
     946    /* Flush the recompiler TLB if the VCPU has changed. */
     947    if (pVM->em.s.idLastRemCpu != pVCpu->idCpu)
     948        REMFlushTBs(pVM);
     949    pVM->em.s.idLastRemCpu = pVCpu->idCpu;
     950
    908951    for (;;)
    909952    {
     
    10081051        STAM_PROFILE_STOP(&pVCpu->em.s.StatREMSync, e);
    10091052    }
     1053    emR3RemUnlock(pVM);
    10101054
    10111055    STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatREMTotal, a);
     
    14121456    STAM_PROFILE_START(&pVCpu->em.s.StatREMEmu, a);
    14131457    Log(("EMINS: %04x:%RGv RSP=%RGv\n", pCtx->cs, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));
     1458    emR3RemLock(pVM);
    14141459    rc = REMR3EmulateInstruction(pVM, pVCpu);
     1460    emR3RemUnlock(pVM);
    14151461    STAM_PROFILE_STOP(&pVCpu->em.s.StatREMEmu, a);
    14161462
     
    24202466        case VERR_REM_FLUSHED_PAGES_OVERFLOW:
    24212467            Assert((pCtx->ss & X86_SEL_RPL) != 1);
     2468            emR3RemLock(pVM);
    24222469            REMR3ReplayInvalidatedPages(pVM, pVCpu);
     2470            emR3RemUnlock(pVM);
    24232471            rc = VINF_SUCCESS;
    24242472            break;
     
    33543402        /* Replay the handler notification changes. */
    33553403        if (VM_FF_IS_PENDING_EXCEPT(pVM, VM_FF_REM_HANDLER_NOTIFY, VM_FF_PGM_NO_MEMORY))
     3404        {
     3405            emR3RemLock(pVM);
    33563406            REMR3ReplayHandlerNotifications(pVM);
     3407            emR3RemUnlock(pVM);
     3408        }
    33573409
    33583410        /* check that we got them all  */
  • trunk/src/VBox/VMM/EMInternal.h

    r18927 r19278  
    2929#include <VBox/patm.h>
    3030#include <VBox/dis.h>
     31#include <VBox/pdmcritsect.h>
    3132#include <iprt/avl.h>
    3233#include <setjmp.h>
     
    289290     * See EM2VM(). */
    290291    RTUINT                  offVM;
     292
     293    /** Id of the VCPU that last executed code in the recompiler. */
     294    VMCPUID                 idLastRemCpu;
     295
     296    /** PGM critical section.
     297     * This protects recompiler usage
     298     */
     299    PDMCRITSECT             CritSectREM;
    291300} EM;
    292301/** Pointer to EM VM instance data. */
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