VirtualBox

Ignore:
Timestamp:
Feb 21, 2013 5:05:42 PM (12 years ago)
Author:
vboxsync
Message:

VMMDev.cpp: No need to enter the critsect till after we've read the whole package into memory.

File:
1 edited

Legend:

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

    r44785 r44788  
    24562456    /*
    24572457     * The caller has passed the guest context physical address of the request
    2458      * structure. Copy the request packet.
     2458     * structure. We'll copy all of it into a heap buffer eventually, but we
     2459     * will have to start off with the header.
    24592460     */
    24602461    VMMDevRequestHeader requestHeader;
     
    24622463    PDMDevHlpPhysRead(pDevIns, (RTGCPHYS)u32, &requestHeader, sizeof(requestHeader));
    24632464
    2464     /* the structure size must be greater or equal to the header size */
     2465    /* The structure size must be greater or equal to the header size. */
    24652466    if (requestHeader.size < sizeof(VMMDevRequestHeader))
    24662467    {
     
    24692470    }
    24702471
    2471     /* check the version of the header structure */
     2472    /* Check the version of the header structure. */
    24722473    if (requestHeader.version != VMMDEV_REQUEST_HEADER_VERSION)
    24732474    {
     
    24782479    Log2(("VMMDev request issued: %d\n", requestHeader.requestType));
    24792480
     2481    int                  rcRet          = VINF_SUCCESS;
    24802482    bool                 fDelayedUnlock = false;
    2481     int                  rcRet          = VINF_SUCCESS;
    24822483    VMMDevRequestHeader *pRequestHeader = NULL;
    24832484
     2485    /* Check that is doesn't exceed the max packet size. */
    24842486    if (requestHeader.size <= VMMDEV_MAX_VMMDEVREQ_SIZE)
    24852487    {
    2486         PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); /** @todo could probably move this to after the 2nd memory read, maybe after fu32AdditionsOk making volatile, if feeling paranoid. */
    2487 
    2488         /* Newer additions starts with VMMDevReq_ReportGuestInfo2, older additions
    2489            started with VMMDevReq_ReportGuestInfo. */
     2488        /*
     2489         * We require the GAs to report it's information before we let it have
     2490         * access to all the functions.  The VMMDevReq_ReportGuestInfo request
     2491         * is the one which unlocks the access.  Newer additions will first
     2492         * issue VMMDevReq_ReportGuestInfo2, older ones doesn't know this one.
     2493         * Two exceptions: VMMDevReq_GetHostVersion and VMMDevReq_WriteCoreDump.
     2494         */
    24902495        if (   pThis->fu32AdditionsOk
    24912496            || requestHeader.requestType == VMMDevReq_ReportGuestInfo2
    24922497            || requestHeader.requestType == VMMDevReq_ReportGuestInfo
    24932498            || requestHeader.requestType == VMMDevReq_WriteCoreDump
    2494             || requestHeader.requestType == VMMDevReq_GetHostVersion) /* Always allow the guest to query the host capabilities. */
     2499            || requestHeader.requestType == VMMDevReq_GetHostVersion
     2500           )
    24952501        {
    24962502            /*
    2497              * Read the entire request packet and feed it to the dispatcher function.
     2503             * The request looks fine. Allocate a heap block for it, read the
     2504             * entire package from guest memory and feed it to the dispatcher.
    24982505             */
    24992506            pRequestHeader = (VMMDevRequestHeader *)RTMemAlloc(requestHeader.size);
     
    25022509                PDMDevHlpPhysRead(pDevIns, (RTGCPHYS)u32, pRequestHeader, requestHeader.size);
    25032510
     2511                PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
    25042512                rcRet = vmmdevReqDispatcher(pThis, pRequestHeader, u32, &fDelayedUnlock);
     2513                if (!fDelayedUnlock)
     2514                    PDMCritSectLeave(&pThis->CritSect);
    25052515            }
    25062516            else
     
    25212531            requestHeader.rc = VERR_NOT_SUPPORTED;
    25222532        }
    2523 
    2524         if (!fDelayedUnlock)
    2525             PDMCritSectLeave(&pThis->CritSect);
    25262533    }
    25272534    else
Note: See TracChangeset for help on using the changeset viewer.

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