VirtualBox

Changeset 76196 in vbox for trunk/src/VBox/Devices/VMMDev


Ignore:
Timestamp:
Dec 12, 2018 7:24:05 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
127453
Message:

VMMDev/HGCM,VBoxGuest: New page list variant for more effectively passing physical contiguous buffers (VbglR0PhysHeapAlloc, kmalloc, ++). bugref:9172

Location:
trunk/src/VBox/Devices/VMMDev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r75990 r76196  
    22992299    pReq->build     = RTBldCfgVersionBuild();
    23002300    pReq->revision  = RTBldCfgRevision();
    2301     pReq->features  = VMMDEV_HVF_HGCM_PHYS_PAGE_LIST | VMMDEV_HVF_HGCM_EMBEDDED_BUFFERS | VMMDEV_HVF_FAST_IRQ_ACK;
     2301    pReq->features  = VMMDEV_HVF_HGCM_PHYS_PAGE_LIST
     2302                    | VMMDEV_HVF_HGCM_EMBEDDED_BUFFERS
     2303                    | VMMDEV_HVF_HGCM_CONTIGUOUS_PAGE_LIST
     2304                    | VMMDEV_HVF_FAST_IRQ_ACK;
    23022305    return VINF_SUCCESS;
    23032306}
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp

    r76145 r76196  
    329329                    || pGuestParm->enmType == VMMDevHGCMParmType_LinAddr_Out
    330330                    || pGuestParm->enmType == VMMDevHGCMParmType_LinAddr
    331                     || pGuestParm->enmType == VMMDevHGCMParmType_PageList)
     331                    || pGuestParm->enmType == VMMDevHGCMParmType_PageList
     332                    || pGuestParm->enmType == VMMDevHGCMParmType_ContiguousPageList)
    332333                    if (pGuestParm->u.ptr.paPages != &pGuestParm->u.ptr.GCPhysSinglePage)
    333334                        RTMemFree(pGuestParm->u.ptr.paPages);
     
    667668            case VMMDevHGCMParmType_PageList:
    668669            case VMMDevHGCMParmType_Embedded:
     670            case VMMDevHGCMParmType_ContiguousPageList:
    669671            {
    670672                const uint32_t cbData = pGuestParm->u.ptr.cbData;
     
    684686                        if (pGuestParm->enmType != VMMDevHGCMParmType_Embedded)
    685687                        {
    686                             int rc = vmmdevHGCMGuestBufferRead(pThis->pDevInsR3, pv, cbData, &pGuestParm->u.ptr);
    687                             ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
    688                             RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
     688                            if (pGuestParm->enmType != VMMDevHGCMParmType_ContiguousPageList)
     689                            {
     690                                int rc = vmmdevHGCMGuestBufferRead(pThis->pDevInsR3, pv, cbData, &pGuestParm->u.ptr);
     691                                ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
     692                                RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
     693                            }
     694                            else
     695                            {
     696                                int rc = PDMDevHlpPhysRead(pThis->pDevInsR3,
     697                                                           pGuestParm->u.ptr.paPages[0] | pGuestParm->u.ptr.offFirstPage,
     698                                                           pv, cbData);
     699                                ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
     700                                RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
     701                            }
    689702                        }
    690703                        else
     
    898911
    899912            case VMMDevHGCMParmType_PageList:
     913            case VMMDevHGCMParmType_ContiguousPageList:
    900914            {
    901915#ifdef VBOX_WITH_64_BITS_GUESTS
     
    929943                                    && pPageListInfo->cPages <= cMaxPages,
    930944                                    VERR_INVALID_PARAMETER);
     945
     946                /* Contiguous page lists only ever have a single page. */
     947                ASSERT_GUEST_RETURN(   pPageListInfo->cPages == 1
     948                                    || pGuestParm->enmType == VMMDevHGCMParmType_PageList, VERR_INVALID_PARAMETER);
    931949
    932950                /* Other fields of PageListInfo. */
     
    11981216    AssertReturn(pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL, VERR_INTERNAL_ERROR);
    11991217
    1200     int rc = VINF_SUCCESS;
    1201 
    12021218    /*
    12031219     * Go over parameter descriptions saved in pCmd.
     
    12301246                const VBOXHGCMPARMPTR * const pPtr = &pGuestParm->u.ptr;
    12311247                if (   pPtr->cbData > 0
    1232                     && pPtr->fu32Direction & VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST)
     1248                    && (pPtr->fu32Direction & VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST))
    12331249                {
    12341250                    const void *pvSrc = pHostParm->u.pointer.addr;
    12351251                    uint32_t cbSrc = pHostParm->u.pointer.size;
    1236                     rc = vmmdevHGCMGuestBufferWrite(pThis->pDevInsR3, pPtr, pvSrc, cbSrc);
     1252                    int rc = vmmdevHGCMGuestBufferWrite(pThis->pDevInsR3, pPtr, pvSrc, cbSrc);
     1253                    if (RT_FAILURE(rc))
     1254                        break;
    12371255                }
    12381256                break;
     
    12541272            }
    12551273
     1274            case VMMDevHGCMParmType_ContiguousPageList:
     1275            {
     1276/** @todo Update the return buffer size.  */
     1277                const VBOXHGCMPARMPTR * const pPtr = &pGuestParm->u.ptr;
     1278                if (   pPtr->cbData > 0
     1279                    && (pPtr->fu32Direction & VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST))
     1280                {
     1281                    const void *pvSrc    = pHostParm->u.pointer.addr;
     1282                    uint32_t    cbSrc    = pHostParm->u.pointer.size;
     1283                    uint32_t    cbToCopy = RT_MIN(cbSrc, pPtr->cbData);
     1284                    int rc = PDMDevHlpPhysWrite(pThis->pDevInsR3, pGuestParm->u.ptr.paPages[0], pvSrc, cbToCopy);
     1285                    if (RT_FAILURE(rc))
     1286                        break;
     1287                }
     1288                break;
     1289            }
     1290
    12561291            default:
    12571292                break;
    12581293        }
    1259 
    1260         if (RT_FAILURE(rc))
    1261             break;
    1262     }
    1263 
    1264     return rc;
     1294    }
     1295
     1296    return VINF_SUCCESS;
    12651297}
    12661298
     
    16421674                             || pGuestParm->enmType == VMMDevHGCMParmType_LinAddr
    16431675                             || pGuestParm->enmType == VMMDevHGCMParmType_PageList
    1644                              || pGuestParm->enmType == VMMDevHGCMParmType_Embedded)
     1676                             || pGuestParm->enmType == VMMDevHGCMParmType_Embedded
     1677                             || pGuestParm->enmType == VMMDevHGCMParmType_ContiguousPageList)
    16451678                    {
    16461679                        const VBOXHGCMPARMPTR * const pPtr = &pGuestParm->u.ptr;
     
    17761809                             || pGuestParm->enmType == VMMDevHGCMParmType_LinAddr
    17771810                             || pGuestParm->enmType == VMMDevHGCMParmType_PageList
    1778                              || pGuestParm->enmType == VMMDevHGCMParmType_Embedded)
     1811                             || pGuestParm->enmType == VMMDevHGCMParmType_Embedded
     1812                             || pGuestParm->enmType == VMMDevHGCMParmType_ContiguousPageList)
    17791813                    {
    17801814                        VBOXHGCMPARMPTR * const pPtr = &pGuestParm->u.ptr;
     
    17891823                            else
    17901824                            {
    1791                                 AssertReturn(pGuestParm->enmType != VMMDevHGCMParmType_Embedded, VERR_INTERNAL_ERROR_3);
     1825                                AssertReturn(   pGuestParm->enmType != VMMDevHGCMParmType_Embedded
     1826                                             && pGuestParm->enmType != VMMDevHGCMParmType_ContiguousPageList, VERR_INTERNAL_ERROR_3);
    17921827                                pPtr->paPages = (RTGCPHYS *)RTMemAlloc(pPtr->cPages * sizeof(RTGCPHYS));
    17931828                                AssertStmt(pPtr->paPages, rc = VERR_NO_MEMORY);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette