VirtualBox

Changeset 87760 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Feb 15, 2021 10:45:27 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142814
Message:

VMM/TM,VMM/DevHlp: Require flag on timers that are to be used in ring-0 (and while refactoring a counte flag to check that all timers have been checked). Removed obsolete timer device helpers. bugref:9943

Location:
trunk/src/VBox/VMM/VMMR3
Files:
5 edited

Legend:

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

    r87519 r87760  
    15021502        PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu);
    15031503        RTStrPrintf(&pApicCpu->szTimerDesc[0], sizeof(pApicCpu->szTimerDesc), "APIC Timer %u", pVCpu->idCpu);
    1504         rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, apicR3TimerCallback, pVCpu, TMTIMER_FLAGS_NO_CRIT_SECT,
    1505                                   pApicCpu->szTimerDesc, &pApicCpu->hTimer);
     1504        rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, apicR3TimerCallback, pVCpu,
     1505                                  TMTIMER_FLAGS_NO_CRIT_SECT | TMTIMER_FLAGS_RING0, pApicCpu->szTimerDesc, &pApicCpu->hTimer);
    15061506        AssertRCReturn(rc, rc);
    15071507    }
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r87494 r87760  
    412412
    413413
    414 /** @interface_method_impl{PDMDEVHLPR3,pfnTMTimerCreate} */
    415 static DECLCALLBACK(int) pdmR3DevHlp_TMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
     414/** @interface_method_impl{PDMDEVHLPR3,pfnTimerCreate} */
     415static DECLCALLBACK(int) pdmR3DevHlp_TimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback,
     416                                                 void *pvUser, uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer)
    416417{
    417418    PDMDEV_ASSERT_DEVINS(pDevIns);
    418419    PVM pVM = pDevIns->Internal.s.pVMR3;
    419420    VM_ASSERT_EMT(pVM);
    420     LogFlow(("pdmR3DevHlp_TMTimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pvUser=%p fFlags=%#x pszDesc=%p:{%s} ppTimer=%p\n",
    421              pDevIns->pReg->szName, pDevIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, ppTimer));
     421    LogFlow(("pdmR3DevHlp_TimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pvUser=%p fFlags=%#x pszDesc=%p:{%s} phTimer=%p\n",
     422             pDevIns->pReg->szName, pDevIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, phTimer));
    422423
    423424    if (pDevIns->iInstance > 0) /** @todo use a string cache here later. */
     
    428429    }
    429430
    430     int rc = TMR3TimerCreateDevice(pVM, pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
    431 
    432     LogFlow(("pdmR3DevHlp_TMTimerCreate: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
    433     return rc;
    434 }
    435 
    436 
    437 
    438 /** @interface_method_impl{PDMDEVHLPR3,pfnTimerCreate} */
    439 static DECLCALLBACK(int) pdmR3DevHlp_TimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback,
    440                                                  void *pvUser, uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer)
    441 {
    442     PDMDEV_ASSERT_DEVINS(pDevIns);
    443     PVM pVM = pDevIns->Internal.s.pVMR3;
    444     VM_ASSERT_EMT(pVM);
    445     LogFlow(("pdmR3DevHlp_TimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pvUser=%p fFlags=%#x pszDesc=%p:{%s} phTimer=%p\n",
    446              pDevIns->pReg->szName, pDevIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, phTimer));
    447 
    448     if (pDevIns->iInstance > 0) /** @todo use a string cache here later. */
    449     {
    450          char *pszDesc2 = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s[%u]", pszDesc, pDevIns->iInstance);
    451          if (pszDesc2)
    452              pszDesc = pszDesc2;
    453     }
     431    /* Clear the ring-0 flag if the device isn't configured for ring-0. */
     432    if (fFlags & TMTIMER_FLAGS_RING0)
     433    {
     434        Assert(pDevIns->Internal.s.pDevR3->pReg->fFlags & PDM_DEVREG_FLAGS_R0);
     435        if (!(pDevIns->Internal.s.fIntFlags & PDMDEVINSINT_FLAGS_R0_ENABLED))
     436            fFlags &= ~TMTIMER_FLAGS_RING0;
     437    }
     438    else
     439        Assert(fFlags & TMTIMER_FLAGS_NO_RING0 /* just to make sure all devices has been considered */);
    454440
    455441    PTMTIMER pTimer = NULL;
     
    462448
    463449
    464 /** @interface_method_impl{PDMDEVHLPR3,pfnTimerToPtr} */
    465 static DECLCALLBACK(PTMTIMERR3) pdmR3DevHlp_TimerToPtr(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
     450/** Converts timer handle to pointer (used to exposed, will be replace soon.) */
     451DECLINLINE(PTMTIMERR3) pdmR3DevHlp_TimerToPtr(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer)
    466452{
    467453    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    41894175    SSMR3HandleVersion,
    41904176    SSMR3HandleHostOSAndArch,
    4191     pdmR3DevHlp_TMTimerCreate,
    41924177    pdmR3DevHlp_TimerCreate,
    4193     pdmR3DevHlp_TimerToPtr,
    41944178    pdmR3DevHlp_TimerFromMicro,
    41954179    pdmR3DevHlp_TimerFromMilli,
     
    45384522    SSMR3HandleVersion,
    45394523    SSMR3HandleHostOSAndArch,
    4540     pdmR3DevHlp_TMTimerCreate,
    45414524    pdmR3DevHlp_TimerCreate,
    4542     pdmR3DevHlp_TimerToPtr,
    45434525    pdmR3DevHlp_TimerFromMicro,
    45444526    pdmR3DevHlp_TimerFromMilli,
     
    47764758    PDM_DEVHLPR3_VERSION /* the end */
    47774759};
    4778 #endif
     4760#endif /* VBOX_WITH_DBGF_TRACING */
    47794761
    47804762
     
    50445026    SSMR3HandleVersion,
    50455027    SSMR3HandleHostOSAndArch,
    5046     pdmR3DevHlp_TMTimerCreate,
    50475028    pdmR3DevHlp_TimerCreate,
    5048     pdmR3DevHlp_TimerToPtr,
    50495029    pdmR3DevHlp_TimerFromMicro,
    50505030    pdmR3DevHlp_TimerFromMilli,
  • trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp

    r82968 r87760  
    13241324    LogFlow(("pdmR3DrvHlp_TMTimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pvUser=%p fFlags=%#x pszDesc=%p:{%s} ppTimer=%p\n",
    13251325             pDrvIns->pReg->szName, pDrvIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, ppTimer));
     1326
     1327    /* Clear the ring-0 flag if the driver isn't configured for ring-0. */
     1328    if (fFlags & TMTIMER_FLAGS_RING0)
     1329    {
     1330        Assert(pDrvIns->Internal.s.pDrv->pReg->fFlags & PDM_DRVREG_FLAGS_R0);
     1331        /** @todo if (!(pDrvIns->Internal.s.fIntFlags & PDMDRVINSINT_FLAGS_R0_ENABLED))   */
     1332            fFlags &= ~TMTIMER_FLAGS_RING0;
     1333    }
    13261334
    13271335    int rc = TMR3TimerCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
  • trunk/src/VBox/VMM/VMMR3/PDMUsb.cpp

    r83196 r87760  
    18291829    if (pszDesc2)
    18301830        pszDesc = pszDesc2;
     1831
     1832    AssertStmt(!(fFlags & TMTIMER_FLAGS_RING0), fFlags &= ~TMTIMER_FLAGS_RING0);
    18311833
    18321834    int rc = TMR3TimerCreateUsb(pVM, pUsbIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
  • trunk/src/VBox/VMM/VMMR3/TM.cpp

    r87748 r87760  
    15081508 * @param   pVM         The cross context VM structure.
    15091509 * @param   enmClock    The timer clock.
     1510 * @param   fFlags      TMTIMER_FLAGS_XXX.
    15101511 * @param   pszDesc     The timer description.
    15111512 * @param   ppTimer     Where to store the timer pointer on success.
    15121513 */
    1513 static int tmr3TimerCreate(PVM pVM, TMCLOCK enmClock, const char *pszDesc, PPTMTIMERR3 ppTimer)
     1514static int tmr3TimerCreate(PVM pVM, TMCLOCK enmClock, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
    15141515{
    15151516    VM_ASSERT_EMT(pVM);
     
    15491550    pTimer->pCritSect       = NULL;
    15501551    pTimer->pszDesc         = pszDesc;
     1552    pTimer->fFlags          = fFlags;
    15511553
    15521554    /* insert into the list of created timers. */
     
    16041606                                        uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
    16051607{
    1606     AssertReturn(!(fFlags & ~(TMTIMER_FLAGS_NO_CRIT_SECT)), VERR_INVALID_PARAMETER);
     1608    AssertReturn(!(fFlags & ~(TMTIMER_FLAGS_NO_CRIT_SECT | TMTIMER_FLAGS_RING0 | TMTIMER_FLAGS_NO_RING0)),
     1609                 VERR_INVALID_FLAGS);
    16071610
    16081611    /*
    16091612     * Allocate and init stuff.
    16101613     */
    1611     int rc = tmr3TimerCreate(pVM, enmClock, pszDesc, ppTimer);
     1614    int rc = tmr3TimerCreate(pVM, enmClock, fFlags, pszDesc, ppTimer);
    16121615    if (RT_SUCCESS(rc))
    16131616    {
     
    16451648                                     uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
    16461649{
    1647     AssertReturn(!(fFlags & ~(TMTIMER_FLAGS_NO_CRIT_SECT)), VERR_INVALID_PARAMETER);
     1650    AssertReturn(!(fFlags & ~(TMTIMER_FLAGS_NO_CRIT_SECT | TMTIMER_FLAGS_NO_RING0)), VERR_INVALID_PARAMETER);
    16481651
    16491652    /*
    16501653     * Allocate and init stuff.
    16511654     */
    1652     int rc = tmr3TimerCreate(pVM, enmClock, pszDesc, ppTimer);
     1655    int rc = tmr3TimerCreate(pVM, enmClock, fFlags, pszDesc, ppTimer);
    16531656    if (RT_SUCCESS(rc))
    16541657    {
     
    16881691                                        uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
    16891692{
    1690     AssertReturn(!(fFlags & ~(TMTIMER_FLAGS_NO_CRIT_SECT)), VERR_INVALID_PARAMETER);
     1693    AssertReturn(!(fFlags & ~(TMTIMER_FLAGS_NO_CRIT_SECT | TMTIMER_FLAGS_RING0 | TMTIMER_FLAGS_NO_RING0)),
     1694                 VERR_INVALID_FLAGS);
    16911695
    16921696    /*
    16931697     * Allocate and init stuff.
    16941698     */
    1695     int rc = tmr3TimerCreate(pVM, enmClock, pszDesc, ppTimer);
     1699    int rc = tmr3TimerCreate(pVM, enmClock, fFlags, pszDesc, ppTimer);
    16961700    if (RT_SUCCESS(rc))
    16971701    {
     
    17191723 * @param   ppTimer         Where to store the timer on success.
    17201724 */
    1721 VMMR3DECL(int) TMR3TimerCreateInternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERR3 ppTimer)
     1725VMMR3DECL(int) TMR3TimerCreateInternal(PVM pVM, TMCLOCK enmClock,
     1726                                       PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERR3 ppTimer)
    17221727{
    17231728    /*
     
    17251730     */
    17261731    PTMTIMER pTimer;
    1727     int rc = tmr3TimerCreate(pVM, enmClock, pszDesc, &pTimer);
     1732    int rc = tmr3TimerCreate(pVM, enmClock, 0 /*fFlags*/, pszDesc, &pTimer);
    17281733    if (RT_SUCCESS(rc))
    17291734    {
     
    17501755 *                          until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
    17511756 */
    1752 VMMR3DECL(PTMTIMERR3) TMR3TimerCreateExternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc)
     1757VMMR3DECL(PTMTIMERR3) TMR3TimerCreateExternal(PVM pVM, TMCLOCK enmClock,
     1758                                              PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc)
    17531759{
    17541760    /*
     
    17561762     */
    17571763    PTMTIMERR3 pTimer;
    1758     int rc = tmr3TimerCreate(pVM, enmClock, pszDesc, &pTimer);
     1764    int rc = tmr3TimerCreate(pVM, enmClock, 0 /*fFlags*/, pszDesc, &pTimer);
    17591765    if (RT_SUCCESS(rc))
    17601766    {
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