VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c@ 54300

Last change on this file since 54300 was 53396, checked in by vboxsync, 10 years ago

HostDrivers/Support: Don't try measuring TSC deltas on OSes that normalizes TSC-deltas themselves, currently only Windows.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 38.3 KB
Line 
1/* $Id: SUPDrv-solaris.c 53396 2014-11-25 15:01:59Z vboxsync $ */
2/** @file
3 * VBoxDrv - The VirtualBox Support Driver - Solaris specifics.
4 */
5
6/*
7 * Copyright (C) 2006-2014 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27/*******************************************************************************
28* Header Files *
29*******************************************************************************/
30#define LOG_GROUP LOG_GROUP_SUP_DRV
31#ifdef DEBUG_ramshankar
32# define LOG_ENABLED
33# define LOG_INSTANCE RTLogRelDefaultInstance()
34#endif
35#include <sys/types.h>
36#include <sys/param.h>
37#include <sys/errno.h>
38#include <sys/uio.h>
39#include <sys/buf.h>
40#include <sys/modctl.h>
41#include <sys/kobj.h>
42#include <sys/kobj_impl.h>
43#include <sys/open.h>
44#include <sys/conf.h>
45#include <sys/cmn_err.h>
46#include <sys/stat.h>
47#include <sys/ddi.h>
48#include <sys/sunddi.h>
49#include <sys/file.h>
50#include <sys/priv_names.h>
51#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
52
53#include "../SUPDrvInternal.h"
54#include <VBox/log.h>
55#include <VBox/version.h>
56#include <iprt/semaphore.h>
57#include <iprt/spinlock.h>
58#include <iprt/mp.h>
59#include <iprt/path.h>
60#include <iprt/power.h>
61#include <iprt/process.h>
62#include <iprt/thread.h>
63#include <iprt/initterm.h>
64#include <iprt/alloc.h>
65#include <iprt/string.h>
66#include <iprt/err.h>
67
68#include "dtrace/SUPDrv.h"
69
70
71/*******************************************************************************
72* Defined Constants And Macros *
73*******************************************************************************/
74/** The system device name. */
75#define DEVICE_NAME_SYS "vboxdrv"
76/** The user device name. */
77#define DEVICE_NAME_USR "vboxdrvu"
78/** The module description as seen in 'modinfo'. */
79#define DEVICE_DESC "VirtualBox HostDrv"
80/** Maximum number of driver instances. */
81#define DEVICE_MAXINSTANCES 16
82
83
84/*******************************************************************************
85* Internal Functions *
86*******************************************************************************/
87static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred);
88static int VBoxDrvSolarisClose(dev_t Dev, int fFlag, int fType, cred_t *pCred);
89static int VBoxDrvSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred);
90static int VBoxDrvSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred);
91static int VBoxDrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArgs, int mode, cred_t *pCred, int *pVal);
92
93static int VBoxDrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t Cmd);
94static int VBoxDrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t Cmd);
95static int VBoxDrvSolarisQuiesceNotNeeded(dev_info_t *pDip);
96
97static int VBoxSupDrvErr2SolarisErr(int rc);
98static int VBoxDrvSolarisIOCtlSlow(PSUPDRVSESSION pSession, int Cmd, int Mode, intptr_t pArgs);
99
100
101/*******************************************************************************
102* Global Variables *
103*******************************************************************************/
104/**
105 * cb_ops: for drivers that support char/block entry points
106 */
107static struct cb_ops g_VBoxDrvSolarisCbOps =
108{
109 VBoxDrvSolarisOpen,
110 VBoxDrvSolarisClose,
111 nodev, /* b strategy */
112 nodev, /* b dump */
113 nodev, /* b print */
114 VBoxDrvSolarisRead,
115 VBoxDrvSolarisWrite,
116 VBoxDrvSolarisIOCtl,
117 nodev, /* c devmap */
118 nodev, /* c mmap */
119 nodev, /* c segmap */
120 nochpoll, /* c poll */
121 ddi_prop_op, /* property ops */
122 NULL, /* streamtab */
123 D_NEW | D_MP, /* compat. flag */
124 CB_REV /* revision */
125};
126
127/**
128 * dev_ops: for driver device operations
129 */
130static struct dev_ops g_VBoxDrvSolarisDevOps =
131{
132 DEVO_REV, /* driver build revision */
133 0, /* ref count */
134 nulldev, /* get info */
135 nulldev, /* identify */
136 nulldev, /* probe */
137 VBoxDrvSolarisAttach,
138 VBoxDrvSolarisDetach,
139 nodev, /* reset */
140 &g_VBoxDrvSolarisCbOps,
141 (struct bus_ops *)0,
142 nodev, /* power */
143 VBoxDrvSolarisQuiesceNotNeeded
144};
145
146/**
147 * modldrv: export driver specifics to the kernel
148 */
149static struct modldrv g_VBoxDrvSolarisModule =
150{
151 &mod_driverops, /* extern from kernel */
152 DEVICE_DESC " " VBOX_VERSION_STRING "r" RT_XSTR(VBOX_SVN_REV),
153 &g_VBoxDrvSolarisDevOps
154};
155
156/**
157 * modlinkage: export install/remove/info to the kernel
158 */
159static struct modlinkage g_VBoxDrvSolarisModLinkage =
160{
161 MODREV_1, /* loadable module system revision */
162 {
163 &g_VBoxDrvSolarisModule,
164 NULL /* terminate array of linkage structures */
165 }
166};
167
168#ifndef USE_SESSION_HASH
169/**
170 * State info for each open file handle.
171 */
172typedef struct
173{
174 /**< Pointer to the session data. */
175 PSUPDRVSESSION pSession;
176} vbox_devstate_t;
177#else
178/** State info. for each driver instance. */
179typedef struct
180{
181 dev_info_t *pDip; /* Device handle */
182} vbox_devstate_t;
183#endif
184
185/** Opaque pointer to list of state */
186static void *g_pVBoxDrvSolarisState;
187
188/** Device extention & session data association structure */
189static SUPDRVDEVEXT g_DevExt;
190
191/** Hash table */
192static PSUPDRVSESSION g_apSessionHashTab[19];
193/** Spinlock protecting g_apSessionHashTab. */
194static RTSPINLOCK g_Spinlock = NIL_RTSPINLOCK;
195/** Calculates bucket index into g_apSessionHashTab.*/
196#define SESSION_HASH(sfn) ((sfn) % RT_ELEMENTS(g_apSessionHashTab))
197
198/**
199 * Kernel entry points
200 */
201int _init(void)
202{
203#if 0 /* No IPRT logging before RTR0Init() is done! */
204 LogFlowFunc(("vboxdrv:_init\n"));
205#endif
206
207 /*
208 * Prevent module autounloading.
209 */
210 modctl_t *pModCtl = mod_getctl(&g_VBoxDrvSolarisModLinkage);
211 if (pModCtl)
212 pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD;
213 else
214 cmn_err(CE_NOTE, "vboxdrv: failed to disable autounloading!\n");
215
216 /*
217 * Initialize IPRT R0 driver, which internally calls OS-specific r0 init.
218 */
219 int rc = RTR0Init(0);
220 if (RT_SUCCESS(rc))
221 {
222 /*
223 * Initialize the device extension
224 */
225 rc = supdrvInitDevExt(&g_DevExt, sizeof(SUPDRVSESSION));
226 if (RT_SUCCESS(rc))
227 {
228 cmn_err(CE_CONT, "!tsc::mode %s @ tentative %lu Hz\n", SUPGetGIPModeName(g_DevExt.pGip), g_DevExt.pGip->u64CpuHz);
229
230 /*
231 * Initialize the session hash table.
232 */
233 memset(g_apSessionHashTab, 0, sizeof(g_apSessionHashTab));
234 rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDrvSol");
235 if (RT_SUCCESS(rc))
236 {
237 rc = ddi_soft_state_init(&g_pVBoxDrvSolarisState, sizeof(vbox_devstate_t), 8);
238 if (!rc)
239 {
240 rc = mod_install(&g_VBoxDrvSolarisModLinkage);
241 if (!rc)
242 return rc; /* success */
243
244 ddi_soft_state_fini(&g_pVBoxDrvSolarisState);
245 LogRel(("vboxdrv: mod_install failed! rc=%d\n", rc));
246 }
247 else
248 LogRel(("vboxdrv: failed to initialize soft state.\n"));
249
250 RTSpinlockDestroy(g_Spinlock);
251 g_Spinlock = NIL_RTSPINLOCK;
252 }
253 else
254 {
255 LogRel(("VBoxDrvSolarisAttach: RTSpinlockCreate failed\n"));
256 rc = RTErrConvertToErrno(rc);
257 }
258 supdrvDeleteDevExt(&g_DevExt);
259 }
260 else
261 {
262 LogRel(("VBoxDrvSolarisAttach: supdrvInitDevExt failed\n"));
263 rc = EINVAL;
264 }
265 RTR0TermForced();
266 }
267 else
268 {
269 LogRel(("VBoxDrvSolarisAttach: failed to init R0Drv\n"));
270 rc = RTErrConvertToErrno(rc);
271 }
272 memset(&g_DevExt, 0, sizeof(g_DevExt));
273
274 return rc;
275}
276
277
278int _fini(void)
279{
280 LogFlowFunc(("vboxdrv:_fini\n"));
281
282 /*
283 * Undo the work we did at start (in the reverse order).
284 */
285 int rc = mod_remove(&g_VBoxDrvSolarisModLinkage);
286 if (rc != 0)
287 return rc;
288
289 supdrvDeleteDevExt(&g_DevExt);
290
291 rc = RTSpinlockDestroy(g_Spinlock);
292 AssertRC(rc);
293 g_Spinlock = NIL_RTSPINLOCK;
294
295 RTR0TermForced();
296
297 memset(&g_DevExt, 0, sizeof(g_DevExt));
298
299 ddi_soft_state_fini(&g_pVBoxDrvSolarisState);
300 return 0;
301}
302
303
304int _info(struct modinfo *pModInfo)
305{
306#if 0 /* No IPRT logging before RTR0Init() is done! And yes this is called before _init()!*/
307 LogFlowFunc(("vboxdrv:_init\n"));
308#endif
309 int e = mod_info(&g_VBoxDrvSolarisModLinkage, pModInfo);
310 return e;
311}
312
313
314/**
315 * Attach entry point, to attach a device to the system or resume it.
316 *
317 * @param pDip The module structure instance.
318 * @param enmCmd Operation type (attach/resume).
319 *
320 * @return corresponding solaris error code.
321 */
322static int VBoxDrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd)
323{
324 LogFlowFunc(("VBoxDrvSolarisAttach\n"));
325
326 switch (enmCmd)
327 {
328 case DDI_ATTACH:
329 {
330 int rc;
331#ifdef USE_SESSION_HASH
332 int instance = ddi_get_instance(pDip);
333 vbox_devstate_t *pState;
334
335 if (ddi_soft_state_zalloc(g_pVBoxDrvSolarisState, instance) != DDI_SUCCESS)
336 {
337 LogRel(("VBoxDrvSolarisAttach: state alloc failed\n"));
338 return DDI_FAILURE;
339 }
340
341 pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, instance);
342#endif
343
344 /*
345 * Register for suspend/resume notifications
346 */
347 rc = ddi_prop_create(DDI_DEV_T_NONE, pDip, DDI_PROP_CANSLEEP /* kmem alloc can sleep */,
348 "pm-hardware-state", "needs-suspend-resume", sizeof("needs-suspend-resume"));
349 if (rc != DDI_PROP_SUCCESS)
350 LogRel(("vboxdrv: Suspend/Resume notification registration failed.\n"));
351
352 /*
353 * Register ourselves as a character device, pseudo-driver
354 */
355#ifdef VBOX_WITH_HARDENING
356 rc = ddi_create_priv_minor_node(pDip, DEVICE_NAME_SYS, S_IFCHR, 0 /*minor*/, DDI_PSEUDO,
357 0, NULL, NULL, 0600);
358#else
359 rc = ddi_create_priv_minor_node(pDip, DEVICE_NAME_SYS, S_IFCHR, 0 /*minor*/, DDI_PSEUDO,
360 0, "none", "none", 0666);
361#endif
362 if (rc == DDI_SUCCESS)
363 {
364 rc = ddi_create_priv_minor_node(pDip, DEVICE_NAME_USR, S_IFCHR, 1 /*minor*/, DDI_PSEUDO,
365 0, "none", "none", 0666);
366 if (rc == DDI_SUCCESS)
367 {
368#ifdef USE_SESSION_HASH
369 pState->pDip = pDip;
370#endif
371 ddi_report_dev(pDip);
372 return DDI_SUCCESS;
373 }
374 ddi_remove_minor_node(pDip, NULL);
375 }
376
377 return DDI_FAILURE;
378 }
379
380 case DDI_RESUME:
381 {
382#if 0
383 RTSemFastMutexRequest(g_DevExt.mtxGip);
384 if (g_DevExt.pGipTimer)
385 RTTimerStart(g_DevExt.pGipTimer, 0);
386
387 RTSemFastMutexRelease(g_DevExt.mtxGip);
388#endif
389 RTPowerSignalEvent(RTPOWEREVENT_RESUME);
390 LogFlow(("vboxdrv: Awakened from suspend.\n"));
391 return DDI_SUCCESS;
392 }
393
394 default:
395 return DDI_FAILURE;
396 }
397
398 return DDI_FAILURE;
399}
400
401
402/**
403 * Detach entry point, to detach a device to the system or suspend it.
404 *
405 * @param pDip The module structure instance.
406 * @param enmCmd Operation type (detach/suspend).
407 *
408 * @return corresponding solaris error code.
409 */
410static int VBoxDrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd)
411{
412 LogFlowFunc(("VBoxDrvSolarisDetach\n"));
413 switch (enmCmd)
414 {
415 case DDI_DETACH:
416 {
417#ifndef USE_SESSION_HASH
418 ddi_remove_minor_node(pDip, NULL);
419#else
420 int instance = ddi_get_instance(pDip);
421 vbox_devstate_t *pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, instance);
422 ddi_remove_minor_node(pDip, NULL);
423 ddi_soft_state_free(g_pVBoxDrvSolarisState, instance);
424#endif
425 ddi_prop_remove_all(pDip);
426 return DDI_SUCCESS;
427 }
428
429 case DDI_SUSPEND:
430 {
431#if 0
432 RTSemFastMutexRequest(g_DevExt.mtxGip);
433 if (g_DevExt.pGipTimer && g_DevExt.cGipUsers > 0)
434 RTTimerStop(g_DevExt.pGipTimer);
435
436 RTSemFastMutexRelease(g_DevExt.mtxGip);
437#endif
438 RTPowerSignalEvent(RTPOWEREVENT_SUSPEND);
439 LogFlow(("vboxdrv: Falling to suspend mode.\n"));
440 return DDI_SUCCESS;
441
442 }
443
444 default:
445 return DDI_FAILURE;
446 }
447}
448
449
450/**
451 * Quiesce not-needed entry point, as Solaris 10 doesn't have any
452 * ddi_quiesce_not_needed() function.
453 *
454 * @param pDip The module structure instance.
455 *
456 * @return corresponding solaris error code.
457 */
458static int VBoxDrvSolarisQuiesceNotNeeded(dev_info_t *pDip)
459{
460 return DDI_SUCCESS;
461}
462
463
464/**
465 * open() worker.
466 */
467static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred)
468{
469 const bool fUnrestricted = getminor(*pDev) == 0;
470 PSUPDRVSESSION pSession;
471 int rc;
472
473 LogFlowFunc(("VBoxDrvSolarisOpen: pDev=%p:%#x\n", pDev, *pDev));
474
475 /*
476 * Validate input
477 */
478 if ( (getminor(*pDev) != 0 && getminor(*pDev) != 1)
479 || fType != OTYP_CHR)
480 return EINVAL; /* See mmopen for precedent. */
481
482#ifndef USE_SESSION_HASH
483 /*
484 * Locate a new device open instance.
485 *
486 * For each open call we'll allocate an item in the soft state of the device.
487 * The item index is stored in the dev_t. I hope this is ok...
488 */
489 vbox_devstate_t *pState = NULL;
490 unsigned iOpenInstance;
491 for (iOpenInstance = 0; iOpenInstance < 4096; iOpenInstance++)
492 {
493 if ( !ddi_get_soft_state(g_pVBoxDrvSolarisState, iOpenInstance) /* faster */
494 && ddi_soft_state_zalloc(g_pVBoxDrvSolarisState, iOpenInstance) == DDI_SUCCESS)
495 {
496 pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, iOpenInstance);
497 break;
498 }
499 }
500 if (!pState)
501 {
502 LogRel(("VBoxDrvSolarisOpen: too many open instances.\n"));
503 return ENXIO;
504 }
505
506 /*
507 * Create a new session.
508 */
509 rc = supdrvCreateSession(&g_DevExt, true /* fUser */, fUnrestricted, &pSession);
510 if (RT_SUCCESS(rc))
511 {
512 pSession->Uid = crgetruid(pCred);
513 pSession->Gid = crgetrgid(pCred);
514
515 pState->pSession = pSession;
516 *pDev = makedevice(getmajor(*pDev), iOpenInstance);
517 LogFlow(("VBoxDrvSolarisOpen: Dev=%#x pSession=%p pid=%d r0proc=%p thread=%p\n",
518 *pDev, pSession, RTProcSelf(), RTR0ProcHandleSelf(), RTThreadNativeSelf() ));
519 return 0;
520 }
521
522 /* failed - clean up */
523 ddi_soft_state_free(g_pVBoxDrvSolarisState, iOpenInstance);
524
525#else
526 /*
527 * Create a new session.
528 * Sessions in Solaris driver are mostly useless. It's however needed
529 * in VBoxDrvSolarisIOCtlSlow() while calling supdrvIOCtl()
530 */
531 rc = supdrvCreateSession(&g_DevExt, true /* fUser */, fUnrestricted, &pSession);
532 if (RT_SUCCESS(rc))
533 {
534 unsigned iHash;
535
536 pSession->Uid = crgetruid(pCred);
537 pSession->Gid = crgetrgid(pCred);
538
539 /*
540 * Insert it into the hash table.
541 */
542# error "Only one entry per process!"
543 iHash = SESSION_HASH(pSession->Process);
544 RTSpinlockAcquire(g_Spinlock);
545 pSession->pNextHash = g_apSessionHashTab[iHash];
546 g_apSessionHashTab[iHash] = pSession;
547 RTSpinlockRelease(g_Spinlock);
548 LogFlow(("VBoxDrvSolarisOpen success\n"));
549 }
550
551 int instance;
552 for (instance = 0; instance < DEVICE_MAXINSTANCES; instance++)
553 {
554 vbox_devstate_t *pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, instance);
555 if (pState)
556 break;
557 }
558
559 if (instance >= DEVICE_MAXINSTANCES)
560 {
561 LogRel(("VBoxDrvSolarisOpen: All instances exhausted\n"));
562 return ENXIO;
563 }
564
565 *pDev = makedevice(getmajor(*pDev), instance);
566#endif
567
568 return VBoxSupDrvErr2SolarisErr(rc);
569}
570
571
572static int VBoxDrvSolarisClose(dev_t Dev, int flag, int otyp, cred_t *cred)
573{
574 LogFlowFunc(("VBoxDrvSolarisClose: Dev=%#x\n", Dev));
575
576#ifndef USE_SESSION_HASH
577 /*
578 * Get the session and free the soft state item.
579 */
580 vbox_devstate_t *pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, getminor(Dev));
581 if (!pState)
582 {
583 LogRel(("VBoxDrvSolarisClose: no state data for %#x (%d)\n", Dev, getminor(Dev)));
584 return EFAULT;
585 }
586
587 PSUPDRVSESSION pSession = pState->pSession;
588 pState->pSession = NULL;
589 ddi_soft_state_free(g_pVBoxDrvSolarisState, getminor(Dev));
590
591 if (!pSession)
592 {
593 LogRel(("VBoxDrvSolarisClose: no session in state data for %#x (%d)\n", Dev, getminor(Dev)));
594 return EFAULT;
595 }
596 LogFlow(("VBoxDrvSolarisClose: Dev=%#x pSession=%p pid=%d r0proc=%p thread=%p\n",
597 Dev, pSession, RTProcSelf(), RTR0ProcHandleSelf(), RTThreadNativeSelf() ));
598
599#else
600 const RTPROCESS Process = RTProcSelf();
601 const unsigned iHash = SESSION_HASH(Process);
602 PSUPDRVSESSION pSession;
603
604 /*
605 * Remove from the hash table.
606 */
607 RTSpinlockAcquire(g_Spinlock);
608 pSession = g_apSessionHashTab[iHash];
609 if (pSession)
610 {
611 if (pSession->Process == Process)
612 {
613 g_apSessionHashTab[iHash] = pSession->pNextHash;
614 pSession->pNextHash = NULL;
615 }
616 else
617 {
618 PSUPDRVSESSION pPrev = pSession;
619 pSession = pSession->pNextHash;
620 while (pSession)
621 {
622 if (pSession->Process == Process)
623 {
624 pPrev->pNextHash = pSession->pNextHash;
625 pSession->pNextHash = NULL;
626 break;
627 }
628
629 /* next */
630 pPrev = pSession;
631 pSession = pSession->pNextHash;
632 }
633 }
634 }
635 RTSpinlockRelease(g_Spinlock);
636 if (!pSession)
637 {
638 LogRel(("VBoxDrvSolarisClose: WHAT?!? pSession == NULL! This must be a mistake... pid=%d (close)\n", (int)Process));
639 return EFAULT;
640 }
641#endif
642
643 /*
644 * Close the session.
645 */
646 supdrvSessionRelease(pSession);
647 return 0;
648}
649
650
651static int VBoxDrvSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred)
652{
653 LogFlowFunc(("VBoxDrvSolarisRead"));
654 return 0;
655}
656
657
658static int VBoxDrvSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred)
659{
660 LogFlowFunc(("VBoxDrvSolarisWrite"));
661 return 0;
662}
663
664
665/**
666 * Driver ioctl, an alternate entry point for this character driver.
667 *
668 * @param Dev Device number
669 * @param Cmd Operation identifier
670 * @param pArg Arguments from user to driver
671 * @param Mode Information bitfield (read/write, address space etc.)
672 * @param pCred User credentials
673 * @param pVal Return value for calling process.
674 *
675 * @return corresponding solaris error code.
676 */
677static int VBoxDrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArgs, int Mode, cred_t *pCred, int *pVal)
678{
679#ifndef USE_SESSION_HASH
680 /*
681 * Get the session from the soft state item.
682 */
683 vbox_devstate_t *pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, getminor(Dev));
684 if (!pState)
685 {
686 LogRel(("VBoxDrvSolarisIOCtl: no state data for %#x (%d)\n", Dev, getminor(Dev)));
687 return EINVAL;
688 }
689
690 PSUPDRVSESSION pSession = pState->pSession;
691 if (!pSession)
692 {
693 LogRel(("VBoxDrvSolarisIOCtl: no session in state data for %#x (%d)\n", Dev, getminor(Dev)));
694 return DDI_SUCCESS;
695 }
696#else
697 const RTPROCESS Process = RTProcSelf();
698 const unsigned iHash = SESSION_HASH(Process);
699 PSUPDRVSESSION pSession;
700 const bool fUnrestricted = getminor(Dev) == 0;
701
702 /*
703 * Find the session.
704 */
705 RTSpinlockAcquire(g_Spinlock);
706 pSession = g_apSessionHashTab[iHash];
707 while (pSession && pSession->Process != Process && pSession->fUnrestricted == fUnrestricted);
708 pSession = pSession->pNextHash;
709 RTSpinlockRelease(g_Spinlock);
710 if (!pSession)
711 {
712 LogRel(("VBoxSupDrvIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x Dev=%#x\n",
713 (int)Process, Cmd, (int)Dev));
714 return EINVAL;
715 }
716#endif
717
718 /*
719 * Deal with the two high-speed IOCtl that takes it's arguments from
720 * the session and iCmd, and only returns a VBox status code.
721 */
722 if ( ( Cmd == SUP_IOCTL_FAST_DO_RAW_RUN
723 || Cmd == SUP_IOCTL_FAST_DO_HM_RUN
724 || Cmd == SUP_IOCTL_FAST_DO_NOP)
725 && pSession->fUnrestricted)
726 {
727 *pVal = supdrvIOCtlFast(Cmd, pArgs, &g_DevExt, pSession);
728 return 0;
729 }
730
731 return VBoxDrvSolarisIOCtlSlow(pSession, Cmd, Mode, pArgs);
732}
733
734
735/** @def IOCPARM_LEN
736 * Gets the length from the ioctl number.
737 * This is normally defined by sys/ioccom.h on BSD systems...
738 */
739#ifndef IOCPARM_LEN
740# define IOCPARM_LEN(x) ( ((x) >> 16) & IOCPARM_MASK )
741#endif
742
743
744/**
745 * Worker for VBoxSupDrvIOCtl that takes the slow IOCtl functions.
746 *
747 * @returns Solaris errno.
748 *
749 * @param pSession The session.
750 * @param Cmd The IOCtl command.
751 * @param Mode Information bitfield (for specifying ownership of data)
752 * @param iArg User space address of the request buffer.
753 */
754static int VBoxDrvSolarisIOCtlSlow(PSUPDRVSESSION pSession, int iCmd, int Mode, intptr_t iArg)
755{
756 int rc;
757 uint32_t cbBuf = 0;
758 union
759 {
760 SUPREQHDR Hdr;
761 uint8_t abBuf[64];
762 } StackBuf;
763 PSUPREQHDR pHdr;
764
765
766 /*
767 * Read the header.
768 */
769 if (RT_UNLIKELY(IOCPARM_LEN(iCmd) != sizeof(StackBuf.Hdr)))
770 {
771 LogRel(("VBoxDrvSolarisIOCtlSlow: iCmd=%#x len %d expected %d\n", iCmd, IOCPARM_LEN(iCmd), sizeof(StackBuf.Hdr)));
772 return EINVAL;
773 }
774 rc = ddi_copyin((void *)iArg, &StackBuf.Hdr, sizeof(StackBuf.Hdr), Mode);
775 if (RT_UNLIKELY(rc))
776 {
777 LogRel(("VBoxDrvSolarisIOCtlSlow: ddi_copyin(,%#lx,) failed; iCmd=%#x. rc=%d\n", iArg, iCmd, rc));
778 return EFAULT;
779 }
780 if (RT_UNLIKELY((StackBuf.Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC))
781 {
782 LogRel(("VBoxDrvSolarisIOCtlSlow: bad header magic %#x; iCmd=%#x\n", StackBuf.Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK, iCmd));
783 return EINVAL;
784 }
785 cbBuf = RT_MAX(StackBuf.Hdr.cbIn, StackBuf.Hdr.cbOut);
786 if (RT_UNLIKELY( StackBuf.Hdr.cbIn < sizeof(StackBuf.Hdr)
787 || StackBuf.Hdr.cbOut < sizeof(StackBuf.Hdr)
788 || cbBuf > _1M*16))
789 {
790 LogRel(("VBoxDrvSolarisIOCtlSlow: max(%#x,%#x); iCmd=%#x\n", StackBuf.Hdr.cbIn, StackBuf.Hdr.cbOut, iCmd));
791 return EINVAL;
792 }
793
794 /*
795 * Buffer the request.
796 */
797 if (cbBuf <= sizeof(StackBuf))
798 pHdr = &StackBuf.Hdr;
799 else
800 {
801 pHdr = RTMemTmpAlloc(cbBuf);
802 if (RT_UNLIKELY(!pHdr))
803 {
804 LogRel(("VBoxDrvSolarisIOCtlSlow: failed to allocate buffer of %d bytes for iCmd=%#x.\n", cbBuf, iCmd));
805 return ENOMEM;
806 }
807 }
808 rc = ddi_copyin((void *)iArg, pHdr, cbBuf, Mode);
809 if (RT_UNLIKELY(rc))
810 {
811 LogRel(("VBoxDrvSolarisIOCtlSlow: copy_from_user(,%#lx, %#x) failed; iCmd=%#x. rc=%d\n", iArg, cbBuf, iCmd, rc));
812 if (pHdr != &StackBuf.Hdr)
813 RTMemFree(pHdr);
814 return EFAULT;
815 }
816
817 /*
818 * Process the IOCtl.
819 */
820 rc = supdrvIOCtl(iCmd, &g_DevExt, pSession, pHdr, cbBuf);
821
822 /*
823 * Copy ioctl data and output buffer back to user space.
824 */
825 if (RT_LIKELY(!rc))
826 {
827 uint32_t cbOut = pHdr->cbOut;
828 if (RT_UNLIKELY(cbOut > cbBuf))
829 {
830 LogRel(("VBoxDrvSolarisIOCtlSlow: too much output! %#x > %#x; iCmd=%#x!\n", cbOut, cbBuf, iCmd));
831 cbOut = cbBuf;
832 }
833 rc = ddi_copyout(pHdr, (void *)iArg, cbOut, Mode);
834 if (RT_UNLIKELY(rc != 0))
835 {
836 /* this is really bad */
837 LogRel(("VBoxDrvSolarisIOCtlSlow: ddi_copyout(,%p,%d) failed. rc=%d\n", (void *)iArg, cbBuf, rc));
838 rc = EFAULT;
839 }
840 }
841 else
842 rc = EINVAL;
843
844 if (pHdr != &StackBuf.Hdr)
845 RTMemTmpFree(pHdr);
846 return rc;
847}
848
849
850/**
851 * The SUPDRV IDC entry point.
852 *
853 * @returns VBox status code, see supdrvIDC.
854 * @param iReq The request code.
855 * @param pReq The request.
856 */
857int VBOXCALL SUPDrvSolarisIDC(uint32_t uReq, PSUPDRVIDCREQHDR pReq)
858{
859 PSUPDRVSESSION pSession;
860
861 /*
862 * Some quick validations.
863 */
864 if (RT_UNLIKELY(!VALID_PTR(pReq)))
865 return VERR_INVALID_POINTER;
866
867 pSession = pReq->pSession;
868 if (pSession)
869 {
870 if (RT_UNLIKELY(!VALID_PTR(pSession)))
871 return VERR_INVALID_PARAMETER;
872 if (RT_UNLIKELY(pSession->pDevExt != &g_DevExt))
873 return VERR_INVALID_PARAMETER;
874 }
875 else if (RT_UNLIKELY(uReq != SUPDRV_IDC_REQ_CONNECT))
876 return VERR_INVALID_PARAMETER;
877
878 /*
879 * Do the job.
880 */
881 return supdrvIDC(uReq, &g_DevExt, pSession, pReq);
882}
883
884
885/**
886 * Converts an supdrv error code to a solaris error code.
887 *
888 * @returns corresponding solaris error code.
889 * @param rc IPRT status code.
890 */
891static int VBoxSupDrvErr2SolarisErr(int rc)
892{
893 switch (rc)
894 {
895 case VINF_SUCCESS: return 0;
896 case VERR_GENERAL_FAILURE: return EACCES;
897 case VERR_INVALID_PARAMETER: return EINVAL;
898 case VERR_INVALID_MAGIC: return EILSEQ;
899 case VERR_INVALID_HANDLE: return ENXIO;
900 case VERR_INVALID_POINTER: return EFAULT;
901 case VERR_LOCK_FAILED: return ENOLCK;
902 case VERR_ALREADY_LOADED: return EEXIST;
903 case VERR_PERMISSION_DENIED: return EPERM;
904 case VERR_VERSION_MISMATCH: return ENOSYS;
905 }
906
907 return EPERM;
908}
909
910
911void VBOXCALL supdrvOSCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession)
912{
913 NOREF(pDevExt);
914 NOREF(pSession);
915}
916
917
918void VBOXCALL supdrvOSSessionHashTabInserted(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser)
919{
920 NOREF(pDevExt); NOREF(pSession); NOREF(pvUser);
921}
922
923
924void VBOXCALL supdrvOSSessionHashTabRemoved(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser)
925{
926 NOREF(pDevExt); NOREF(pSession); NOREF(pvUser);
927}
928
929
930/**
931 * Initializes any OS specific object creator fields.
932 */
933void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession)
934{
935 NOREF(pObj);
936 NOREF(pSession);
937}
938
939
940/**
941 * Checks if the session can access the object.
942 *
943 * @returns true if a decision has been made.
944 * @returns false if the default access policy should be applied.
945 *
946 * @param pObj The object in question.
947 * @param pSession The session wanting to access the object.
948 * @param pszObjName The object name, can be NULL.
949 * @param prc Where to store the result when returning true.
950 */
951bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc)
952{
953 NOREF(pObj);
954 NOREF(pSession);
955 NOREF(pszObjName);
956 NOREF(prc);
957 return false;
958}
959
960
961bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt)
962{
963 return false;
964}
965
966
967bool VBOXCALL supdrvOSAreTscDeltasInSync(void)
968{
969 return false;
970}
971
972
973#if defined(VBOX_WITH_NATIVE_SOLARIS_LOADING) \
974 && !defined(VBOX_WITHOUT_NATIVE_R0_LOADER)
975
976int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename)
977{
978 pImage->idSolMod = -1;
979 pImage->pSolModCtl = NULL;
980
981# if 1 /* This approach requires _init/_fini/_info stubs. */
982 /*
983 * Construct a filename that escapes the module search path and let us
984 * specify a root path.
985 */
986 /** @todo change this to use modctl and use_path=0. */
987 const char *pszName = RTPathFilename(pszFilename);
988 AssertReturn(pszName, VERR_INVALID_PARAMETER);
989 char *pszSubDir = RTStrAPrintf2("../../../../../../../../../../..%.*s", pszName - pszFilename - 1, pszFilename);
990 if (!pszSubDir)
991 return VERR_NO_STR_MEMORY;
992 int idMod = modload(pszSubDir, pszName);
993 if (idMod == -1)
994 {
995 /* This is an horrible hack for avoiding the mod-present check in
996 modrload on S10. Fortunately, nobody else seems to be using that
997 variable... */
998 extern int swaploaded;
999 int saved_swaploaded = swaploaded;
1000 swaploaded = 0;
1001 idMod = modload(pszSubDir, pszName);
1002 swaploaded = saved_swaploaded;
1003 }
1004 RTStrFree(pszSubDir);
1005 if (idMod == -1)
1006 {
1007 LogRel(("modload(,%s): failed, could be anything...\n", pszFilename));
1008 return VERR_LDR_GENERAL_FAILURE;
1009 }
1010
1011 modctl_t *pModCtl = mod_hold_by_id(idMod);
1012 if (!pModCtl)
1013 {
1014 LogRel(("mod_hold_by_id(,%s): failed, weird.\n", pszFilename));
1015 /* No point in calling modunload. */
1016 return VERR_LDR_GENERAL_FAILURE;
1017 }
1018 pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD | MOD_NOUNLOAD; /* paranoia */
1019
1020# else
1021
1022 const int idMod = -1;
1023 modctl_t *pModCtl = mod_hold_by_name(pszFilename);
1024 if (!pModCtl)
1025 {
1026 LogRel(("mod_hold_by_name failed for '%s'\n", pszFilename));
1027 return VERR_LDR_GENERAL_FAILURE;
1028 }
1029
1030 int rc = kobj_load_module(pModCtl, 0 /*use_path*/);
1031 if (rc != 0)
1032 {
1033 LogRel(("kobj_load_module failed with rc=%d for '%s'\n", rc, pszFilename));
1034 mod_release_mod(pModCtl);
1035 return RTErrConvertFromErrno(rc);
1036 }
1037# endif
1038
1039 /*
1040 * Get the module info.
1041 *
1042 * Note! The text section is actually not at mi_base, but and the next
1043 * alignment boundrary and there seems to be no easy way of
1044 * getting at this address. This sabotages supdrvOSLdrLoad.
1045 * Bastards!
1046 */
1047 struct modinfo ModInfo;
1048 kobj_getmodinfo(pModCtl->mod_mp, &ModInfo);
1049 pImage->pvImage = ModInfo.mi_base;
1050 pImage->idSolMod = idMod;
1051 pImage->pSolModCtl = pModCtl;
1052
1053 mod_release_mod(pImage->pSolModCtl);
1054 LogRel(("supdrvOSLdrOpen: succeeded for '%s' (mi_base=%p mi_size=%#x), id=%d ctl=%p\n",
1055 pszFilename, ModInfo.mi_base, ModInfo.mi_size, idMod, pModCtl));
1056 return VINF_SUCCESS;
1057}
1058
1059
1060void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
1061{
1062 NOREF(pDevExt); NOREF(pImage);
1063}
1064
1065
1066int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits)
1067{
1068 NOREF(pDevExt); NOREF(pImage); NOREF(pv); NOREF(pbImageBits);
1069 if (kobj_addrcheck(pImage->pSolModCtl->mod_mp, pv))
1070 return VERR_INVALID_PARAMETER;
1071 return VINF_SUCCESS;
1072}
1073
1074
1075/**
1076 * Resolves a module entry point address.
1077 *
1078 * @returns VBox status code.
1079 * @param pImage The image.
1080 * @param pszSymbol The symbol name.
1081 * @param ppvValue Where to store the value. On input this holds
1082 * the symbol value SUPLib calculated.
1083 */
1084static int supdrvSolLdrResolvEp(PSUPDRVLDRIMAGE pImage, const char *pszSymbol, void **ppvValue)
1085{
1086 /* Don't try resolve symbols which, according to SUPLib, aren't there. */
1087 if (!*ppvValue)
1088 return VINF_SUCCESS;
1089
1090 uintptr_t uValue = modlookup_by_modctl(pImage->pSolModCtl, pszSymbol);
1091 if (!uValue)
1092 {
1093 LogRel(("supdrvOSLdrLoad on %s failed to resolve %s\n", pImage->szName, pszSymbol));
1094 return VERR_SYMBOL_NOT_FOUND;
1095 }
1096 *ppvValue = (void *)uValue;
1097 return VINF_SUCCESS;
1098}
1099
1100
1101int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq)
1102{
1103#if 0 /* This doesn't work because of text alignment. */
1104 /*
1105 * Comparing is very very difficult since text and data may be allocated
1106 * separately.
1107 */
1108 size_t cbCompare = RT_MIN(pImage->cbImageBits, 64);
1109 if (memcmp(pImage->pvImage, pbImageBits, cbCompare))
1110 {
1111 LogRel(("Image mismatch: %s (%p)\n", pImage->szName, pImage->pvImage));
1112 LogRel(("Native: %.*Rhxs\n", cbCompare, pImage->pvImage));
1113 LogRel(("SUPLib: %.*Rhxs\n", cbCompare, pbImageBits));
1114 return VERR_LDR_MISMATCH_NATIVE;
1115 }
1116#endif
1117
1118 /*
1119 * Get the exported symbol addresses.
1120 */
1121 int rc;
1122 modctl_t *pModCtl = mod_hold_by_id(pImage->idSolMod);
1123 if (pModCtl && pModCtl == pImage->pSolModCtl)
1124 {
1125 uint32_t iSym = pImage->cSymbols;
1126 while (iSym-- > 0)
1127 {
1128 const char *pszSymbol = &pImage->pachStrTab[pImage->paSymbols[iSym].offName];
1129 uintptr_t uValue = modlookup_by_modctl(pImage->pSolModCtl, pszSymbol);
1130 if (!uValue)
1131 {
1132 LogRel(("supdrvOSLdrLoad on %s failed to resolve the exported symbol: '%s'\n", pImage->szName, pszSymbol));
1133 break;
1134 }
1135 uintptr_t offSymbol = uValue - (uintptr_t)pImage->pvImage;
1136 pImage->paSymbols[iSym].offSymbol = offSymbol;
1137 if (pImage->paSymbols[iSym].offSymbol != (int32_t)offSymbol)
1138 {
1139 LogRel(("supdrvOSLdrLoad on %s symbol out of range: %p (%s) \n", pImage->szName, offSymbol, pszSymbol));
1140 break;
1141 }
1142 }
1143
1144 rc = iSym == UINT32_MAX ? VINF_SUCCESS : VERR_LDR_GENERAL_FAILURE;
1145
1146 /*
1147 * Get the standard module entry points.
1148 */
1149 if (RT_SUCCESS(rc))
1150 {
1151 rc = supdrvSolLdrResolvEp(pImage, "ModuleInit", (void **)&pImage->pfnModuleInit);
1152 if (RT_SUCCESS(rc))
1153 rc = supdrvSolLdrResolvEp(pImage, "ModuleTerm", (void **)&pImage->pfnModuleTerm);
1154
1155 switch (pReq->u.In.eEPType)
1156 {
1157 case SUPLDRLOADEP_VMMR0:
1158 {
1159 if (RT_SUCCESS(rc))
1160 rc = supdrvSolLdrResolvEp(pImage, "VMMR0EntryInt", (void **)&pReq->u.In.EP.VMMR0.pvVMMR0EntryInt);
1161 if (RT_SUCCESS(rc))
1162 rc = supdrvSolLdrResolvEp(pImage, "VMMR0EntryFast", (void **)&pReq->u.In.EP.VMMR0.pvVMMR0EntryFast);
1163 if (RT_SUCCESS(rc))
1164 rc = supdrvSolLdrResolvEp(pImage, "VMMR0EntryEx", (void **)&pReq->u.In.EP.VMMR0.pvVMMR0EntryEx);
1165 break;
1166 }
1167
1168 case SUPLDRLOADEP_SERVICE:
1169 {
1170 /** @todo we need the name of the entry point. */
1171 return VERR_NOT_SUPPORTED;
1172 }
1173 }
1174 }
1175
1176 mod_release_mod(pImage->pSolModCtl);
1177 }
1178 else
1179 {
1180 LogRel(("mod_hold_by_id failed in supdrvOSLdrLoad on %s: %p\n", pImage->szName, pModCtl));
1181 rc = VERR_LDR_MISMATCH_NATIVE;
1182 }
1183 return rc;
1184}
1185
1186
1187void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
1188{
1189# if 1
1190 pImage->pSolModCtl->mod_loadflags &= ~MOD_NOUNLOAD;
1191 int rc = modunload(pImage->idSolMod);
1192 if (rc)
1193 LogRel(("modunload(%u (%s)) failed: %d\n", pImage->idSolMod, pImage->szName, rc));
1194# else
1195 kobj_unload_module(pImage->pSolModCtl);
1196# endif
1197 pImage->pSolModCtl = NULL;
1198 pImage->idSolMod = NULL;
1199}
1200
1201#else /* !VBOX_WITH_NATIVE_SOLARIS_LOADING */
1202
1203int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename)
1204{
1205 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename);
1206 return VERR_NOT_SUPPORTED;
1207}
1208
1209
1210void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
1211{
1212 NOREF(pDevExt); NOREF(pImage);
1213}
1214
1215
1216int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits)
1217{
1218 NOREF(pDevExt); NOREF(pImage); NOREF(pv); NOREF(pbImageBits);
1219 return VERR_NOT_SUPPORTED;
1220}
1221
1222
1223int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq)
1224{
1225 NOREF(pDevExt); NOREF(pImage); NOREF(pbImageBits); NOREF(pReq);
1226 return VERR_NOT_SUPPORTED;
1227}
1228
1229
1230void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
1231{
1232 NOREF(pDevExt); NOREF(pImage);
1233}
1234
1235#endif /* !VBOX_WITH_NATIVE_SOLARIS_LOADING */
1236
1237
1238#ifdef SUPDRV_WITH_MSR_PROBER
1239
1240int VBOXCALL supdrvOSMsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue)
1241{
1242/** @todo cmi_hdl_rdmsr can safely do this. there is also the on_trap() fun
1243 * for catching traps that could possibly be used directly. */
1244 NOREF(uMsr); NOREF(idCpu); NOREF(puValue);
1245 return VERR_NOT_SUPPORTED;
1246}
1247
1248
1249int VBOXCALL supdrvOSMsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue)
1250{
1251/** @todo cmi_hdl_wrmsr can safely do this. */
1252 NOREF(uMsr); NOREF(idCpu); NOREF(uValue);
1253 return VERR_NOT_SUPPORTED;
1254}
1255
1256
1257int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu, PSUPMSRPROBER pReq)
1258{
1259 NOREF(idCpu); NOREF(pReq);
1260 return VERR_NOT_SUPPORTED;
1261}
1262
1263#endif /* SUPDRV_WITH_MSR_PROBER */
1264
1265
1266RTDECL(int) SUPR0Printf(const char *pszFormat, ...)
1267{
1268 va_list args;
1269 char szMsg[512];
1270
1271 /* cmn_err() acquires adaptive mutexes. Not preemption safe, see @bugref{6657}. */
1272 if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
1273 return 0;
1274
1275 va_start(args, pszFormat);
1276 RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, args);
1277 va_end(args);
1278
1279 szMsg[sizeof(szMsg) - 1] = '\0';
1280 cmn_err(CE_CONT, "%s", szMsg);
1281 return 0;
1282}
1283
1284
1285/**
1286 * Returns configuration flags of the host kernel.
1287 */
1288SUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void)
1289{
1290 return 0;
1291}
1292
Note: See TracBrowser for help on using the repository browser.

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