- Timestamp:
- Jun 11, 2015 12:36:15 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
r56293 r56356 114 114 RT_C_DECLS_END 115 115 116 static voidvboxdrvDarwinResolveSymbols(void);116 static int vboxdrvDarwinResolveSymbols(void); 117 117 static bool vboxdrvDarwinCpuHasSMAP(void); 118 118 … … 285 285 286 286 /* 287 * Re gistering ourselves as a character device.287 * Resolve some extra kernel symbols. 288 288 */ 289 g_iMajorDeviceNo = cdevsw_add(-1, &g_DevCW);290 if ( g_iMajorDeviceNo >= 0)289 rc = vboxdrvDarwinResolveSymbols(); 290 if (RT_SUCCESS(rc)) 291 291 { 292 293 /* 294 * Registering ourselves as a character device. 295 */ 296 g_iMajorDeviceNo = cdevsw_add(-1, &g_DevCW); 297 if (g_iMajorDeviceNo >= 0) 298 { 292 299 #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); 295 302 #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); 298 305 #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) 304 307 { 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; 316 326 } 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; 321 332 } 322 333 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)); 327 335 } 328 else329 LogRel(("VBoxDrv: cdevsw_add failed (%d)\n", g_iMajorDeviceNo));330 336 RTSpinlockDestroy(g_Spinlock); 331 337 g_Spinlock = NIL_RTSPINLOCK; … … 350 356 * Resolves kernel symbols we want (but may do without). 351 357 */ 352 static voidvboxdrvDarwinResolveSymbols(void)358 static int vboxdrvDarwinResolveSymbols(void) 353 359 { 354 360 RTDBGKRNLINFO hKrnlInfo; … … 356 362 if (RT_SUCCESS(rc)) 357 363 { 358 /* The VMX stuff. */ 364 /* 365 * The VMX stuff - required (for raw-mode). 366 */ 359 367 int rc1 = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "vmx_resume", (void **)&g_pfnVmxResume); 360 368 int rc2 = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "vmx_suspend", (void **)&g_pfnVmxSuspend); … … 371 379 g_pfnVmxSuspend = NULL; 372 380 g_pVmxUseCount = NULL; 373 } 374 381 rc = VERR_SYMBOL_NOT_FOUND; 382 } 383 384 if (RT_SUCCESS(rc)) 385 { 375 386 #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; 383 396 # 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)) 386 399 # 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)); 391 404 392 405 #endif /* SUPDRV_WITH_MSR_PROBER */ 406 } 393 407 394 408 RTR0DbgKrnlInfoRelease(hKrnlInfo); … … 396 410 else 397 411 LogRel(("VBoxDrv: Failed to open kernel symbols, rc=%Rrc\n", rc)); 412 return rc; 398 413 } 399 414
Note:
See TracChangeset
for help on using the changeset viewer.