VirtualBox

Changeset 55490 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Apr 28, 2015 3:42:11 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99839
Message:

PDMLdr.cpp: Relax the initialization order requirements.

File:
1 edited

Legend:

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

    r52213 r55490  
    102102    PVM pVM = pUVM->pVM; AssertPtr(pVM);
    103103    if (!HMIsEnabled(pVM))
    104         return PDMR3LdrLoadRC(pVM, NULL, VMMGC_MAIN_MODULE_NAME);
     104    {
     105        int rc = PDMR3LdrLoadRC(pVM, NULL, VMMGC_MAIN_MODULE_NAME);
     106        if (RT_FAILURE(rc))
     107            return rc;
     108    }
    105109#endif
    106110    return VINF_SUCCESS;
     
    246250     * Validate input.
    247251     */
    248     AssertMsg(PDMCritSectIsInitialized(&pUVM->pVM->pdm.s.CritSect), ("bad init order!\n"));
     252    AssertMsg(RTCritSectIsInitialized(&pUVM->pdm.s.ListCritSect), ("bad init order!\n"));
    249253    Assert(pszFilename);
    250254    size_t cchFilename = strlen(pszFilename);
     
    439443 *
    440444 * @returns VBox status code.
     445 * @retval  VINF_PDM_ALREADY_LOADED if the module is already loaded (name +
     446 *          filename match).
     447 * @retval  VERR_PDM_MODULE_NAME_CLASH if a different file has already been
     448 *          loaded with the name module name.
     449 *
    441450 * @param   pVM             The VM to load it into.
    442451 * @param   pszFilename     Filename of the module binary.
     
    448457     * Validate input.
    449458     */
    450     AssertMsg(PDMCritSectIsInitialized(&pVM->pdm.s.CritSect), ("bad init order!\n"));
     459    AssertMsg(MMR3IsInitialized(pVM), ("bad init order!\n"));
    451460    AssertReturn(!HMIsEnabled(pVM), VERR_PDM_HM_IPE);
    452 
    453     PUVM     pUVM = pVM->pUVM;
    454     RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
    455     PPDMMOD  pCur = pUVM->pdm.s.pModules;
    456     while (pCur)
    457     {
    458         if (!strcmp(pCur->szName, pszName))
    459         {
    460             RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    461             AssertMsgFailed(("We've already got a module '%s' loaded!\n", pszName));
    462             return VERR_PDM_MODULE_NAME_CLASH;
    463         }
    464         /* next */
    465         pCur = pCur->pNext;
    466     }
    467461
    468462    /*
     
    474468
    475469    /*
     470     * Check if a module by that name is already loaded.
     471     */
     472    int     rc;
     473    PUVM    pUVM = pVM->pUVM;
     474    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     475    PPDMMOD pCur = pUVM->pdm.s.pModules;
     476    while (pCur)
     477    {
     478        if (!strcmp(pCur->szName, pszName))
     479        {
     480            /* Name clash. Hopefully due to it being the same file. */
     481            if (!strcmp(pCur->szFilename, pszFilename))
     482                rc = VINF_PDM_ALREADY_LOADED;
     483            else
     484            {
     485                rc = VERR_PDM_MODULE_NAME_CLASH;
     486                AssertMsgFailed(("We've already got a module '%s' loaded!\n", pszName));
     487            }
     488            RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
     489            RTMemTmpFree(pszFile);
     490            return rc;
     491        }
     492        /* next */
     493        pCur = pCur->pNext;
     494    }
     495
     496    /*
    476497     * Allocate the module list node.
    477498     */
    478     PPDMMOD     pModule = (PPDMMOD)RTMemAllocZ(sizeof(*pModule) + strlen(pszFilename));
     499    PPDMMOD pModule = (PPDMMOD)RTMemAllocZ(sizeof(*pModule) + strlen(pszFilename));
    479500    if (!pModule)
    480501    {
     
    495516    RTERRINFOSTATIC ErrInfo;
    496517    RTErrInfoInitStatic(&ErrInfo);
    497     int rc = SUPR3HardenedVerifyPlugIn(pszFilename, &ErrInfo.Core);
     518    rc = SUPR3HardenedVerifyPlugIn(pszFilename, &ErrInfo.Core);
    498519    if (RT_SUCCESS(rc))
    499520    {
     
    727748    AssertPtr(pszModule);
    728749    AssertPtr(ppvValue);
    729     AssertMsg(PDMCritSectIsInitialized(&pVM->pdm.s.CritSect), ("bad init order!\n"));
     750    PUVM pUVM = pVM->pUVM;
     751    AssertMsg(RTCritSectIsInitialized(&pUVM->pdm.s.ListCritSect), ("bad init order!\n"));
    730752
    731753    /*
    732754     * Find the module.
    733755     */
    734     PUVM pUVM = pVM->pUVM;
    735756    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
    736757    for (PPDMMOD pModule = pUVM->pdm.s.pModules; pModule; pModule = pModule->pNext)
     
    786807    AssertPtrNull(pszModule);
    787808    AssertPtr(ppvValue);
    788     AssertMsg(PDMCritSectIsInitialized(&pVM->pdm.s.CritSect), ("bad init order!\n"));
     809    PUVM pUVM = pVM->pUVM;
     810    AssertMsg(RTCritSectIsInitialized(&pUVM->pdm.s.ListCritSect), ("bad init order!\n"));
    789811
    790812    if (!pszModule)
     
    794816     * Find the module.
    795817     */
    796     PUVM pUVM = pVM->pUVM;
    797818    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
    798819    for (PPDMMOD pModule = pUVM->pdm.s.pModules; pModule; pModule = pModule->pNext)
     
    842863    AssertPtrNull(pszModule);
    843864    AssertPtr(ppvValue);
    844     AssertMsg(PDMCritSectIsInitialized(&pVM->pdm.s.CritSect), ("bad init order!\n"));
     865    PUVM pUVM = pVM->pUVM;
     866    AssertMsg(RTCritSectIsInitialized(&pUVM->pdm.s.ListCritSect), ("bad init order!\n"));
    845867
    846868    /*
     
    851873    {
    852874        AssertMsgReturn(!strpbrk(pszModule, "/\\:\n\r\t"), ("pszModule=%s\n", pszModule), VERR_INVALID_PARAMETER);
    853         PUVM    pUVM = pVM->pUVM;
    854875        PPDMMOD pModule;
    855876        RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     
    894915    AssertPtrNull(pszModule);
    895916    AssertPtr(pRCPtrValue);
    896     AssertMsg(PDMCritSectIsInitialized(&pVM->pdm.s.CritSect), ("bad init order!\n"));
     917    AssertMsg(MMR3IsInitialized(pVM), ("bad init order!\n"));
    897918
    898919    if (!pszModule)
     
    959980    AssertPtrNull(pszModule);
    960981    AssertPtr(pRCPtrValue);
    961     AssertMsg(PDMCritSectIsInitialized(&pVM->pdm.s.CritSect), ("bad init order!\n"));
     982    AssertMsg(MMR3IsInitialized(pVM), ("bad init order!\n"));
    962983
    963984    /*
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