VirtualBox

Changeset 88346 in vbox


Ignore:
Timestamp:
Apr 1, 2021 1:16:25 PM (4 years ago)
Author:
vboxsync
Message:

Forward ported r143574 from 6.1: VMM: Must do vmR3SetHaltMethodCallback on all EMTs or only one of them will be doing halting in ring-0. oem2ticketref:40

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

Legend:

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

    r88344 r88346  
    601601}
    602602
    603 #if 0 /** @todo broken see oem2 ticket 40 */
     603#if 0 /** @todo temporarily disabled, see oem2 ticket 40 */
    604604
    605605/**
     
    644644    else if (VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_SMI))
    645645    {
     646        Log12(("vmmR0DoHaltInterrupt: CPU%d failed #3\n", pVCpu->idCpu));
    646647        return VINF_EM_HALT;
    647648    }
     
    654655        {
    655656            /** @todo later. */
     657            Log12(("vmmR0DoHaltInterrupt: CPU%d failed #2 (uMWait=%u enmInt=%d)\n", pVCpu->idCpu, uMWait, enmInterruptibility));
    656658            return VINF_EM_HALT;
    657659        }
     
    667669             *        here before injecting the virtual interrupt. See emR3ForcedActions
    668670             *        for details. */
     671            Log12(("vmmR0DoHaltInterrupt: CPU%d failed #1 (uMWait=%u enmInt=%d)\n", pVCpu->idCpu, uMWait, enmInterruptibility));
    669672            return VINF_EM_HALT;
    670673        }
     
    674677    {
    675678        STAM_REL_COUNTER_INC(&pVCpu->vmm.s.StatR0HaltExec);
     679        Log11(("vmmR0DoHaltInterrupt: CPU%d success VINF_SUCCESS (UNHALT)\n", pVCpu->idCpu));
    676680        return VINF_SUCCESS;
    677681    }
     
    679683    {
    680684        STAM_REL_COUNTER_INC(&pVCpu->vmm.s.StatR0HaltExec);
     685        Log11(("vmmR0DoHaltInterrupt: CPU%d success VINF_SUCCESS (uMWait=%u > 1)\n", pVCpu->idCpu, uMWait));
    681686        return VINF_SUCCESS;
    682687    }
    683688
     689    Log12(("vmmR0DoHaltInterrupt: CPU%d failed #0 (uMWait=%u enmInt=%d)\n", pVCpu->idCpu, uMWait, enmInterruptibility));
    684690    return VINF_EM_HALT;
    685691}
     
    850856                            uint64_t const u64EndSchedHalt     = RTTimeNanoTS();
    851857                            uint64_t const cNsElapsedSchedHalt = u64EndSchedHalt - u64StartSchedHalt;
     858                            Log10(("vmmR0DoHalt: CPU%d: halted %llu ns\n", pGVCpu->idCpu, cNsElapsedSchedHalt));
    852859
    853860                            VMCPU_CMPXCHG_STATE(pGVCpu, VMCPUSTATE_STARTED, VMCPUSTATE_STARTED_HALTED);
     
    878885                                        return vmmR0DoHaltInterrupt(pGVCpu, uMWait, enmInterruptibility);
    879886                                    }
     887                                    Log12(("vmmR0DoHalt: CPU%d post #2 - No pending interrupt\n", pGVCpu->idCpu));
    880888                                }
     889                                else
     890                                    Log12(("vmmR0DoHalt: CPU%d post #1 - Pending FF\n", pGVCpu->idCpu));
    881891                            }
     892                            else
     893                                Log12(("vmmR0DoHalt: CPU%d GVMMR0SchedHalt failed: %Rrc\n", pGVCpu->idCpu, rc));
    882894                        }
    883895                        else
     896                        {
    884897                            VMCPU_CMPXCHG_STATE(pGVCpu, VMCPUSTATE_STARTED, VMCPUSTATE_STARTED_HALTED);
     898                            Log12(("vmmR0DoHalt: CPU%d failed #4 - Pending FF\n", pGVCpu->idCpu));
     899                        }
    885900                    }
     901                    else
     902                        Log12(("vmmR0DoHalt: CPU%d failed #3 - enmState=%d\n", pGVCpu->idCpu, VMCPU_GET_STATE(pGVCpu)));
    886903                }
     904                else
     905                    Log12(("vmmR0DoHalt: CPU%d failed #2 - Pending FF\n", pGVCpu->idCpu));
    887906            }
    888907        }
    889     }
     908        else
     909            Log12(("vmmR0DoHalt: CPU%d failed #1 - Pending FF\n", pGVCpu->idCpu));
     910    }
     911    else
     912        Log12(("vmmR0DoHalt: CPU%d failed #0 - fMayHaltInRing0=%d TRPMHasTrap=%d enmInt=%d uMWait=%u\n",
     913               pGVCpu->idCpu, pGVCpu->vmm.s.fMayHaltInRing0, TRPMHasTrap(pGVCpu), enmInterruptibility, uMWait));
     914
    890915    return VINF_EM_HALT;
    891916}
     
    14911516                    vmmR0RecordRC(pGVM, pGVCpu, rc);
    14921517#endif
    1493 #if 0 /** @todo broken see oem2 ticket 40 */
     1518#if 0 /** @todo temporarily disabled, see oem2 ticket 40 */
    14941519                    /*
    14951520                     * If this is a halt.
  • trunk/src/VBox/VMM/VMMR3/VMEmt.cpp

    r86118 r88346  
    12531253static DECLCALLBACK(VBOXSTRICTRC) vmR3SetHaltMethodCallback(PVM pVM, PVMCPU pVCpu, void *pvUser)
    12541254{
    1255     PUVM        pUVM = pVM->pUVM;
    1256     uintptr_t   i    = (uintptr_t)pvUser;
     1255    PUVM      pUVM = pVM->pUVM;
     1256    int       rc   = VINF_SUCCESS;
     1257    uintptr_t i    = (uintptr_t)pvUser;
    12571258    Assert(i < RT_ELEMENTS(g_aHaltMethods));
    1258     NOREF(pVCpu);
    1259 
    1260     /*
    1261      * Terminate the old one.
    1262      */
    1263     if (    pUVM->vm.s.enmHaltMethod != VMHALTMETHOD_INVALID
    1264         &&  g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnTerm)
    1265     {
    1266         g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnTerm(pUVM);
    1267         pUVM->vm.s.enmHaltMethod = VMHALTMETHOD_INVALID;
    1268     }
    1269 
    1270     /* Assert that the failure fallback is where we expect. */
    1271     Assert(g_aHaltMethods[0].enmHaltMethod == VMHALTMETHOD_BOOTSTRAP);
    1272     Assert(!g_aHaltMethods[0].pfnTerm && !g_aHaltMethods[0].pfnInit);
    1273 
    1274     /*
    1275      * Init the new one.
    1276      */
    1277     int rc = VINF_SUCCESS;
    1278     memset(&pUVM->vm.s.Halt, 0, sizeof(pUVM->vm.s.Halt));
    1279     if (g_aHaltMethods[i].pfnInit)
    1280     {
    1281         rc = g_aHaltMethods[i].pfnInit(pUVM);
    1282         if (RT_FAILURE(rc))
    1283         {
    1284             /* Fall back on the bootstrap method. This requires no
    1285                init/term (see assertion above), and will always work. */
    1286             AssertLogRelRC(rc);
    1287             i = 0;
    1288         }
    1289     }
    1290 
    1291     /*
    1292      * Commit it.
    1293      */
    1294     pUVM->vm.s.enmHaltMethod = g_aHaltMethods[i].enmHaltMethod;
    1295     ASMAtomicWriteU32(&pUVM->vm.s.iHaltMethod, i);
    1296 
     1259
     1260    /*
     1261     * Main job is done once on EMT0 (it goes thru here first).
     1262     */
     1263    if (pVCpu->idCpu == 0)
     1264    {
     1265        /*
     1266         * Terminate the old one.
     1267         */
     1268        if (    pUVM->vm.s.enmHaltMethod != VMHALTMETHOD_INVALID
     1269            &&  g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnTerm)
     1270        {
     1271            g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnTerm(pUVM);
     1272            pUVM->vm.s.enmHaltMethod = VMHALTMETHOD_INVALID;
     1273        }
     1274
     1275        /* Assert that the failure fallback is where we expect. */
     1276        Assert(g_aHaltMethods[0].enmHaltMethod == VMHALTMETHOD_BOOTSTRAP);
     1277        Assert(!g_aHaltMethods[0].pfnTerm && !g_aHaltMethods[0].pfnInit);
     1278
     1279        /*
     1280         * Init the new one.
     1281         */
     1282        memset(&pUVM->vm.s.Halt, 0, sizeof(pUVM->vm.s.Halt));
     1283        if (g_aHaltMethods[i].pfnInit)
     1284        {
     1285            rc = g_aHaltMethods[i].pfnInit(pUVM);
     1286            if (RT_FAILURE(rc))
     1287            {
     1288                /* Fall back on the bootstrap method. This requires no
     1289                   init/term (see assertion above), and will always work. */
     1290                AssertLogRelRC(rc);
     1291                i = 0;
     1292            }
     1293        }
     1294
     1295        /*
     1296         * Commit it.
     1297         */
     1298        pUVM->vm.s.enmHaltMethod = g_aHaltMethods[i].enmHaltMethod;
     1299        ASMAtomicWriteU32(&pUVM->vm.s.iHaltMethod, i);
     1300    }
     1301    else
     1302        i = pUVM->vm.s.iHaltMethod;
     1303
     1304    /*
     1305     * All EMTs must update their ring-0 halt configuration.
     1306     */
    12971307    VMMR3SetMayHaltInRing0(pVCpu, g_aHaltMethods[i].fMayHaltInRing0,
    12981308                           g_aHaltMethods[i].enmHaltMethod == VMHALTMETHOD_GLOBAL_1
     
    13511361     * This needs to be done while the other EMTs are not sleeping or otherwise messing around.
    13521362     */
    1353     return VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE, vmR3SetHaltMethodCallback, (void *)(uintptr_t)i);
     1363    return VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ASCENDING, vmR3SetHaltMethodCallback, (void *)(uintptr_t)i);
    13541364}
    13551365
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r88344 r88346  
    21342134VMMR3_INT_DECL(void) VMMR3SetMayHaltInRing0(PVMCPU pVCpu, bool fMayHaltInRing0, uint32_t cNsSpinBlockThreshold)
    21352135{
     2136    LogFlow(("VMMR3SetMayHaltInRing0(#%u, %d, %u)\n", pVCpu->idCpu, fMayHaltInRing0, cNsSpinBlockThreshold));
    21362137    pVCpu->vmm.s.fMayHaltInRing0       = fMayHaltInRing0;
    21372138    pVCpu->vmm.s.cNsSpinBlockThreshold = cNsSpinBlockThreshold;
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