VirtualBox

Changeset 56356 in vbox for trunk


Ignore:
Timestamp:
Jun 11, 2015 12:36:15 PM (9 years ago)
Author:
vboxsync
Message:

vboxdrvDarwinResolveSymbols: Fail if we cannot get the vmx_* symbols we need for raw-mode.

File:
1 edited

Legend:

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

    r56293 r56356  
    114114RT_C_DECLS_END
    115115
    116 static void             vboxdrvDarwinResolveSymbols(void);
     116static int              vboxdrvDarwinResolveSymbols(void);
    117117static bool             vboxdrvDarwinCpuHasSMAP(void);
    118118
     
    285285
    286286                /*
    287                  * Registering ourselves as a character device.
     287                 * Resolve some extra kernel symbols.
    288288                 */
    289                 g_iMajorDeviceNo = cdevsw_add(-1, &g_DevCW);
    290                 if (g_iMajorDeviceNo >= 0)
     289                rc = vboxdrvDarwinResolveSymbols();
     290                if (RT_SUCCESS(rc))
    291291                {
     292
     293                    /*
     294                     * Registering ourselves as a character device.
     295                     */
     296                    g_iMajorDeviceNo = cdevsw_add(-1, &g_DevCW);
     297                    if (g_iMajorDeviceNo >= 0)
     298                    {
    292299#ifdef VBOX_WITH_HARDENING
    293                     g_hDevFsDeviceSys = devfs_make_node(makedev(g_iMajorDeviceNo, 0), DEVFS_CHAR,
    294                                                         UID_ROOT, GID_WHEEL, 0600, DEVICE_NAME_SYS);
     300                        g_hDevFsDeviceSys = devfs_make_node(makedev(g_iMajorDeviceNo, 0), DEVFS_CHAR,
     301                                                            UID_ROOT, GID_WHEEL, 0600, DEVICE_NAME_SYS);
    295302#else
    296                     g_hDevFsDeviceSys = devfs_make_node(makedev(g_iMajorDeviceNo, 0), DEVFS_CHAR,
    297                                                         UID_ROOT, GID_WHEEL, 0666, DEVICE_NAME_SYS);
     303                        g_hDevFsDeviceSys = devfs_make_node(makedev(g_iMajorDeviceNo, 0), DEVFS_CHAR,
     304                                                            UID_ROOT, GID_WHEEL, 0666, DEVICE_NAME_SYS);
    298305#endif
    299                     if (g_hDevFsDeviceSys)
    300                     {
    301                         g_hDevFsDeviceUsr = devfs_make_node(makedev(g_iMajorDeviceNo, 1), DEVFS_CHAR,
    302                                                             UID_ROOT, GID_WHEEL, 0666, DEVICE_NAME_USR);
    303                         if (g_hDevFsDeviceUsr)
     306                        if (g_hDevFsDeviceSys)
    304307                        {
    305                             LogRel(("VBoxDrv: version " VBOX_VERSION_STRING " r%d; IOCtl version %#x; IDC version %#x; dev major=%d\n",
    306                                     VBOX_SVN_REV, SUPDRV_IOC_VERSION, SUPDRV_IDC_VERSION, g_iMajorDeviceNo));
    307 
    308                             /* Register a sleep/wakeup notification callback */
    309                             g_pSleepNotifier = registerPrioritySleepWakeInterest(&VBoxDrvDarwinSleepHandler, &g_DevExt, NULL);
    310                             if (g_pSleepNotifier == NULL)
    311                                 LogRel(("VBoxDrv: register for sleep/wakeup events failed\n"));
    312 
    313                             /* Find kernel symbols that are kind of optional. */
    314                             vboxdrvDarwinResolveSymbols();
    315                             return KMOD_RETURN_SUCCESS;
     308                            g_hDevFsDeviceUsr = devfs_make_node(makedev(g_iMajorDeviceNo, 1), DEVFS_CHAR,
     309                                                                UID_ROOT, GID_WHEEL, 0666, DEVICE_NAME_USR);
     310                            if (g_hDevFsDeviceUsr)
     311                            {
     312                                LogRel(("VBoxDrv: version " VBOX_VERSION_STRING " r%d; IOCtl version %#x; IDC version %#x; dev major=%d\n",
     313                                        VBOX_SVN_REV, SUPDRV_IOC_VERSION, SUPDRV_IDC_VERSION, g_iMajorDeviceNo));
     314
     315                                /* Register a sleep/wakeup notification callback */
     316                                g_pSleepNotifier = registerPrioritySleepWakeInterest(&VBoxDrvDarwinSleepHandler, &g_DevExt, NULL);
     317                                if (g_pSleepNotifier == NULL)
     318                                    LogRel(("VBoxDrv: register for sleep/wakeup events failed\n"));
     319
     320                                return KMOD_RETURN_SUCCESS;
     321                            }
     322
     323                            LogRel(("VBoxDrv: devfs_make_node(makedev(%d,1),,,,%s) failed\n", g_iMajorDeviceNo, DEVICE_NAME_USR));
     324                            devfs_remove(g_hDevFsDeviceSys);
     325                            g_hDevFsDeviceSys = NULL;
    316326                        }
    317 
    318                         LogRel(("VBoxDrv: devfs_make_node(makedev(%d,1),,,,%s) failed\n", g_iMajorDeviceNo, DEVICE_NAME_USR));
    319                         devfs_remove(g_hDevFsDeviceSys);
    320                         g_hDevFsDeviceSys = NULL;
     327                        else
     328                            LogRel(("VBoxDrv: devfs_make_node(makedev(%d,0),,,,%s) failed\n", g_iMajorDeviceNo, DEVICE_NAME_SYS));
     329
     330                        cdevsw_remove(g_iMajorDeviceNo, &g_DevCW);
     331                        g_iMajorDeviceNo = -1;
    321332                    }
    322333                    else
    323                         LogRel(("VBoxDrv: devfs_make_node(makedev(%d,0),,,,%s) failed\n", g_iMajorDeviceNo, DEVICE_NAME_SYS));
    324 
    325                     cdevsw_remove(g_iMajorDeviceNo, &g_DevCW);
    326                     g_iMajorDeviceNo = -1;
     334                        LogRel(("VBoxDrv: cdevsw_add failed (%d)\n", g_iMajorDeviceNo));
    327335                }
    328                 else
    329                     LogRel(("VBoxDrv: cdevsw_add failed (%d)\n", g_iMajorDeviceNo));
    330336                RTSpinlockDestroy(g_Spinlock);
    331337                g_Spinlock = NIL_RTSPINLOCK;
     
    350356 * Resolves kernel symbols we want (but may do without).
    351357 */
    352 static void vboxdrvDarwinResolveSymbols(void)
     358static int vboxdrvDarwinResolveSymbols(void)
    353359{
    354360    RTDBGKRNLINFO hKrnlInfo;
     
    356362    if (RT_SUCCESS(rc))
    357363    {
    358         /* The VMX stuff. */
     364        /*
     365         * The VMX stuff - required (for raw-mode).
     366         */
    359367        int rc1 = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "vmx_resume", (void **)&g_pfnVmxResume);
    360368        int rc2 = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "vmx_suspend", (void **)&g_pfnVmxSuspend);
     
    371379            g_pfnVmxSuspend = NULL;
    372380            g_pVmxUseCount  = NULL;
    373         }
    374 
     381            rc = VERR_SYMBOL_NOT_FOUND;
     382        }
     383
     384        if (RT_SUCCESS(rc))
     385        {
    375386#ifdef SUPDRV_WITH_MSR_PROBER
    376         /* MSR prober stuff. */
    377         int rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "rdmsr_carefully", (void **)&g_pfnRdMsrCarefully);
    378         if (RT_FAILURE(rc))
    379             g_pfnRdMsrCarefully = NULL;
    380         rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "rdmsr64_carefully", (void **)&g_pfnRdMsr64Carefully);
    381         if (RT_FAILURE(rc))
    382             g_pfnRdMsr64Carefully = NULL;
     387            /*
     388             * MSR prober stuff - optional!
     389             */
     390            int rc2 = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "rdmsr_carefully", (void **)&g_pfnRdMsrCarefully);
     391            if (RT_FAILURE(rc2))
     392                g_pfnRdMsrCarefully = NULL;
     393            rc2 = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "rdmsr64_carefully", (void **)&g_pfnRdMsr64Carefully);
     394            if (RT_FAILURE(rc2))
     395                g_pfnRdMsr64Carefully = NULL;
    383396# ifdef RT_ARCH_AMD64 /* Missing 64 in name, so if implemented on 32-bit it could have different signature. */
    384         rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "wrmsr_carefully", (void **)&g_pfnWrMsr64Carefully);
    385         if (RT_FAILURE(rc))
     397            rc2 = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "wrmsr_carefully", (void **)&g_pfnWrMsr64Carefully);
     398            if (RT_FAILURE(rc2))
    386399# endif
    387             g_pfnWrMsr64Carefully = NULL;
    388 
    389         LogRel(("VBoxDrv: g_pfnRdMsrCarefully=%p g_pfnRdMsr64Carefully=%p g_pfnWrMsr64Carefully=%p\n",
    390                 g_pfnRdMsrCarefully, g_pfnRdMsr64Carefully, g_pfnWrMsr64Carefully));
     400                g_pfnWrMsr64Carefully = NULL;
     401
     402            LogRel(("VBoxDrv: g_pfnRdMsrCarefully=%p g_pfnRdMsr64Carefully=%p g_pfnWrMsr64Carefully=%p\n",
     403                    g_pfnRdMsrCarefully, g_pfnRdMsr64Carefully, g_pfnWrMsr64Carefully));
    391404
    392405#endif /* SUPDRV_WITH_MSR_PROBER */
     406        }
    393407
    394408        RTR0DbgKrnlInfoRelease(hKrnlInfo);
     
    396410    else
    397411        LogRel(("VBoxDrv: Failed to open kernel symbols, rc=%Rrc\n", rc));
     412    return rc;
    398413}
    399414
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