VirtualBox

Changeset 68853 in vbox for trunk/src


Ignore:
Timestamp:
Sep 25, 2017 1:10:41 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118107
Message:

VMMR3EmtRendezvous: Pretend we're a single CPU config when called during vmR3Destroy after the EMTs have started terminating.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r67529 r68853  
    25352535        LogFlow(("vmR3Destroy: returning %Rrc\n", VINF_EM_TERMINATE));
    25362536    }
     2537
     2538    /*
     2539     * Decrement the active EMT count here.
     2540     */
     2541    PUVMCPU pUVCpu = &pUVM->aCpus[pVCpu->idCpu];
     2542    if (!pUVCpu->vm.s.fBeenThruVmDestroy)
     2543    {
     2544        pUVCpu->vm.s.fBeenThruVmDestroy = true;
     2545        ASMAtomicDecU32(&pUVM->vm.s.cActiveEmts);
     2546    }
     2547    else
     2548        AssertFailed();
     2549
    25372550    return VINF_EM_TERMINATE;
    25382551}
  • trunk/src/VBox/VMM/VMMR3/VMEmt.cpp

    r67987 r68853  
    9494    Log(("vmR3EmulationThread: Emulation thread starting the days work... Thread=%#x pUVM=%p\n", hThreadSelf, pUVM));
    9595    VMSTATE enmBefore = VMSTATE_CREATED; /* (only used for logging atm.) */
     96    ASMAtomicIncU32(&pUVM->vm.s.cActiveEmts);
    9697    for (;;)
    9798    {
     
    244245
    245246    } /* forever */
     247
     248
     249    /*
     250     * Decrement the active EMT count if we haven't done it yet in vmR3Destroy.
     251     */
     252    if (!pUVCpu->vm.s.fBeenThruVmDestroy)
     253        ASMAtomicDecU32(&pUVM->vm.s.cActiveEmts);
    246254
    247255
     
    13811389}
    13821390
     1391
     1392/**
     1393 * Returns the number of active EMTs.
     1394 *
     1395 * This is used by the rendezvous code during VM destruction to avoid waiting
     1396 * for EMTs that aren't around any more.
     1397 *
     1398 * @returns Number of active EMTs.  0 if invalid parameter.
     1399 * @param   pUVM                The user mode VM structure.
     1400 */
     1401VMMR3_INT_DECL(uint32_t) VMR3GetActiveEmts(PUVM pUVM)
     1402{
     1403    UVM_ASSERT_VALID_EXT_RETURN(pUVM, 0);
     1404    return pUVM->vm.s.cActiveEmts;
     1405}
     1406
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r66848 r68853  
    21602160    PVMCPU pVCpu = VMMGetCpu(pVM);
    21612161    if (!pVCpu)
     2162    {
    21622163        /*
    21632164         * Forward the request to an EMT thread.
    21642165         */
    2165     {
    21662166        Log(("VMMR3EmtRendezvous: %#x non-EMT\n", fFlags));
    21672167        if (!(fFlags & VMMEMTRENDEZVOUS_FLAGS_PRIORITY))
     
    21712171        Log(("VMMR3EmtRendezvous: %#x non-EMT returns %Rrc\n", fFlags, VBOXSTRICTRC_VAL(rcStrict)));
    21722172    }
    2173     else if (pVM->cCpus == 1)
     2173    else if (   pVM->cCpus == 1
     2174             || (   pVM->enmVMState == VMSTATE_DESTROYING
     2175                 && VMR3GetActiveEmts(pVM->pUVM) < pVM->cCpus ) )
    21742176    {
    21752177        /*
    21762178         * Shortcut for the single EMT case.
     2179         *
     2180         * We also ends up here if EMT(0) (or others) tries to issue a rendezvous
     2181         * during vmR3Destroy after other emulation threads have started terminating.
    21772182         */
    21782183        if (!pVCpu->vmm.s.fInRendezvous)
  • trunk/src/VBox/VMM/include/VMInternal.h

    r62478 r68853  
    191191    /** The reference count of the UVM handle. */
    192192    volatile uint32_t               cUvmRefs;
     193
     194    /** Number of active EMTs. */
     195    volatile uint32_t               cActiveEmts;
    193196
    194197# ifdef VBOX_WITH_STATISTICS
     
    342345    /** Wait/Idle indicator. */
    343346    bool volatile                   fWait;
     347    /** Set if we've been thru vmR3Destroy and decremented the active EMT count
     348     *  already. */
     349    bool volatile                   fBeenThruVmDestroy;
    344350    /** Align the next bit. */
    345     bool                            afAlignment[HC_ARCH_BITS == 32 ? 3 : 7];
     351    bool                            afAlignment[HC_ARCH_BITS == 32 ? 2 : 6];
    346352
    347353    /** @name Generic Halt data
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette