Changeset 71607 in vbox
- Timestamp:
- Apr 1, 2018 11:38:00 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/Graphics/VBoxVideoHost3D.h
r70596 r71607 83 83 typedef void * HVBOXCRCMDSVR; 84 84 85 /* enables the CrCmd interface, thus the hgcm interface gets disabled.85 /** enables the CrCmd interface, thus the hgcm interface gets disabled. 86 86 * all subsequent calls will be done in the thread Enable was done, 87 87 * until the Disable is called */ 88 88 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_ENABLE)(HVBOXCRCMDSVR hSvr, VBOXCRCMD_SVRENABLE_INFO *pInfo); 89 /* Opposite to Enable (see above) */89 /** Opposite to Enable (see above) */ 90 90 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_DISABLE)(HVBOXCRCMDSVR hSvr); 91 /* process command */ 92 typedef DECLCALLBACKPTR(int8_t, PFNVBOXCRCMD_SVR_CMD)(HVBOXCRCMDSVR hSvr, const VBOXCMDVBVA_HDR *pCmd, uint32_t cbCmd); 93 /* process host control */ 94 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_HOSTCTL)(HVBOXCRCMDSVR hSvr, uint8_t* pCtl, uint32_t cbCmd); 95 /* process guest control */ 96 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_GUESTCTL)(HVBOXCRCMDSVR hSvr, uint8_t* pCtl, uint32_t cbCmd); 97 /* screen resize */ 98 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_RESIZE)(HVBOXCRCMDSVR hSvr, const struct VBVAINFOSCREEN *pScreen, const uint32_t *pTargetMap); 99 /* process SaveState */ 91 /** process command */ 92 typedef DECLCALLBACKPTR(int8_t, PFNVBOXCRCMD_SVR_CMD)(HVBOXCRCMDSVR hSvr, 93 const VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd); 94 /** process host control */ 95 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_HOSTCTL)(HVBOXCRCMDSVR hSvr, uint8_t *pCtl, uint32_t cbCmd); 96 /** process guest control */ 97 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_GUESTCTL)(HVBOXCRCMDSVR hSvr, uint8_t RT_UNTRUSTED_VOLATILE_GUEST *pCtl, 98 uint32_t cbCmd); 99 /** screen resize */ 100 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_RESIZE)(HVBOXCRCMDSVR hSvr, const struct VBVAINFOSCREEN *pScreen, 101 const uint32_t *pTargetMap); 102 /** process SaveState */ 100 103 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_SAVESTATE)(HVBOXCRCMDSVR hSvr, PSSMHANDLE pSSM); 101 /* process LoadState */104 /** process LoadState */ 102 105 typedef DECLCALLBACKPTR(int, PFNVBOXCRCMD_SVR_LOADSTATE)(HVBOXCRCMDSVR hSvr, PSSMHANDLE pSSM, uint32_t u32Version); 103 106 -
trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp
r71592 r71607 2569 2569 { 2570 2570 VBVAENABLE RT_UNTRUSTED_VOLATILE_GUEST *pVbvaEnable = (VBVAENABLE RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer; 2571 2572 uint32_t u32ScreenId;2573 2571 const uint32_t u32Flags = pVbvaEnable->u32Flags; 2572 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2573 2574 uint32_t u32ScreenId; 2574 2575 if (u32Flags & VBVA_F_EXTENDED) 2575 2576 { … … 2621 2622 VBVACAPS RT_UNTRUSTED_VOLATILE_GUEST *pCaps = (VBVACAPS RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer; 2622 2623 pVGAState->fGuestCaps = pCaps->fCaps; 2624 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2625 2623 2626 pVGAState->pDrv->pfnVBVAGuestCapabilityUpdate(pVGAState->pDrv, pVGAState->fGuestCaps); 2624 2627 pCaps->rc = rc = VINF_SUCCESS; … … 2634 2637 VBVASCANLINECFG RT_UNTRUSTED_VOLATILE_GUEST *pCfg = (VBVASCANLINECFG RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer; 2635 2638 pVGAState->fScanLineCfg = pCfg->fFlags; 2639 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2640 2636 2641 pCfg->rc = rc = VINF_SUCCESS; 2637 2642 } … … 2664 2669 inputMapping.cy = pInputMapping->cy; 2665 2670 } 2666 ASMCompilerBarrier();2671 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2667 2672 2668 2673 LogRelFlowFunc(("VBVA: ChannelHandler: VBVA_REPORT_INPUT_MAPPING: x=%RI32, y=%RI32, cx=%RU32, cy=%RU32\n", … … 2685 2690 Report.x = pReport->x; 2686 2691 Report.y = pReport->y; 2687 ASMCompilerBarrier();2692 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2688 2693 2689 2694 LogRelFlowFunc(("VBVA: ChannelHandler: VBVA_CURSOR_POSITION: fReportPosition=%RTbool, x=%RU32, y=%RU32\n", -
trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp
r71604 r71607 25 25 #include <VBox/vmm/pgm.h> 26 26 #include <VBoxVideo.h> 27 #include <VBox/AssertGuest.h> 27 28 #include <iprt/semaphore.h> 28 29 #include <iprt/thread.h> … … 104 105 typedef struct VBVAEXHOSTCONTEXT 105 106 { 106 VBVABUFFER *pVBVA; 107 uint32_t cbMaxData; /**< Maximum number of data bytes addressible relative to pVBVA. */ 107 VBVABUFFER RT_UNTRUSTED_VOLATILE_GUEST *pVBVA; 108 /** Maximum number of data bytes addressible relative to pVBVA. */ 109 uint32_t cbMaxData; 108 110 volatile int32_t i32State; 109 111 volatile int32_t i32EnableState; … … 148 150 struct 149 151 { 150 uint8_t * pu8Cmd;152 void RT_UNTRUSTED_VOLATILE_GUEST *pvCmd; 151 153 uint32_t cbCmd; 152 154 } cmd; … … 241 243 { 242 244 # ifndef VBOXVDBG_MEMCACHE_DISABLE 243 VBVAEXHOSTCTL *pCtl = (VBVAEXHOSTCTL *)RTMemCacheAlloc(pCmdVbva->CtlCache);245 VBVAEXHOSTCTL *pCtl = (VBVAEXHOSTCTL *)RTMemCacheAlloc(pCmdVbva->CtlCache); 244 246 # else 245 VBVAEXHOSTCTL *pCtl = (VBVAEXHOSTCTL *)RTMemAlloc(sizeof(VBVAEXHOSTCTL));247 VBVAEXHOSTCTL *pCtl = (VBVAEXHOSTCTL *)RTMemAlloc(sizeof(VBVAEXHOSTCTL)); 246 248 # endif 247 249 if (pCtl) … … 282 284 283 285 /** 284 * Worker for vboxVBVAExHPDataGet () and VBoxVBVAExHPCheckHostCtlOnDisable() that285 * gets the next control command.286 * Worker for vboxVBVAExHPDataGetInner() and VBoxVBVAExHPCheckHostCtlOnDisable() 287 * that gets the next control command. 286 288 * 287 289 * @returns Pointer to command if found, NULL if not. … … 375 377 376 378 /** 377 * Worker for vboxVBVAExHPDataGet that processes PAUSE and RESUME requests.379 * Worker for vboxVBVAExHPDataGetInner that processes PAUSE and RESUME requests. 378 380 * 379 381 * Unclear why these cannot be handled the normal way. … … 433 435 434 436 /** 435 * Worker for vboxVBVAExHPDataGet .437 * Worker for vboxVBVAExHPDataGetInner. 436 438 * 437 439 * @retval VINF_SUCCESS … … 442 444 * @thread VDMA 443 445 */ 444 static int vboxVBVAExHPCmdGet(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t **ppbCmd, uint32_t *pcbCmd)446 static int vboxVBVAExHPCmdGet(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t RT_UNTRUSTED_VOLATILE_GUEST **ppbCmd, uint32_t *pcbCmd) 445 447 { 446 448 Assert(pCmdVbva->i32State == VBVAEXHOSTCONTEXT_STATE_PROCESSING); 447 449 Assert(pCmdVbva->i32EnableState > VBVAEXHOSTCONTEXT_ESTATE_PAUSED); 448 450 449 VBVABUFFER volatile*pVBVA = pCmdVbva->pVBVA; /* This is shared with the guest, so careful! */451 VBVABUFFER RT_UNTRUSTED_VOLATILE_GUEST *pVBVA = pCmdVbva->pVBVA; /* This is shared with the guest, so careful! */ 450 452 451 453 /* … … 454 456 uint32_t idxRecordFirst = ASMAtomicUoReadU32(&pVBVA->indexRecordFirst); 455 457 uint32_t idxRecordFree = ASMAtomicReadU32(&pVBVA->indexRecordFree); 458 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 456 459 Log(("first = %d, free = %d\n", idxRecordFirst, idxRecordFree)); 457 460 if (idxRecordFirst == idxRecordFree) 458 461 return VINF_EOF; /* No records to process. Return without assigning output variables. */ 459 462 AssertReturn(idxRecordFirst < VBVA_MAX_RECORDS, VERR_INVALID_STATE); 463 RT_UNTRUSTED_VALIDATED_FENCE(); 460 464 461 465 /* … … 464 468 uint32_t const cbRecordCurrent = ASMAtomicReadU32(&pVBVA->aRecords[idxRecordFirst].cbRecord); 465 469 uint32_t const cbRecord = cbRecordCurrent & ~VBVA_F_RECORD_PARTIAL; 470 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 466 471 if ( (cbRecordCurrent & VBVA_F_RECORD_PARTIAL) 467 472 || !cbRecord) … … 474 479 uint32_t const offData = ASMAtomicReadU32(&pVBVA->off32Data); 475 480 uint32_t cbMaxData = ASMAtomicReadU32(&pVBVA->cbData); 481 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 476 482 AssertLogRelMsgStmt(cbMaxData <= pCmdVbva->cbMaxData, ("%#x vs %#x\n", cbMaxData, pCmdVbva->cbMaxData), 477 483 cbMaxData = pCmdVbva->cbMaxData); … … 480 486 ("offData=%#x cbRecord=%#x cbMaxData=%#x cbRecord\n", offData, cbRecord, cbMaxData), 481 487 VERR_INVALID_STATE); 488 RT_UNTRUSTED_VALIDATED_FENCE(); 482 489 483 490 /* 484 491 * Just set the return values and we're done. 485 492 */ 486 *ppbCmd = (uint8_t*)&pVBVA->au8Data[offData];493 *ppbCmd = (uint8_t RT_UNTRUSTED_VOLATILE_GUEST *)&pVBVA->au8Data[offData]; 487 494 *pcbCmd = cbRecord; 488 495 return VINF_SUCCESS; … … 497 504 static void VBoxVBVAExHPDataCompleteCmd(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint32_t cbCmd) 498 505 { 499 VBVABUFFER volatile *pVBVA = pCmdVbva->pVBVA; 500 501 /* Move data head. */ 502 uint32_t const cbData = pVBVA->cbData; 503 uint32_t const offData = pVBVA->off32Data; 504 if (cbData > 0) 505 ASMAtomicWriteU32(&pVBVA->off32Data, (offData + cbCmd) % cbData); 506 else 507 ASMAtomicWriteU32(&pVBVA->off32Data, 0); 508 509 /* Increment record pointer. */ 510 uint32_t const idxRecFirst = pVBVA->indexRecordFirst; 511 ASMAtomicWriteU32(&pVBVA->indexRecordFirst, (idxRecFirst + 1) % RT_ELEMENTS(pVBVA->aRecords)); 506 VBVABUFFER RT_UNTRUSTED_VOLATILE_GUEST *pVBVA = pCmdVbva->pVBVA; 507 if (pVBVA) 508 { 509 /* Move data head. */ 510 uint32_t const cbData = pVBVA->cbData; 511 uint32_t const offData = pVBVA->off32Data; 512 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 513 if (cbData > 0) 514 ASMAtomicWriteU32(&pVBVA->off32Data, (offData + cbCmd) % cbData); 515 else 516 ASMAtomicWriteU32(&pVBVA->off32Data, 0); 517 518 /* Increment record pointer. */ 519 uint32_t const idxRecFirst = pVBVA->indexRecordFirst; 520 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 521 ASMAtomicWriteU32(&pVBVA->indexRecordFirst, (idxRecFirst + 1) % RT_ELEMENTS(pVBVA->aRecords)); 522 } 512 523 } 513 524 … … 528 539 * @thread VDMA 529 540 */ 530 static VBVAEXHOST_DATA_TYPE vboxVBVAExHPDataGet(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t **ppCmd, uint32_t *pcbCmd) 541 static VBVAEXHOST_DATA_TYPE vboxVBVAExHPDataGetInner(struct VBVAEXHOSTCONTEXT *pCmdVbva, 542 uint8_t RT_UNTRUSTED_VOLATILE_GUEST **ppbCmd, uint32_t *pcbCmd) 531 543 { 532 544 Assert(pCmdVbva->i32State == VBVAEXHOSTCONTEXT_STATE_PROCESSING); 533 VBVAEXHOSTCTL *pCtl;545 VBVAEXHOSTCTL *pCtl; 534 546 bool fHostClt; 535 547 … … 543 555 if (!vboxVBVAExHPCheckProcessCtlInternal(pCmdVbva, pCtl)) 544 556 { 545 *pp Cmd = (uint8_t*)pCtl;557 *ppbCmd = (uint8_t RT_UNTRUSTED_VOLATILE_GUEST *)pCtl; /* Note! pCtl is host data, so trusted */ 546 558 *pcbCmd = sizeof (*pCtl); 547 559 return VBVAEXHOST_DATA_TYPE_HOSTCTL; … … 549 561 continue; /* Processed by vboxVBVAExHPCheckProcessCtlInternal, get next. */ 550 562 } 551 *pp Cmd = (uint8_t*)pCtl;563 *ppbCmd = (uint8_t RT_UNTRUSTED_VOLATILE_GUEST *)pCtl; /* Note! pCtl is host data, so trusted */ 552 564 *pcbCmd = sizeof (*pCtl); 553 565 return VBVAEXHOST_DATA_TYPE_GUESTCTL; … … 557 569 return VBVAEXHOST_DATA_TYPE_NO_DATA; 558 570 559 int rc = vboxVBVAExHPCmdGet(pCmdVbva, pp Cmd, pcbCmd);571 int rc = vboxVBVAExHPCmdGet(pCmdVbva, ppbCmd, pcbCmd); 560 572 switch (rc) 561 573 { … … 580 592 * @thread VDMA 581 593 */ 582 static VBVAEXHOST_DATA_TYPE VBoxVBVAExHPDataGet(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t **ppCmd, uint32_t *pcbCmd) 583 { 584 VBVAEXHOST_DATA_TYPE enmType = vboxVBVAExHPDataGet(pCmdVbva, ppCmd, pcbCmd); 594 static VBVAEXHOST_DATA_TYPE VBoxVBVAExHPDataGet(struct VBVAEXHOSTCONTEXT *pCmdVbva, 595 uint8_t RT_UNTRUSTED_VOLATILE_GUEST **ppbCmd, uint32_t *pcbCmd) 596 { 597 VBVAEXHOST_DATA_TYPE enmType = vboxVBVAExHPDataGetInner(pCmdVbva, ppbCmd, pcbCmd); 585 598 if (enmType == VBVAEXHOST_DATA_TYPE_NO_DATA) 586 599 { … … 601 614 { 602 615 /* we are the processor now */ 603 enmType = vboxVBVAExHPDataGet (pCmdVbva, ppCmd, pcbCmd);616 enmType = vboxVBVAExHPDataGetInner(pCmdVbva, ppbCmd, pcbCmd); 604 617 if (enmType == VBVAEXHOST_DATA_TYPE_NO_DATA) 605 618 { … … 620 633 DECLINLINE(bool) vboxVBVAExHSHasCommands(struct VBVAEXHOSTCONTEXT *pCmdVbva) 621 634 { 622 VBVABUFFER *pVBVA = pCmdVbva->pVBVA;635 VBVABUFFER RT_UNTRUSTED_VOLATILE_GUEST *pVBVA = pCmdVbva->pVBVA; 623 636 if (pVBVA) 624 637 { 625 638 uint32_t indexRecordFirst = pVBVA->indexRecordFirst; 626 uint32_t indexRecordFree = pVBVA->indexRecordFree; 639 uint32_t indexRecordFree = pVBVA->indexRecordFree; 640 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 627 641 628 642 if (indexRecordFirst != indexRecordFree) … … 717 731 * @thread VDMA 718 732 */ 719 static int VBoxVBVAExHSEnable(struct VBVAEXHOSTCONTEXT *pCmdVbva, VBVABUFFER *pVBVA, uint8_t *pbVRam, uint32_t cbVRam) 733 static int VBoxVBVAExHSEnable(struct VBVAEXHOSTCONTEXT *pCmdVbva, VBVABUFFER RT_UNTRUSTED_VOLATILE_GUEST *pVBVA, 734 uint8_t *pbVRam, uint32_t cbVRam) 720 735 { 721 736 if (VBoxVBVAExHSIsEnabled(pCmdVbva)) … … 727 742 uintptr_t offVRam = (uintptr_t)pVBVA - (uintptr_t)pbVRam; 728 743 AssertLogRelMsgReturn(offVRam < cbVRam - sizeof(*pVBVA), ("%#p cbVRam=%#x\n", offVRam, cbVRam), VERR_OUT_OF_RANGE); 744 RT_UNTRUSTED_VALIDATED_FENCE(); 729 745 730 746 pCmdVbva->pVBVA = pVBVA; … … 784 800 rc = SSMR3PutU32(pSSM, pCtl->u.cmd.cbCmd); 785 801 AssertRCReturn(rc, rc); 786 rc = SSMR3PutU32(pSSM, (uint32_t)( pCtl->u.cmd.pu8Cmd -pu8VramBase));802 rc = SSMR3PutU32(pSSM, (uint32_t)((uintptr_t)pCtl->u.cmd.pvCmd - (uintptr_t)pu8VramBase)); 787 803 AssertRCReturn(rc, rc); 788 804 … … 865 881 rc = SSMR3GetU32(pSSM, &u32); 866 882 AssertLogRelRCReturn(rc, rc); 867 pHCtl->u.cmd.p u8Cmd = pu8VramBase + u32;883 pHCtl->u.cmd.pvCmd = pu8VramBase + u32; 868 884 869 885 RTListAppend(&pCmdVbva->GuestCtlList, &pHCtl->Node); … … 924 940 * 925 941 */ 926 static int VBoxVBVAExHCtlSubmit(VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL *pCtl, VBVAEXHOSTCTL_SOURCE enmSource,942 static int VBoxVBVAExHCtlSubmit(VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL *pCtl, VBVAEXHOSTCTL_SOURCE enmSource, 927 943 PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete) 928 944 { … … 1447 1463 { 1448 1464 *pcbCtl = pVdma->pCurRemainingHostCtl->u.cmd.cbCmd; 1449 return pVdma->pCurRemainingHostCtl->u.cmd.pu8Cmd;1465 return (uint8_t *)pVdma->pCurRemainingHostCtl->u.cmd.pvCmd; 1450 1466 } 1451 1467 … … 1534 1550 } 1535 1551 1536 VBVABUFFER *pVBVA = (VBVABUFFER *)HGSMIOffsetToPointerHost(pVdma->pHgsmi, u32Offset); 1552 VBVABUFFER RT_UNTRUSTED_VOLATILE_GUEST *pVBVA 1553 = (VBVABUFFER RT_UNTRUSTED_VOLATILE_GUEST *)HGSMIOffsetToPointerHost(pVdma->pHgsmi, u32Offset); 1537 1554 if (!pVBVA) 1538 1555 { … … 1660 1677 { 1661 1678 if (pVdma->CrSrvInfo.pfnHostCtl) 1662 return pVdma->CrSrvInfo.pfnHostCtl(pVdma->CrSrvInfo.hSvr, pCmd->u.cmd.pu8Cmd, pCmd->u.cmd.cbCmd);1679 return pVdma->CrSrvInfo.pfnHostCtl(pVdma->CrSrvInfo.hSvr, (uint8_t *)pCmd->u.cmd.pvCmd, pCmd->u.cmd.cbCmd); 1663 1680 WARN(("VBVAEXHOSTCTL_TYPE_GHH_BE_OPAQUE for disabled vdma VBVA\n")); 1664 1681 } … … 1772 1789 || idxView == UINT32_C(0xFFFFFFFF)) 1773 1790 { 1791 RT_UNTRUSTED_VALIDATED_FENCE(); 1792 1774 1793 RT_ZERO(*pScreen); 1775 1794 pScreen->u32ViewIndex = idxView; … … 1785 1804 && idxView != UINT32_C(0xFFFFFFFF)) 1786 1805 return VERR_INVALID_PARAMETER; 1806 RT_UNTRUSTED_VALIDATED_FENCE(); 1787 1807 1788 1808 /* Special case for blanking using current video mode. … … 1826 1846 * @thread VDMA 1827 1847 */ 1828 static int vboxVDMACrGuestCtlResizeEntryProcess(struct VBOXVDMAHOST *pVdma, VBOXCMDVBVA_RESIZE_ENTRY *pEntry) 1848 static int vboxVDMACrGuestCtlResizeEntryProcess(struct VBOXVDMAHOST *pVdma, 1849 VBOXCMDVBVA_RESIZE_ENTRY RT_UNTRUSTED_VOLATILE_GUEST *pEntry) 1829 1850 { 1830 1851 PVGASTATE pVGAState = pVdma->pVGAState; 1831 VBVAINFOSCREEN Screen = pEntry->Screen; 1852 1853 VBVAINFOSCREEN Screen; 1854 RT_COPY_VOLATILE(Screen, pEntry->Screen); 1855 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 1832 1856 1833 1857 /* Verify and cleanup local copy of the input data. */ … … 1838 1862 return rc; 1839 1863 } 1864 RT_UNTRUSTED_VALIDATED_FENCE(); 1840 1865 1841 1866 VBOXCMDVBVA_SCREENMAP_DECL(uint32_t, aTargetMap); 1842 memcpy(aTargetMap, pEntry->aTargetMap, sizeof(aTargetMap)); 1867 RT_BCOPY_VOLATILE(aTargetMap, pEntry->aTargetMap, sizeof(aTargetMap)); 1868 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 1869 1843 1870 ASMBitClearRange(aTargetMap, pVGAState->cMonitors, VBOX_VIDEO_MAX_SCREENS); 1844 1871 … … 1926 1953 { 1927 1954 if (pVdma->CrSrvInfo.pfnGuestCtl) 1928 return pVdma->CrSrvInfo.pfnGuestCtl(pVdma->CrSrvInfo.hSvr, pCmd->u.cmd.pu8Cmd, pCmd->u.cmd.cbCmd); 1955 return pVdma->CrSrvInfo.pfnGuestCtl(pVdma->CrSrvInfo.hSvr, 1956 (uint8_t RT_UNTRUSTED_VOLATILE_GUEST *)pCmd->u.cmd.pvCmd, 1957 pCmd->u.cmd.cbCmd); 1929 1958 1930 1959 /* Unexpected. */ … … 1946 1975 { 1947 1976 uint32_t cElements = cbCmd / sizeof(VBOXCMDVBVA_RESIZE_ENTRY); 1948 VBOXCMDVBVA_RESIZE *pResize = (VBOXCMDVBVA_RESIZE *)pCmd->u.cmd.pu8Cmd; 1977 VBOXCMDVBVA_RESIZE RT_UNTRUSTED_VOLATILE_GUEST *pResize 1978 = (VBOXCMDVBVA_RESIZE RT_UNTRUSTED_VOLATILE_GUEST *)pCmd->u.cmd.pvCmd; 1949 1979 for (uint32_t i = 0; i < cElements; ++i) 1950 1980 { 1951 VBOXCMDVBVA_RESIZE_ENTRY *pEntry = &pResize->aEntries[i];1981 VBOXCMDVBVA_RESIZE_ENTRY RT_UNTRUSTED_VOLATILE_GUEST *pEntry = &pResize->aEntries[i]; 1952 1982 int rc = vboxVDMACrGuestCtlResizeEntryProcess(pVdma, pEntry); 1953 1983 if (RT_FAILURE(rc)) … … 1972 2002 case VBVAEXHOSTCTL_TYPE_GHH_ENABLE_PAUSED: 1973 2003 { 1974 VBVAENABLE *pEnable = (VBVAENABLE *)pCmd->u.cmd.pu8Cmd;2004 VBVAENABLE RT_UNTRUSTED_VOLATILE_GUEST *pEnable = (VBVAENABLE RT_UNTRUSTED_VOLATILE_GUEST *)pCmd->u.cmd.pvCmd; 1975 2005 Assert(pCmd->u.cmd.cbCmd == sizeof(VBVAENABLE)); 1976 2006 1977 uint32_t u32Offset = pEnable->u32Offset; 2007 uint32_t const u32Offset = pEnable->u32Offset; 2008 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2009 1978 2010 int rc = vdmaVBVAEnableProcess(pVdma, u32Offset); 1979 2011 if (RT_SUCCESS(rc)) … … 2030 2062 RTGCPHYS GCPhysPage = (RTGCPHYS)uPageNo << X86_PAGE_SHIFT; 2031 2063 PGMPAGEMAPLOCK Lock; 2032 int rc;2033 2064 2034 2065 if (fIn) 2035 2066 { 2036 2067 const void *pvPage; 2037 rc = PDMDevHlpPhysGCPhys2CCPtrReadOnly(pDevIns, GCPhysPage, 0, &pvPage, &Lock); 2038 if (RT_SUCCESS(rc)) 2039 { 2040 memcpy(pbVram, pvPage, PAGE_SIZE); 2041 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &Lock); 2042 } 2043 else 2044 WARN(("PDMDevHlpPhysGCPhys2CCPtrReadOnly failed %Rrc", rc)); 2068 int rc = PDMDevHlpPhysGCPhys2CCPtrReadOnly(pDevIns, GCPhysPage, 0, &pvPage, &Lock); 2069 ASSERT_GUEST_LOGREL_MSG_RC_RETURN(rc, ("PDMDevHlpPhysGCPhys2CCPtrReadOnly %RGp -> %Rrc\n", GCPhysPage, rc), rc); 2070 2071 memcpy(pbVram, pvPage, PAGE_SIZE); 2072 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &Lock); 2045 2073 } 2046 2074 else 2047 2075 { 2048 2076 void *pvPage; 2049 rc = PDMDevHlpPhysGCPhys2CCPtr(pDevIns, GCPhysPage, 0, &pvPage, &Lock); 2050 if (RT_SUCCESS(rc)) 2051 { 2052 memcpy(pvPage, pbVram, PAGE_SIZE); 2053 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &Lock); 2054 } 2055 else 2056 WARN(("PDMDevHlpPhysGCPhys2CCPtr failed %Rrc", rc)); 2057 } 2058 2059 return rc; 2077 int rc = PDMDevHlpPhysGCPhys2CCPtr(pDevIns, GCPhysPage, 0, &pvPage, &Lock); 2078 ASSERT_GUEST_LOGREL_MSG_RC_RETURN(rc, ("PDMDevHlpPhysGCPhys2CCPtr %RGp -> %Rrc\n", GCPhysPage, rc), rc); 2079 2080 memcpy(pvPage, pbVram, PAGE_SIZE); 2081 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &Lock); 2082 } 2083 2084 return VINF_SUCCESS; 2060 2085 } 2061 2086 … … 2067 2092 * @thread VDMA 2068 2093 */ 2069 static int8_t vboxVDMACrCmdVbvaPageTransfer(PVGASTATE pVGAState, VBOXCMDVBVA_HDR const volatile *pHdr, uint32_t cbCmd,2070 const VBOXCMDVBVA_PAGING_TRANSFER_DATA*pData)2094 static int8_t vboxVDMACrCmdVbvaPageTransfer(PVGASTATE pVGAState, VBOXCMDVBVA_HDR const RT_UNTRUSTED_VOLATILE_GUEST *pHdr, 2095 uint32_t cbCmd, const VBOXCMDVBVA_PAGING_TRANSFER_DATA RT_UNTRUSTED_VOLATILE_GUEST *pData) 2071 2096 { 2072 2097 /* 2073 2098 * Extract and validate information. 2074 2099 */ 2075 A ssertMsgReturn(cbCmd >= sizeof(VBOXCMDVBVA_PAGING_TRANSFER), ("%#x\n", cbCmd), -1);2100 ASSERT_GUEST_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_PAGING_TRANSFER), ("%#x\n", cbCmd), -1); 2076 2101 2077 2102 bool const fIn = RT_BOOL(pHdr->u8Flags & VBOXCMDVBVA_OPF_PAGING_TRANSFER_IN); 2103 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2078 2104 2079 2105 uint32_t cbPageNumbers = cbCmd - RT_OFFSETOF(VBOXCMDVBVA_PAGING_TRANSFER, Data.aPageNumbers); 2080 A ssertMsgReturn(!(cbPageNumbers % sizeof(VBOXCMDVBVAPAGEIDX)), ("%#x\n", cbPageNumbers), -1);2106 ASSERT_GUEST_MSG_RETURN(!(cbPageNumbers % sizeof(VBOXCMDVBVAPAGEIDX)), ("%#x\n", cbPageNumbers), -1); 2081 2107 VBOXCMDVBVAPAGEIDX const cPages = cbPageNumbers / sizeof(VBOXCMDVBVAPAGEIDX); 2082 2108 2083 2109 VBOXCMDVBVAOFFSET offVRam = pData->Alloc.u.offVRAM; 2084 AssertMsgReturn(!(offVRam & X86_PAGE_OFFSET_MASK), ("%#x\n", offVRam), -1); 2085 AssertMsgReturn(offVRam < pVGAState->vram_size, ("%#x vs %#x\n", offVRam, pVGAState->vram_size), -1); 2110 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2111 ASSERT_GUEST_MSG_RETURN(!(offVRam & X86_PAGE_OFFSET_MASK), ("%#x\n", offVRam), -1); 2112 ASSERT_GUEST_MSG_RETURN(offVRam < pVGAState->vram_size, ("%#x vs %#x\n", offVRam, pVGAState->vram_size), -1); 2086 2113 uint32_t cVRamPages = (pVGAState->vram_size - offVRam) >> X86_PAGE_SHIFT; 2087 AssertMsgReturn(cPages <= cVRamPages, ("cPages=%#x vs cVRamPages=%#x @ offVRam=%#x\n", cPages, cVRamPages, offVRam), -1); 2114 ASSERT_GUEST_MSG_RETURN(cPages <= cVRamPages, ("cPages=%#x vs cVRamPages=%#x @ offVRam=%#x\n", cPages, cVRamPages, offVRam), -1); 2115 2116 RT_UNTRUSTED_VALIDATED_FENCE(); 2088 2117 2089 2118 /* … … 2094 2123 { 2095 2124 uint32_t uPageNo = pData->aPageNumbers[iPage]; 2125 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2096 2126 int rc = vboxVDMACrCmdVbvaProcessPagingEl(pVGAState->pDevInsR3, uPageNo, pbVRam, fIn); 2097 A ssertMsgReturn(RT_SUCCESS(rc), ("#%#x: uPageNo=%#x rc=%Rrc\n", iPage, uPageNo, rc), -1);2127 ASSERT_GUEST_MSG_RETURN(RT_SUCCESS(rc), ("#%#x: uPageNo=%#x rc=%Rrc\n", iPage, uPageNo, rc), -1); 2098 2128 } 2099 2129 return 0; … … 2110 2140 * @thread VDMA 2111 2141 */ 2112 static int8_t vboxVDMACrCmdVbvaPagingFill(PVGASTATE pVGAState, VBOXCMDVBVA_PAGING_FILL *pFill) 2113 { 2114 VBOXCMDVBVA_PAGING_FILL FillSafe = *pFill; 2115 VBOXCMDVBVAOFFSET offVRAM = FillSafe.offVRAM; 2116 if (!(offVRAM & X86_PAGE_OFFSET_MASK)) 2117 { 2118 if (offVRAM <= pVGAState->vram_size) 2119 { 2120 uint32_t cbFill = FillSafe.u32CbFill; 2121 AssertStmt(!(cbFill & 3), cbFill &= ~(uint32_t)3); 2122 2123 if ( cbFill < pVGAState->vram_size 2124 && offVRAM <= pVGAState->vram_size - cbFill) 2125 { 2126 uint32_t *pu32Vram = (uint32_t *)((uint8_t *)pVGAState->vram_ptrR3 + offVRAM); 2127 uint32_t const u32Color = FillSafe.u32Pattern; 2128 2129 uint32_t cLoops = cbFill / 4; 2130 while (cLoops-- > 0) 2131 pu32Vram[cLoops] = u32Color; 2132 2133 return 0; 2134 2135 } 2136 else 2137 WARN(("invalid cbFill")); 2138 2139 } 2140 WARN(("invalid vram offset")); 2141 2142 } 2143 else 2144 WARN(("offVRAM address is not on page boundary\n")); 2145 return -1; 2142 static int8_t vboxVDMACrCmdVbvaPagingFill(PVGASTATE pVGAState, VBOXCMDVBVA_PAGING_FILL RT_UNTRUSTED_VOLATILE_GUEST *pFill) 2143 { 2144 /* 2145 * Copy and validate input. 2146 */ 2147 VBOXCMDVBVA_PAGING_FILL FillSafe; 2148 RT_COPY_VOLATILE(FillSafe, *pFill); 2149 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2150 2151 VBOXCMDVBVAOFFSET offVRAM = FillSafe.offVRAM; 2152 ASSERT_GUEST_MSG_RETURN(!(offVRAM & X86_PAGE_OFFSET_MASK), ("offVRAM=%#x\n", offVRAM), -1); 2153 ASSERT_GUEST_MSG_RETURN(offVRAM <= pVGAState->vram_size, ("offVRAM=%#x\n", offVRAM), -1); 2154 2155 uint32_t cbFill = FillSafe.u32CbFill; 2156 ASSERT_GUEST_STMT(!(cbFill & 3), cbFill &= ~(uint32_t)3); 2157 ASSERT_GUEST_MSG_RETURN( cbFill < pVGAState->vram_size 2158 && offVRAM <= pVGAState->vram_size - cbFill, 2159 ("offVRAM=%#x cbFill=%#x\n", offVRAM, cbFill), -1); 2160 2161 RT_UNTRUSTED_VALIDATED_FENCE(); 2162 2163 /* 2164 * Execute. 2165 */ 2166 uint32_t *pu32Vram = (uint32_t *)((uint8_t *)pVGAState->vram_ptrR3 + offVRAM); 2167 uint32_t const u32Color = FillSafe.u32Pattern; 2168 2169 uint32_t cLoops = cbFill / 4; 2170 while (cLoops-- > 0) 2171 pu32Vram[cLoops] = u32Color; 2172 2173 return 0; 2146 2174 } 2147 2175 … … 2156 2184 * @thread VDMA 2157 2185 */ 2158 static int8_t vboxVDMACrCmdVbvaProcessCmdData(struct VBOXVDMAHOST *pVdma, const VBOXCMDVBVA_HDR *pCmd, uint32_t cbCmd) 2186 static int8_t vboxVDMACrCmdVbvaProcessCmdData(struct VBOXVDMAHOST *pVdma, const VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, 2187 uint32_t cbCmd) 2159 2188 { 2160 2189 uint8_t bOpCode = pCmd->u8OpCode; 2190 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2161 2191 switch (bOpCode) 2162 2192 { … … 2165 2195 2166 2196 case VBOXCMDVBVA_OPTYPE_PAGING_TRANSFER: 2167 return vboxVDMACrCmdVbvaPageTransfer(pVdma->pVGAState, pCmd, cbCmd, &((VBOXCMDVBVA_PAGING_TRANSFER *)pCmd)->Data); 2197 return vboxVDMACrCmdVbvaPageTransfer(pVdma->pVGAState, pCmd, cbCmd, 2198 &((VBOXCMDVBVA_PAGING_TRANSFER RT_UNTRUSTED_VOLATILE_GUEST *)pCmd)->Data); 2168 2199 2169 2200 case VBOXCMDVBVA_OPTYPE_PAGING_FILL: 2170 if (cbCmd == sizeof(VBOXCMDVBVA_PAGING_FILL)) 2171 return vboxVDMACrCmdVbvaPagingFill(pVdma->pVGAState, (VBOXCMDVBVA_PAGING_FILL *)pCmd); 2172 WARN(("cmd too small")); 2173 return -1; 2201 ASSERT_GUEST_RETURN(cbCmd == sizeof(VBOXCMDVBVA_PAGING_FILL), -1); 2202 return vboxVDMACrCmdVbvaPagingFill(pVdma->pVGAState, (VBOXCMDVBVA_PAGING_FILL RT_UNTRUSTED_VOLATILE_GUEST *)pCmd); 2174 2203 2175 2204 default: 2176 if (pVdma->CrSrvInfo.pfnCmd) 2177 return pVdma->CrSrvInfo.pfnCmd(pVdma->CrSrvInfo.hSvr, pCmd, cbCmd); 2178 /* Unexpected. */ 2179 WARN(("no HGCM")); 2180 return -1; 2205 ASSERT_GUEST_RETURN(pVdma->CrSrvInfo.pfnCmd != NULL, -1); 2206 return pVdma->CrSrvInfo.pfnCmd(pVdma->CrSrvInfo.hSvr, pCmd, cbCmd); 2181 2207 } 2182 2208 } … … 2213 2239 * @thread VDMA 2214 2240 */ 2215 static int8_t vboxVDMACrCmdVbvaProcess(struct VBOXVDMAHOST *pVdma, const VBOXCMDVBVA_HDR *pCmd, uint32_t cbCmd, bool fRecursion) 2241 static int8_t vboxVDMACrCmdVbvaProcess(struct VBOXVDMAHOST *pVdma, const VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, 2242 uint32_t cbCmd, bool fRecursion) 2216 2243 { 2217 2244 int8_t i8Result = 0; 2218 2245 uint8_t const bOpCode = pCmd->u8OpCode; 2246 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2219 2247 LogRelFlow(("VDMA: vboxVDMACrCmdVbvaProcess: ENTER, bOpCode=%u\n", bOpCode)); 2220 2248 switch (bOpCode) … … 2225 2253 * Extract the command physical address and size. 2226 2254 */ 2227 AssertMsgReturn(cbCmd >= sizeof(VBOXCMDVBVA_SYSMEMCMD), ("%#x\n", cbCmd), -1); 2228 RTGCPHYS GCPhysCmd = ((VBOXCMDVBVA_SYSMEMCMD *)pCmd)->phCmd; 2255 ASSERT_GUEST_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_SYSMEMCMD), ("%#x\n", cbCmd), -1); 2256 RTGCPHYS GCPhysCmd = ((VBOXCMDVBVA_SYSMEMCMD RT_UNTRUSTED_VOLATILE_GUEST *)pCmd)->phCmd; 2257 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2229 2258 uint32_t cbCmdPart = X86_PAGE_SIZE - (uint32_t)(GCPhysCmd & X86_PAGE_OFFSET_MASK); 2230 2259 2231 2260 uint32_t cbRealCmd = pCmd->u8Flags; 2232 2261 cbRealCmd |= (uint32_t)pCmd->u.u8PrimaryID << 8; 2233 A ssertMsgReturn(cbRealCmd >= sizeof(VBOXCMDVBVA_HDR), ("%#x\n", cbRealCmd), -1);2234 A ssertMsgReturn(cbRealCmd <= _1M, ("%#x\n", cbRealCmd), -1);2262 ASSERT_GUEST_MSG_RETURN(cbRealCmd >= sizeof(VBOXCMDVBVA_HDR), ("%#x\n", cbRealCmd), -1); 2263 ASSERT_GUEST_MSG_RETURN(cbRealCmd <= _1M, ("%#x\n", cbRealCmd), -1); 2235 2264 2236 2265 /* … … 2242 2271 VBOXCMDVBVA_HDR const *pRealCmdHdr = NULL; 2243 2272 int rc = PDMDevHlpPhysGCPhys2CCPtrReadOnly(pDevIns, GCPhysCmd, 0, (const void **)&pRealCmdHdr, &Lock); 2244 if (!RT_SUCCESS(rc)) 2245 { 2246 WARN(("PDMDevHlpPhysGCPhys2CCPtrReadOnly failed %Rrc\n", rc)); 2247 return -1; 2248 } 2273 ASSERT_GUEST_LOGREL_MSG_RC_RETURN(rc, ("VDMA: %RGp -> %Rrc\n", GCPhysCmd, rc), -1); 2249 2274 Assert((GCPhysCmd & PAGE_OFFSET_MASK) == (((uintptr_t)pRealCmdHdr) & PAGE_OFFSET_MASK)); 2250 2275 … … 2290 2315 { 2291 2316 Assert(cbCmd >= sizeof(VBOXCMDVBVA_HDR)); /* caller already checked this */ 2292 A ssertReturn(!fRecursion, -1);2317 ASSERT_GUEST_RETURN(!fRecursion, -1); 2293 2318 2294 2319 /* Skip current command. */ … … 2299 2324 while (cbCmd > 0) 2300 2325 { 2301 A ssertMsgReturn(cbCmd >= sizeof(VBOXCMDVBVA_HDR), ("%#x\n", cbCmd), -1);2326 ASSERT_GUEST_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_HDR), ("%#x\n", cbCmd), -1); 2302 2327 2303 2328 uint16_t cbCurCmd = pCmd->u2.complexCmdEl.u16CbCmdHost; 2304 AssertMsgReturn(cbCurCmd <= cbCmd, ("cbCurCmd=%#x, cbCmd=%#x\n", cbCurCmd, cbCmd), -1); 2329 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2330 ASSERT_GUEST_MSG_RETURN(cbCurCmd <= cbCmd, ("cbCurCmd=%#x, cbCmd=%#x\n", cbCurCmd, cbCmd), -1); 2305 2331 2306 2332 i8Result = vboxVDMACrCmdVbvaProcess(pVdma, pCmd, cbCurCmd, true /*fRecursive*/); 2307 if (i8Result < 0) 2308 { 2309 WARN(("vboxVDMACrCmdVbvaProcess failed")); 2310 return i8Result; 2311 } 2333 ASSERT_GUEST_MSG_RETURN(i8Result >= 0, ("vboxVDMACrCmdVbvaProcess -> %d\n", i8Result), i8Result); 2312 2334 2313 2335 /* Advance to the next command. */ 2314 pCmd = (VBOXCMDVBVA_HDR *)((uintptr_t)pCmd + cbCurCmd);2336 pCmd = (VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *)((uintptr_t)pCmd + cbCurCmd); 2315 2337 cbCmd -= cbCurCmd; 2316 2338 } … … 2330 2352 * @thread VDMA 2331 2353 */ 2332 static void vboxVDMACrCmdProcess(struct VBOXVDMAHOST *pVdma, uint8_t *pbCmd, uint32_t cbCmd)2354 static void vboxVDMACrCmdProcess(struct VBOXVDMAHOST *pVdma, uint8_t RT_UNTRUSTED_VOLATILE_GUEST *pbCmd, uint32_t cbCmd) 2333 2355 { 2334 2356 if ( cbCmd > 0 2335 2357 && *pbCmd == VBOXCMDVBVA_OPTYPE_NOP) 2336 2358 { /* nop */ } 2337 else if (cbCmd >= sizeof(VBOXCMDVBVA_HDR)) 2338 { 2339 PVBOXCMDVBVA_HDR pCmd = (PVBOXCMDVBVA_HDR)pbCmd; 2359 else 2360 { 2361 ASSERT_GUEST_RETURN_VOID(cbCmd >= sizeof(VBOXCMDVBVA_HDR)); 2362 VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd = (VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *)pbCmd; 2340 2363 2341 2364 /* check if the command is cancelled */ … … 2348 2371 Assert(pCmd->u8State == VBOXCMDVBVA_STATE_CANCELLED); 2349 2372 } 2350 else2351 WARN(("invalid command size"));2352 2373 2353 2374 } … … 2546 2567 AssertReturn(cbBuffer >= RT_UOFFSETOF(VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects), VERR_INVALID_PARAMETER); 2547 2568 VBOXVDMACMD_DMA_PRESENT_BLT BltSafe; 2548 memcpy(&BltSafe, (void const *)pBlt, RT_UOFFSETOF(VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects));2569 RT_BCOPY_VOLATILE(&BltSafe, (void const *)pBlt, RT_UOFFSETOF(VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects)); 2549 2570 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2550 2571 … … 2626 2647 AssertReturn(cbBuffer >= sizeof(*pTransfer), VERR_INVALID_PARAMETER); 2627 2648 VBOXVDMACMD_DMA_BPB_TRANSFER TransferSafeCopy; 2628 memcpy(&TransferSafeCopy, (void const *)pTransfer, sizeof(TransferSafeCopy));2649 RT_COPY_VOLATILE(TransferSafeCopy, *pTransfer); 2629 2650 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2630 2651 … … 2820 2841 while (!VBoxVDMAThreadIsTerminating(&pVdma->Thread)) 2821 2842 { 2822 uint8_t *pbCmd= NULL;2823 uint32_t cbCmd= 0;2843 uint8_t RT_UNTRUSTED_VOLATILE_GUEST *pbCmd = NULL; 2844 uint32_t cbCmd = 0; 2824 2845 VBVAEXHOST_DATA_TYPE enmType = VBoxVBVAExHPDataGet(pCmdVbva, &pbCmd, &cbCmd); 2825 2846 switch (enmType) … … 2873 2894 * requests. Input stat is false, so it only ever need to 2874 2895 * be set to true. 2875 * @thread VDMA2896 * @thread EMT 2876 2897 */ 2877 2898 static int vboxVDMACommandProcess(PVBOXVDMAHOST pVdma, VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, … … 3135 3156 * @param pCmd The command to handle. Considered volatile. 3136 3157 * @param cbCmd The size of the command. At least sizeof(VBOXVDMACBUF_DR). 3158 * @thread EMT 3137 3159 */ 3138 3160 void vboxVDMACommand(struct VBOXVDMAHOST *pVdma, VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd) … … 3170 3192 { 3171 3193 PVBOXVDMAHOST pVdma = (PVBOXVDMAHOST)pvContext; 3172 VBOXCMDVBVA_CTL *pGCtl = (VBOXCMDVBVA_CTL*)(pCtl->u.cmd.pu8Cmd - sizeof (VBOXCMDVBVA_CTL)); 3194 VBOXCMDVBVA_CTL RT_UNTRUSTED_VOLATILE_GUEST *pGCtl 3195 = (VBOXCMDVBVA_CTL RT_UNTRUSTED_VOLATILE_GUEST *)((uintptr_t)pCtl->u.cmd.pvCmd - sizeof(VBOXCMDVBVA_CTL)); 3173 3196 AssertRC(rc); 3174 3197 pGCtl->i32Result = rc; … … 3185 3208 */ 3186 3209 static int vdmaVBVACtlGenericSubmit(PVBOXVDMAHOST pVdma, VBVAEXHOSTCTL_SOURCE enmSource, VBVAEXHOSTCTL_TYPE enmType, 3187 uint8_t* pu8Cmd, uint32_t cbCmd, PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete) 3210 uint8_t RT_UNTRUSTED_VOLATILE_GUEST *pbCmd, uint32_t cbCmd, 3211 PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete) 3188 3212 { 3189 3213 int rc; … … 3191 3215 if (pHCtl) 3192 3216 { 3193 pHCtl->u.cmd.p u8Cmd = pu8Cmd;3194 pHCtl->u.cmd.cbCmd 3217 pHCtl->u.cmd.pvCmd = pbCmd; 3218 pHCtl->u.cmd.cbCmd = cbCmd; 3195 3219 rc = vdmaVBVACtlSubmit(pVdma, pHCtl, enmSource, pfnComplete, pvComplete); 3196 3220 if (RT_SUCCESS(rc)) … … 3217 3241 3218 3242 VBoxSHGSMICommandMarkAsynchCompletion(pCtl); 3219 int rc = vdmaVBVACtlGenericSubmit(pVdma, VBVAEXHOSTCTL_SOURCE_GUEST, enmType, (uint8_t *)(pCtl + 1), 3220 cbCtl - sizeof(VBOXCMDVBVA_CTL), vboxCmdVBVACmdCtlGuestCompletion, pVdma); 3243 int rc = vdmaVBVACtlGenericSubmit(pVdma, VBVAEXHOSTCTL_SOURCE_GUEST, enmType, 3244 (uint8_t RT_UNTRUSTED_VOLATILE_GUEST *)(pCtl + 1), 3245 cbCtl - sizeof(VBOXCMDVBVA_CTL), 3246 vboxCmdVBVACmdCtlGuestCompletion, pVdma); 3221 3247 if (RT_SUCCESS(rc)) 3222 3248 return VINF_SUCCESS; … … 3235 3261 int rc, void *pvCompletion) 3236 3262 { 3237 VBOXCRCMDCTL * pVboxCtl = (VBOXCRCMDCTL*)pCtl->u.cmd.pu8Cmd;3263 VBOXCRCMDCTL *pVboxCtl = (VBOXCRCMDCTL *)pCtl->u.cmd.pvCmd; 3238 3264 if (pVboxCtl->u.pfnInternal) 3239 3265 ((PFNCRCTLCOMPLETION)pVboxCtl->u.pfnInternal)(pVboxCtl, pCtl->u.cmd.cbCmd, rc, pvCompletion); … … 3341 3367 * Worker for vdmaVBVACtlEnableDisableSubmitInternal() and vdmaVBVACtlEnableSubmitSync(). 3342 3368 */ 3343 static int vdmaVBVACtlEnableSubmitInternal(PVBOXVDMAHOST pVdma, VBVAENABLE *pEnable, bool fPaused, PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete) 3369 static int vdmaVBVACtlEnableSubmitInternal(PVBOXVDMAHOST pVdma, VBVAENABLE RT_UNTRUSTED_VOLATILE_GUEST *pEnable, bool fPaused, 3370 PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete) 3344 3371 { 3345 3372 int rc; … … 3348 3375 if (pHCtl) 3349 3376 { 3350 pHCtl->u.cmd.p u8Cmd = (uint8_t *)pEnable;3377 pHCtl->u.cmd.pvCmd = pEnable; 3351 3378 pHCtl->u.cmd.cbCmd = sizeof(*pEnable); 3352 3379 pHCtl->pfnComplete = pfnComplete; … … 3356 3383 if (RT_SUCCESS(rc)) 3357 3384 return VINF_SUCCESS; 3358 WARN(("VBoxVDMAThreadCreate failed %d\n", rc)); 3359 3385 3386 WARN(("VBoxVDMAThreadCreate failed %Rrc\n", rc)); 3360 3387 VBoxVBVAExHCtlFree(&pVdma->CmdVbva, pHCtl); 3361 3388 } … … 3411 3438 * Worker for vdmaVBVACtlEnableDisableSubmitInternal(). 3412 3439 */ 3413 static int vdmaVBVACtlDisableSubmitInternal(PVBOXVDMAHOST pVdma, VBVAENABLE *pEnable,3440 static int vdmaVBVACtlDisableSubmitInternal(PVBOXVDMAHOST pVdma, VBVAENABLE RT_UNTRUSTED_VOLATILE_GUEST *pEnable, 3414 3441 PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete) 3415 3442 { 3416 3443 int rc; 3417 VBVAEXHOSTCTL* pHCtl;3418 3444 if (VBoxVBVAExHSIsDisabled(&pVdma->CmdVbva)) 3419 3445 { … … 3422 3448 } 3423 3449 3424 pHCtl = VBoxVBVAExHCtlCreate(&pVdma->CmdVbva, VBVAEXHOSTCTL_TYPE_GHH_DISABLE);3450 VBVAEXHOSTCTL *pHCtl = VBoxVBVAExHCtlCreate(&pVdma->CmdVbva, VBVAEXHOSTCTL_TYPE_GHH_DISABLE); 3425 3451 if (!pHCtl) 3426 3452 { … … 3429 3455 } 3430 3456 3431 pHCtl->u.cmd.p u8Cmd = (uint8_t*)pEnable;3432 pHCtl->u.cmd.cbCmd = sizeof 3457 pHCtl->u.cmd.pvCmd = pEnable; 3458 pHCtl->u.cmd.cbCmd = sizeof(*pEnable); 3433 3459 rc = vdmaVBVACtlSubmit(pVdma, pHCtl, VBVAEXHOSTCTL_SOURCE_GUEST, pfnComplete, pvComplete); 3434 3460 if (RT_SUCCESS(rc)) … … 3443 3469 * Worker for vdmaVBVACtlEnableDisableSubmit(). 3444 3470 */ 3445 static int vdmaVBVACtlEnableDisableSubmitInternal(PVBOXVDMAHOST pVdma, VBVAENABLE *pEnable,3471 static int vdmaVBVACtlEnableDisableSubmitInternal(PVBOXVDMAHOST pVdma, VBVAENABLE RT_UNTRUSTED_VOLATILE_GUEST *pEnable, 3446 3472 PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete) 3447 3473 { … … 3455 3481 * Handler for vboxCmdVBVACmdCtl/VBOXCMDVBVACTL_TYPE_ENABLE. 3456 3482 */ 3457 static int vdmaVBVACtlEnableDisableSubmit(PVBOXVDMAHOST pVdma, VBOXCMDVBVA_CTL_ENABLE *pEnable)3483 static int vdmaVBVACtlEnableDisableSubmit(PVBOXVDMAHOST pVdma, VBOXCMDVBVA_CTL_ENABLE RT_UNTRUSTED_VOLATILE_GUEST *pEnable) 3458 3484 { 3459 3485 VBoxSHGSMICommandMarkAsynchCompletion(&pEnable->Hdr); … … 3485 3511 3486 3512 3487 static int vdmaVBVACtlSubmitSync(PVBOXVDMAHOST pVdma, VBVAEXHOSTCTL* pCtl, VBVAEXHOSTCTL_SOURCE enmSource) 3513 /** 3514 * 3515 */ 3516 static int vdmaVBVACtlSubmitSync(PVBOXVDMAHOST pVdma, VBVAEXHOSTCTL *pCtl, VBVAEXHOSTCTL_SOURCE enmSource) 3488 3517 { 3489 3518 VDMA_VBVA_CTL_CYNC_COMPLETION Data; 3490 Data.rc = VERR_NOT_IMPLEMENTED; 3519 Data.rc = VERR_NOT_IMPLEMENTED; 3520 Data.hEvent = NIL_RTSEMEVENT; 3491 3521 int rc = RTSemEventCreate(&Data.hEvent); 3492 if (!RT_SUCCESS(rc)) 3493 { 3522 if (RT_SUCCESS(rc)) 3523 { 3524 rc = vdmaVBVACtlSubmit(pVdma, pCtl, enmSource, vdmaVBVACtlSubmitSyncCompletion, &Data); 3525 if (RT_SUCCESS(rc)) 3526 { 3527 rc = RTSemEventWait(Data.hEvent, RT_INDEFINITE_WAIT); 3528 if (RT_SUCCESS(rc)) 3529 { 3530 rc = Data.rc; 3531 if (!RT_SUCCESS(rc)) 3532 WARN(("vdmaVBVACtlSubmitSyncCompletion returned %Rrc\n", rc)); 3533 } 3534 else 3535 WARN(("RTSemEventWait failed %Rrc\n", rc)); 3536 } 3537 else 3538 Log(("vdmaVBVACtlSubmit failed %Rrc\n", rc)); 3539 3540 RTSemEventDestroy(Data.hEvent); 3541 } 3542 else 3494 3543 WARN(("RTSemEventCreate failed %Rrc\n", rc)); 3495 return rc;3496 }3497 3498 rc = vdmaVBVACtlSubmit(pVdma, pCtl, enmSource, vdmaVBVACtlSubmitSyncCompletion, &Data);3499 if (RT_SUCCESS(rc))3500 {3501 rc = RTSemEventWait(Data.hEvent, RT_INDEFINITE_WAIT);3502 if (RT_SUCCESS(rc))3503 {3504 rc = Data.rc;3505 if (!RT_SUCCESS(rc))3506 WARN(("vdmaVBVACtlSubmitSyncCompletion returned %Rrc\n", rc));3507 }3508 else3509 WARN(("RTSemEventWait failed %Rrc\n", rc));3510 }3511 else3512 Log(("vdmaVBVACtlSubmit failed %Rrc\n", rc));3513 3514 RTSemEventDestroy(Data.hEvent);3515 3516 3544 return rc; 3517 3545 } … … 3720 3748 * @param cbCtl The size of it. This is at least 3721 3749 * sizeof(VBOXCMDVBVA_CTL). 3750 * @thread EMT 3722 3751 */ 3723 3752 int vboxCmdVBVACmdCtl(PVGASTATE pVGAState, VBOXCMDVBVA_CTL RT_UNTRUSTED_VOLATILE_GUEST *pCtl, uint32_t cbCtl) 3724 3753 { 3725 3754 struct VBOXVDMAHOST *pVdma = pVGAState->pVdma; 3726 switch (pCtl->u32Type) 3755 uint32_t uType = pCtl->u32Type; 3756 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 3757 3758 switch (uType) 3727 3759 { 3728 3760 case VBOXCMDVBVACTL_TYPE_3DCTL: … … 3734 3766 case VBOXCMDVBVACTL_TYPE_ENABLE: 3735 3767 if (cbCtl == sizeof(VBOXCMDVBVA_CTL_ENABLE)) 3736 return vdmaVBVACtlEnableDisableSubmit(pVdma, (VBOXCMDVBVA_CTL_ENABLE *)pCtl);3768 return vdmaVBVACtlEnableDisableSubmit(pVdma, (VBOXCMDVBVA_CTL_ENABLE RT_UNTRUSTED_VOLATILE_GUEST *)pCtl); 3737 3769 WARN(("incorrect enable size\n")); 3738 3770 break; … … 3750 3782 /** 3751 3783 * Handler for VBVA_CMDVBVA_SUBMIT, see vbvaChannelHandler(). 3784 * 3785 * @thread EMT 3752 3786 */ 3753 3787 int vboxCmdVBVACmdSubmit(PVGASTATE pVGAState) … … 3764 3798 /** 3765 3799 * Handler for VBVA_CMDVBVA_FLUSH, see vbvaChannelHandler(). 3800 * 3801 * @thread EMT 3766 3802 */ 3767 3803 int vboxCmdVBVACmdFlush(PVGASTATE pVGAState) … … 3896 3932 uint8_t * pu8VramBase = pVGAState->vram_ptrR3; 3897 3933 3898 rc = SSMR3PutU32(pSSM, (uint32_t)(( (uint8_t*)pVdma->CmdVbva.pVBVA) -pu8VramBase));3934 rc = SSMR3PutU32(pSSM, (uint32_t)((uintptr_t)pVdma->CmdVbva.pVBVA - (uintptr_t)pu8VramBase)); 3899 3935 AssertRCReturn(rc, rc); 3900 3936 … … 3958 3994 3959 3995 /* sanity */ 3960 pHCtl->u.cmd.p u8Cmd = NULL;3996 pHCtl->u.cmd.pvCmd = NULL; 3961 3997 pHCtl->u.cmd.cbCmd = 0; 3962 3998 -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.cpp
r69500 r71607 3888 3888 } 3889 3889 3890 int8_t crVBoxServerCrCmdClrFillProcess(const VBOXCMDVBVA_CLRFILL_HDR *pCmd, uint32_t cbCmd) 3891 { 3890 /** @todo RT_UNTRUSTED_VOLATILE_GUEST */ 3891 int8_t crVBoxServerCrCmdClrFillProcess(VBOXCMDVBVA_CLRFILL_HDR const RT_UNTRUSTED_VOLATILE_GUEST *pCmdTodo, uint32_t cbCmd) 3892 { 3893 VBOXCMDVBVA_CLRFILL_HDR const *pCmd = (VBOXCMDVBVA_CLRFILL_HDR const *)pCmdTodo; 3892 3894 uint8_t u8Flags = pCmd->Hdr.u8Flags; 3893 3895 uint8_t u8Cmd = (VBOXCMDVBVA_OPF_CLRFILL_TYPE_MASK & u8Flags); … … 3912 3914 } 3913 3915 3914 int8_t crVBoxServerCrCmdBltProcess(const VBOXCMDVBVA_BLT_HDR *pCmd, uint32_t cbCmd) 3915 { 3916 /** @todo RT_UNTRUSTED_VOLATILE_GUEST */ 3917 int8_t crVBoxServerCrCmdBltProcess(VBOXCMDVBVA_BLT_HDR const RT_UNTRUSTED_VOLATILE_GUEST *pCmdTodo, uint32_t cbCmd) 3918 { 3919 VBOXCMDVBVA_BLT_HDR const *pCmd = (VBOXCMDVBVA_BLT_HDR const *)pCmdTodo; 3916 3920 uint8_t u8Flags = pCmd->Hdr.u8Flags; 3917 3921 uint8_t u8Cmd = (VBOXCMDVBVA_OPF_BLT_TYPE_MASK & u8Flags); … … 3955 3959 } 3956 3960 3957 int8_t crVBoxServerCrCmdFlipProcess(const VBOXCMDVBVA_FLIP *pFlip, uint32_t cbCmd) 3958 { 3961 /** @todo RT_UNTRUSTED_VOLATILE_GUEST */ 3962 int8_t crVBoxServerCrCmdFlipProcess(VBOXCMDVBVA_FLIP const RT_UNTRUSTED_VOLATILE_GUEST *pFlipTodo, uint32_t cbCmd) 3963 { 3964 VBOXCMDVBVA_FLIP const *pFlip = (VBOXCMDVBVA_FLIP const *)pFlipTodo; 3959 3965 uint32_t hostId; 3960 3966 const VBOXCMDVBVA_RECT *pPRects = pFlip->aRects; -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h
r69474 r71607 470 470 void CrFbTexDataInit(CR_TEXDATA* pFbTex, const VBOXVR_TEXTURE *pTex, PFNCRTEXDATA_RELEASED pfnTextureReleased); 471 471 472 int8_t crVBoxServerCrCmdBltProcess( const VBOXCMDVBVA_BLT_HDR*pCmd, uint32_t cbCmd);473 int8_t crVBoxServerCrCmdClrFillProcess( const VBOXCMDVBVA_CLRFILL_HDR*pCmd, uint32_t cbCmd);474 int8_t crVBoxServerCrCmdFlipProcess( const VBOXCMDVBVA_FLIP*pFlip, uint32_t cbCmd);472 int8_t crVBoxServerCrCmdBltProcess(VBOXCMDVBVA_BLT_HDR const RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd); 473 int8_t crVBoxServerCrCmdClrFillProcess(VBOXCMDVBVA_CLRFILL_HDR const RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd); 474 int8_t crVBoxServerCrCmdFlipProcess(VBOXCMDVBVA_FLIP const RT_UNTRUSTED_VOLATILE_GUEST *pFlip, uint32_t cbCmd); 475 475 476 476 -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r69390 r71607 34 34 #include <VBox/err.h> 35 35 #include <VBox/log.h> 36 #include <VBox/AssertGuest.h> 36 37 37 38 #ifdef VBOXCR_LOGFPS … … 67 68 int tearingdown = 0; /* can't be static */ 68 69 69 static DECLCALLBACK(int8_t) crVBoxCrCmdCmd(HVBOXCRCMDSVR hSvr, const VBOXCMDVBVA_HDR *pCmd, uint32_t cbCmd); 70 static DECLCALLBACK(int8_t) crVBoxCrCmdCmd(HVBOXCRCMDSVR hSvr, 71 const VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd); 70 72 71 73 DECLINLINE(CRClient*) crVBoxServerClientById(uint32_t u32ClientID) … … 2873 2875 #ifdef VBOX_WITH_CRHGSMI 2874 2876 2875 static int32_t crVBoxServerCmdVbvaCrCmdProcess(const struct VBOXCMDVBVA_CRCMD_CMD *pCmd, uint32_t cbCmd) 2876 { 2877 /** @todo RT_UNTRUSTED_VOLATILE_GUEST */ 2878 static int32_t crVBoxServerCmdVbvaCrCmdProcess(VBOXCMDVBVA_CRCMD_CMD const RT_UNTRUSTED_VOLATILE_GUEST *pCmdTodo, uint32_t cbCmd) 2879 { 2880 VBOXCMDVBVA_CRCMD_CMD const *pCmd = (VBOXCMDVBVA_CRCMD_CMD const *)pCmdTodo; 2877 2881 int32_t rc; 2878 2882 uint32_t cBuffers = pCmd->cBuffers; … … 3233 3237 } 3234 3238 3235 static int crVBoxCrConnectEx(VBOXCMDVBVA_3DCTL_CONNECT *pConnect, uint32_t u32ClientId)3239 static int crVBoxCrConnectEx(VBOXCMDVBVA_3DCTL_CONNECT RT_UNTRUSTED_VOLATILE_GUEST *pConnect, uint32_t u32ClientId) 3236 3240 { 3237 3241 CRClient *pClient; 3238 3242 int rc; 3243 uint32_t const uMajorVersion = pConnect->u32MajorVersion; 3244 uint32_t const uMinorVersion = pConnect->u32MinorVersion; 3245 uint64_t const uPid = pConnect->u64Pid; 3246 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 3239 3247 3240 3248 if (u32ClientId == CRHTABLE_HANDLE_INVALID) … … 3252 3260 if (RT_SUCCESS(rc)) 3253 3261 { 3254 rc = crVBoxServerClientObjSetVersion(pClient, pConnect->u32MajorVersion, pConnect->u32MinorVersion);3262 rc = crVBoxServerClientObjSetVersion(pClient, uMajorVersion, uMinorVersion); 3255 3263 if (RT_SUCCESS(rc)) 3256 3264 { 3257 rc = crVBoxServerClientObjSetPID(pClient, pConnect->u64Pid);3265 rc = crVBoxServerClientObjSetPID(pClient, uPid); 3258 3266 if (RT_SUCCESS(rc)) 3259 3267 { … … 3264 3272 return VINF_SUCCESS; 3265 3273 } 3266 else 3267 WARN(("CrHTablePutToSlot failed %d", rc)); 3274 WARN(("CrHTablePutToSlot failed %d", rc)); 3268 3275 } 3269 3276 else … … 3283 3290 } 3284 3291 3285 static int crVBoxCrConnect(VBOXCMDVBVA_3DCTL_CONNECT *pConnect)3292 static int crVBoxCrConnect(VBOXCMDVBVA_3DCTL_CONNECT RT_UNTRUSTED_VOLATILE_GUEST *pConnect) 3286 3293 { 3287 3294 return crVBoxCrConnectEx(pConnect, CRHTABLE_HANDLE_INVALID); 3288 3295 } 3289 3296 3290 static DECLCALLBACK(int) crVBoxCrCmdGuestCtl(HVBOXCRCMDSVR hSvr, uint8_t* pCmd, uint32_t cbCmd) 3291 { 3292 VBOXCMDVBVA_3DCTL *pCtl = (VBOXCMDVBVA_3DCTL*)pCmd; 3293 if (cbCmd < sizeof (VBOXCMDVBVA_3DCTL)) 3294 { 3295 WARN(("invalid buffer size")); 3296 return VERR_INVALID_PARAMETER; 3297 } 3298 3299 switch (pCtl->u32Type) 3300 { 3301 case VBOXCMDVBVA3DCTL_TYPE_CONNECT: 3302 { 3303 if (cbCmd != sizeof (VBOXCMDVBVA_3DCTL_CONNECT)) 3304 { 3305 WARN(("invalid command size")); 3306 return VERR_INVALID_PARAMETER; 3307 } 3308 3309 return crVBoxCrConnect((VBOXCMDVBVA_3DCTL_CONNECT*)pCtl); 3310 } 3311 case VBOXCMDVBVA3DCTL_TYPE_DISCONNECT: 3312 { 3313 if (cbCmd != sizeof (VBOXCMDVBVA_3DCTL)) 3314 { 3315 WARN(("invalid command size")); 3316 return VERR_INVALID_PARAMETER; 3317 } 3318 3319 return crVBoxCrDisconnect(pCtl->u32CmdClientId); 3320 } 3321 case VBOXCMDVBVA3DCTL_TYPE_CMD: 3322 { 3323 VBOXCMDVBVA_3DCTL_CMD *p3DCmd; 3324 if (cbCmd < sizeof (VBOXCMDVBVA_3DCTL_CMD)) 3325 { 3326 WARN(("invalid size")); 3327 return VERR_INVALID_PARAMETER; 3328 } 3329 3330 p3DCmd = (VBOXCMDVBVA_3DCTL_CMD*)pCmd; 3331 3332 return crVBoxCrCmdCmd(NULL, &p3DCmd->Cmd, cbCmd - RT_OFFSETOF(VBOXCMDVBVA_3DCTL_CMD, Cmd)); 3333 } 3334 default: 3335 WARN(("crVBoxCrCmdGuestCtl: invalid function %d", pCtl->u32Type)); 3336 return VERR_INVALID_PARAMETER; 3297 /** 3298 * @interface_method_impl{VBOXCRCMD_SVRINFO,pfnGuestCtl} 3299 */ 3300 static DECLCALLBACK(int) crVBoxCrCmdGuestCtl(HVBOXCRCMDSVR hSvr, uint8_t RT_UNTRUSTED_VOLATILE_GUEST *pbCmd, uint32_t cbCmd) 3301 { 3302 /* 3303 * Toplevel input validation. 3304 */ 3305 ASSERT_GUEST_LOGREL_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_3DCTL), VERR_INVALID_PARAMETER); 3306 { 3307 VBOXCMDVBVA_3DCTL RT_UNTRUSTED_VOLATILE_GUEST *pCtl = (VBOXCMDVBVA_3DCTL RT_UNTRUSTED_VOLATILE_GUEST*)pbCmd; 3308 const uint32_t uType = pCtl->u32Type; 3309 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 3310 3311 ASSERT_GUEST_LOGREL_RETURN( uType == VBOXCMDVBVA3DCTL_TYPE_CMD 3312 || uType == VBOXCMDVBVA3DCTL_TYPE_CONNECT 3313 || uType == VBOXCMDVBVA3DCTL_TYPE_DISCONNECT 3314 , VERR_INVALID_PARAMETER); 3315 RT_UNTRUSTED_VALIDATED_FENCE(); 3316 3317 /* 3318 * Call worker abd process the request. 3319 */ 3320 switch (uType) 3321 { 3322 case VBOXCMDVBVA3DCTL_TYPE_CMD: 3323 ASSERT_GUEST_LOGREL_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_3DCTL_CMD), VERR_INVALID_PARAMETER); 3324 { 3325 VBOXCMDVBVA_3DCTL_CMD RT_UNTRUSTED_VOLATILE_GUEST *p3DCmd 3326 = (VBOXCMDVBVA_3DCTL_CMD RT_UNTRUSTED_VOLATILE_GUEST *)pbCmd; 3327 return crVBoxCrCmdCmd(NULL, &p3DCmd->Cmd, cbCmd - RT_OFFSETOF(VBOXCMDVBVA_3DCTL_CMD, Cmd)); 3328 } 3329 3330 case VBOXCMDVBVA3DCTL_TYPE_CONNECT: 3331 ASSERT_GUEST_LOGREL_RETURN(cbCmd == sizeof(VBOXCMDVBVA_3DCTL_CONNECT), VERR_INVALID_PARAMETER); 3332 return crVBoxCrConnect((VBOXCMDVBVA_3DCTL_CONNECT RT_UNTRUSTED_VOLATILE_GUEST *)pCtl); 3333 3334 case VBOXCMDVBVA3DCTL_TYPE_DISCONNECT: 3335 ASSERT_GUEST_LOGREL_RETURN(cbCmd == sizeof(VBOXCMDVBVA_3DCTL), VERR_INVALID_PARAMETER); 3336 { 3337 uint32_t idClient = pCtl->u32CmdClientId; 3338 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 3339 return crVBoxCrDisconnect(idClient); 3340 } 3341 3342 default: 3343 AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE); 3344 } 3337 3345 } 3338 3346 } … … 3512 3520 3513 3521 3514 static DECLCALLBACK(int8_t) crVBoxCrCmdCmd(HVBOXCRCMDSVR hSvr, const VBOXCMDVBVA_HDR *pCmd, uint32_t cbCmd) 3515 { 3516 switch (pCmd->u8OpCode) 3522 /** 3523 * @interface_method_impl{VBOXCRCMD_SVRINFO,pfnCmd} 3524 */ 3525 static DECLCALLBACK(int8_t) crVBoxCrCmdCmd(HVBOXCRCMDSVR hSvr, 3526 const VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd) 3527 { 3528 uint8_t bOpcode = pCmd->u8OpCode; 3529 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 3530 ASSERT_GUEST_LOGREL_MSG_RETURN( bOpcode == VBOXCMDVBVA_OPTYPE_CRCMD 3531 || bOpcode == VBOXCMDVBVA_OPTYPE_FLIP 3532 || bOpcode == VBOXCMDVBVA_OPTYPE_BLT 3533 || bOpcode == VBOXCMDVBVA_OPTYPE_CLRFILL, 3534 ("%#x\n", bOpcode), -1); 3535 RT_UNTRUSTED_VALIDATED_FENCE(); 3536 3537 switch (bOpcode) 3517 3538 { 3518 3539 case VBOXCMDVBVA_OPTYPE_CRCMD: 3519 { 3520 const VBOXCMDVBVA_CRCMD *pCrCmdDr; 3521 const VBOXCMDVBVA_CRCMD_CMD *pCrCmd; 3522 int rc; 3523 pCrCmdDr = (const VBOXCMDVBVA_CRCMD*)pCmd; 3524 pCrCmd = &pCrCmdDr->Cmd; 3525 if (cbCmd < sizeof (VBOXCMDVBVA_CRCMD)) 3540 ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_CRCMD), ("cbCmd=%u\n", cbCmd), -1); 3526 3541 { 3527 WARN(("invalid buffer size")); 3528 return -1; 3529 } 3530 rc = crVBoxServerCmdVbvaCrCmdProcess(pCrCmd, cbCmd - RT_OFFSETOF(VBOXCMDVBVA_CRCMD, Cmd)); 3531 if (RT_SUCCESS(rc)) 3532 { 3533 /* success */ 3542 VBOXCMDVBVA_CRCMD const RT_UNTRUSTED_VOLATILE_GUEST *pCrCmdDr 3543 = (VBOXCMDVBVA_CRCMD const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd; 3544 VBOXCMDVBVA_CRCMD_CMD const RT_UNTRUSTED_VOLATILE_GUEST *pCrCmd = &pCrCmdDr->Cmd; 3545 int rc = crVBoxServerCmdVbvaCrCmdProcess(pCrCmd, cbCmd - RT_OFFSETOF(VBOXCMDVBVA_CRCMD, Cmd)); 3546 ASSERT_GUEST_LOGREL_RC_RETURN(rc, -1); 3534 3547 return 0; 3535 3548 } 3536 3549 3537 WARN(("crVBoxServerCmdVbvaCrCmdProcess failed, rc %d", rc));3538 return -1;3539 }3540 3550 case VBOXCMDVBVA_OPTYPE_FLIP: 3541 { 3542 const VBOXCMDVBVA_FLIP *pFlip; 3543 3544 if (cbCmd < VBOXCMDVBVA_SIZEOF_FLIPSTRUCT_MIN) 3551 ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= VBOXCMDVBVA_SIZEOF_FLIPSTRUCT_MIN, ("cbCmd=%u\n", cbCmd), -1); 3545 3552 { 3546 WARN(("invalid buffer size (cbCmd(%u) < sizeof(VBOXCMDVBVA_FLIP)(%u))", cbCmd, sizeof(VBOXCMDVBVA_FLIP))); 3547 return -1; 3553 VBOXCMDVBVA_FLIP const RT_UNTRUSTED_VOLATILE_GUEST *pFlip 3554 = (VBOXCMDVBVA_FLIP const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd; 3555 return crVBoxServerCrCmdFlipProcess(pFlip, cbCmd); 3548 3556 } 3549 3557 3550 pFlip = (const VBOXCMDVBVA_FLIP*)pCmd;3551 return crVBoxServerCrCmdFlipProcess(pFlip, cbCmd);3552 }3553 3558 case VBOXCMDVBVA_OPTYPE_BLT: 3554 { 3555 if (cbCmd < sizeof (VBOXCMDVBVA_BLT_HDR)) 3556 { 3557 WARN(("invalid buffer size")); 3558 return -1; 3559 } 3560 3561 return crVBoxServerCrCmdBltProcess((const VBOXCMDVBVA_BLT_HDR*)pCmd, cbCmd); 3562 } 3559 ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_BLT_HDR), ("cbCmd=%u\n", cbCmd), -1); 3560 return crVBoxServerCrCmdBltProcess((VBOXCMDVBVA_BLT_HDR const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd, cbCmd); 3561 3563 3562 case VBOXCMDVBVA_OPTYPE_CLRFILL: 3564 { 3565 if (cbCmd < sizeof (VBOXCMDVBVA_CLRFILL_HDR)) 3566 { 3567 WARN(("invalid buffer size")); 3568 return -1; 3569 } 3570 3571 return crVBoxServerCrCmdClrFillProcess((const VBOXCMDVBVA_CLRFILL_HDR*)pCmd, cbCmd); 3572 } 3563 ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_CLRFILL_HDR), ("cbCmd=%u\n", cbCmd), -1); 3564 return crVBoxServerCrCmdClrFillProcess((VBOXCMDVBVA_CLRFILL_HDR const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd, cbCmd); 3565 3573 3566 default: 3574 WARN(("unsupported command")); 3575 return -1; 3567 AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE); 3576 3568 } 3577 3569 /* not reached */
Note:
See TracChangeset
for help on using the changeset viewer.