VirtualBox

Ignore:
Timestamp:
Mar 5, 2018 10:59:17 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121103
Message:

SUPDrv,VMMR0: Prepped for extending the fast I/O control interface a bit for NEM; SUPDRV version increment. bugref:9044

Location:
trunk/src/VBox/HostDrivers/Support
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp

    r71136 r71198  
    14371437 *
    14381438 * @returns VBox status code that should be passed down to ring-3 unchanged.
    1439  * @param   uIOCtl      Function number.
     1439 * @param   uOperation  SUP_VMMR0_DO_XXX (not the I/O control number!).
    14401440 * @param   idCpu       VMCPU id.
    14411441 * @param   pDevExt     Device extention.
    14421442 * @param   pSession    Session data.
    14431443 */
    1444 int VBOXCALL supdrvIOCtlFast(uintptr_t uIOCtl, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession)
     1444int VBOXCALL supdrvIOCtlFast(uintptr_t uOperation, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession)
    14451445{
    14461446    /*
     
    14581458            {
    14591459                /*
    1460                  * Do the call.
     1460                 * Make the call.
    14611461                 */
    1462                 switch (uIOCtl)
    1463                 {
    1464                     case SUP_IOCTL_FAST_DO_RAW_RUN:
    1465                         pDevExt->pfnVMMR0EntryFast(pGVM, pVM, idCpu, SUP_VMMR0_DO_RAW_RUN);
    1466                         break;
    1467                     case SUP_IOCTL_FAST_DO_HM_RUN:
    1468                         pDevExt->pfnVMMR0EntryFast(pGVM, pVM, idCpu, SUP_VMMR0_DO_HM_RUN);
    1469                         break;
    1470                     case SUP_IOCTL_FAST_DO_NOP:
    1471                         pDevExt->pfnVMMR0EntryFast(pGVM, pVM, idCpu, SUP_VMMR0_DO_NOP);
    1472                         break;
    1473                     default:
    1474                         return VERR_INTERNAL_ERROR;
    1475                 }
     1462                pDevExt->pfnVMMR0EntryFast(pGVM, pVM, idCpu, uOperation);
    14761463                return VINF_SUCCESS;
    14771464            }
  • trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h

    r71136 r71198  
    113113#endif
    114114
     115/** @name Fast path I/O control codes.
     116 * @note These must run parallel to SUP_VMMR0_DO_XXX
     117 * @note Implementations ASSUMES up to 32 I/O controls codes in the fast range.
     118 * @{ */
    115119/** Fast path IOCtl: VMMR0_DO_RAW_RUN */
    116120#define SUP_IOCTL_FAST_DO_RAW_RUN               SUP_CTL_CODE_FAST(64)
     
    119123/** Just a NOP call for profiling the latency of a fast ioctl call to VMMR0. */
    120124#define SUP_IOCTL_FAST_DO_NOP                   SUP_CTL_CODE_FAST(66)
     125/** Fast path IOCtl: VMMR0_DO_NEM_RUN */
     126#define SUP_IOCTL_FAST_DO_NEM_RUN               SUP_CTL_CODE_FAST(67)
     127/** First fast path IOCtl number. */
     128#define SUP_IOCTL_FAST_DO_FIRST                 SUP_IOCTL_FAST_DO_RAW_RUN
     129/** @} */
     130
    121131
    122132#ifdef RT_OS_DARWIN
     
    210220 *
    211221 * @todo Pending work on next major version change:
    212  *          - nothing.
     222 *          - Move SUP_IOCTL_FAST_DO_NOP and SUP_VMMR0_DO_NEM_RUN after NEM.
    213223 *
    214224 * @remarks 0x002a0000 is used by 5.1. The next version number must be 0x002b0000.
    215225 */
    216 #define SUPDRV_IOC_VERSION                              0x00290003
     226#define SUPDRV_IOC_VERSION                              0x00290004
    217227
    218228/** SUP_IOCTL_COOKIE. */
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r71136 r71198  
    10121012/* SUPDrv.c */
    10131013int  VBOXCALL   supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr, size_t cbReq);
    1014 int  VBOXCALL   supdrvIOCtlFast(uintptr_t uIOCtl, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
     1014int  VBOXCALL   supdrvIOCtlFast(uintptr_t uOperation, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
    10151015int  VBOXCALL   supdrvIDC(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr);
    10161016int  VBOXCALL   supdrvInitDevExt(PSUPDRVDEVEXT pDevExt, size_t cbSession);
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r71136 r71198  
    277277        CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION;
    278278        const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x00290000
    279                                    ? 0x00290003
     279                                   ? 0x00290004
    280280                                   : SUPDRV_IOC_VERSION & 0xffff0000;
    281281        CookieReq.u.In.u32MinVersion = uMinVersion;
     
    613613{
    614614    NOREF(pVMR0);
    615     if (RT_LIKELY(uOperation == SUP_VMMR0_DO_RAW_RUN))
    616         return suplibOsIOCtlFast(&g_supLibData, SUP_IOCTL_FAST_DO_RAW_RUN, idCpu);
    617     if (RT_LIKELY(uOperation == SUP_VMMR0_DO_HM_RUN))
    618         return suplibOsIOCtlFast(&g_supLibData, SUP_IOCTL_FAST_DO_HM_RUN, idCpu);
    619     if (RT_LIKELY(uOperation == SUP_VMMR0_DO_NOP))
    620         return suplibOsIOCtlFast(&g_supLibData, SUP_IOCTL_FAST_DO_NOP, idCpu);
    621 
    622     AssertMsgFailed(("%#x\n", uOperation));
    623     return VERR_INTERNAL_ERROR;
     615    static const uintptr_t s_auFunctions[4] =
     616    {
     617        SUP_IOCTL_FAST_DO_RAW_RUN,
     618        SUP_IOCTL_FAST_DO_HM_RUN,
     619        SUP_IOCTL_FAST_DO_NOP,
     620        SUP_IOCTL_FAST_DO_NEM_RUN
     621    };
     622    AssertCompile(SUP_VMMR0_DO_RAW_RUN == 0);
     623    AssertCompile(SUP_VMMR0_DO_HM_RUN  == 1);
     624    AssertCompile(SUP_VMMR0_DO_NOP     == 2);
     625    AssertCompile(SUP_VMMR0_DO_NEM_RUN == 3);
     626    AssertMsgReturn(uOperation < RT_ELEMENTS(s_auFunctions), ("%#x\n", uOperation), VERR_INTERNAL_ERROR);
     627    return suplibOsIOCtlFast(&g_supLibData, s_auFunctions[uOperation], idCpu);
    624628}
    625629
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

    r69500 r71198  
    633633     */
    634634    int rc;
    635     if (   (    iCmd == SUP_IOCTL_FAST_DO_RAW_RUN
    636             ||  iCmd == SUP_IOCTL_FAST_DO_HM_RUN
    637             ||  iCmd == SUP_IOCTL_FAST_DO_NOP)
     635    AssertCompile((SUP_IOCTL_FAST_DO_FIRST & 0xff) == (SUP_IOCTL_FLAG | 64));
     636    if (   (uintptr_t)(iCmd - SUP_IOCTL_FAST_DO_FIRST) < (uintptr_t)32
    638637        && fUnrestricted)
    639         rc = supdrvIOCtlFast(iCmd, *(uint32_t *)pData, &g_DevExt, pSession);
     638        rc = supdrvIOCtlFast(iCmd - SUP_IOCTL_FAST_DO_FIRST, *(uint32_t *)pData, &g_DevExt, pSession);
    640639    else
    641640        rc = VBoxDrvDarwinIOCtlSlow(pSession, iCmd, pData, pProcess);
  • trunk/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c

    r59217 r71198  
    315315     * Deal with the fast ioctl path first.
    316316     */
    317     if (   (   ulCmd == SUP_IOCTL_FAST_DO_RAW_RUN
    318             || ulCmd == SUP_IOCTL_FAST_DO_HM_RUN
    319             || ulCmd == SUP_IOCTL_FAST_DO_NOP)
    320         && pSession->fUnrestricted == true)
    321         return supdrvIOCtlFast(ulCmd, *(uint32_t *)pvData, &g_VBoxDrvFreeBSDDevExt, pSession);
     317    AssertCompile((SUP_IOCTL_FAST_DO_FIRST & 0xff) == (SUP_IOCTL_FLAG | 64));
     318    if (   (uintptr_t)(iCmd - SUP_IOCTL_FAST_DO_FIRST) < (uintptr_t)32
     319        && pSession->fUnrestricted)
     320        return supdrvIOCtlFast(ulCmd - SUP_IOCTL_FAST_DO_FIRST, *(uint32_t *)pvData, &g_VBoxDrvFreeBSDDevExt, pSession);
    322321
    323322    return VBoxDrvFreeBSDIOCtlSlow(pSession, ulCmd, pvData, pTd);
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r69500 r71198  
    582582     * the session and iCmd, and only returns a VBox status code.
    583583     */
     584    AssertCompile(_IOC_NRSHIFT == 0 && _IOC_NRBITS == 8);
    584585#ifdef HAVE_UNLOCKED_IOCTL
    585     if (RT_LIKELY(   (   uCmd == SUP_IOCTL_FAST_DO_RAW_RUN
    586                       || uCmd == SUP_IOCTL_FAST_DO_HM_RUN
    587                       || uCmd == SUP_IOCTL_FAST_DO_NOP)
     586    if (RT_LIKELY(   (unsigned int)(uCmd - SUP_IOCTL_FAST_DO_FIRST) < (unsigned int)32)
    588587                  && pSession->fUnrestricted == true))
    589         rc = supdrvIOCtlFast(uCmd, ulArg, &g_DevExt, pSession);
     588        rc = supdrvIOCtlFast(uCmd - SUP_IOCTL_FAST_DO_FIRST, ulArg, &g_DevExt, pSession);
    590589    else
    591590        rc = VBoxDrvLinuxIOCtlSlow(pFilp, uCmd, ulArg, pSession);
    592591#else   /* !HAVE_UNLOCKED_IOCTL */
    593592    unlock_kernel();
    594     if (RT_LIKELY(   (   uCmd == SUP_IOCTL_FAST_DO_RAW_RUN
    595                       || uCmd == SUP_IOCTL_FAST_DO_HM_RUN
    596                       || uCmd == SUP_IOCTL_FAST_DO_NOP)
     593    if (RT_LIKELY(   (unsigned int)(uCmd - SUP_IOCTL_FAST_DO_FIRST) < (unsigned int)32)
    597594                  && pSession->fUnrestricted == true))
    598         rc = supdrvIOCtlFast(uCmd, ulArg, &g_DevExt, pSession);
     595        rc = supdrvIOCtlFast(uCmd - SUP_IOCTL_FAST_DO_FIRST, ulArg, &g_DevExt, pSession);
    599596    else
    600597        rc = VBoxDrvLinuxIOCtlSlow(pFilp, uCmd, ulArg, pSession);
  • trunk/src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp

    r62490 r71198  
    259259     * Dispatch the fast IOCtl.
    260260     */
    261     supdrvIOCtlFast(iFunction, 0, &g_DevExt, pSession);
     261    int rc;
     262    if ((unsigned)(iFunction - SUP_IOCTL_FAST_DO_FIRST) < (unsigned)32)
     263        rc = supdrvIOCtlFast(iFunction, 0, &g_DevExt, pSession);
     264    else
     265        rc = VERR_INVALID_FUNCTION;
    262266    supdrvSessionRelease(pSession);
    263     return 0;
     267    return rc;
    264268}
    265269
  • trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c

    r69500 r71198  
    664664 *
    665665 * @param   Dev             Device number
    666  * @param   Cmd             Operation identifier
     666 * @param   iCmd            Operation identifier
    667667 * @param   pArgs           Arguments from user to driver
    668668 * @param   Mode            Information bitfield (read/write, address space etc.)
     
    672672 * @return  corresponding solaris error code.
    673673 */
    674 static int VBoxDrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArgs, int Mode, cred_t *pCred, int *pVal)
     674static int VBoxDrvSolarisIOCtl(dev_t Dev, int iCmd, intptr_t pArgs, int Mode, cred_t *pCred, int *pVal)
    675675{
    676676#ifndef USE_SESSION_HASH
     
    708708    {
    709709        LogRel(("VBoxSupDrvIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x Dev=%#x\n",
    710                     (int)Process, Cmd, (int)Dev));
     710                    (int)Process, iCmd, (int)Dev));
    711711        return EINVAL;
    712712    }
     
    717717     * the session and iCmd, and only returns a VBox status code.
    718718     */
    719     if (   (   Cmd == SUP_IOCTL_FAST_DO_RAW_RUN
    720             || Cmd == SUP_IOCTL_FAST_DO_HM_RUN
    721             || Cmd == SUP_IOCTL_FAST_DO_NOP)
     719    AssertCompile((SUP_IOCTL_FAST_DO_FIRST & 0xff) == (SUP_IOCTL_FLAG | 64));
     720    if (   (unsigned)(iCmd - SUP_IOCTL_FAST_DO_FIRST) < (unsigned)32
    722721        && pSession->fUnrestricted)
    723722    {
    724         *pVal = supdrvIOCtlFast(Cmd, pArgs, &g_DevExt, pSession);
     723        *pVal = supdrvIOCtlFast(iCmd - SUP_IOCTL_FAST_DO_FIRST, pArgs, &g_DevExt, pSession);
    725724        return 0;
    726725    }
    727726
    728     return VBoxDrvSolarisIOCtlSlow(pSession, Cmd, Mode, pArgs);
     727    return VBoxDrvSolarisIOCtlSlow(pSession, iCmd, Mode, pArgs);
    729728}
    730729
  • trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp

    r71136 r71198  
    11291129         * the session and iCmd, and does not return anything.
    11301130         */
    1131         if (   uCmd == SUP_IOCTL_FAST_DO_RAW_RUN
    1132             || uCmd == SUP_IOCTL_FAST_DO_HM_RUN
    1133             || uCmd == SUP_IOCTL_FAST_DO_NOP)
    1134         {
    1135             int rc = supdrvIOCtlFast(uCmd, (unsigned)(uintptr_t)pvOutput/* VMCPU id */, pDevExt, pSession);
     1131        if (   (uCmd & 3) == METHOD_NEITHER
     1132            && (uint32_t)((uCmd - SUP_IOCTL_FAST_DO_FIRST) >> 2) < (uint32_t)32)
     1133        {
     1134            int rc = supdrvIOCtlFast((uCmd - SUP_IOCTL_FAST_DO_FIRST) >> 2,
     1135                                     (unsigned)(uintptr_t)pvOutput/* VMCPU id */,
     1136                                     pDevExt, pSession);
    11361137            pIoStatus->Status      = RT_SUCCESS(rc) ? STATUS_SUCCESS : STATUS_INVALID_PARAMETER;
    11371138            pIoStatus->Information = 0; /* Could be used to pass rc if we liked. */
     
    13181319#endif
    13191320
    1320         ULONG ulCmd = pStack->Parameters.DeviceIoControl.IoControlCode;
    1321         if (   ulCmd == SUP_IOCTL_FAST_DO_RAW_RUN
    1322             || ulCmd == SUP_IOCTL_FAST_DO_HM_RUN
    1323             || ulCmd == SUP_IOCTL_FAST_DO_NOP)
    1324         {
    1325             int rc = supdrvIOCtlFast(ulCmd, (unsigned)(uintptr_t)pIrp->UserBuffer /* VMCPU id */, pDevExt, pSession);
     1321        ULONG uCmd = pStack->Parameters.DeviceIoControl.IoControlCode;
     1322        if (   (uCmd & 3) == METHOD_NEITHER
     1323            && (uint32_t)((uCmd - SUP_IOCTL_FAST_DO_FIRST) >> 2) < (uint32_t)32)
     1324        {
     1325            int rc = supdrvIOCtlFast((uCmd - SUP_IOCTL_FAST_DO_FIRST) >> 2,
     1326                                     (unsigned)(uintptr_t)pIrp->UserBuffer /* VMCPU id */,
     1327                                     pDevExt, pSession);
    13261328
    13271329            /* Complete the I/O request. */
  • trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp

    r69500 r71198  
    673673    Assert(cbReq == RT_MAX(pHdr->cbIn, pHdr->cbOut));
    674674# ifdef USE_NT_DEVICE_IO_CONTROL_FILE
    675     IO_STATUS_BLOCK Ios;
    676     Ios.Status = -1;
    677     Ios.Information = 0;
     675    IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    678676    NTSTATUS rcNt = NtDeviceIoControlFile((HANDLE)pThis->hDevice, NULL /*hEvent*/, NULL /*pfnApc*/, NULL /*pvApcCtx*/, &Ios,
    679677                                          (ULONG)uFunction,
     
    703701     */
    704702# ifdef USE_NT_DEVICE_IO_CONTROL_FILE
    705     IO_STATUS_BLOCK Ios;
    706     Ios.Status = -1;
    707     Ios.Information = 0;
     703    IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    708704    NTSTATUS rcNt = NtDeviceIoControlFile((HANDLE)pThis->hDevice, NULL /*hEvent*/, NULL /*pfnApc*/, NULL /*pvApcCtx*/, &Ios,
    709705                                          (ULONG)uFunction,
Note: See TracChangeset for help on using the changeset viewer.

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