Changeset 68013 in vbox
- Timestamp:
- Jul 17, 2017 5:59:59 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
include/VBox/vmm/gvmm.h (modified) (1 diff)
-
include/VBox/vmm/pdmpci.h (modified) (2 diffs)
-
src/VBox/Devices/Bus/SrvPciRawR0.cpp (modified) (10 diffs)
-
src/VBox/VMM/VMMR0/GVMMR0.cpp (modified) (1 diff)
-
src/VBox/VMM/VMMR0/VMMR0.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/gvmm.h
r68011 r68013 167 167 GVMMR0DECL(int) GVMMR0DeregisterVCpu(PGVM pGVM, PVM pVM, VMCPUID idCpu); 168 168 GVMMR0DECL(PGVM) GVMMR0ByHandle(uint32_t hGVM); 169 GVMMR0DECL(int) GVMMR0ByVM(PVM pVM, PGVM *ppGVM);170 169 GVMMR0DECL(int) GVMMR0ValidateGVMandVM(PGVM pGVM, PVM pVM); 171 170 GVMMR0DECL(int) GVMMR0ValidateGVMandVMandEMT(PGVM pGVM, PVM pVM, VMCPUID idCpu); -
trunk/include/VBox/vmm/pdmpci.h
r65101 r68013 349 349 * Process request (in R0). 350 350 */ 351 PCIRAWR0DECL(int) PciRawR0ProcessReq(P SUPDRVSESSION pSession, PVM pVM, PPCIRAWSENDREQ pReq);351 PCIRAWR0DECL(int) PciRawR0ProcessReq(PGVM pGVM, PVM pVM, PSUPDRVSESSION pSession, PPCIRAWSENDREQ pReq); 352 352 /** 353 353 * Terminate R0 PCI module. … … 358 358 * Per-VM R0 module init. 359 359 */ 360 PCIRAWR0DECL(int) PciRawR0InitVM(P VM pVM);360 PCIRAWR0DECL(int) PciRawR0InitVM(PGVM pGVM, PVM pVM); 361 361 362 362 /** 363 363 * Per-VM R0 module termination routine. 364 364 */ 365 PCIRAWR0DECL(void) PciRawR0TermVM(P VM pVM);365 PCIRAWR0DECL(void) PciRawR0TermVM(PGVM pGVM, PVM pVM); 366 366 367 367 /** -
trunk/src/VBox/Devices/Bus/SrvPciRawR0.cpp
r63562 r68013 170 170 * Per-VM R0 module init. 171 171 */ 172 PCIRAWR0DECL(int) PciRawR0InitVM(P VM pVM)172 PCIRAWR0DECL(int) PciRawR0InitVM(PGVM pGVM, PVM pVM) 173 173 { 174 174 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); 179 176 if (RT_SUCCESS(rc)) 180 177 { 181 178 if (pFactory) 182 179 { 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); 187 181 pFactory->pfnRelease(pFactory); 188 182 } 189 183 } 190 191 184 return VINF_SUCCESS; 192 185 } … … 195 188 * Per-VM R0 module termination routine. 196 189 */ 197 PCIRAWR0DECL(void) PciRawR0TermVM(P VM pVM)190 PCIRAWR0DECL(void) PciRawR0TermVM(PGVM pGVM, PVM pVM) 198 191 { 199 192 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); 204 194 if (RT_SUCCESS(rc)) 205 195 { 206 196 if (pFactory) 207 197 { 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); 212 199 pFactory->pfnRelease(pFactory); 213 200 } … … 501 488 return &pNew->DevPort; 502 489 } 503 #endif 490 491 #endif /* DEBUG_nike */ 504 492 505 493 static DECLCALLBACK(void) pcirawr0DevObjDestructor(void *pvObj, void *pvIns, void *pvUnused) … … 518 506 519 507 520 static int pcirawr0OpenDevice(PSUPDRVSESSION pSession, 521 PVM pVM, 508 static int pcirawr0OpenDevice(PGVM pGVM, PVM pVM, PSUPDRVSESSION pSession, 522 509 uint32_t HostDevice, 523 510 uint32_t fFlags, … … 525 512 uint32_t *pfDevFlags) 526 513 { 514 515 int rc = GVMMR0ValidateGVMandVMandEMT(pGVM, pVM, 0 /*idCpu*/); 516 if (RT_FAILURE(rc)) 517 return rc; 518 527 519 /* 528 520 * Query the factory we want, then use it create and connect the host device. 529 521 */ 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)); 536 523 if (!pNew) 537 524 return VERR_NO_MEMORY; 538 525 539 526 PRAWPCIFACTORY pFactory = NULL; 540 527 rc = SUPR0ComponentQueryFactory(pSession, "VBoxRawPci", RAWPCIFACTORY_UUID_STR, (void **)&pFactory); 541 528 /* No host driver registered, provide some fake implementation 542 529 for debugging purposes. */ 530 PRAWPCIDEVPORT pDevPort = NULL; 543 531 #ifdef DEBUG_nike 544 532 if (rc == VERR_SUPDRV_COMPONENT_NOT_FOUND) … … 559 547 if (pFactory) 560 548 { 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); 571 555 pFactory->pfnRelease(pFactory); 572 556 } … … 576 560 rc = RTSpinlockCreate(&pNew->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "PciRaw"); 577 561 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);588 562 if (RT_SUCCESS(rc)) 589 563 { 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 } 596 587 RTSpinlockDestroy(pNew->hSpinlock); 597 RTSemEventDestroy(pNew->hIrqEvent);598 588 } 599 589 } … … 926 916 * @returns VBox status code. 927 917 */ 928 PCIRAWR0DECL(int) PciRawR0ProcessReq(P SUPDRVSESSION pSession, PVM pVM, PPCIRAWSENDREQ pReq)918 PCIRAWR0DECL(int) PciRawR0ProcessReq(PGVM pGVM, PVM pVM, PSUPDRVSESSION pSession, PPCIRAWSENDREQ pReq) 929 919 { 930 920 LogFlow(("PciRawR0ProcessReq: %d for %x\n", pReq->iRequest, pReq->TargetDevice)); … … 935 925 { 936 926 case PCIRAWR0_DO_OPEN_DEVICE: 937 rc = pcirawr0OpenDevice(p Session, pVM,927 rc = pcirawr0OpenDevice(pGVM, pVM, pSession, 938 928 pReq->u.aOpenDevice.PciAddress, 939 929 pReq->u.aOpenDevice.fFlags, … … 1039 1029 return rc; 1040 1030 } 1031 -
trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp
r68011 r68013 1724 1724 1725 1725 /** 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 do1733 * nesting and this function will be used from under the lock.1734 * Update: This is no longer true. Consider taking the lock in shared1735 * 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 /**1745 1726 * Check that the given GVM and VM structures match up. 1746 1727 * -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r68011 r68013 462 462 VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 463 463 #ifdef VBOX_WITH_PCI_PASSTHROUGH 464 rc = PciRawR0InitVM(p VM);464 rc = PciRawR0InitVM(pGVM, pVM); 465 465 #endif 466 466 if (RT_SUCCESS(rc)) … … 482 482 } 483 483 #ifdef VBOX_WITH_PCI_PASSTHROUGH 484 PciRawR0TermVM(p VM);484 PciRawR0TermVM(pGVM, pVM); 485 485 #endif 486 486 } … … 525 525 526 526 #ifdef VBOX_WITH_PCI_PASSTHROUGH 527 PciRawR0TermVM(p VM);527 PciRawR0TermVM(pGVM, pVM); 528 528 #endif 529 529 … … 1940 1940 if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PPCIRAWSENDREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID) 1941 1941 return VERR_INVALID_PARAMETER; 1942 rc = PciRawR0ProcessReq(p Session, pVM, (PPCIRAWSENDREQ)pReqHdr);1942 rc = PciRawR0ProcessReq(pGVM, pVM, pSession, (PPCIRAWSENDREQ)pReqHdr); 1943 1943 VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING); 1944 1944 break;
Note:
See TracChangeset
for help on using the changeset viewer.

