Changeset 5040 in vbox for trunk/src/VBox/Devices/VMMDev
- Timestamp:
- Sep 26, 2007 9:03:00 AM (17 years ago)
- Location:
- trunk/src/VBox/Devices/VMMDev
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/VMMDev/VBoxDev.cpp
r4915 r5040 35 35 #include <iprt/assert.h> 36 36 #include <iprt/time.h> 37 #ifndef IN_GC 38 #include <iprt/mem.h> 39 #endif 37 40 38 41 #include "VMMDevState.h" … … 408 411 VMMDevState *pData = (VMMDevState*)pvUser; 409 412 int rcRet = VINF_SUCCESS; 410 int rc;411 413 412 414 /* 413 415 * The caller has passed the guest context physical address 414 * of the request structure. Get the corresponding host virtual 415 * address. 416 * of the request structure. Copy the request packet. 416 417 */ 417 VMMDevRequestHeader *requestHeader = NULL; 418 rc = PDMDevHlpPhys2HCVirt(pDevIns, (RTGCPHYS)u32, 0, (PRTHCPTR)&requestHeader); 419 if (VBOX_FAILURE(rc) || !requestHeader) 420 { 421 AssertMsgFailed(("VMMDev could not convert guest physical address to host virtual! rc = %Vrc\n", rc)); 422 return VINF_SUCCESS; 423 } 418 VMMDevRequestHeader requestHeader = {0}; 419 VMMDevRequestHeader *pRequestHeader = NULL; 420 421 PDMDevHlpPhysRead(pDevIns, (RTGCPHYS)u32, &requestHeader, sizeof(requestHeader)); 424 422 425 423 /* the structure size must be greater or equal to the header size */ 426 if (requestHeader->size < sizeof(VMMDevRequestHeader)) 427 { 428 Log(("VMMDev request header size too small! size = %d\n", requestHeader->size)); 429 return VINF_SUCCESS; 424 if (requestHeader.size < sizeof(VMMDevRequestHeader)) 425 { 426 Log(("VMMDev request header size too small! size = %d\n", requestHeader.size)); 427 rcRet = VINF_SUCCESS; 428 goto end; 430 429 } 431 430 432 431 /* check the version of the header structure */ 433 if (requestHeader->version != VMMDEV_REQUEST_HEADER_VERSION) 434 { 435 Log(("VMMDev: guest header version (0x%08X) differs from ours (0x%08X)\n", requestHeader->version, VMMDEV_REQUEST_HEADER_VERSION)); 436 return VINF_SUCCESS; 437 } 438 439 Log2(("VMMDev request issued: %d\n", requestHeader->requestType)); 440 441 if (requestHeader->requestType != VMMDevReq_ReportGuestInfo 432 if (requestHeader.version != VMMDEV_REQUEST_HEADER_VERSION) 433 { 434 Log(("VMMDev: guest header version (0x%08X) differs from ours (0x%08X)\n", requestHeader.version, VMMDEV_REQUEST_HEADER_VERSION)); 435 rcRet = VINF_SUCCESS; 436 goto end; 437 } 438 439 Log2(("VMMDev request issued: %d\n", requestHeader.requestType)); 440 441 if ( requestHeader.requestType != VMMDevReq_ReportGuestInfo 442 442 && !pData->fu32AdditionsOk) 443 443 { 444 444 Log(("VMMDev: guest has not yet reported to us. Refusing operation.\n")); 445 requestHeader->rc = VERR_NOT_SUPPORTED; 446 return VINF_SUCCESS; 447 } 445 requestHeader.rc = VERR_NOT_SUPPORTED; 446 rcRet = VINF_SUCCESS; 447 goto end; 448 } 449 450 /* Check upper limit */ 451 if (requestHeader.size > VMMDEV_MAX_VMMDEVREQ_SIZE) 452 { 453 LogRel(("VMMDev: request packet too big (%x). Refusing operation.\n", requestHeader.size)); 454 requestHeader.rc = VERR_NOT_SUPPORTED; 455 rcRet = VINF_SUCCESS; 456 goto end; 457 } 458 459 /* Read the entire request packet */ 460 pRequestHeader = (VMMDevRequestHeader *)RTMemAlloc(requestHeader.size); 461 if (!pRequestHeader) 462 { 463 Log(("VMMDev: RTMemAlloc failed!\n")); 464 rcRet = VINF_SUCCESS; 465 requestHeader.rc = VERR_NO_MEMORY; 466 goto end; 467 } 468 PDMDevHlpPhysRead(pDevIns, (RTGCPHYS)u32, pRequestHeader, requestHeader.size); 448 469 449 470 /* which request was sent? */ 450 switch ( requestHeader->requestType)471 switch (pRequestHeader->requestType) 451 472 { 452 473 /* … … 456 477 { 457 478 /* just return to EMT telling it that we want to halt */ 458 r eturnVINF_EM_HALT;479 rcRet = VINF_EM_HALT; 459 480 break; 460 481 } … … 465 486 case VMMDevReq_ReportGuestInfo: 466 487 { 467 if ( requestHeader->size < sizeof(VMMDevReportGuestInfo))488 if (pRequestHeader->size < sizeof(VMMDevReportGuestInfo)) 468 489 { 469 490 AssertMsgFailed(("VMMDev guest information structure has invalid size!\n")); 470 requestHeader->rc = VERR_INVALID_PARAMETER;471 } 472 else 473 { 474 VMMDevReportGuestInfo *guestInfo = (VMMDevReportGuestInfo*) requestHeader;491 pRequestHeader->rc = VERR_INVALID_PARAMETER; 492 } 493 else 494 { 495 VMMDevReportGuestInfo *guestInfo = (VMMDevReportGuestInfo*)pRequestHeader; 475 496 476 497 if (memcmp (&pData->guestInfo, &guestInfo->guestInfo, sizeof (guestInfo->guestInfo)) != 0) … … 490 511 if (pData->fu32AdditionsOk) 491 512 { 492 requestHeader->rc = VINF_SUCCESS;513 pRequestHeader->rc = VINF_SUCCESS; 493 514 } 494 515 else 495 516 { 496 requestHeader->rc = VERR_VERSION_MISMATCH;517 pRequestHeader->rc = VERR_VERSION_MISMATCH; 497 518 } 498 519 } … … 503 524 case VMMDevReq_ReportGuestCapabilities: 504 525 { 505 if ( requestHeader->size != sizeof(VMMDevReqGuestCapabilities))526 if (pRequestHeader->size != sizeof(VMMDevReqGuestCapabilities)) 506 527 { 507 528 AssertMsgFailed(("VMMDev guest caps structure has invalid size!\n")); 508 requestHeader->rc = VERR_INVALID_PARAMETER;509 } 510 else 511 { 512 VMMDevReqGuestCapabilities *guestCaps = (VMMDevReqGuestCapabilities*) requestHeader;529 pRequestHeader->rc = VERR_INVALID_PARAMETER; 530 } 531 else 532 { 533 VMMDevReqGuestCapabilities *guestCaps = (VMMDevReqGuestCapabilities*)pRequestHeader; 513 534 514 535 if (pData->guestCaps != guestCaps->caps) … … 526 547 pData->pDrv->pfnUpdateGuestCapabilities(pData->pDrv, guestCaps->caps); 527 548 } 528 requestHeader->rc = VINF_SUCCESS;549 pRequestHeader->rc = VINF_SUCCESS; 529 550 } 530 551 break; … … 536 557 case VMMDevReq_GetMouseStatus: 537 558 { 538 if ( requestHeader->size != sizeof(VMMDevReqMouseStatus))559 if (pRequestHeader->size != sizeof(VMMDevReqMouseStatus)) 539 560 { 540 561 AssertMsgFailed(("VMMDev mouse status structure has invalid size!\n")); 541 requestHeader->rc = VERR_INVALID_PARAMETER;542 } 543 else 544 { 545 VMMDevReqMouseStatus *mouseStatus = (VMMDevReqMouseStatus*) requestHeader;562 pRequestHeader->rc = VERR_INVALID_PARAMETER; 563 } 564 else 565 { 566 VMMDevReqMouseStatus *mouseStatus = (VMMDevReqMouseStatus*)pRequestHeader; 546 567 mouseStatus->mouseFeatures = 0; 547 568 if (pData->mouseCapabilities & VMMDEV_MOUSEHOSTWANTSABS) … … 561 582 Log2(("returning mouse status: features = %d, absX = %d, absY = %d\n", mouseStatus->mouseFeatures, 562 583 mouseStatus->pointerXPos, mouseStatus->pointerYPos)); 563 requestHeader->rc = VINF_SUCCESS;584 pRequestHeader->rc = VINF_SUCCESS; 564 585 } 565 586 break; … … 571 592 case VMMDevReq_SetMouseStatus: 572 593 { 573 if ( requestHeader->size != sizeof(VMMDevReqMouseStatus))594 if (pRequestHeader->size != sizeof(VMMDevReqMouseStatus)) 574 595 { 575 596 AssertMsgFailed(("VMMDev mouse status structure has invalid size %d (%#x) version=%d!\n", 576 requestHeader->size, requestHeader->size, requestHeader->size, requestHeader->version));577 requestHeader->rc = VERR_INVALID_PARAMETER;597 pRequestHeader->size, pRequestHeader->size, pRequestHeader->size, pRequestHeader->version)); 598 pRequestHeader->rc = VERR_INVALID_PARAMETER; 578 599 } 579 600 else … … 581 602 bool bCapsChanged = false; 582 603 583 VMMDevReqMouseStatus *mouseStatus = (VMMDevReqMouseStatus*) requestHeader;604 VMMDevReqMouseStatus *mouseStatus = (VMMDevReqMouseStatus*)pRequestHeader; 584 605 585 606 /* check if the guest wants absolute coordinates */ … … 615 636 pData->pDrv->pfnUpdateMouseCapabilities(pData->pDrv, pData->mouseCapabilities); 616 637 } 617 requestHeader->rc = VINF_SUCCESS;638 pRequestHeader->rc = VINF_SUCCESS; 618 639 } 619 640 … … 626 647 case VMMDevReq_SetPointerShape: 627 648 { 628 if ( requestHeader->size < sizeof(VMMDevReqMousePointer))629 { 630 AssertMsg( requestHeader->size == 0x10028 && requestHeader->version == 10000, /* don't bitch about legacy!!! */649 if (pRequestHeader->size < sizeof(VMMDevReqMousePointer)) 650 { 651 AssertMsg(pRequestHeader->size == 0x10028 && pRequestHeader->version == 10000, /* don't bitch about legacy!!! */ 631 652 ("VMMDev mouse shape structure has invalid size %d (%#x) version=%d!\n", 632 requestHeader->size, requestHeader->size, requestHeader->size, requestHeader->version));633 requestHeader->rc = VERR_INVALID_PARAMETER;634 } 635 else 636 { 637 VMMDevReqMousePointer *pointerShape = (VMMDevReqMousePointer*) requestHeader;653 pRequestHeader->size, pRequestHeader->size, pRequestHeader->size, pRequestHeader->version)); 654 pRequestHeader->rc = VERR_INVALID_PARAMETER; 655 } 656 else 657 { 658 VMMDevReqMousePointer *pointerShape = (VMMDevReqMousePointer*)pRequestHeader; 638 659 639 660 bool fVisible = (pointerShape->fFlags & VBOX_MOUSE_POINTER_VISIBLE) != 0; … … 663 684 NULL); 664 685 } 665 requestHeader->rc = VINF_SUCCESS;686 pRequestHeader->rc = VINF_SUCCESS; 666 687 } 667 688 break; … … 673 694 case VMMDevReq_GetHostTime: 674 695 { 675 if ( requestHeader->size != sizeof(VMMDevReqHostTime))696 if (pRequestHeader->size != sizeof(VMMDevReqHostTime)) 676 697 { 677 698 AssertMsgFailed(("VMMDev host time structure has invalid size!\n")); 678 requestHeader->rc = VERR_INVALID_PARAMETER;699 pRequestHeader->rc = VERR_INVALID_PARAMETER; 679 700 } 680 701 else if (RT_UNLIKELY(pData->fGetHostTimeDisabled)) 681 requestHeader->rc = VERR_NOT_SUPPORTED;682 else 683 { 684 VMMDevReqHostTime *hostTimeReq = (VMMDevReqHostTime*) requestHeader;702 pRequestHeader->rc = VERR_NOT_SUPPORTED; 703 else 704 { 705 VMMDevReqHostTime *hostTimeReq = (VMMDevReqHostTime*)pRequestHeader; 685 706 RTTIMESPEC now; 686 707 hostTimeReq->time = RTTimeSpecGetMilli(PDMDevHlpUTCNow(pDevIns, &now)); 687 requestHeader->rc = VINF_SUCCESS;708 pRequestHeader->rc = VINF_SUCCESS; 688 709 } 689 710 break; … … 695 716 case VMMDevReq_GetHypervisorInfo: 696 717 { 697 if ( requestHeader->size != sizeof(VMMDevReqHypervisorInfo))718 if (pRequestHeader->size != sizeof(VMMDevReqHypervisorInfo)) 698 719 { 699 720 AssertMsgFailed(("VMMDev hypervisor info structure has invalid size!\n")); 700 requestHeader->rc = VERR_INVALID_PARAMETER;701 } 702 else 703 { 704 VMMDevReqHypervisorInfo *hypervisorInfo = (VMMDevReqHypervisorInfo*) requestHeader;721 pRequestHeader->rc = VERR_INVALID_PARAMETER; 722 } 723 else 724 { 725 VMMDevReqHypervisorInfo *hypervisorInfo = (VMMDevReqHypervisorInfo*)pRequestHeader; 705 726 PVM pVM = PDMDevHlpGetVM(pDevIns); 706 727 size_t hypervisorSize = 0; 707 requestHeader->rc = PGMR3MappingsSize(pVM, &hypervisorSize);728 pRequestHeader->rc = PGMR3MappingsSize(pVM, &hypervisorSize); 708 729 hypervisorInfo->hypervisorSize = (uint32_t)hypervisorSize; 709 730 Assert(hypervisorInfo->hypervisorSize == hypervisorSize); … … 717 738 case VMMDevReq_SetHypervisorInfo: 718 739 { 719 if ( requestHeader->size != sizeof(VMMDevReqHypervisorInfo))740 if (pRequestHeader->size != sizeof(VMMDevReqHypervisorInfo)) 720 741 { 721 742 AssertMsgFailed(("VMMDev hypervisor info structure has invalid size!\n")); 722 requestHeader->rc = VERR_INVALID_PARAMETER;723 } 724 else 725 { 726 VMMDevReqHypervisorInfo *hypervisorInfo = (VMMDevReqHypervisorInfo*) requestHeader;743 pRequestHeader->rc = VERR_INVALID_PARAMETER; 744 } 745 else 746 { 747 VMMDevReqHypervisorInfo *hypervisorInfo = (VMMDevReqHypervisorInfo*)pRequestHeader; 727 748 PVM pVM = PDMDevHlpGetVM(pDevIns); 728 749 if (hypervisorInfo->hypervisorStart == 0) 729 750 { 730 requestHeader->rc = PGMR3MappingsUnfix(pVM);751 pRequestHeader->rc = PGMR3MappingsUnfix(pVM); 731 752 } else 732 753 { 733 754 /* only if the client has queried the size before! */ 734 755 size_t mappingsSize; 735 requestHeader->rc = PGMR3MappingsSize(pVM, &mappingsSize);736 if (VBOX_SUCCESS( requestHeader->rc) && (hypervisorInfo->hypervisorSize == mappingsSize))756 pRequestHeader->rc = PGMR3MappingsSize(pVM, &mappingsSize); 757 if (VBOX_SUCCESS(pRequestHeader->rc) && (hypervisorInfo->hypervisorSize == mappingsSize)) 737 758 { 738 759 /* new reservation */ 739 requestHeader->rc = PGMR3MappingsFix(pVM, hypervisorInfo->hypervisorStart,760 pRequestHeader->rc = PGMR3MappingsFix(pVM, hypervisorInfo->hypervisorStart, 740 761 hypervisorInfo->hypervisorSize); 741 762 LogRel(("Guest reported fixed hypervisor window at 0x%p (size = 0x%x, rc = %Vrc)\n", 742 763 hypervisorInfo->hypervisorStart, 743 764 hypervisorInfo->hypervisorSize, 744 requestHeader->rc));765 pRequestHeader->rc)); 745 766 } 746 767 } … … 754 775 case VMMDevReq_SetPowerStatus: 755 776 { 756 if ( requestHeader->size != sizeof(VMMDevPowerStateRequest))777 if (pRequestHeader->size != sizeof(VMMDevPowerStateRequest)) 757 778 { 758 779 AssertMsgFailed(("VMMDev power state request structure has invalid size!\n")); 759 requestHeader->rc = VERR_INVALID_PARAMETER;760 } 761 else 762 { 763 VMMDevPowerStateRequest *powerStateRequest = (VMMDevPowerStateRequest*) requestHeader;780 pRequestHeader->rc = VERR_INVALID_PARAMETER; 781 } 782 else 783 { 784 VMMDevPowerStateRequest *powerStateRequest = (VMMDevPowerStateRequest*)pRequestHeader; 764 785 switch(powerStateRequest->powerState) 765 786 { … … 767 788 { 768 789 LogRel(("Guest requests the VM to be suspended (paused)\n")); 769 requestHeader->rc = rcRet = PDMDevHlpVMSuspend(pDevIns);790 pRequestHeader->rc = rcRet = PDMDevHlpVMSuspend(pDevIns); 770 791 break; 771 792 } … … 774 795 { 775 796 LogRel(("Guest requests the VM to be turned off\n")); 776 requestHeader->rc = rcRet = PDMDevHlpVMPowerOff(pDevIns);797 pRequestHeader->rc = rcRet = PDMDevHlpVMPowerOff(pDevIns); 777 798 break; 778 799 } … … 781 802 { 782 803 /** @todo no API for that yet */ 783 requestHeader->rc = VERR_NOT_IMPLEMENTED;804 pRequestHeader->rc = VERR_NOT_IMPLEMENTED; 784 805 break; 785 806 } … … 787 808 default: 788 809 AssertMsgFailed(("VMMDev invalid power state request: %d\n", powerStateRequest->powerState)); 789 requestHeader->rc = VERR_INVALID_PARAMETER;810 pRequestHeader->rc = VERR_INVALID_PARAMETER; 790 811 break; 791 812 } … … 799 820 case VMMDevReq_GetDisplayChangeRequest: 800 821 { 801 if ( requestHeader->size != sizeof(VMMDevDisplayChangeRequest))822 if (pRequestHeader->size != sizeof(VMMDevDisplayChangeRequest)) 802 823 { 803 824 /* Assert only if the size also not equal to a previous version size to prevent 804 825 * assertion with old additions. 805 826 */ 806 AssertMsg( requestHeader->size == sizeof(VMMDevDisplayChangeRequest) - sizeof (uint32_t),827 AssertMsg(pRequestHeader->size == sizeof(VMMDevDisplayChangeRequest) - sizeof (uint32_t), 807 828 ("VMMDev display change request structure has invalid size!\n")); 808 requestHeader->rc = VERR_INVALID_PARAMETER;809 } 810 else 811 { 812 VMMDevDisplayChangeRequest *displayChangeRequest = (VMMDevDisplayChangeRequest*) requestHeader;829 pRequestHeader->rc = VERR_INVALID_PARAMETER; 830 } 831 else 832 { 833 VMMDevDisplayChangeRequest *displayChangeRequest = (VMMDevDisplayChangeRequest*)pRequestHeader; 813 834 /* just pass on the information */ 814 835 Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d\n", … … 824 845 } 825 846 826 requestHeader->rc = VINF_SUCCESS;847 pRequestHeader->rc = VINF_SUCCESS; 827 848 } 828 849 break; … … 831 852 case VMMDevReq_GetDisplayChangeRequest2: 832 853 { 833 if ( requestHeader->size != sizeof(VMMDevDisplayChangeRequest2))834 { 835 requestHeader->rc = VERR_INVALID_PARAMETER;836 } 837 else 838 { 839 VMMDevDisplayChangeRequest2 *displayChangeRequest = (VMMDevDisplayChangeRequest2*) requestHeader;854 if (pRequestHeader->size != sizeof(VMMDevDisplayChangeRequest2)) 855 { 856 pRequestHeader->rc = VERR_INVALID_PARAMETER; 857 } 858 else 859 { 860 VMMDevDisplayChangeRequest2 *displayChangeRequest = (VMMDevDisplayChangeRequest2*)pRequestHeader; 840 861 /* just pass on the information */ 841 862 Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d at %d\n", … … 852 873 } 853 874 854 requestHeader->rc = VINF_SUCCESS;875 pRequestHeader->rc = VINF_SUCCESS; 855 876 } 856 877 break; … … 862 883 case VMMDevReq_VideoModeSupported: 863 884 { 864 if ( requestHeader->size != sizeof(VMMDevVideoModeSupportedRequest))885 if (pRequestHeader->size != sizeof(VMMDevVideoModeSupportedRequest)) 865 886 { 866 887 AssertMsgFailed(("VMMDev video mode supported request structure has invalid size!\n")); 867 requestHeader->rc = VERR_INVALID_PARAMETER;868 } 869 else 870 { 871 VMMDevVideoModeSupportedRequest *videoModeSupportedRequest = (VMMDevVideoModeSupportedRequest*) requestHeader;888 pRequestHeader->rc = VERR_INVALID_PARAMETER; 889 } 890 else 891 { 892 VMMDevVideoModeSupportedRequest *videoModeSupportedRequest = (VMMDevVideoModeSupportedRequest*)pRequestHeader; 872 893 /* forward the call */ 873 requestHeader->rc = pData->pDrv->pfnVideoModeSupported(pData->pDrv,894 pRequestHeader->rc = pData->pDrv->pfnVideoModeSupported(pData->pDrv, 874 895 videoModeSupportedRequest->width, 875 896 videoModeSupportedRequest->height, … … 885 906 case VMMDevReq_GetHeightReduction: 886 907 { 887 if ( requestHeader->size != sizeof(VMMDevGetHeightReductionRequest))908 if (pRequestHeader->size != sizeof(VMMDevGetHeightReductionRequest)) 888 909 { 889 910 AssertMsgFailed(("VMMDev height reduction request structure has invalid size!\n")); 890 requestHeader->rc = VERR_INVALID_PARAMETER;891 } 892 else 893 { 894 VMMDevGetHeightReductionRequest *heightReductionRequest = (VMMDevGetHeightReductionRequest*) requestHeader;911 pRequestHeader->rc = VERR_INVALID_PARAMETER; 912 } 913 else 914 { 915 VMMDevGetHeightReductionRequest *heightReductionRequest = (VMMDevGetHeightReductionRequest*)pRequestHeader; 895 916 /* forward the call */ 896 requestHeader->rc = pData->pDrv->pfnGetHeightReduction(pData->pDrv,917 pRequestHeader->rc = pData->pDrv->pfnGetHeightReduction(pData->pDrv, 897 918 &heightReductionRequest->heightReduction); 898 919 } … … 905 926 case VMMDevReq_AcknowledgeEvents: 906 927 { 907 if ( requestHeader->size != sizeof(VMMDevEvents))928 if (pRequestHeader->size != sizeof(VMMDevEvents)) 908 929 { 909 930 AssertMsgFailed(("VMMDevReq_AcknowledgeEvents structure has invalid size!\n")); 910 requestHeader->rc = VERR_INVALID_PARAMETER;931 pRequestHeader->rc = VERR_INVALID_PARAMETER; 911 932 } 912 933 else … … 926 947 } 927 948 928 pAckRequest = (VMMDevEvents *) requestHeader;949 pAckRequest = (VMMDevEvents *)pRequestHeader; 929 950 pAckRequest->events = 930 951 pData->u32HostEventFlags & pData->u32GuestFilterMask; … … 934 955 PDMDevHlpPCISetIrqNoWait (pData->pDevIns, 0, 0); 935 956 } 936 requestHeader->rc = VINF_SUCCESS;957 pRequestHeader->rc = VINF_SUCCESS; 937 958 } 938 959 break; … … 944 965 case VMMDevReq_CtlGuestFilterMask: 945 966 { 946 if ( requestHeader->size != sizeof(VMMDevCtlGuestFilterMask))967 if (pRequestHeader->size != sizeof(VMMDevCtlGuestFilterMask)) 947 968 { 948 969 AssertMsgFailed(("VMMDevReq_AcknowledgeEvents structure has invalid size!\n")); 949 requestHeader->rc = VERR_INVALID_PARAMETER;970 pRequestHeader->rc = VERR_INVALID_PARAMETER; 950 971 } 951 972 else … … 953 974 VMMDevCtlGuestFilterMask *pCtlMaskRequest; 954 975 955 pCtlMaskRequest = (VMMDevCtlGuestFilterMask *) requestHeader;976 pCtlMaskRequest = (VMMDevCtlGuestFilterMask *)pRequestHeader; 956 977 /* The HGCM events are enabled by the VMMDev device automatically when any 957 978 * HGCM command is issued. The guest then can not disable these events. … … 960 981 pCtlMaskRequest->u32OrMask, 961 982 pCtlMaskRequest->u32NotMask & ~VMMDEV_EVENT_HGCM); 962 requestHeader->rc = VINF_SUCCESS;983 pRequestHeader->rc = VINF_SUCCESS; 963 984 964 985 } … … 972 993 case VMMDevReq_HGCMConnect: 973 994 { 974 if ( requestHeader->size < sizeof(VMMDevHGCMConnect))995 if (pRequestHeader->size < sizeof(VMMDevHGCMConnect)) 975 996 { 976 997 AssertMsgFailed(("VMMDevReq_HGCMConnect structure has invalid size!\n")); 977 requestHeader->rc = VERR_INVALID_PARAMETER;998 pRequestHeader->rc = VERR_INVALID_PARAMETER; 978 999 } 979 1000 else if (!pData->pHGCMDrv) 980 1001 { 981 1002 Log(("VMMDevReq_HGCMConnect HGCM Connector is NULL!\n")); 982 requestHeader->rc = VERR_NOT_SUPPORTED;983 } 984 else 985 { 986 VMMDevHGCMConnect *pHGCMConnect = (VMMDevHGCMConnect *) requestHeader;1003 pRequestHeader->rc = VERR_NOT_SUPPORTED; 1004 } 1005 else 1006 { 1007 VMMDevHGCMConnect *pHGCMConnect = (VMMDevHGCMConnect *)pRequestHeader; 987 1008 988 1009 Log(("VMMDevReq_HGCMConnect\n")); 989 1010 990 requestHeader->rc = vmmdevHGCMConnect (pData, pHGCMConnect, (RTGCPHYS)u32);1011 pRequestHeader->rc = vmmdevHGCMConnect (pData, pHGCMConnect, (RTGCPHYS)u32); 991 1012 } 992 1013 break; … … 995 1016 case VMMDevReq_HGCMDisconnect: 996 1017 { 997 if ( requestHeader->size < sizeof(VMMDevHGCMDisconnect))1018 if (pRequestHeader->size < sizeof(VMMDevHGCMDisconnect)) 998 1019 { 999 1020 AssertMsgFailed(("VMMDevReq_HGCMDisconnect structure has invalid size!\n")); 1000 requestHeader->rc = VERR_INVALID_PARAMETER;1021 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1001 1022 } 1002 1023 else if (!pData->pHGCMDrv) 1003 1024 { 1004 1025 Log(("VMMDevReq_HGCMDisconnect HGCM Connector is NULL!\n")); 1005 requestHeader->rc = VERR_NOT_SUPPORTED;1006 } 1007 else 1008 { 1009 VMMDevHGCMDisconnect *pHGCMDisconnect = (VMMDevHGCMDisconnect *) requestHeader;1026 pRequestHeader->rc = VERR_NOT_SUPPORTED; 1027 } 1028 else 1029 { 1030 VMMDevHGCMDisconnect *pHGCMDisconnect = (VMMDevHGCMDisconnect *)pRequestHeader; 1010 1031 1011 1032 Log(("VMMDevReq_VMMDevHGCMDisconnect\n")); 1012 requestHeader->rc = vmmdevHGCMDisconnect (pData, pHGCMDisconnect, (RTGCPHYS)u32);1033 pRequestHeader->rc = vmmdevHGCMDisconnect (pData, pHGCMDisconnect, (RTGCPHYS)u32); 1013 1034 } 1014 1035 break; … … 1017 1038 case VMMDevReq_HGCMCall: 1018 1039 { 1019 if ( requestHeader->size < sizeof(VMMDevHGCMCall))1040 if (pRequestHeader->size < sizeof(VMMDevHGCMCall)) 1020 1041 { 1021 1042 AssertMsgFailed(("VMMDevReq_HGCMCall structure has invalid size!\n")); 1022 requestHeader->rc = VERR_INVALID_PARAMETER;1043 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1023 1044 } 1024 1045 else if (!pData->pHGCMDrv) 1025 1046 { 1026 1047 Log(("VMMDevReq_HGCMCall HGCM Connector is NULL!\n")); 1027 requestHeader->rc = VERR_NOT_SUPPORTED;1028 } 1029 else 1030 { 1031 VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *) requestHeader;1048 pRequestHeader->rc = VERR_NOT_SUPPORTED; 1049 } 1050 else 1051 { 1052 VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)pRequestHeader; 1032 1053 1033 1054 Log2(("VMMDevReq_HGCMCall: sizeof (VMMDevHGCMRequest) = %04X\n", sizeof (VMMDevHGCMCall))); 1034 Log2(("%.*Vhxd\n", requestHeader->size, requestHeader));1035 1036 requestHeader->rc = vmmdevHGCMCall (pData, pHGCMCall, (RTGCPHYS)u32);1055 Log2(("%.*Vhxd\n", pRequestHeader->size, requestHeader)); 1056 1057 pRequestHeader->rc = vmmdevHGCMCall (pData, pHGCMCall, (RTGCPHYS)u32); 1037 1058 } 1038 1059 break; … … 1042 1063 case VMMDevReq_VideoAccelEnable: 1043 1064 { 1044 if ( requestHeader->size < sizeof(VMMDevVideoAccelEnable))1065 if (pRequestHeader->size < sizeof(VMMDevVideoAccelEnable)) 1045 1066 { 1046 1067 Log(("VMMDevReq_VideoAccelEnable request size too small!!!\n")); 1047 requestHeader->rc = VERR_INVALID_PARAMETER;1068 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1048 1069 } 1049 1070 else if (!pData->pDrv) 1050 1071 { 1051 1072 Log(("VMMDevReq_VideoAccelEnable Connector is NULL!!!\n")); 1052 requestHeader->rc = VERR_NOT_SUPPORTED;1053 } 1054 else 1055 { 1056 VMMDevVideoAccelEnable *ptr = (VMMDevVideoAccelEnable *) requestHeader;1073 pRequestHeader->rc = VERR_NOT_SUPPORTED; 1074 } 1075 else 1076 { 1077 VMMDevVideoAccelEnable *ptr = (VMMDevVideoAccelEnable *)pRequestHeader; 1057 1078 1058 1079 if (ptr->cbRingBuffer != VBVA_RING_BUFFER_SIZE) … … 1060 1081 /* The guest driver seems compiled with another headers. */ 1061 1082 Log(("VMMDevReq_VideoAccelEnable guest ring buffer size %d, should be %d!!!\n", ptr->cbRingBuffer, VBVA_RING_BUFFER_SIZE)); 1062 requestHeader->rc = VERR_INVALID_PARAMETER;1083 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1063 1084 } 1064 1085 else … … 1069 1090 LogFlow(("VMMDevReq_VideoAccelEnable ptr->u32Enable = %d\n", ptr->u32Enable)); 1070 1091 1071 requestHeader->rc = ptr->u32Enable?1092 pRequestHeader->rc = ptr->u32Enable? 1072 1093 pData->pDrv->pfnVideoAccelEnable (pData->pDrv, true, &pData->pVMMDevRAMHC->vbvaMemory): 1073 1094 pData->pDrv->pfnVideoAccelEnable (pData->pDrv, false, NULL); 1074 1095 1075 1096 if ( ptr->u32Enable 1076 && VBOX_SUCCESS ( requestHeader->rc))1097 && VBOX_SUCCESS (pRequestHeader->rc)) 1077 1098 { 1078 1099 ptr->fu32Status |= VBVA_F_STATUS_ENABLED; … … 1095 1116 case VMMDevReq_VideoAccelFlush: 1096 1117 { 1097 if ( requestHeader->size < sizeof(VMMDevVideoAccelFlush))1118 if (pRequestHeader->size < sizeof(VMMDevVideoAccelFlush)) 1098 1119 { 1099 1120 AssertMsgFailed(("VMMDevReq_VideoAccelFlush request size too small.\n")); 1100 requestHeader->rc = VERR_INVALID_PARAMETER;1121 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1101 1122 } 1102 1123 else if (!pData->pDrv) 1103 1124 { 1104 1125 Log(("VMMDevReq_VideoAccelFlush Connector is NULL!\n")); 1105 requestHeader->rc = VERR_NOT_SUPPORTED;1126 pRequestHeader->rc = VERR_NOT_SUPPORTED; 1106 1127 } 1107 1128 else … … 1109 1130 pData->pDrv->pfnVideoAccelFlush (pData->pDrv); 1110 1131 1111 requestHeader->rc = VINF_SUCCESS;1132 pRequestHeader->rc = VINF_SUCCESS; 1112 1133 } 1113 1134 break; … … 1116 1137 case VMMDevReq_VideoSetVisibleRegion: 1117 1138 { 1118 if ( requestHeader->size < sizeof(VMMDevVideoSetVisibleRegion))1139 if (pRequestHeader->size < sizeof(VMMDevVideoSetVisibleRegion)) 1119 1140 { 1120 1141 Log(("VMMDevReq_VideoSetVisibleRegion request size too small!!!\n")); 1121 requestHeader->rc = VERR_INVALID_PARAMETER;1142 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1122 1143 } 1123 1144 else if (!pData->pDrv) 1124 1145 { 1125 1146 Log(("VMMDevReq_VideoSetVisibleRegion Connector is NULL!!!\n")); 1126 requestHeader->rc = VERR_NOT_SUPPORTED;1127 } 1128 else 1129 { 1130 VMMDevVideoSetVisibleRegion *ptr = (VMMDevVideoSetVisibleRegion *) requestHeader;1147 pRequestHeader->rc = VERR_NOT_SUPPORTED; 1148 } 1149 else 1150 { 1151 VMMDevVideoSetVisibleRegion *ptr = (VMMDevVideoSetVisibleRegion *)pRequestHeader; 1131 1152 1132 1153 if (!ptr->cRect) 1133 1154 { 1134 1155 Log(("VMMDevReq_VideoSetVisibleRegion no rectangles!!!\n")); 1135 requestHeader->rc = VERR_INVALID_PARAMETER;1156 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1136 1157 } 1137 1158 else 1138 if ( requestHeader->size != sizeof(VMMDevVideoSetVisibleRegion) + (ptr->cRect-1)*sizeof(RTRECT))1159 if (pRequestHeader->size != sizeof(VMMDevVideoSetVisibleRegion) + (ptr->cRect-1)*sizeof(RTRECT)) 1139 1160 { 1140 1161 Log(("VMMDevReq_VideoSetVisibleRegion request size too small!!!\n")); 1141 requestHeader->rc = VERR_INVALID_PARAMETER;1162 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1142 1163 } 1143 1164 else … … 1145 1166 Log(("VMMDevReq_VideoSetVisibleRegion %d rectangles\n", ptr->cRect)); 1146 1167 /* forward the call */ 1147 requestHeader->rc = pData->pDrv->pfnSetVisibleRegion(pData->pDrv, ptr->cRect, &ptr->Rect);1168 pRequestHeader->rc = pData->pDrv->pfnSetVisibleRegion(pData->pDrv, ptr->cRect, &ptr->Rect); 1148 1169 } 1149 1170 } … … 1153 1174 case VMMDevReq_GetSeamlessChangeRequest: 1154 1175 { 1155 if ( requestHeader->size != sizeof(VMMDevSeamlessChangeRequest))1156 { 1157 requestHeader->rc = VERR_INVALID_PARAMETER;1158 } 1159 else 1160 { 1161 VMMDevSeamlessChangeRequest *seamlessChangeRequest = (VMMDevSeamlessChangeRequest*) requestHeader;1176 if (pRequestHeader->size != sizeof(VMMDevSeamlessChangeRequest)) 1177 { 1178 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1179 } 1180 else 1181 { 1182 VMMDevSeamlessChangeRequest *seamlessChangeRequest = (VMMDevSeamlessChangeRequest*)pRequestHeader; 1162 1183 /* just pass on the information */ 1163 1184 Log(("VMMDev: returning seamless change request mode=%d\n", pData->fSeamlessEnabled)); … … 1173 1194 } 1174 1195 1175 requestHeader->rc = VINF_SUCCESS;1196 pRequestHeader->rc = VINF_SUCCESS; 1176 1197 } 1177 1198 break; … … 1180 1201 case VMMDevReq_GetVRDPChangeRequest: 1181 1202 { 1182 if ( requestHeader->size != sizeof(VMMDevVRDPChangeRequest))1183 { 1184 requestHeader->rc = VERR_INVALID_PARAMETER;1185 } 1186 else 1187 { 1188 VMMDevVRDPChangeRequest *vrdpChangeRequest = (VMMDevVRDPChangeRequest*) requestHeader;1203 if (pRequestHeader->size != sizeof(VMMDevVRDPChangeRequest)) 1204 { 1205 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1206 } 1207 else 1208 { 1209 VMMDevVRDPChangeRequest *vrdpChangeRequest = (VMMDevVRDPChangeRequest*)pRequestHeader; 1189 1210 /* just pass on the information */ 1190 1211 Log(("VMMDev: returning VRDP status %d level %d\n", pData->fVRDPEnabled, pData->u32VRDPExperienceLevel)); … … 1193 1214 vrdpChangeRequest->u32VRDPExperienceLevel = pData->u32VRDPExperienceLevel; 1194 1215 1195 requestHeader->rc = VINF_SUCCESS;1216 pRequestHeader->rc = VINF_SUCCESS; 1196 1217 } 1197 1218 break; … … 1201 1222 { 1202 1223 Log(("VMMDevReq_GetMemBalloonChangeRequest\n")); 1203 if ( requestHeader->size != sizeof(VMMDevGetMemBalloonChangeRequest))1224 if (pRequestHeader->size != sizeof(VMMDevGetMemBalloonChangeRequest)) 1204 1225 { 1205 1226 AssertFailed(); 1206 requestHeader->rc = VERR_INVALID_PARAMETER;1207 } 1208 else 1209 { 1210 VMMDevGetMemBalloonChangeRequest *memBalloonChangeRequest = (VMMDevGetMemBalloonChangeRequest*) requestHeader;1227 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1228 } 1229 else 1230 { 1231 VMMDevGetMemBalloonChangeRequest *memBalloonChangeRequest = (VMMDevGetMemBalloonChangeRequest*)pRequestHeader; 1211 1232 /* just pass on the information */ 1212 1233 Log(("VMMDev: returning memory balloon size =%d\n", pData->u32MemoryBalloonSize)); … … 1220 1241 } 1221 1242 1222 requestHeader->rc = VINF_SUCCESS;1243 pRequestHeader->rc = VINF_SUCCESS; 1223 1244 } 1224 1245 break; … … 1227 1248 case VMMDevReq_ChangeMemBalloon: 1228 1249 { 1229 VMMDevChangeMemBalloon *memBalloonChange = (VMMDevChangeMemBalloon*) requestHeader;1250 VMMDevChangeMemBalloon *memBalloonChange = (VMMDevChangeMemBalloon*)pRequestHeader; 1230 1251 1231 1252 Log(("VMMDevReq_ChangeMemBalloon\n")); 1232 if ( requestHeader->size < sizeof(VMMDevChangeMemBalloon)1253 if ( pRequestHeader->size < sizeof(VMMDevChangeMemBalloon) 1233 1254 || memBalloonChange->cPages != VMMDEV_MEMORY_BALLOON_CHUNK_PAGES 1234 || requestHeader->size != (uint32_t)RT_OFFSETOF(VMMDevChangeMemBalloon, aPhysPage[memBalloonChange->cPages]))1255 || pRequestHeader->size != (uint32_t)RT_OFFSETOF(VMMDevChangeMemBalloon, aPhysPage[memBalloonChange->cPages])) 1235 1256 { 1236 1257 AssertFailed(); 1237 requestHeader->rc = VERR_INVALID_PARAMETER;1238 } 1239 else 1240 { 1241 requestHeader->rc = pData->pDrv->pfnChangeMemoryBalloon(pData->pDrv, !!memBalloonChange->fInflate, memBalloonChange->cPages, memBalloonChange->aPhysPage);1258 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1259 } 1260 else 1261 { 1262 pRequestHeader->rc = pData->pDrv->pfnChangeMemoryBalloon(pData->pDrv, !!memBalloonChange->fInflate, memBalloonChange->cPages, memBalloonChange->aPhysPage); 1242 1263 } 1243 1264 break; … … 1247 1268 { 1248 1269 Log(("VMMDevReq_GetStatisticsChangeRequest\n")); 1249 if ( requestHeader->size != sizeof(VMMDevGetStatisticsChangeRequest))1270 if (pRequestHeader->size != sizeof(VMMDevGetStatisticsChangeRequest)) 1250 1271 { 1251 1272 AssertFailed(); 1252 requestHeader->rc = VERR_INVALID_PARAMETER;1253 } 1254 else 1255 { 1256 VMMDevGetStatisticsChangeRequest *statIntervalChangeRequest = (VMMDevGetStatisticsChangeRequest*) requestHeader;1273 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1274 } 1275 else 1276 { 1277 VMMDevGetStatisticsChangeRequest *statIntervalChangeRequest = (VMMDevGetStatisticsChangeRequest*)pRequestHeader; 1257 1278 /* just pass on the information */ 1258 1279 Log(("VMMDev: returning statistics interval %d seconds\n", pData->u32StatIntervalSize)); … … 1265 1286 } 1266 1287 1267 requestHeader->rc = VINF_SUCCESS;1288 pRequestHeader->rc = VINF_SUCCESS; 1268 1289 } 1269 1290 break; … … 1273 1294 { 1274 1295 Log(("VMMDevReq_ReportGuestStats\n")); 1275 if ( requestHeader->size != sizeof(VMMDevReportGuestStats))1276 { 1277 requestHeader->rc = VERR_INVALID_PARAMETER;1278 } 1279 else 1280 { 1281 VMMDevReportGuestStats *stats = (VMMDevReportGuestStats*) requestHeader;1296 if (pRequestHeader->size != sizeof(VMMDevReportGuestStats)) 1297 { 1298 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1299 } 1300 else 1301 { 1302 VMMDevReportGuestStats *stats = (VMMDevReportGuestStats*)pRequestHeader; 1282 1303 1283 1304 #ifdef DEBUG … … 1341 1362 1342 1363 /* forward the call */ 1343 requestHeader->rc = pData->pDrv->pfnReportStatistics(pData->pDrv, &stats->guestStats);1364 pRequestHeader->rc = pData->pDrv->pfnReportStatistics(pData->pDrv, &stats->guestStats); 1344 1365 } 1345 1366 break; … … 1348 1369 case VMMDevReq_QueryCredentials: 1349 1370 { 1350 if ( requestHeader->size != sizeof(VMMDevCredentials))1371 if (pRequestHeader->size != sizeof(VMMDevCredentials)) 1351 1372 { 1352 1373 AssertMsgFailed(("VMMDevReq_QueryCredentials request size too small.\n")); 1353 requestHeader->rc = VERR_INVALID_PARAMETER;1354 } 1355 else 1356 { 1357 VMMDevCredentials *credentials = (VMMDevCredentials*) requestHeader;1374 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1375 } 1376 else 1377 { 1378 VMMDevCredentials *credentials = (VMMDevCredentials*)pRequestHeader; 1358 1379 1359 1380 /* let's start by nulling out the data */ … … 1419 1440 } 1420 1441 1421 requestHeader->rc = VINF_SUCCESS;1442 pRequestHeader->rc = VINF_SUCCESS; 1422 1443 } 1423 1444 break; … … 1426 1447 case VMMDevReq_ReportCredentialsJudgement: 1427 1448 { 1428 if ( requestHeader->size != sizeof(VMMDevCredentials))1449 if (pRequestHeader->size != sizeof(VMMDevCredentials)) 1429 1450 { 1430 1451 AssertMsgFailed(("VMMDevReq_ReportCredentialsJudgement request size too small.\n")); 1431 requestHeader->rc = VERR_INVALID_PARAMETER;1432 } 1433 else 1434 { 1435 VMMDevCredentials *credentials = (VMMDevCredentials*) requestHeader;1452 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1453 } 1454 else 1455 { 1456 VMMDevCredentials *credentials = (VMMDevCredentials*)pRequestHeader; 1436 1457 1437 1458 /* what does the guest think about the credentials? (note: the order is important here!) */ … … 1451 1472 Log(("VMMDevReq_ReportCredentialsJudgement: invalid flags: %d!!!\n", credentials->u32Flags)); 1452 1473 1453 requestHeader->rc = VINF_SUCCESS;1474 pRequestHeader->rc = VINF_SUCCESS; 1454 1475 } 1455 1476 break; … … 1459 1480 case VMMDevReq_LogString: 1460 1481 { 1461 if ( requestHeader->size < sizeof(VMMDevReqLogString))1482 if (pRequestHeader->size < sizeof(VMMDevReqLogString)) 1462 1483 { 1463 1484 AssertMsgFailed(("VMMDevReq_LogString request size too small.\n")); 1464 requestHeader->rc = VERR_INVALID_PARAMETER;1465 } 1466 else 1467 { 1468 VMMDevReqLogString *pReqLogString = (VMMDevReqLogString*) requestHeader;1485 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1486 } 1487 else 1488 { 1489 VMMDevReqLogString *pReqLogString = (VMMDevReqLogString*)pRequestHeader; 1469 1490 #undef LOG_GROUP 1470 1491 #define LOG_GROUP LOG_GROUP_DEV_VMM_BACKDOOR … … 1474 1495 #undef LOG_GROUP 1475 1496 #define LOG_GROUP LOG_GROUP_DEV_VMM 1476 requestHeader->rc = VINF_SUCCESS;1497 pRequestHeader->rc = VINF_SUCCESS; 1477 1498 } 1478 1499 break; … … 1481 1502 default: 1482 1503 { 1483 requestHeader->rc = VERR_NOT_IMPLEMENTED; 1484 1485 Log(("VMMDev unknown request type %d\n", requestHeader->requestType)); 1486 1487 break; 1488 } 1489 } 1490 1504 pRequestHeader->rc = VERR_NOT_IMPLEMENTED; 1505 1506 Log(("VMMDev unknown request type %d\n", pRequestHeader->requestType)); 1507 1508 break; 1509 } 1510 } 1511 1512 end: 1513 /* Write the result back to guest memory */ 1514 if (pRequestHeader) 1515 { 1516 PDMDevHlpPhysWrite(pDevIns, (RTGCPHYS)u32, pRequestHeader, pRequestHeader->size); 1517 RTMemFree(pRequestHeader); 1518 } 1519 else 1520 { 1521 /* early error case; write back header only */ 1522 PDMDevHlpPhysWrite(pDevIns, (RTGCPHYS)u32, &requestHeader, sizeof(requestHeader)); 1523 } 1491 1524 return rcRet; 1492 1525 } … … 1918 1951 1919 1952 1920 #define VMMDEV_SSM_VERSION 51953 #define VMMDEV_SSM_VERSION 6 1921 1954 1922 1955 /** -
trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp
r4599 r5040 70 70 VBOXHGCMCMDTYPE enmCmdType; 71 71 72 /* GC p ointerof the guest request. */73 RTGCPHYS GCPtr;74 75 /* HC pointer to guest request.*/76 VMMDevHGCMRequestHeader *pHeader;72 /* GC physical address of the guest request. */ 73 RTGCPHYS GCPhys; 74 75 /* Request packet size */ 76 uint32_t cbSize; 77 77 78 78 /* Pointer to converted host parameters in case of a Call request. */ … … 99 99 } 100 100 101 static int vmmdevHGCMAddCommand (VMMDevState *pVMMDevState, PVBOXHGCMCMD pCmd, RTGCPHYS GCP tr, VBOXHGCMCMDTYPE enmCmdType)101 static int vmmdevHGCMAddCommand (VMMDevState *pVMMDevState, PVBOXHGCMCMD pCmd, RTGCPHYS GCPhys, uint32_t cbSize, VBOXHGCMCMDTYPE enmCmdType) 102 102 { 103 103 /* PPDMDEVINS pDevIns = pVMMDevState->pDevIns; */ … … 121 121 122 122 pCmd->enmCmdType = enmCmdType; 123 pCmd->GCPtr = GCPtr; 123 pCmd->GCPhys = GCPhys; 124 pCmd->cbSize = cbSize; 124 125 125 126 /* Automatically enable HGCM events, if there are HGCM commands. */ … … 287 288 } 288 289 289 int vmmdevHGCMConnect (VMMDevState *pVMMDevState, VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCP tr)290 int vmmdevHGCMConnect (VMMDevState *pVMMDevState, VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCPhys) 290 291 { 291 292 int rc = VINF_SUCCESS; 292 293 293 PVBOXHGCMCMD pCmd = (PVBOXHGCMCMD)RTMemAllocZ (sizeof (struct VBOXHGCMCMD) );294 PVBOXHGCMCMD pCmd = (PVBOXHGCMCMD)RTMemAllocZ (sizeof (struct VBOXHGCMCMD) + pHGCMConnect->header.header.size); 294 295 295 296 if (pCmd) 296 297 { 297 vmmdevHGCMAddCommand (pVMMDevState, pCmd, GCPtr, VBOXHGCMCMDTYPE_CONNECT); 298 299 pCmd->pHeader = &pHGCMConnect->header; 298 VMMDevHGCMConnect *pHGCMConnectCopy = (VMMDevHGCMConnect *)(pCmd+1); 299 300 vmmdevHGCMAddCommand (pVMMDevState, pCmd, GCPhys, pHGCMConnect->header.header.size, VBOXHGCMCMDTYPE_CONNECT); 301 302 memcpy(pHGCMConnectCopy, pHGCMConnect, pHGCMConnect->header.header.size); 303 300 304 pCmd->paHostParms = NULL; 301 305 pCmd->cLinPtrs = 0; … … 306 310 pHGCMConnect->loc.type = VMMDevHGCMLoc_LocalHost_Existing; 307 311 308 rc = pVMMDevState->pHGCMDrv->pfnConnect (pVMMDevState->pHGCMDrv, pCmd, &pHGCMConnect ->loc, &pHGCMConnect->u32ClientID);312 rc = pVMMDevState->pHGCMDrv->pfnConnect (pVMMDevState->pHGCMDrv, pCmd, &pHGCMConnectCopy->loc, &pHGCMConnectCopy->u32ClientID); 309 313 } 310 314 else … … 316 320 } 317 321 318 int vmmdevHGCMDisconnect (VMMDevState *pVMMDevState, VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCP tr)322 int vmmdevHGCMDisconnect (VMMDevState *pVMMDevState, VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCPhys) 319 323 { 320 324 int rc = VINF_SUCCESS; … … 324 328 if (pCmd) 325 329 { 326 vmmdevHGCMAddCommand (pVMMDevState, pCmd, GCPtr, VBOXHGCMCMDTYPE_DISCONNECT); 327 328 pCmd->pHeader = &pHGCMDisconnect->header; 330 vmmdevHGCMAddCommand (pVMMDevState, pCmd, GCPhys, pHGCMDisconnect->header.header.size, VBOXHGCMCMDTYPE_DISCONNECT); 331 329 332 pCmd->paHostParms = NULL; 330 333 pCmd->cLinPtrs = 0; … … 342 345 343 346 344 int vmmdevHGCMCall (VMMDevState *pVMMDevState, VMMDevHGCMCall *pHGCMCall, RTGCPHYS GCP tr)347 int vmmdevHGCMCall (VMMDevState *pVMMDevState, VMMDevHGCMCall *pHGCMCall, RTGCPHYS GCPhys) 345 348 { 346 349 int rc = VINF_SUCCESS; … … 392 395 Log(("vmmdevHGCMCall: linptr size = %d\n", pGuestParm->u.Pointer.size)); 393 396 } break; 397 394 398 case VMMDevHGCMParmType_32bit: 395 399 case VMMDevHGCMParmType_64bit: … … 397 401 { 398 402 } break; 403 399 404 default: 400 405 { … … 420 425 memset (pCmd, 0, sizeof (*pCmd)); 421 426 422 pCmd->pHeader = &pHGCMCall->header;423 427 pCmd->paHostParms = NULL; 424 428 pCmd->cLinPtrs = cLinPtrs; … … 494 498 495 499 AssertFailed(); 496 /** @todo It's no longer allowed to save a conversion address for later use! */ 497 rc = PDMDevHlpPhys2HCVirt (pVMMDevState->pDevIns, physAddr, size, &pHostParm->u.pointer.addr); 500 /* rc = PDMDevHlpPhys2HCVirt (pVMMDevState->pDevIns, physAddr, size, &pHostParm->u.pointer.addr); */ 498 501 499 502 Log(("vmmdevHGCMCall: PhysAddr guest parameter %VGp\n", physAddr)); … … 555 558 if (VBOX_SUCCESS (rc)) 556 559 { 557 vmmdevHGCMAddCommand (pVMMDevState, pCmd, GCP tr, VBOXHGCMCMDTYPE_CALL);560 vmmdevHGCMAddCommand (pVMMDevState, pCmd, GCPhys, pHGCMCall->header.header.size, VBOXHGCMCMDTYPE_CALL); 558 561 559 562 /* Pass the function call to HGCM connector for actual processing */ … … 573 576 } 574 577 575 static int vmmdevHGCMCmdVerify (PVBOXHGCMCMD pCmd) 576 { 577 VMMDevHGCMRequestHeader *pHeader = pCmd->pHeader; 578 578 static int vmmdevHGCMCmdVerify (PVBOXHGCMCMD pCmd, VMMDevHGCMRequestHeader *pHeader) 579 { 579 580 switch (pCmd->enmCmdType) 580 581 { … … 602 603 #define PDMIHGCMPORT_2_VMMDEVSTATE(pInterface) ( (VMMDevState *) ((uintptr_t)pInterface - RT_OFFSETOF(VMMDevState, HGCMPort)) ) 603 604 604 DECLCALLBACK(void) hgcmCompleted (PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd) 605 { 606 int rc = VINF_SUCCESS; 607 608 VMMDevHGCMRequestHeader *pHeader = pCmd->pHeader; 609 610 VMMDevState *pVMMDevState = PDMIHGCMPORT_2_VMMDEVSTATE(pInterface); 605 DECLCALLBACK(void) hgcmCompletedWorker (PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd) 606 { 607 VMMDevState *pVMMDevState = PDMIHGCMPORT_2_VMMDEVSTATE(pInterface); 608 VMMDevHGCMRequestHeader *pHeader; 609 int rc = VINF_SUCCESS; 610 611 pHeader = (VMMDevHGCMRequestHeader *)RTMemAllocZ (pCmd->cbSize); 612 Assert(pHeader); 613 if (pHeader == NULL) 614 return; 615 616 PDMDevHlpPhysRead(pVMMDevState->pDevIns, (RTGCPHYS)pCmd->GCPhys, pHeader, pCmd->cbSize); 611 617 612 618 if (result != VINF_HGCM_SAVE_STATE) … … 616 622 617 623 /* Verify the request type. */ 618 rc = vmmdevHGCMCmdVerify (pCmd );624 rc = vmmdevHGCMCmdVerify (pCmd, pHeader); 619 625 620 626 if (VBOX_SUCCESS (rc)) 621 627 { 622 628 /* Update parameters and data buffers. */ 623 624 if (pHeader->header.requestType == VMMDevReq_HGCMCall) 629 630 switch (pHeader->header.requestType) 631 { 632 case VMMDevReq_HGCMCall: 625 633 { 626 634 VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)pHeader; … … 676 684 } 677 685 } 686 break; 687 } 688 689 case VMMDevReq_HGCMConnect: 690 { 691 VMMDevHGCMConnect *pHGCMConnectCopy = (VMMDevHGCMConnect *)(pCmd+1); 692 693 /* save the client id in the guest request packet */ 694 VMMDevHGCMConnect *pHGCMConnect = (VMMDevHGCMConnect *)pHeader; 695 pHGCMConnect->u32ClientID = pHGCMConnectCopy->u32ClientID; 696 break; 697 } 678 698 } 679 699 } … … 687 707 pHeader->fu32Flags |= VBOX_HGCM_REQ_DONE; 688 708 709 /* Write back the request */ 710 PDMDevHlpPhysWrite(pVMMDevState->pDevIns, pCmd->GCPhys, pHeader, pCmd->cbSize); 711 689 712 VMMDevNotifyGuest (pVMMDevState, VMMDEV_EVENT_HGCM); 690 713 … … 699 722 RTMemFree (pCmd); 700 723 } 724 RTMemFree(pHeader); 701 725 702 726 return; 727 } 728 729 DECLCALLBACK(void) hgcmCompleted (PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd) 730 { 731 VMMDevState *pVMMDevState = PDMIHGCMPORT_2_VMMDEVSTATE(pInterface); 732 733 /* Not safe to execute asynchroneously; forward to EMT */ 734 int rc = VMR3ReqCallEx(PDMDevHlpGetVM(pVMMDevState->pDevIns), NULL, 0, VMREQFLAGS_NO_WAIT | VMREQFLAGS_VOID, 735 (PFNRT)hgcmCompletedWorker, 3, pInterface, result, pCmd); 736 AssertRC(rc); 703 737 } 704 738 … … 739 773 PVBOXHGCMCMD pNext = pIter->pNext; 740 774 741 LogFlowFunc (("Saving %VGp\n", pIter->GCPtr)); 742 rc = SSMR3PutGCPtr(pSSM, pIter->GCPtr); 775 LogFlowFunc (("Saving %VGp\n", pIter->GCPhys)); 776 rc = SSMR3PutGCPhys(pSSM, pIter->GCPhys); 777 AssertRCReturn(rc, rc); 778 779 rc = SSMR3PutU32(pSSM, pIter->cbSize); 743 780 AssertRCReturn(rc, rc); 744 781 … … 768 805 while (cCmds--) 769 806 { 770 RTGCPHYS GCPtr; 771 rc = SSMR3GetGCPtr(pSSM, &GCPtr); 807 RTGCPHYS GCPhys; 808 uint32_t cbSize; 809 810 rc = SSMR3GetGCPhys(pSSM, &GCPhys); 772 811 AssertRCReturn(rc, rc); 773 812 774 LogFlowFunc (("Restoring %VGp\n", GCPtr)); 813 rc = SSMR3GetU32(pSSM, &cbSize); 814 AssertRCReturn(rc, rc); 815 816 LogFlowFunc (("Restoring %VGp size %x bytes\n", GCPhys, cbSize)); 775 817 776 818 PVBOXHGCMCMD pCmd = (PVBOXHGCMCMD)RTMemAllocZ (sizeof (struct VBOXHGCMCMD)); 777 819 AssertReturn(pCmd, VERR_NO_MEMORY); 778 820 779 vmmdevHGCMAddCommand (pVMMDevState, pCmd, GCP tr, VBOXHGCMCMDTYPE_LOADSTATE);821 vmmdevHGCMAddCommand (pVMMDevState, pCmd, GCPhys, cbSize, VBOXHGCMCMDTYPE_LOADSTATE); 780 822 } 781 823 … … 803 845 PVBOXHGCMCMD pNext = pIter->pNext; 804 846 805 VMMDevRequestHeader *requestHeader = NULL; 806 rc = PDMDevHlpPhys2HCVirt(pDevIns, pIter->GCPtr, 0, (PRTHCPTR)&requestHeader); 807 808 if (VBOX_FAILURE(rc) || !requestHeader) 847 VMMDevRequestHeader *requestHeader = (VMMDevRequestHeader *)RTMemAllocZ (pIter->cbSize); 848 Assert(requestHeader); 849 if (requestHeader == NULL) 850 return VERR_NO_MEMORY; 851 852 PDMDevHlpPhysRead(pVMMDevState->pDevIns, (RTGCPHYS)pIter->GCPhys, requestHeader, pIter->cbSize); 853 854 /* the structure size must be greater or equal to the header size */ 855 if (requestHeader->size < sizeof(VMMDevRequestHeader)) 809 856 { 810 AssertMsgFailed(("VMMDev::LoadStateDone: could not convert guest physical address to host virtual!!! rc = %Vrc\n", rc));857 Log(("VMMDev request header size too small! size = %d\n", requestHeader->size)); 811 858 } 812 859 else 813 860 { 814 /* the structure size must be greater or equal to the header size */815 if (requestHeader-> size < sizeof(VMMDevRequestHeader))861 /* check the version of the header structure */ 862 if (requestHeader->version != VMMDEV_REQUEST_HEADER_VERSION) 816 863 { 817 Log(("VMMDev request header size too small! size = %d\n", requestHeader->size));864 Log(("VMMDev: guest header version (0x%08X) differs from ours (0x%08X)\n", requestHeader->version, VMMDEV_REQUEST_HEADER_VERSION)); 818 865 } 819 866 else 820 867 { 821 /* check the version of the header structure */ 822 if (requestHeader->version != VMMDEV_REQUEST_HEADER_VERSION) 868 Log(("VMMDev request issued: %d\n", requestHeader->requestType)); 869 870 switch (requestHeader->requestType) 823 871 { 824 Log(("VMMDev: guest header version (0x%08X) differs from ours (0x%08X)\n", requestHeader->version, VMMDEV_REQUEST_HEADER_VERSION)); 825 } 826 else 827 { 828 Log(("VMMDev request issued: %d\n", requestHeader->requestType)); 829 830 switch (requestHeader->requestType) 872 case VMMDevReq_HGCMConnect: 831 873 { 832 case VMMDevReq_HGCMConnect:874 if (requestHeader->size < sizeof(VMMDevHGCMConnect)) 833 875 { 834 if (requestHeader->size < sizeof(VMMDevHGCMConnect)) 835 { 836 AssertMsgFailed(("VMMDevReq_HGCMConnect structure has invalid size!\n")); 837 requestHeader->rc = VERR_INVALID_PARAMETER; 838 } 839 else if (!pVMMDevState->pHGCMDrv) 840 { 841 Log(("VMMDevReq_HGCMConnect HGCM Connector is NULL!\n")); 842 requestHeader->rc = VERR_NOT_SUPPORTED; 843 } 844 else 845 { 846 VMMDevHGCMConnect *pHGCMConnect = (VMMDevHGCMConnect *)requestHeader; 847 848 Log(("VMMDevReq_HGCMConnect\n")); 849 850 requestHeader->rc = vmmdevHGCMConnect (pVMMDevState, pHGCMConnect, pIter->GCPtr); 851 } 852 break; 876 AssertMsgFailed(("VMMDevReq_HGCMConnect structure has invalid size!\n")); 877 requestHeader->rc = VERR_INVALID_PARAMETER; 853 878 } 854 855 case VMMDevReq_HGCMDisconnect: 879 else if (!pVMMDevState->pHGCMDrv) 856 880 { 857 if (requestHeader->size < sizeof(VMMDevHGCMDisconnect)) 858 { 859 AssertMsgFailed(("VMMDevReq_HGCMDisconnect structure has invalid size!\n")); 860 requestHeader->rc = VERR_INVALID_PARAMETER; 861 } 862 else if (!pVMMDevState->pHGCMDrv) 863 { 864 Log(("VMMDevReq_HGCMDisconnect HGCM Connector is NULL!\n")); 865 requestHeader->rc = VERR_NOT_SUPPORTED; 866 } 867 else 868 { 869 VMMDevHGCMDisconnect *pHGCMDisconnect = (VMMDevHGCMDisconnect *)requestHeader; 870 871 Log(("VMMDevReq_VMMDevHGCMDisconnect\n")); 872 requestHeader->rc = vmmdevHGCMDisconnect (pVMMDevState, pHGCMDisconnect, pIter->GCPtr); 873 } 874 break; 881 Log(("VMMDevReq_HGCMConnect HGCM Connector is NULL!\n")); 882 requestHeader->rc = VERR_NOT_SUPPORTED; 875 883 } 876 877 case VMMDevReq_HGCMCall: 884 else 878 885 { 879 if (requestHeader->size < sizeof(VMMDevHGCMCall)) 880 { 881 AssertMsgFailed(("VMMDevReq_HGCMCall structure has invalid size!\n")); 882 requestHeader->rc = VERR_INVALID_PARAMETER; 883 } 884 else if (!pVMMDevState->pHGCMDrv) 885 { 886 Log(("VMMDevReq_HGCMCall HGCM Connector is NULL!\n")); 887 requestHeader->rc = VERR_NOT_SUPPORTED; 888 } 889 else 890 { 891 VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)requestHeader; 892 893 Log(("VMMDevReq_HGCMCall: sizeof (VMMDevHGCMRequest) = %04X\n", sizeof (VMMDevHGCMCall))); 894 895 Log(("%.*Vhxd\n", requestHeader->size, requestHeader)); 896 897 requestHeader->rc = vmmdevHGCMCall (pVMMDevState, pHGCMCall, pIter->GCPtr); 898 } 899 break; 886 VMMDevHGCMConnect *pHGCMConnect = (VMMDevHGCMConnect *)requestHeader; 887 888 Log(("VMMDevReq_HGCMConnect\n")); 889 890 requestHeader->rc = vmmdevHGCMConnect (pVMMDevState, pHGCMConnect, pIter->GCPhys); 900 891 } 901 default: 902 AssertReleaseFailed(); 892 break; 903 893 } 894 895 case VMMDevReq_HGCMDisconnect: 896 { 897 if (requestHeader->size < sizeof(VMMDevHGCMDisconnect)) 898 { 899 AssertMsgFailed(("VMMDevReq_HGCMDisconnect structure has invalid size!\n")); 900 requestHeader->rc = VERR_INVALID_PARAMETER; 901 } 902 else if (!pVMMDevState->pHGCMDrv) 903 { 904 Log(("VMMDevReq_HGCMDisconnect HGCM Connector is NULL!\n")); 905 requestHeader->rc = VERR_NOT_SUPPORTED; 906 } 907 else 908 { 909 VMMDevHGCMDisconnect *pHGCMDisconnect = (VMMDevHGCMDisconnect *)requestHeader; 910 911 Log(("VMMDevReq_VMMDevHGCMDisconnect\n")); 912 requestHeader->rc = vmmdevHGCMDisconnect (pVMMDevState, pHGCMDisconnect, pIter->GCPhys); 913 } 914 break; 915 } 916 917 case VMMDevReq_HGCMCall: 918 { 919 if (requestHeader->size < sizeof(VMMDevHGCMCall)) 920 { 921 AssertMsgFailed(("VMMDevReq_HGCMCall structure has invalid size!\n")); 922 requestHeader->rc = VERR_INVALID_PARAMETER; 923 } 924 else if (!pVMMDevState->pHGCMDrv) 925 { 926 Log(("VMMDevReq_HGCMCall HGCM Connector is NULL!\n")); 927 requestHeader->rc = VERR_NOT_SUPPORTED; 928 } 929 else 930 { 931 VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)requestHeader; 932 933 Log(("VMMDevReq_HGCMCall: sizeof (VMMDevHGCMRequest) = %04X\n", sizeof (VMMDevHGCMCall))); 934 935 Log(("%.*Vhxd\n", requestHeader->size, requestHeader)); 936 937 requestHeader->rc = vmmdevHGCMCall (pVMMDevState, pHGCMCall, pIter->GCPhys); 938 } 939 break; 940 } 941 default: 942 AssertReleaseFailed(); 904 943 } 905 944 } 906 945 } 907 946 947 /* Write back the request */ 948 PDMDevHlpPhysWrite(pVMMDevState->pDevIns, pIter->GCPhys, requestHeader, pIter->cbSize); 949 RTMemFree(requestHeader); 950 908 951 vmmdevHGCMRemoveCommand (pVMMDevState, pIter); 952 RTMemFree(pIter); 909 953 pIter = pNext; 910 954 }
Note:
See TracChangeset
for help on using the changeset viewer.