VirtualBox

Changeset 13765 in vbox for trunk/src/VBox/VMM/VMReq.cpp


Ignore:
Timestamp:
Nov 3, 2008 5:20:11 PM (16 years ago)
Author:
vboxsync
Message:

VM request updates for dispatching packets to individual CPU threads.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMReq.cpp

    r13755 r13765  
    401401                    VERR_VM_REQUEST_INVALID_TYPE);
    402402    AssertPtrReturn(ppReq, VERR_INVALID_POINTER);
     403    AssertMsgReturn(enmDest == VMREQDEST_ALL || (unsigned)enmDest < pUVM->pVM->cCPUs, ("Invalid destination %d (max=%d)\n", enmDest, pUVM->pVM->cCPUs), VERR_INVALID_PARAMETER);
    403404
    404405    /*
     
    619620    int rc = VINF_SUCCESS;
    620621    PUVM pUVM = ((VMREQ volatile *)pReq)->pUVM;                 /* volatile paranoia */
    621     if (pUVM->vm.s.NativeThreadEMT != RTThreadNativeSelf())
     622    if (    pReq->enmDest == VMREQDEST_ALL
     623        &&  pUVM->vm.s.NativeThreadEMT != RTThreadNativeSelf())
    622624    {
    623625        unsigned fFlags = ((VMREQ volatile *)pReq)->fFlags;     /* volatile paranoia */
     
    639641        if (pUVM->pVM)
    640642            VM_FF_SET(pUVM->pVM, VM_FF_REQUEST);
     643        VMR3NotifyFFU(pUVM, false);
     644
     645        /*
     646         * Wait and return.
     647         */
     648        if (!(fFlags & VMREQFLAGS_NO_WAIT))
     649            rc = VMR3ReqWait(pReq, cMillies);
     650        LogFlow(("VMR3ReqQueue: returns %Vrc\n", rc));
     651    }
     652    else
     653    if (    pReq->enmDest != VMREQDEST_ALL
     654        &&  pUVM->aCpu[pReq->enmDest].vm.s.NativeThreadEMT != RTThreadNativeSelf())
     655    {
     656        RTCPUID  idTarget = (RTCPUID)pReq->enmDest;
     657        unsigned fFlags = ((VMREQ volatile *)pReq)->fFlags;     /* volatile paranoia */
     658
     659        /*
     660         * Insert it.
     661         */
     662        pReq->enmState = VMREQSTATE_QUEUED;
     663        PVMREQ pNext;
     664        do
     665        {
     666            pNext = pUVM->aCpu[idTarget].vm.s.pReqs;
     667            pReq->pNext = pNext;
     668        } while (!ASMAtomicCmpXchgPtr((void * volatile *)&pUVM->aCpu[idTarget].vm.s.pReqs, (void *)pReq, (void *)pNext));
     669
     670        /*
     671         * Notify EMT.
     672         */
     673        if (pUVM->pVM)
     674            VMCPU_FF_SET(pUVM->pVM, VM_FF_REQUEST, idTarget);
     675        /* @todo: VMR3NotifyFFU*/
     676        AssertFailed();
    641677        VMR3NotifyFFU(pUVM, false);
    642678
     
    735771 *
    736772 * @param   pUVM            Pointer to the user mode VM structure.
    737  */
    738 VMMR3DECL(int) VMR3ReqProcessU(PUVM pUVM)
    739 {
    740     LogFlow(("VMR3ReqProcessU: (enmVMState=%d)\n", pUVM->pVM ? pUVM->pVM->enmVMState : VMSTATE_CREATING));
     773 * @param   enmDest         Destination of the request packet (global or per VCPU).
     774 */
     775VMMR3DECL(int) VMR3ReqProcessU(PUVM pUVM, VMREQDEST enmDest)
     776{
     777    LogFlow(("VMR3ReqProcessU: (enmVMState=%d) enmDest=%d\n", pUVM->pVM ? pUVM->pVM->enmVMState : VMSTATE_CREATING, enmDest));
    741778
    742779    /*
     
    749786    while (rc <= VINF_SUCCESS)
    750787    {
     788        void *volatile *ppReqs;
     789
    751790        /*
    752791         * Get pending requests.
    753792         */
    754         if (RT_LIKELY(pUVM->pVM))
    755             VM_FF_CLEAR(pUVM->pVM, VM_FF_REQUEST);
    756         PVMREQ pReqs = (PVMREQ)ASMAtomicXchgPtr((void * volatile *)&pUVM->vm.s.pReqs, NULL);
     793        if (enmDest == VMREQDEST_ALL)
     794        {
     795            ppReqs = (void * volatile *)&pUVM->vm.s.pReqs;
     796            if (RT_LIKELY(pUVM->pVM))
     797                VM_FF_CLEAR(pUVM->pVM, VM_FF_REQUEST);
     798        }
     799        else
     800        {
     801            ppReqs = (void * volatile *)&pUVM->aCpu[enmDest].vm.s.pReqs;
     802            if (RT_LIKELY(pUVM->pVM))
     803                VMCPU_FF_CLEAR(pUVM->pVM, enmDest, VM_FF_REQUEST);
     804        }
     805
     806        PVMREQ pReqs = (PVMREQ)ASMAtomicXchgPtr(ppReqs, NULL);
    757807        if (!pReqs)
    758808            break;
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