Changeset 97697 in vbox
- Timestamp:
- Nov 29, 2022 7:02:14 AM (2 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp
r96407 r97697 356 356 */ 357 357 358 /**359 * HC access handler for GBOs which require write protection, i.e. OTables, etc.360 *361 * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.362 * @param pVM VM Handle.363 * @param pVCpu The cross context CPU structure for the calling EMT.364 * @param GCPhys The physical address the guest is writing to.365 * @param pvPhys The HC mapping of that address.366 * @param pvBuf What the guest is reading/writing.367 * @param cbBuf How much it's reading/writing.368 * @param enmAccessType The access type.369 * @param enmOrigin Who is making the access.370 * @param uUser The VMM automatically sets this to the address of371 * the device instance.372 */373 DECLCALLBACK(VBOXSTRICTRC)374 vmsvgaR3GboAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,375 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser)376 {377 RT_NOREF(pVM, pVCpu, pvPhys, enmAccessType);378 379 if (RT_LIKELY(enmOrigin == PGMACCESSORIGIN_DEVICE || enmOrigin == PGMACCESSORIGIN_DEBUGGER))380 return VINF_PGM_HANDLER_DO_DEFAULT;381 382 PPDMDEVINS pDevIns = (PPDMDEVINS)uUser;383 AssertPtrReturn(pDevIns, VERR_INTERNAL_ERROR_4);384 AssertReturn(pDevIns->u32Version == PDM_DEVINSR3_VERSION, VERR_INTERNAL_ERROR_5);385 PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);386 PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);387 PVMSVGAR3STATE pSvgaR3State = pThisCC->svga.pSvgaR3State;388 389 /*390 * The guest is not allowed to access the memory.391 * Set the error condition.392 */393 ASMAtomicWriteBool(&pThis->svga.fBadGuest, true);394 395 /* Try to find the GBO which the guest is accessing. */396 char const *pszTarget = NULL;397 for (uint32_t i = 0; i < RT_ELEMENTS(pSvgaR3State->aGboOTables) && !pszTarget; ++i)398 {399 PVMSVGAGBO pGbo = &pSvgaR3State->aGboOTables[i];400 if (pGbo->cDescriptors)401 {402 for (uint32_t j = 0; j < pGbo->cDescriptors; ++j)403 {404 if ( GCPhys >= pGbo->paDescriptors[j].GCPhys405 && GCPhys < pGbo->paDescriptors[j].GCPhys + pGbo->paDescriptors[j].cPages * GUEST_PAGE_SIZE)406 {407 switch (i)408 {409 case SVGA_OTABLE_MOB: pszTarget = "SVGA_OTABLE_MOB"; break;410 case SVGA_OTABLE_SURFACE: pszTarget = "SVGA_OTABLE_SURFACE"; break;411 case SVGA_OTABLE_CONTEXT: pszTarget = "SVGA_OTABLE_CONTEXT"; break;412 case SVGA_OTABLE_SHADER: pszTarget = "SVGA_OTABLE_SHADER"; break;413 case SVGA_OTABLE_SCREENTARGET: pszTarget = "SVGA_OTABLE_SCREENTARGET"; break;414 case SVGA_OTABLE_DXCONTEXT: pszTarget = "SVGA_OTABLE_DXCONTEXT"; break;415 default: pszTarget = "Unknown OTABLE"; break;416 }417 break;418 }419 }420 }421 }422 423 LogRelMax(8, ("VMSVGA: invalid guest access to page %RGp, target %s:\n"424 "%.*Rhxd\n",425 GCPhys, pszTarget ? pszTarget : "unknown", RT_MIN(cbBuf, 256), pvBuf));426 427 return VINF_PGM_HANDLER_DO_DEFAULT;428 }429 430 358 #ifdef VBOX_WITH_VMSVGA3D 431 359 432 static int vmsvgaR3GboCreate(PVMSVGAR3STATE pSvgaR3State, SVGAMobFormat ptDepth, PPN64 baseAddress, uint32_t sizeInBytes, bool fWriteProtected,PVMSVGAGBO pGbo)360 static int vmsvgaR3GboCreate(PVMSVGAR3STATE pSvgaR3State, SVGAMobFormat ptDepth, PPN64 baseAddress, uint32_t sizeInBytes, PVMSVGAGBO pGbo) 433 361 { 434 362 ASSERT_GUEST_RETURN(sizeInBytes <= _128M, VERR_INVALID_PARAMETER); /** @todo Less than SVGA_REG_MOB_MAX_SIZE */ … … 598 526 pGbo->paDescriptors = paDescriptors; 599 527 600 #if 1 /// @todo PGMHandlerPhysicalRegister asserts deep in PGM code with enmKind of a page being out of range. 601 fWriteProtected = false; 602 #endif 603 if (fWriteProtected) 604 { 605 pGbo->fGboFlags |= VMSVGAGBO_F_WRITE_PROTECTED; 606 for (uint32_t i = 0; i < pGbo->cDescriptors; ++i) 607 { 608 rc = PDMDevHlpPGMHandlerPhysicalRegister(pSvgaR3State->pDevIns, 609 pGbo->paDescriptors[i].GCPhys, 610 pGbo->paDescriptors[i].GCPhys 611 + pGbo->paDescriptors[i].cPages * GUEST_PAGE_SIZE - 1, 612 pSvgaR3State->hGboAccessHandlerType, "VMSVGA GBO"); 613 AssertRC(rc); 614 } 615 } 528 pGbo->fGboFlags = 0; 529 pGbo->pvHost = NULL; 616 530 617 531 return VINF_SUCCESS; … … 621 535 static void vmsvgaR3GboDestroy(PVMSVGAR3STATE pSvgaR3State, PVMSVGAGBO pGbo) 622 536 { 537 RT_NOREF(pSvgaR3State); 538 623 539 if (RT_LIKELY(VMSVGA_IS_GBO_CREATED(pGbo))) 624 540 { 625 if (pGbo->fGboFlags & VMSVGAGBO_F_WRITE_PROTECTED)626 {627 for (uint32_t i = 0; i < pGbo->cDescriptors; ++i)628 {629 int rc = PDMDevHlpPGMHandlerPhysicalDeregister(pSvgaR3State->pDevIns, pGbo->paDescriptors[i].GCPhys);630 AssertRC(rc);631 }632 }633 541 RTMemFree(pGbo->paDescriptors); 634 RT_ZERO( pGbo);542 RT_ZERO(*pGbo); 635 543 } 636 544 } … … 821 729 /* Create a new guest backed object for the object table. */ 822 730 VMSVGAGBO gbo; 823 int rc = vmsvgaR3GboCreate(pSvgaR3State, ptDepth, baseAddress, sizeInBytes, /* fWriteProtected = */ true,&gbo);731 int rc = vmsvgaR3GboCreate(pSvgaR3State, ptDepth, baseAddress, sizeInBytes, &gbo); 824 732 AssertRCReturn(rc, rc); 825 733 734 /* If the guest sets a new OTable (fGrow == false), then it has already copied the valid data to the new GBO. */ 826 735 if (fGrow && validSizeInBytes) 827 736 { … … 915 824 { 916 825 /* Create the corresponding GBO. */ 917 rc = vmsvgaR3GboCreate(pSvgaR3State, ptDepth, baseAddress, sizeInBytes, /* fWriteProtected = */ false,&pMob->Gbo);826 rc = vmsvgaR3GboCreate(pSvgaR3State, ptDepth, baseAddress, sizeInBytes, &pMob->Gbo); 918 827 if (RT_SUCCESS(rc)) 919 828 { -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-internal.h
r96407 r97697 140 140 RTCRITSECT CritSectCmdBuf; 141 141 142 /** Write protected GBOs (OTables) access handler type handle. */ 143 PGMPHYSHANDLERTYPE hGboAccessHandlerType; 144 145 /** */ 142 /** Object Tables: MOBs, etc. see SVGA_OTABLE_* */ 146 143 VMSVGAGBO aGboOTables[SVGA_OTABLE_MAX]; 147 144 … … 262 259 #endif 263 260 264 DECLCALLBACK(VBOXSTRICTRC) vmsvgaR3GboAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,265 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser);266 267 261 void vmsvgaR3ResetScreens(PVGASTATE pThis, PVGASTATECC pThisCC); 268 262 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r96950 r97697 6618 6618 pSVGAState = pThisCC->svga.pSvgaR3State; 6619 6619 6620 /* Register the write-protected GBO access handler type (no ring-0 callbacks here). */6621 rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE, vmsvgaR3GboAccessHandler,6622 "VMSVGA GBO", &pSVGAState->hGboAccessHandlerType);6623 AssertRCReturn(rc, rc);6624 6625 6620 /* VRAM tracking is enabled by default during bootup. */ 6626 6621 pThis->svga.fVRAMTracking = true; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.h
r96407 r97697 621 621 typedef VMSVGAGBO const *PCVMSVGAGBO; 622 622 623 #define VMSVGAGBO_F_ WRITE_PROTECTED0x1623 #define VMSVGAGBO_F_OBSOLETE_0x1 0x1 624 624 #define VMSVGAGBO_F_HOST_BACKED 0x2 625 625
Note:
See TracChangeset
for help on using the changeset viewer.