VirtualBox

Changeset 68009 in vbox


Ignore:
Timestamp:
Jul 17, 2017 5:17:59 PM (7 years ago)
Author:
vboxsync
Message:

VMMR0,PDMR0: Adding GVM parameter and validation thereof to the generic ring-0 device & driver calls.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/gvmm.h

    r68001 r68009  
    168168GVMMR0DECL(PGVM)    GVMMR0ByHandle(uint32_t hGVM);
    169169GVMMR0DECL(int)     GVMMR0ByVM(PVM pVM, PGVM *ppGVM);
    170 GVMMR0DECL(int)     GVMMR0ByVMAndEMT(PVM pVM, VMCPUID idCpu, PGVM *ppGVM);
    171170GVMMR0DECL(int)     GVMMR0ValidateGVMandVM(PGVM pGVM, PVM pVM);
    172171GVMMR0DECL(int)     GVMMR0ValidateGVMandVMandEMT(PGVM pGVM, PVM pVM, VMCPUID idCpu);
    173 GVMMR0DECL(PVM)     GVMMR0GetVMByHandle(uint32_t hGVM);
    174172GVMMR0DECL(PVM)     GVMMR0GetVMByEMT(RTNATIVETHREAD hEMT);
    175173GVMMR0DECL(int)     GVMMR0SchedHalt(PGVM pGVM, PVM pVM, VMCPUID idCpu, uint64_t u64ExpireGipTime);
  • trunk/include/VBox/vmm/pdmapi.h

    r64663 r68009  
    208208typedef PDMDRIVERCALLREQHANDLERREQ *PPDMDRIVERCALLREQHANDLERREQ;
    209209
    210 VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PVM pVM, PPDMDRIVERCALLREQHANDLERREQ pReq);
     210VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PGVM pGVM, PVM pVM, PPDMDRIVERCALLREQHANDLERREQ pReq);
    211211
    212212/**
     
    233233typedef PDMDEVICECALLREQHANDLERREQ *PPDMDEVICECALLREQHANDLERREQ;
    234234
    235 VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PVM pVM, PPDMDEVICECALLREQHANDLERREQ pReq);
     235VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PGVM pGVM, PVM pVM, PPDMDEVICECALLREQHANDLERREQ pReq);
    236236
    237237/** @} */
  • trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp

    r68007 r68009  
    19141914
    19151915/**
    1916  * Lookup a GVM structure by the shared VM structure
    1917  * and ensuring that the caller is the EMT thread.
    1918  *
    1919  * @returns VBox status code.
    1920  * @param   pVM         The cross context VM structure.
    1921  * @param   idCpu       The Virtual CPU ID of the calling EMT.
    1922  * @param   ppGVM       Where to store the GVM pointer.
    1923  * @thread  EMT(idCpu)
    1924  */
    1925 GVMMR0DECL(int) GVMMR0ByVMAndEMT(PVM pVM, VMCPUID idCpu, PGVM *ppGVM)
    1926 {
    1927     AssertPtrReturn(ppGVM, VERR_INVALID_POINTER);
    1928     PGVMM pGVMM;
    1929     return gvmmR0ByVMAndEMT(pVM, idCpu, ppGVM, &pGVMM);
    1930 }
    1931 
    1932 
    1933 /**
    1934  * Lookup a VM by its global handle.
    1935  *
    1936  * @returns Pointer to the VM on success, NULL on failure.
    1937  * @param   hGVM    The global VM handle. Asserts on bad handle.
    1938  */
    1939 GVMMR0DECL(PVM) GVMMR0GetVMByHandle(uint32_t hGVM)
    1940 {
    1941     PGVM pGVM = GVMMR0ByHandle(hGVM);
    1942     return pGVM ? pGVM->pVM : NULL;
    1943 }
    1944 
    1945 
    1946 /**
    19471916 * Looks up the VM belonging to the specified EMT thread.
    19481917 *
  • trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp

    r65338 r68009  
    821821 *
    822822 * @returns See PFNPDMDEVREQHANDLERR0.
     823 * @param   pGVM    The global (ring-0) VM structure. (For validation.)
    823824 * @param   pVM     The cross context VM structure. (For validation.)
    824825 * @param   pReq    Pointer to the request buffer.
    825826 */
    826 VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PVM pVM, PPDMDEVICECALLREQHANDLERREQ pReq)
     827VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PGVM pGVM, PVM pVM, PPDMDEVICECALLREQHANDLERREQ pReq)
    827828{
    828829    /*
    829830     * Validate input and make the call.
    830831     */
    831     AssertPtrReturn(pVM, VERR_INVALID_POINTER);
    832     AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    833     AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
    834 
    835     PPDMDEVINS pDevIns = pReq->pDevInsR0;
    836     AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
    837     AssertReturn(pDevIns->Internal.s.pVMR0 == pVM, VERR_INVALID_PARAMETER);
    838 
    839     PFNPDMDEVREQHANDLERR0 pfnReqHandlerR0 = pReq->pfnReqHandlerR0;
    840     AssertPtrReturn(pfnReqHandlerR0, VERR_INVALID_POINTER);
    841 
    842     return pfnReqHandlerR0(pDevIns, pReq->uOperation, pReq->u64Arg);
    843 }
    844 
     832    int rc = GVMMR0ValidateGVMandVM(pGVM, pVM);
     833    if (RT_SUCCESS(rc))
     834    {
     835        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
     836        AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
     837
     838        PPDMDEVINS pDevIns = pReq->pDevInsR0;
     839        AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
     840        AssertReturn(pDevIns->Internal.s.pVMR0 == pVM, VERR_INVALID_PARAMETER);
     841
     842        PFNPDMDEVREQHANDLERR0 pfnReqHandlerR0 = pReq->pfnReqHandlerR0;
     843        AssertPtrReturn(pfnReqHandlerR0, VERR_INVALID_POINTER);
     844
     845        rc = pfnReqHandlerR0(pDevIns, pReq->uOperation, pReq->u64Arg);
     846    }
     847    return rc;
     848}
     849
  • trunk/src/VBox/VMM/VMMR0/PDMR0Driver.cpp

    r62478 r68009  
    2424#include <VBox/vmm/pdm.h>
    2525#include <VBox/vmm/vm.h>
     26#include <VBox/vmm/gvmm.h>
    2627
    2728#include <VBox/log.h>
     
    3536 *
    3637 * @returns See PFNPDMDRVREQHANDLERR0.
     38 * @param   pGVM    The global (ring-0) VM structure. (For validation.)
    3739 * @param   pVM     The cross context VM structure. (For validation.)
    3840 * @param   pReq    Pointer to the request buffer.
    3941 */
    40 VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PVM pVM, PPDMDRIVERCALLREQHANDLERREQ pReq)
     42VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PGVM pGVM, PVM pVM, PPDMDRIVERCALLREQHANDLERREQ pReq)
    4143{
    4244    /*
    4345     * Validate input and make the call.
    4446     */
    45     AssertPtrReturn(pVM, VERR_INVALID_POINTER);
    46     AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    47     AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
     47    int rc = GVMMR0ValidateGVMandVM(pGVM, pVM);
     48    if (RT_SUCCESS(rc))
     49    {
     50        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
     51        AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
    4852
    49     PPDMDRVINS pDrvIns = pReq->pDrvInsR0;
    50     AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
    51     AssertReturn(pDrvIns->Internal.s.pVMR0 == pVM, VERR_INVALID_PARAMETER);
     53        PPDMDRVINS pDrvIns = pReq->pDrvInsR0;
     54        AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
     55        AssertReturn(pDrvIns->Internal.s.pVMR0 == pVM, VERR_INVALID_PARAMETER);
    5256
    53     PFNPDMDRVREQHANDLERR0 pfnReqHandlerR0 = pDrvIns->Internal.s.pfnReqHandlerR0;
    54     AssertPtrReturn(pfnReqHandlerR0, VERR_INVALID_POINTER);
     57        PFNPDMDRVREQHANDLERR0 pfnReqHandlerR0 = pDrvIns->Internal.s.pfnReqHandlerR0;
     58        AssertPtrReturn(pfnReqHandlerR0, VERR_INVALID_POINTER);
    5559
    56     return pfnReqHandlerR0(pDrvIns, pReq->uOperation, pReq->u64Arg);
     60        rc = pfnReqHandlerR0(pDrvIns, pReq->uOperation, pReq->u64Arg);
     61    }
     62    return rc;
    5763}
    5864
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r68007 r68009  
    18061806        case VMMR0_DO_GCFGM_QUERY_VALUE:
    18071807        {
    1808             if (pVM || !pReqHdr || u64Arg || idCpu != NIL_VMCPUID)
     1808            if (pGVM || pVM || !pReqHdr || u64Arg || idCpu != NIL_VMCPUID)
    18091809                return VERR_INVALID_PARAMETER;
    18101810            PGCFGMVALUEREQ pReq = (PGCFGMVALUEREQ)pReqHdr;
     
    18321832        case VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER:
    18331833        {
    1834             if (!pVM || !pReqHdr || u64Arg || idCpu != NIL_VMCPUID)
    1835                 return VERR_INVALID_PARAMETER;
    1836             rc = PDMR0DriverCallReqHandler(pVM, (PPDMDRIVERCALLREQHANDLERREQ)pReqHdr);
     1834            if (!pReqHdr || u64Arg || idCpu != NIL_VMCPUID)
     1835                return VERR_INVALID_PARAMETER;
     1836            rc = PDMR0DriverCallReqHandler(pGVM, pVM, (PPDMDRIVERCALLREQHANDLERREQ)pReqHdr);
    18371837            VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    18381838            break;
     
    18411841        case VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER:
    18421842        {
    1843             if (!pVM || !pReqHdr || u64Arg || idCpu != NIL_VMCPUID)
    1844                 return VERR_INVALID_PARAMETER;
    1845             rc = PDMR0DeviceCallReqHandler(pVM, (PPDMDEVICECALLREQHANDLERREQ)pReqHdr);
     1843            if (!pReqHdr || u64Arg || idCpu != NIL_VMCPUID)
     1844                return VERR_INVALID_PARAMETER;
     1845            rc = PDMR0DeviceCallReqHandler(pGVM, pVM, (PPDMDEVICECALLREQHANDLERREQ)pReqHdr);
    18461846            VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    18471847            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