VirtualBox

Changeset 21062 in vbox


Ignore:
Timestamp:
Jun 30, 2009 10:14:10 AM (15 years ago)
Author:
vboxsync
Message:

VMMDev: Ensure read/write order in hgcmCompletedWorker. (bug 4052)

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

Legend:

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

    r20991 r21062  
    400400 * Port I/O Handler for the generic request interface
    401401 * @see FNIOMIOPORTOUT for details.
     402 *
     403 * @todo Too long, suggest doing the request copying here and moving the
     404 *       switch into a different function (or better case -> functions), and
     405 *       looing the gotos.
    402406 */
    403407static DECLCALLBACK(int) vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     
    405409    VMMDevState *pThis = (VMMDevState*)pvUser;
    406410    int rcRet = VINF_SUCCESS;
     411    PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
    407412
    408413    /*
     
    420425        Log(("VMMDev request header size too small! size = %d\n", requestHeader.size));
    421426        rcRet = VINF_SUCCESS;
    422         goto end;
     427        goto end; /** @todo shouldn't (/ no need to) write back.*/
    423428    }
    424429
     
    428433        Log(("VMMDev: guest header version (0x%08X) differs from ours (0x%08X)\n", requestHeader.version, VMMDEV_REQUEST_HEADER_VERSION));
    429434        rcRet = VINF_SUCCESS;
    430         goto end;
     435        goto end; /** @todo shouldn't (/ no need to) write back.*/
    431436    }
    432437
     
    15961601        PDMDevHlpPhysWrite(pDevIns, (RTGCPHYS)u32, &requestHeader, sizeof(requestHeader));
    15971602    }
     1603
     1604    PDMCritSectLeave(&pThis->CritSect);
    15981605    return rcRet;
    15991606}
     
    22762283    /** @todo convert this into a config parameter like we do everywhere else! */
    22772284    pThis->cbGuestRAM = MMR3PhysGetRamSize(PDMDevHlpGetVM(pDevIns));
     2285
     2286    /*
     2287     * Create the critical section for the device.
     2288     */
     2289    rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, "VMMDev");
     2290    AssertRCReturn(rc, rc);
     2291    /* Later: pDevIns->pCritSectR3 = &pThis->CritSect; */
    22782292
    22792293    /*
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp

    r20731 r21062  
    391391    }
    392392
    393     VMMDevHGCMConnect *pHGCMConnectCopy = (VMMDevHGCMConnect *)(pSavedCmd+1); 
     393    VMMDevHGCMConnect *pHGCMConnectCopy = (VMMDevHGCMConnect *)(pSavedCmd+1);
    394394
    395395    memcpy(pHGCMConnectCopy, pHGCMConnect, pHGCMConnect->header.header.size);
     
    10191019
    10201020                                         AssertRCBreak(rc);
    1021                                          
     1021
    10221022                                         offPage = 0; /* A next page is read from 0 offset. */
    10231023                                         cbRemaining -= cbChunk;
     
    11591159
    11601160                                         AssertRCBreak(rc);
    1161                                          
     1161
    11621162                                         offPage = 0; /* A next page is read from 0 offset. */
    11631163                                         cbRemaining -= cbChunk;
     
    13241324        }
    13251325
     1326        /*
     1327         * Enter and leave the critical section here so we make sure
     1328         * vmmdevRequestHandler has completed before we read & write
     1329         * the request. (This isn't 100% optimal, but it solves the
     1330         * 3.0 blocker.)
     1331         */
     1332        /** @todo s/pVMMDevState/pThis/g */
     1333        /** @todo It would be faster if this interface would use MMIO2 memory and we
     1334         *        didn't have to mess around with PDMDevHlpPhysRead/Write. We're
     1335         *        reading the header 3 times now and writing the request back twice. */
     1336        PDMCritSectEnter(&pVMMDevState->CritSect, VERR_SEM_BUSY);
     1337        PDMCritSectLeave(&pVMMDevState->CritSect);
     1338
    13261339        PDMDevHlpPhysRead(pVMMDevState->pDevIns, pCmd->GCPhys, pHeader, pCmd->cbSize);
    13271340
     
    14411454                            uint32_t size = pGuestParm->u.Pointer.size;
    14421455
    1443                             if (size > 0) 
     1456                            if (size > 0)
    14441457                            {
    14451458                                if (pGuestParm->type != VMMDevHGCMParmType_LinAddr_In)
     
    15041517                            uint32_t size = pGuestParm->u.Pointer.size;
    15051518
    1506                             if (size > 0) 
     1519                            if (size > 0)
    15071520                            {
    15081521                                if (pGuestParm->type != VMMDevHGCMParmType_LinAddr_In)
     
    15831596    VMMDevState *pVMMDevState = PDMIHGCMPORT_2_VMMDEVSTATE(pInterface);
    15841597
     1598/** @todo no longer necessary to forward to EMT, but it might be more
     1599 *        efficient...? */
    15851600    /* Not safe to execute asynchroneously; forward to EMT */
    15861601    int rc = VMR3ReqCallEx(PDMDevHlpGetVM(pVMMDevState->pDevIns), VMCPUID_ANY, NULL, 0, VMREQFLAGS_NO_WAIT | VMREQFLAGS_VOID,
     
    18571872            rc = SSMR3GetU32(pSSM, &u32);
    18581873            AssertRCReturn(rc, rc);
    1859            
     1874
    18601875            vmmdevHGCMAddCommand (pVMMDevState, pCmd, GCPhys, cbSize, VBOXHGCMCMDTYPE_LOADSTATE);
    18611876        }
     
    21382153
    21392154                   RTMemFree(pIter);
    2140                
     2155
    21412156                   VMMDevNotifyGuest (pVMMDevState, VMMDEV_EVENT_HGCM);
    21422157                }
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r12687 r21062  
    9191    RTGCPHYS32 GCPhysVMMDevRAM;
    9292
    93     /** R3 pointer to VMMDev Heap RAM area 
     93    /** R3 pointer to VMMDev Heap RAM area
    9494     */
    9595    R3PTRTYPE(VMMDevMemory *) pVMMDevHeapR3;
     
    191191    } SharedFolders;
    192192
     193    /** The critical section for this device. */
     194    PDMCRITSECT CritSect;
    193195} VMMDevState;
    194196
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