VirtualBox

Changeset 68013 in vbox


Ignore:
Timestamp:
Jul 17, 2017 5:59:59 PM (7 years ago)
Author:
vboxsync
Message:

VMMR0,PciRawR0,GVMMR0: More pGVM cleanups.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/gvmm.h

    r68011 r68013  
    167167GVMMR0DECL(int)     GVMMR0DeregisterVCpu(PGVM pGVM, PVM pVM, VMCPUID idCpu);
    168168GVMMR0DECL(PGVM)    GVMMR0ByHandle(uint32_t hGVM);
    169 GVMMR0DECL(int)     GVMMR0ByVM(PVM pVM, PGVM *ppGVM);
    170169GVMMR0DECL(int)     GVMMR0ValidateGVMandVM(PGVM pGVM, PVM pVM);
    171170GVMMR0DECL(int)     GVMMR0ValidateGVMandVMandEMT(PGVM pGVM, PVM pVM, VMCPUID idCpu);
  • trunk/include/VBox/vmm/pdmpci.h

    r65101 r68013  
    349349 * Process request (in R0).
    350350 */
    351 PCIRAWR0DECL(int)  PciRawR0ProcessReq(PSUPDRVSESSION pSession, PVM pVM, PPCIRAWSENDREQ pReq);
     351PCIRAWR0DECL(int)  PciRawR0ProcessReq(PGVM pGVM, PVM pVM, PSUPDRVSESSION pSession, PPCIRAWSENDREQ pReq);
    352352/**
    353353 * Terminate R0 PCI module.
     
    358358 * Per-VM R0 module init.
    359359 */
    360 PCIRAWR0DECL(int)  PciRawR0InitVM(PVM pVM);
     360PCIRAWR0DECL(int)  PciRawR0InitVM(PGVM pGVM, PVM pVM);
    361361
    362362/**
    363363 * Per-VM R0 module termination routine.
    364364 */
    365 PCIRAWR0DECL(void)  PciRawR0TermVM(PVM pVM);
     365PCIRAWR0DECL(void)  PciRawR0TermVM(PGVM pGVM, PVM pVM);
    366366
    367367/**
  • trunk/src/VBox/Devices/Bus/SrvPciRawR0.cpp

    r63562 r68013  
    170170 * Per-VM R0 module init.
    171171 */
    172 PCIRAWR0DECL(int)  PciRawR0InitVM(PVM pVM)
     172PCIRAWR0DECL(int)  PciRawR0InitVM(PGVM pGVM, PVM pVM)
    173173{
    174174    PRAWPCIFACTORY pFactory = NULL;
    175     int            rc;
    176 
    177     rc = SUPR0ComponentQueryFactory(pVM->pSession, "VBoxRawPci", RAWPCIFACTORY_UUID_STR, (void **)&pFactory);
    178 
     175    int rc = SUPR0ComponentQueryFactory(pGVM->pSession, "VBoxRawPci", RAWPCIFACTORY_UUID_STR, (void **)&pFactory);
    179176    if (RT_SUCCESS(rc))
    180177    {
    181178        if (pFactory)
    182179        {
    183             PGVM pGVM = NULL;
    184             rc = GVMMR0ByVM(pVM, &pGVM);
    185             if (RT_SUCCESS(rc))
    186                 rc = pFactory->pfnInitVm(pFactory, pVM, &pGVM->rawpci.s);
     180            rc = pFactory->pfnInitVm(pFactory, pVM, &pGVM->rawpci.s);
    187181            pFactory->pfnRelease(pFactory);
    188182        }
    189183    }
    190 
    191184    return VINF_SUCCESS;
    192185}
     
    195188 * Per-VM R0 module termination routine.
    196189 */
    197 PCIRAWR0DECL(void)  PciRawR0TermVM(PVM pVM)
     190PCIRAWR0DECL(void)  PciRawR0TermVM(PGVM pGVM, PVM pVM)
    198191{
    199192    PRAWPCIFACTORY pFactory = NULL;
    200     int            rc;
    201 
    202     rc = SUPR0ComponentQueryFactory(pVM->pSession, "VBoxRawPci", RAWPCIFACTORY_UUID_STR, (void **)&pFactory);
    203 
     193    int rc = SUPR0ComponentQueryFactory(pGVM->pSession, "VBoxRawPci", RAWPCIFACTORY_UUID_STR, (void **)&pFactory);
    204194    if (RT_SUCCESS(rc))
    205195    {
    206196        if (pFactory)
    207197        {
    208             PGVM pGVM = NULL;
    209             rc = GVMMR0ByVM(pVM, &pGVM);
    210             if (RT_SUCCESS(rc))
    211                 pFactory->pfnDeinitVm(pFactory, pVM, &pGVM->rawpci.s);
     198            pFactory->pfnDeinitVm(pFactory, pVM, &pGVM->rawpci.s);
    212199            pFactory->pfnRelease(pFactory);
    213200        }
     
    501488    return &pNew->DevPort;
    502489}
    503 #endif
     490
     491#endif /* DEBUG_nike */
    504492
    505493static DECLCALLBACK(void) pcirawr0DevObjDestructor(void *pvObj, void *pvIns, void *pvUnused)
     
    518506
    519507
    520 static int pcirawr0OpenDevice(PSUPDRVSESSION   pSession,
    521                               PVM              pVM,
     508static int pcirawr0OpenDevice(PGVM pGVM, PVM pVM, PSUPDRVSESSION pSession,
    522509                              uint32_t         HostDevice,
    523510                              uint32_t         fFlags,
     
    525512                              uint32_t        *pfDevFlags)
    526513{
     514
     515    int rc = GVMMR0ValidateGVMandVMandEMT(pGVM, pVM, 0 /*idCpu*/);
     516    if (RT_FAILURE(rc))
     517        return rc;
     518
    527519    /*
    528520     * Query the factory we want, then use it create and connect the host device.
    529521     */
    530     PRAWPCIFACTORY pFactory = NULL;
    531     PRAWPCIDEVPORT pDevPort = NULL;
    532     int rc;
    533     PPCIRAWDEV     pNew;
    534 
    535     pNew = (PPCIRAWDEV)RTMemAllocZ(sizeof(*pNew));
     522    PPCIRAWDEV pNew = (PPCIRAWDEV)RTMemAllocZ(sizeof(*pNew));
    536523    if (!pNew)
    537524        return VERR_NO_MEMORY;
    538525
    539 
     526    PRAWPCIFACTORY pFactory = NULL;
    540527    rc = SUPR0ComponentQueryFactory(pSession, "VBoxRawPci", RAWPCIFACTORY_UUID_STR, (void **)&pFactory);
    541528    /* No host driver registered, provide some fake implementation
    542529       for debugging purposes. */
     530    PRAWPCIDEVPORT pDevPort = NULL;
    543531#ifdef DEBUG_nike
    544532    if (rc == VERR_SUPDRV_COMPONENT_NOT_FOUND)
     
    559547        if (pFactory)
    560548        {
    561              PGVM pGVM = NULL;
    562              rc = GVMMR0ByVM(pVM, &pGVM);
    563 
    564             if (RT_SUCCESS(rc))
    565                 rc = pFactory->pfnCreateAndConnect(pFactory,
    566                                                    HostDevice,
    567                                                    fFlags,
    568                                                    &pGVM->rawpci.s,
    569                                                    &pDevPort,
    570                                                    pfDevFlags);
     549            rc = pFactory->pfnCreateAndConnect(pFactory,
     550                                               HostDevice,
     551                                               fFlags,
     552                                               &pGVM->rawpci.s,
     553                                               &pDevPort,
     554                                               pfDevFlags);
    571555            pFactory->pfnRelease(pFactory);
    572556        }
     
    576560            rc = RTSpinlockCreate(&pNew->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "PciRaw");
    577561            AssertRC(rc);
    578             rc = RTSemEventCreate(&pNew->hIrqEvent);
    579             AssertRC(rc);
    580 
    581             pNew->pSession = pSession;
    582             pNew->pPort    = pDevPort;
    583             pNew->pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_RAW_PCI_DEVICE,
    584                                            pcirawr0DevObjDestructor, pNew, NULL);
    585 
    586             uint32_t hHandle = 0;
    587             rc = RTHandleTableAllocWithCtx(g_State.hHtDevs, pNew, pSession, &hHandle);
    588562            if (RT_SUCCESS(rc))
    589563            {
    590                 pNew->hHandle = (PCIRAWDEVHANDLE)hHandle;
    591                 *pHandle = pNew->hHandle;
    592             }
    593             else
    594             {
    595                 SUPR0ObjRelease(pNew->pvObj, pSession);
     564                rc = RTSemEventCreate(&pNew->hIrqEvent);
     565                AssertRC(rc);
     566                if (RT_SUCCESS(rc))
     567                {
     568                    pNew->pSession = pSession;
     569                    pNew->pPort    = pDevPort;
     570                    pNew->pvObj    = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_RAW_PCI_DEVICE,
     571                                                      pcirawr0DevObjDestructor, pNew, NULL);
     572                    if (pNew->pvObj)
     573                    {
     574
     575                        uint32_t hHandle = 0;
     576                        rc = RTHandleTableAllocWithCtx(g_State.hHtDevs, pNew, pSession, &hHandle);
     577                        if (RT_SUCCESS(rc))
     578                        {
     579                            pNew->hHandle = (PCIRAWDEVHANDLE)hHandle;
     580                            *pHandle = pNew->hHandle;
     581                            return rc;
     582                        }
     583                        SUPR0ObjRelease(pNew->pvObj, pSession);
     584                    }
     585                    RTSemEventDestroy(pNew->hIrqEvent);
     586                }
    596587                RTSpinlockDestroy(pNew->hSpinlock);
    597                 RTSemEventDestroy(pNew->hIrqEvent);
    598588            }
    599589        }
     
    926916 * @returns VBox status code.
    927917 */
    928 PCIRAWR0DECL(int) PciRawR0ProcessReq(PSUPDRVSESSION pSession, PVM pVM, PPCIRAWSENDREQ pReq)
     918PCIRAWR0DECL(int) PciRawR0ProcessReq(PGVM pGVM, PVM pVM, PSUPDRVSESSION pSession, PPCIRAWSENDREQ pReq)
    929919{
    930920    LogFlow(("PciRawR0ProcessReq: %d for %x\n", pReq->iRequest, pReq->TargetDevice));
     
    935925    {
    936926        case PCIRAWR0_DO_OPEN_DEVICE:
    937             rc = pcirawr0OpenDevice(pSession, pVM,
     927            rc = pcirawr0OpenDevice(pGVM, pVM, pSession,
    938928                                    pReq->u.aOpenDevice.PciAddress,
    939929                                    pReq->u.aOpenDevice.fFlags,
     
    10391029    return rc;
    10401030}
     1031
  • trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp

    r68011 r68013  
    17241724
    17251725/**
    1726  * Lookup a GVM structure by the shared VM structure.
    1727  *
    1728  * @returns VBox status code.
    1729  * @param   pVM         The cross context VM structure.
    1730  * @param   ppGVM       Where to store the GVM pointer.
    1731  *
    1732  * @remark  This will not take the 'used'-lock because it doesn't do
    1733  *          nesting and this function will be used from under the lock.
    1734  *          Update: This is no longer true.  Consider taking the lock in shared
    1735  *          mode!
    1736  */
    1737 GVMMR0DECL(int) GVMMR0ByVM(PVM pVM, PGVM *ppGVM)
    1738 {
    1739     PGVMM pGVMM;
    1740     return gvmmR0ByVM(pVM, ppGVM, &pGVMM, false /* fTakeUsedLock */);
    1741 }
    1742 
    1743 
    1744 /**
    17451726 * Check that the given GVM and VM structures match up.
    17461727 *
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r68011 r68013  
    462462                    VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    463463#ifdef VBOX_WITH_PCI_PASSTHROUGH
    464                     rc = PciRawR0InitVM(pVM);
     464                    rc = PciRawR0InitVM(pGVM, pVM);
    465465#endif
    466466                    if (RT_SUCCESS(rc))
     
    482482                        }
    483483#ifdef VBOX_WITH_PCI_PASSTHROUGH
    484                         PciRawR0TermVM(pVM);
     484                        PciRawR0TermVM(pGVM, pVM);
    485485#endif
    486486                    }
     
    525525
    526526#ifdef VBOX_WITH_PCI_PASSTHROUGH
    527     PciRawR0TermVM(pVM);
     527    PciRawR0TermVM(pGVM, pVM);
    528528#endif
    529529
     
    19401940            if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PPCIRAWSENDREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID)
    19411941                return VERR_INVALID_PARAMETER;
    1942             rc = PciRawR0ProcessReq(pSession, pVM, (PPCIRAWSENDREQ)pReqHdr);
     1942            rc = PciRawR0ProcessReq(pGVM, pVM, pSession, (PPCIRAWSENDREQ)pReqHdr);
    19431943            VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    19441944            break;
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