VirtualBox

Changeset 48426 in vbox


Ignore:
Timestamp:
Sep 11, 2013 11:52:56 AM (11 years ago)
Author:
vboxsync
Message:

VMM: Fixed strict build assertion assumption with thread-context hooks. More assertions, slight cleanup.

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

Legend:

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

    r47989 r48426  
    201201     */
    202202    /* RTMpCpuId had better be cheap. */
     203    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    203204    RTCPUID idHostCpu = RTMpCpuId();
    204205
  • trunk/src/VBox/VMM/VMMR0/HMR0.cpp

    r48328 r48426  
    800800{
    801801    PHMR0FIRSTRC pFirstRc = (PHMR0FIRSTRC)pvUser1;
    802     Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /// @todo fix idCpu == index assumption (rainy day)
     802    Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /** @todo fix idCpu == index assumption (rainy day) */
    803803    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    804804    NOREF(pvUser2);
     
    862862{
    863863    PHMR0FIRSTRC pFirstRc = (PHMR0FIRSTRC)pvUser1;
    864     Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /// @todo fix idCpu == index assumption (rainy day)
     864    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     865    Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /** @todo fix idCpu == index assumption (rainy day) */
    865866    NOREF(pvUser2);
    866867
     
    908909    PHMGLOBALCPUINFO pCpu = &g_HvmR0.aCpuInfo[idCpu];
    909910
    910     Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu));  /** @todo fix idCpu == index assumption (rainy day) */
     911    Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /** @todo fix idCpu == index assumption (rainy day) */
    911912    Assert(idCpu < RT_ELEMENTS(g_HvmR0.aCpuInfo));
    912913    Assert(!pCpu->fConfigured);
     
    10621063 * @returns VBox status code.
    10631064 * @param   idCpu       The identifier for the CPU the function is called on.
     1065 *
     1066 * @remarks Must be called with preemption disabled.
    10641067 */
    10651068static int hmR0DisableCpu(RTCPUID idCpu)
     
    10681071
    10691072    Assert(!g_HvmR0.vmx.fSupported || !g_HvmR0.vmx.fUsingSUPR0EnableVTx);
    1070     Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /// @todo fix idCpu == index assumption (rainy day)
     1073    Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /** @todo fix idCpu == index assumption (rainy day) */
    10711074    Assert(idCpu < RT_ELEMENTS(g_HvmR0.aCpuInfo));
    10721075    Assert(!pCpu->fConfigured || pCpu->hMemObj != NIL_RTR0MEMOBJ);
     1076    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    10731077
    10741078    if (pCpu->hMemObj == NIL_RTR0MEMOBJ)
     
    10801084        void    *pvCpuPage     = RTR0MemObjAddress(pCpu->hMemObj);
    10811085        RTHCPHYS HCPhysCpuPage = RTR0MemObjGetPagePhysAddr(pCpu->hMemObj, 0);
    1082         if (idCpu == RTMpCpuId())
    1083         {
    1084             rc = g_HvmR0.pfnDisableCpu(pCpu, pvCpuPage, HCPhysCpuPage);
    1085             AssertRCReturn(rc, rc);
    1086         }
    1087         else
    1088         {
    1089             pCpu->fIgnoreAMDVInUseError = true;
    1090             rc = VINF_SUCCESS;
    1091         }
     1086
     1087        rc = g_HvmR0.pfnDisableCpu(pCpu, pvCpuPage, HCPhysCpuPage);
     1088        AssertRCReturn(rc, rc);
    10921089
    10931090        pCpu->fConfigured = false;
     
    11021099
    11031100/**
    1104  * Worker function passed to RTMpOnAll, RTMpOnOthers and RTMpOnSpecific that
    1105  * is to be called on the target CPUs.
     1101 * Worker function passed to RTMpOnAll() that is to be called on the target
     1102 * CPUs.
    11061103 *
    11071104 * @param   idCpu       The identifier for the CPU the function is called on.
     
    15171514 * @param   pVCpu       Pointer to the VMCPU.
    15181515 *
    1519  * @remarks Called with preemption disabled and after first having called
    1520  *          HMR0Enter.
     1516 * @remarks Can be called with preemption enabled if thread-context hooks are
     1517 *          used!!!
    15211518 */
    15221519VMMR0_INT_DECL(int) HMR0RunGuestCode(PVM pVM, PVMCPU pVCpu)
    15231520{
    15241521#ifdef VBOX_STRICT
    1525     PHMGLOBALCPUINFO pCpu = &g_HvmR0.aCpuInfo[RTMpCpuId()];
    1526     Assert(!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL));
    1527     Assert(pCpu->fConfigured);
    1528     AssertReturn(!ASMAtomicReadBool(&g_HvmR0.fSuspended), VERR_HM_SUSPEND_PENDING);
     1522    /* With thread-context hooks we would be running this code with preemption enabled. */
     1523    if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
     1524    {
     1525        PHMGLOBALCPUINFO pCpu = &g_HvmR0.aCpuInfo[RTMpCpuId()];
     1526        Assert(!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL));
     1527        Assert(pCpu->fConfigured);
     1528        AssertReturn(!ASMAtomicReadBool(&g_HvmR0.fSuspended), VERR_HM_SUSPEND_PENDING);
     1529    }
    15291530#endif
    15301531
    15311532#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    15321533    AssertReturn(!VMMR0ThreadCtxHooksAreRegistered(pVCpu), VERR_HM_IPE_4);
     1534    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    15331535    PGMRZDynMapStartAutoSet(pVCpu);
    15341536#endif
     
    16221624VMMR0DECL(PHMGLOBALCPUINFO) HMR0GetCurrentCpu(void)
    16231625{
     1626    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    16241627    RTCPUID idCpu = RTMpCpuId();
    16251628    Assert(idCpu < RT_ELEMENTS(g_HvmR0.aCpuInfo));
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r48421 r48426  
    61976197    {
    61986198        int rc2 = hmR0VmxLeave(pVM, pVCpu, pMixedCtx, true /* fSaveGuestState */);
    6199         AssertRCReturn(rc2, rc2);
     6199        AssertRCReturnStmt(rc2, HM_RESTORE_PREEMPT_IF_NEEDED(), rc2);
    62006200        pVCpu->hm.s.fLeaveDone = true;
    62016201    }
     
    62856285    /* Save guest state and restore host state bits. */
    62866286    int rc = hmR0VmxLeaveSession(pVM, pVCpu, pMixedCtx);
     6287    AssertRCReturn(rc, rc);
    62876288    STAM_COUNTER_DEC(&pVCpu->hm.s.StatSwitchLongJmpToR3);
    62886289
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