VirtualBox

Changeset 81519 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Oct 24, 2019 1:25:31 PM (5 years ago)
Author:
vboxsync
Message:

DevSmc,PDM: Converted the SMC device to the new style. Converted PDMDevHlpCallR0 to use PDMDEVREGR0::pfnRequest and ditch the inefficient symbol resolving stuff. The SMC device was the only user I could find for this helper. bugref:9218

Location:
trunk/src/VBox/VMM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp

    r81475 r81519  
    15441544
    15451545/**
    1546  * PDMDevHlpCallR0 helper.
    1547  *
    1548  * @returns See PFNPDMDEVREQHANDLERR0.
    1549  * @param   pGVM    The global (ring-0) VM structure. (For validation.)
    1550  * @param   pReq    Pointer to the request buffer.
    1551  */
    1552 VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PGVM pGVM, PPDMDEVICECALLREQHANDLERREQ pReq)
    1553 {
    1554     /*
    1555      * Validate input and make the call.
    1556      */
    1557     int rc = GVMMR0ValidateGVM(pGVM);
    1558     if (RT_SUCCESS(rc))
    1559     {
    1560         AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    1561         AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
    1562 
    1563         PPDMDEVINS pDevIns = pReq->pDevInsR0;
    1564         AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
    1565         AssertReturn(pDevIns->Internal.s.pGVM == pGVM, VERR_INVALID_PARAMETER);
    1566 
    1567         PFNPDMDEVREQHANDLERR0 pfnReqHandlerR0 = pReq->pfnReqHandlerR0;
    1568         AssertPtrReturn(pfnReqHandlerR0, VERR_INVALID_POINTER);
    1569 
    1570         rc = pfnReqHandlerR0(pDevIns, pReq->uOperation, pReq->u64Arg);
    1571     }
    1572     return rc;
    1573 }
    1574 
    1575 
    1576 /**
    15771546 * Worker for PDMR0DeviceCreate that does the actual instantiation.
    15781547 *
     
    19481917 * @param   pGVM    The global (ring-0) VM structure.
    19491918 * @param   pReq    Pointer to the request buffer.
    1950  * @thread  EMT(0)
    1951  */
    1952 VMMR0_INT_DECL(int) PDMR0DeviceGenCallReqHandler(PGVM pGVM, PPDMDEVICEGENCALLREQ pReq)
     1919 * @thread  EMT(0), except for PDMDEVICEGENCALL_REQUEST which can be any EMT.
     1920 */
     1921VMMR0_INT_DECL(int) PDMR0DeviceGenCallReqHandler(PGVM pGVM, PPDMDEVICEGENCALLREQ pReq, VMCPUID idCpu)
    19531922{
    19541923    /*
     
    19571926    AssertReturn(pReq->Hdr.cbReq == sizeof(*pReq), VERR_INVALID_PARAMETER);
    19581927
    1959     int rc = GVMMR0ValidateGVMandEMT(pGVM, 0);
     1928    int rc = GVMMR0ValidateGVMandEMT(pGVM, idCpu);
    19601929    AssertRCReturn(rc, rc);
    19611930
     
    19731942        case PDMDEVICEGENCALL_CONSTRUCT:
    19741943            AssertMsgBreakStmt(pGVM->enmVMState < VMSTATE_CREATED, ("enmVMState=%d\n", pGVM->enmVMState), rc = VERR_INVALID_STATE);
     1944            AssertReturn(idCpu == 0,  VERR_VM_THREAD_NOT_EMT);
    19751945            if (pDevIns->pReg->pfnConstruct)
    19761946                rc = pDevIns->pReg->pfnConstruct(pDevIns);
     
    19801950            AssertMsgBreakStmt(pGVM->enmVMState < VMSTATE_CREATED || pGVM->enmVMState >= VMSTATE_DESTROYING,
    19811951                               ("enmVMState=%d\n", pGVM->enmVMState), rc = VERR_INVALID_STATE);
     1952            AssertReturn(idCpu == 0,  VERR_VM_THREAD_NOT_EMT);
    19821953            if (pDevIns->pReg->pfnDestruct)
    19831954            {
     
    19851956                rc = VINF_SUCCESS;
    19861957            }
     1958            break;
     1959
     1960        case PDMDEVICEGENCALL_REQUEST:
     1961            if (pDevIns->pReg->pfnRequest)
     1962                rc = pDevIns->pReg->pfnRequest(pDevIns, pReq->Params.Req.uReq, pReq->Params.Req.uArg);
     1963            else
     1964                rc = VERR_INVALID_FUNCTION;
    19871965            break;
    19881966
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r81333 r81519  
    19801980        }
    19811981
    1982         case VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER:
    1983         {
    1984             if (!pReqHdr || u64Arg || idCpu != NIL_VMCPUID)
    1985                 return VERR_INVALID_PARAMETER;
    1986             rc = PDMR0DeviceCallReqHandler(pGVM, (PPDMDEVICECALLREQHANDLERREQ)pReqHdr);
    1987             VMM_CHECK_SMAP_CHECK2(pGVM, RT_NOTHING);
    1988             break;
    1989         }
    1990 
    19911982        case VMMR0_DO_PDM_DEVICE_CREATE:
    19921983        {
     
    20001991        case VMMR0_DO_PDM_DEVICE_GEN_CALL:
    20011992        {
    2002             if (!pReqHdr || u64Arg || idCpu != 0)
    2003                 return VERR_INVALID_PARAMETER;
    2004             rc = PDMR0DeviceGenCallReqHandler(pGVM, (PPDMDEVICEGENCALLREQ)pReqHdr);
     1993            if (!pReqHdr || u64Arg)
     1994                return VERR_INVALID_PARAMETER;
     1995            rc = PDMR0DeviceGenCallReqHandler(pGVM, (PPDMDEVICEGENCALLREQ)pReqHdr, idCpu);
    20051996            VMM_CHECK_SMAP_CHECK2(pGVM, RT_NOTHING);
    20061997            break;
  • trunk/src/VBox/VMM/VMMR3/PDM.cpp

    r81513 r81519  
    818818            LogFlow(("pdmR3DevTerm: Destroying (ring-0) - device '%s'/%d\n", pDevIns->pReg->szName, pDevIns->iInstance));
    819819            PDMDEVICEGENCALLREQ Req;
     820            RT_ZERO(Req.Params);
    820821            Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
    821822            Req.Hdr.cbReq    = sizeof(Req);
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r81475 r81519  
    34253425{
    34263426    PDMDEV_ASSERT_DEVINS(pDevIns);
    3427     PVM pVM = pDevIns->Internal.s.pVMR3;
    3428     VM_ASSERT_EMT(pVM);
     3427    PVM    pVM = pDevIns->Internal.s.pVMR3;
     3428    PVMCPU pVCpu = VMMGetCpu(pVM);
     3429    AssertReturn(pVCpu, VERR_VM_THREAD_IS_EMT);
    34293430    LogFlow(("pdmR3DevHlp_CallR0: caller='%s'/%d: uOperation=%#x u64Arg=%#RX64\n",
    34303431             pDevIns->pReg->szName, pDevIns->iInstance, uOperation, u64Arg));
     
    34383439    if (pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_R0)
    34393440    {
    3440         char szSymbol[          sizeof("devR0") + sizeof(pDevIns->pReg->szName) + sizeof("ReqHandler")];
    3441         strcat(strcat(strcpy(szSymbol, "devR0"),         pDevIns->pReg->szName),         "ReqHandler");
    3442         szSymbol[sizeof("devR0") - 1] = RT_C_TO_UPPER(szSymbol[sizeof("devR0") - 1]);
    3443 
    3444         PFNPDMDRVREQHANDLERR0 pfnReqHandlerR0;
    3445         rc = pdmR3DevGetSymbolR0Lazy(pDevIns, szSymbol, &pfnReqHandlerR0);
    3446         if (RT_SUCCESS(rc))
    3447         {
    3448             /*
    3449              * Make the ring-0 call.
    3450              */
    3451             PDMDEVICECALLREQHANDLERREQ Req;
    3452             Req.Hdr.u32Magic    = SUPVMMR0REQHDR_MAGIC;
    3453             Req.Hdr.cbReq       = sizeof(Req);
    3454             Req.pDevInsR0       = PDMDEVINS_2_R0PTR(pDevIns);
    3455             Req.pfnReqHandlerR0 = pfnReqHandlerR0;
    3456             Req.uOperation      = uOperation;
    3457             Req.u32Alignment    = 0;
    3458             Req.u64Arg          = u64Arg;
    3459             rc = SUPR3CallVMMR0Ex(VMCC_GET_VMR0_FOR_CALL(pVM), NIL_VMCPUID, VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER, 0, &Req.Hdr);
    3460         }
    3461         else
    3462             pfnReqHandlerR0 = NIL_RTR0PTR;
     3441        /*
     3442         * Make the ring-0 call.
     3443         */
     3444        PDMDEVICEGENCALLREQ Req;
     3445        RT_ZERO(Req.Params);
     3446        Req.Hdr.u32Magic    = SUPVMMR0REQHDR_MAGIC;
     3447        Req.Hdr.cbReq       = sizeof(Req);
     3448        Req.pDevInsR3       = pDevIns;
     3449        Req.idxR0Device     = pDevIns->Internal.s.idxR0Device;
     3450        Req.enmCall         = PDMDEVICEGENCALL_REQUEST;
     3451        Req.Params.Req.uReq = uOperation;
     3452        Req.Params.Req.uArg = u64Arg;
     3453        rc = VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_PDM_DEVICE_GEN_CALL, 0, &Req.Hdr);
    34633454    }
    34643455    else
  • trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp

    r81150 r81519  
    479479        {
    480480            PDMDEVICEGENCALLREQ Req;
     481            RT_ZERO(Req.Params);
    481482            Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
    482483            Req.Hdr.cbReq    = sizeof(Req);
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