Changeset 82210 in vbox
- Timestamp:
- Nov 26, 2019 12:27:40 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/gim.h
r80281 r82210 92 92 /** The guest-physical address of the first page in the region. */ 93 93 RTGCPHYS GCPhysPage; 94 /** The MMIO2 handle. */ 95 PGMMMIO2HANDLE hMmio2; 94 96 /** The description of the region. */ 95 97 char szDescription[32]; … … 182 184 VMMR3DECL(void) GIMR3GimDeviceRegister(PVM pVM, PPDMDEVINS pDevInsR3, PGIMDEBUG pDbg); 183 185 VMMR3DECL(int) GIMR3GetDebugSetup(PVM pVM, PGIMDEBUGSETUP pDbgSetup); 184 VMMR3DECL(PGIMMMIO2REGION) GIMR3GetMmio2Regions(PVM pVM, uint32_t *pcRegions);185 186 /** @} */ 186 187 #endif /* IN_RING3 */ … … 188 189 VMMDECL(bool) GIMIsEnabled(PVM pVM); 189 190 VMMDECL(GIMPROVIDERID) GIMGetProvider(PVM pVM); 191 VMMDECL(PGIMMMIO2REGION) GIMGetMmio2Regions(PVMCC pVM, uint32_t *pcRegions); 190 192 VMM_INT_DECL(bool) GIMIsParavirtTscEnabled(PVMCC pVM); 191 193 VMM_INT_DECL(bool) GIMAreHypercallsEnabled(PVMCPUCC pVCpu); -
trunk/src/VBox/Devices/GIMDev/GIMDev.cpp
r82209 r82210 206 206 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); 207 207 PGIMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGIMDEV); 208 PVM pVM = PDMDevHlpGetVM(pDevIns);209 210 uint32_t cRegions = 0;211 PGIMMMIO2REGION pCur = GIMR3GetMmio2Regions(pVM, &cRegions);212 for (uint32_t i = 0; i < cRegions; i++, pCur++)213 {214 int rc = PDMDevHlpMMIOExDeregister(pDevIns, NULL, pCur->iRegion);215 if (RT_FAILURE(rc))216 return rc;217 }218 208 219 209 /* … … 260 250 { 261 251 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 252 PGIMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGIMDEV); 262 253 RT_NOREF2(iInstance, pCfg); 254 263 255 Assert(iInstance == 0); 264 PGIMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGIMDEV);265 256 266 257 /* … … 274 265 * Get debug setup requirements from GIM. 275 266 */ 276 PVM pVM = PDMDevHlpGetVM(pDevIns);267 PVMCC pVM = PDMDevHlpGetVM(pDevIns); 277 268 int rc = GIMR3GetDebugSetup(pVM, &pThis->DbgSetup); 278 269 if ( RT_SUCCESS(rc) … … 348 339 349 340 /* 350 * Get the MMIO2 regions from the GIM provider. 351 */ 352 uint32_t cRegions = 0; 353 PGIMMMIO2REGION pRegionsR3 = GIMR3GetMmio2Regions(pVM, &cRegions); 341 * Get the MMIO2 regions from the GIM provider and make the registrations. 342 */ 343 /** @todo r=bird: consider ditching this as GIM doesn't actually make use of it */ 344 uint32_t cRegions = 0; 345 PGIMMMIO2REGION paRegions = GIMGetMmio2Regions(pVM, &cRegions); 354 346 if ( cRegions 355 && pRegionsR3) 356 { 357 /* 358 * Register the MMIO2 regions. 359 */ 360 PGIMMMIO2REGION pCur = pRegionsR3; 361 for (uint32_t i = 0; i < cRegions; i++, pCur++) 362 { 363 Assert(!pCur->fRegistered); 364 rc = PDMDevHlpMMIO2Register(pDevIns, NULL, pCur->iRegion, pCur->cbRegion, 0 /* fFlags */, &pCur->pvPageR3, 365 pCur->szDescription); 366 if (RT_FAILURE(rc)) 367 return rc; 368 347 && paRegions) 348 { 349 for (uint32_t i = 0; i < cRegions; i++) 350 { 351 PGIMMMIO2REGION pCur = &paRegions[i]; 352 Assert(pCur->iRegion < 8); 353 rc = PDMDevHlpMmio2Create(pDevIns, NULL, pCur->iRegion << 16, pCur->cbRegion, 0 /* fFlags */, pCur->szDescription, 354 &pCur->pvPageR3, &pCur->hMmio2); 355 AssertLogRelMsgRCReturn(rc, ("rc=%Rrc iRegion=%u cbRegion=%#x %s\n", 356 rc, pCur->iRegion, pCur->cbRegion, pCur->szDescription), 357 rc); 369 358 pCur->fRegistered = true; 370 371 #if defined(VBOX_WITH_2X_4GB_ADDR_SPACE) 372 RTR0PTR pR0Mapping = 0; 373 rc = PDMDevHlpMMIO2MapKernel(pDevIns, NULL, pCur->iRegion, 0 /* off */, pCur->cbRegion, pCur->szDescription, 374 &pR0Mapping); 375 AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMapMMIO2IntoR0(%#x,) -> %Rrc\n", pCur->cbRegion, rc), rc); 376 pCur->pvPageR0 = pR0Mapping; 377 #else 378 pCur->pvPageR0 = (RTR0PTR)pCur->pvPageR3; 379 #endif 380 381 #ifdef VBOX_WITH_RAW_MODE_KEEP 382 /* 383 * Map into RC if required. 384 */ 385 if (pCur->fRCMapping) 386 { 387 RTRCPTR pRCMapping = 0; 388 rc = PDMDevHlpMMHyperMapMMIO2(pDevIns, NULL, pCur->iRegion, 0 /* off */, pCur->cbRegion, pCur->szDescription, 389 &pRCMapping); 390 AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMMHyperMapMMIO2(%#x,) -> %Rrc\n", pCur->cbRegion, rc), rc); 391 pCur->pvPageRC = pRCMapping; 392 } 393 else 394 pCur->pvPageRC = NIL_RTRCPTR; 395 #endif 359 pCur->pvPageR0 = NIL_RTR0PTR; 360 # ifdef VBOX_WITH_RAW_MODE_KEEP 361 pCur->pvPageRC = NIL_RTRCPTR; 362 # endif 396 363 397 364 LogRel(("GIMDev: Registered %s\n", pCur->szDescription)); 398 365 } 399 366 } 367 else 368 Assert(cRegions == 0); 400 369 401 370 /** @todo Register SSM: PDMDevHlpSSMRegister(). */ … … 407 376 408 377 409 #endif /* IN_RING3 */ 378 #else /* !IN_RING3 */ 379 380 /** 381 * @callback_method_impl{PDMDEVREGR0,pfnConstruct} 382 */ 383 static DECLCALLBACK(int) gimdevRZConstruct(PPDMDEVINS pDevIns) 384 { 385 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 386 //PGIMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGIMDEV); 387 388 /* 389 * Map the MMIO2 regions into the context. 390 */ 391 /** @todo r=bird: consider ditching this as GIM doesn't actually make use of it */ 392 PVMCC pVM = PDMDevHlpGetVM(pDevIns); 393 uint32_t cRegions = 0; 394 PGIMMMIO2REGION paRegions = GIMGetMmio2Regions(pVM, &cRegions); 395 if ( cRegions 396 && paRegions) 397 { 398 for (uint32_t i = 0; i < cRegions; i++) 399 { 400 PGIMMMIO2REGION pCur = &paRegions[i]; 401 int rc = PDMDevHlpMmio2SetUpContext(pDevIns, pCur->hMmio2, 0, 0, &pCur->CTX_SUFF(pvPage)); 402 AssertLogRelMsgRCReturn(rc, ("rc=%Rrc iRegion=%u cbRegion=%#x %s\n", 403 rc, pCur->iRegion, pCur->cbRegion, pCur->szDescription), 404 rc); 405 Assert(pCur->fRegistered); 406 } 407 } 408 else 409 Assert(cRegions == 0); 410 411 return VINF_SUCCESS; 412 } 413 414 #endif /* !IN_RING3 */ 410 415 411 416 /** … … 417 422 /* .uReserved0 = */ 0, 418 423 /* .szName = */ "GIMDev", 419 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ, 424 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_REQUIRE_R0 425 | PDM_DEVREG_FLAGS_NEW_STYLE, 420 426 /* .fClass = */ PDM_DEVREG_CLASS_MISC, 421 427 /* .cMaxInstances = */ 1, … … 454 460 #elif defined(IN_RING0) 455 461 /* .pfnEarlyConstruct = */ NULL, 456 /* .pfnConstruct = */ NULL,462 /* .pfnConstruct = */ gimdevRZConstruct, 457 463 /* .pfnDestruct = */ NULL, 458 464 /* .pfnFinalDestruct = */ NULL, … … 467 473 /* .pfnReserved7 = */ NULL, 468 474 #elif defined(IN_RC) 469 /* .pfnConstruct = */ NULL,475 /* .pfnConstruct = */ gimdevRZConstruct, 470 476 /* .pfnReserved0 = */ NULL, 471 477 /* .pfnReserved1 = */ NULL, -
trunk/src/VBox/VMM/VMMAll/GIMAll.cpp
r81605 r82210 58 58 { 59 59 return pVM->gim.s.enmProviderId; 60 } 61 62 63 /** 64 * Returns the array of MMIO2 regions that are expected to be registered and 65 * later mapped into the guest-physical address space for the GIM provider 66 * configured for the VM. 67 * 68 * @returns Pointer to an array of GIM MMIO2 regions, may return NULL. 69 * @param pVM The cross context VM structure. 70 * @param pcRegions Where to store the number of items in the array. 71 * 72 * @remarks The caller does not own and therefore must -NOT- try to free the 73 * returned pointer. 74 */ 75 VMMDECL(PGIMMMIO2REGION) GIMGetMmio2Regions(PVMCC pVM, uint32_t *pcRegions) 76 { 77 Assert(pVM); 78 Assert(pcRegions); 79 80 *pcRegions = 0; 81 switch (pVM->gim.s.enmProviderId) 82 { 83 case GIMPROVIDERID_HYPERV: 84 return gimHvGetMmio2Regions(pVM, pcRegions); 85 86 default: 87 break; 88 } 89 90 return NULL; 60 91 } 61 92 -
trunk/src/VBox/VMM/VMMAll/GIMAllHv.cpp
r81605 r82210 406 406 407 407 /** 408 * Returns a pointer to the MMIO2 regions supported by Hyper-V. 409 * 410 * @returns Pointer to an array of MMIO2 regions. 411 * @param pVM The cross context VM structure. 412 * @param pcRegions Where to store the number of regions in the array. 413 */ 414 VMM_INT_DECL(PGIMMMIO2REGION) gimHvGetMmio2Regions(PVM pVM, uint32_t *pcRegions) 415 { 416 Assert(GIMIsEnabled(pVM)); 417 PGIMHV pHv = &pVM->gim.s.u.Hv; 418 419 AssertCompile(RT_ELEMENTS(pHv->aMmio2Regions) <= 8); 420 *pcRegions = RT_ELEMENTS(pHv->aMmio2Regions); 421 return pHv->aMmio2Regions; 422 } 423 424 425 /** 408 426 * Returns whether the guest has configured and enabled the use of Hyper-V's 409 427 * hypercall interface. -
trunk/src/VBox/VMM/VMMR0/VMMR0.def
r82094 r82210 20 20 21 21 ; code 22 GIMGetMmio2Regions 22 23 PDMCritSectEnter 23 24 PDMCritSectEnterDebug -
trunk/src/VBox/VMM/VMMR3/GIM.cpp
r80597 r82210 526 526 } 527 527 return VERR_GIM_NO_DEBUG_CONNECTION; 528 }529 530 531 /**532 * Returns the array of MMIO2 regions that are expected to be registered and533 * later mapped into the guest-physical address space for the GIM provider534 * configured for the VM.535 *536 * @returns Pointer to an array of GIM MMIO2 regions, may return NULL.537 * @param pVM The cross context VM structure.538 * @param pcRegions Where to store the number of items in the array.539 *540 * @remarks The caller does not own and therefore must -NOT- try to free the541 * returned pointer.542 */543 VMMR3DECL(PGIMMMIO2REGION) GIMR3GetMmio2Regions(PVM pVM, uint32_t *pcRegions)544 {545 Assert(pVM);546 Assert(pcRegions);547 548 *pcRegions = 0;549 switch (pVM->gim.s.enmProviderId)550 {551 case GIMPROVIDERID_HYPERV:552 return gimR3HvGetMmio2Regions(pVM, pcRegions);553 554 default:555 break;556 }557 558 return NULL;559 528 } 560 529 -
trunk/src/VBox/VMM/VMMR3/GIMHv.cpp
r81766 r82210 304 304 * Populate the required fields in MMIO2 region records for registering. 305 305 */ 306 for (size_t i = 0; i < RT_ELEMENTS(pHv->aMmio2Regions); i++) 307 pHv->aMmio2Regions[i].hMmio2 = NIL_PGMMMIO2HANDLE; 308 306 309 AssertCompile(GIM_HV_PAGE_SIZE == PAGE_SIZE); 307 310 PGIMMMIO2REGION pRegion = &pHv->aMmio2Regions[GIM_HV_HYPERCALL_PAGE_REGION_IDX]; … … 688 691 } 689 692 } 690 }691 692 693 /**694 * Returns a pointer to the MMIO2 regions supported by Hyper-V.695 *696 * @returns Pointer to an array of MMIO2 regions.697 * @param pVM The cross context VM structure.698 * @param pcRegions Where to store the number of regions in the array.699 */700 VMMR3_INT_DECL(PGIMMMIO2REGION) gimR3HvGetMmio2Regions(PVM pVM, uint32_t *pcRegions)701 {702 Assert(GIMIsEnabled(pVM));703 PGIMHV pHv = &pVM->gim.s.u.Hv;704 705 *pcRegions = RT_ELEMENTS(pHv->aMmio2Regions);706 Assert(*pcRegions <= UINT8_MAX); /* See PGMR3PhysMMIO2Register(). */707 return pHv->aMmio2Regions;708 693 } 709 694 -
trunk/src/VBox/VMM/include/GIMHvInternal.h
r81369 r82210 1332 1332 VMMR3_INT_DECL(void) gimR3HvRelocate(PVM pVM, RTGCINTPTR offDelta); 1333 1333 VMMR3_INT_DECL(void) gimR3HvReset(PVM pVM); 1334 VMMR3_INT_DECL(PGIMMMIO2REGION) gimR3HvGetMmio2Regions(PVM pVM, uint32_t *pcRegions);1335 1334 VMMR3_INT_DECL(int) gimR3HvSave(PVM pVM, PSSMHANDLE pSSM); 1336 1335 VMMR3_INT_DECL(int) gimR3HvLoad(PVM pVM, PSSMHANDLE pSSM); … … 1359 1358 #endif /* IN_RING3 */ 1360 1359 1360 VMM_INT_DECL(PGIMMMIO2REGION) gimHvGetMmio2Regions(PVM pVM, uint32_t *pcRegions); 1361 1361 VMM_INT_DECL(bool) gimHvIsParavirtTscEnabled(PVM pVM); 1362 1362 VMM_INT_DECL(bool) gimHvAreHypercallsEnabled(PCVM pVM);
Note:
See TracChangeset
for help on using the changeset viewer.