diff options
Diffstat (limited to 'src/VBox/HostDrivers/Support/solaris')
5 files changed, 117 insertions, 80 deletions
diff --git a/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c b/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c index 6916c8bc..9b0f60b9 100644 --- a/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c +++ b/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2007 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -71,8 +71,10 @@ /******************************************************************************* * Defined Constants And Macros * *******************************************************************************/ -/** The module name. */ -#define DEVICE_NAME "vboxdrv" +/** The system device name. */ +#define DEVICE_NAME_SYS "vboxdrv" +/** The user device name. */ +#define DEVICE_NAME_USR "vboxdrvu" /** The module description as seen in 'modinfo'. */ #define DEVICE_DESC "VirtualBox HostDrv" /** Maximum number of driver instances. */ @@ -196,7 +198,7 @@ static RTSPINLOCK g_Spinlock = NIL_RTSPINLOCK; */ int _init(void) { - LogFlowFunc((DEVICE_NAME ":_init\n")); + LogFlowFunc(("vboxdrv:_init\n")); /* * Prevent module autounloading. @@ -205,7 +207,7 @@ int _init(void) if (pModCtl) pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD; else - LogRel((DEVICE_NAME ":failed to disable autounloading!\n")); + LogRel(("vboxdrv: failed to disable autounloading!\n")); /* * Initialize IPRT R0 driver, which internally calls OS-specific r0 init. @@ -234,31 +236,31 @@ int _init(void) return rc; /* success */ ddi_soft_state_fini(&g_pVBoxDrvSolarisState); - LogRel((DEVICE_NAME ":mod_install failed! rc=%d\n", rc)); + LogRel(("vboxdrv: mod_install failed! rc=%d\n", rc)); } else - LogRel((DEVICE_NAME ":failed to initialize soft state.\n")); + LogRel(("vboxdrv: failed to initialize soft state.\n")); RTSpinlockDestroy(g_Spinlock); g_Spinlock = NIL_RTSPINLOCK; } else { - LogRel((DEVICE_NAME ":VBoxDrvSolarisAttach: RTSpinlockCreate failed\n")); + LogRel(("VBoxDrvSolarisAttach: RTSpinlockCreate failed\n")); rc = RTErrConvertToErrno(rc); } supdrvDeleteDevExt(&g_DevExt); } else { - LogRel((DEVICE_NAME ":VBoxDrvSolarisAttach: supdrvInitDevExt failed\n")); + LogRel(("VBoxDrvSolarisAttach: supdrvInitDevExt failed\n")); rc = RTErrConvertToErrno(rc); } RTR0TermForced(); } else { - LogRel((DEVICE_NAME ":VBoxDrvSolarisAttach: failed to init R0Drv\n")); + LogRel(("VBoxDrvSolarisAttach: failed to init R0Drv\n")); rc = RTErrConvertToErrno(rc); } memset(&g_DevExt, 0, sizeof(g_DevExt)); @@ -269,7 +271,7 @@ int _init(void) int _fini(void) { - LogFlowFunc((DEVICE_NAME ":_fini\n")); + LogFlowFunc(("vboxdrv:_fini\n")); /* * Undo the work we did at start (in the reverse order). @@ -295,7 +297,7 @@ int _fini(void) int _info(struct modinfo *pModInfo) { - LogFlowFunc((DEVICE_NAME ":_info\n")); + LogFlowFunc(("vboxdrv:_info\n")); int e = mod_info(&g_VBoxDrvSolarisModLinkage, pModInfo); return e; } @@ -311,20 +313,20 @@ int _info(struct modinfo *pModInfo) */ static int VBoxDrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd) { - LogFlowFunc((DEVICE_NAME ":VBoxDrvSolarisAttach\n")); + LogFlowFunc(("VBoxDrvSolarisAttach\n")); switch (enmCmd) { case DDI_ATTACH: { int rc; - int instance = ddi_get_instance(pDip); #ifdef USE_SESSION_HASH + int instance = ddi_get_instance(pDip); vbox_devstate_t *pState; if (ddi_soft_state_zalloc(g_pVBoxDrvSolarisState, instance) != DDI_SUCCESS) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisAttach: state alloc failed\n")); + LogRel(("VBoxDrvSolarisAttach: state alloc failed\n")); return DDI_FAILURE; } @@ -337,25 +339,31 @@ static int VBoxDrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd) rc = ddi_prop_create(DDI_DEV_T_NONE, pDip, DDI_PROP_CANSLEEP /* kmem alloc can sleep */, "pm-hardware-state", "needs-suspend-resume", sizeof("needs-suspend-resume")); if (rc != DDI_PROP_SUCCESS) - LogRel((DEVICE_NAME ":Suspend/Resume notification registration failed.\n")); + LogRel(("vboxdrv: Suspend/Resume notification registration failed.\n")); /* * Register ourselves as a character device, pseudo-driver */ #ifdef VBOX_WITH_HARDENING - rc = ddi_create_priv_minor_node(pDip, DEVICE_NAME, S_IFCHR, instance, DDI_PSEUDO, + rc = ddi_create_priv_minor_node(pDip, DEVICE_NAME_SYS, S_IFCHR, 0 /*minor*/, DDI_PSEUDO, 0, NULL, NULL, 0600); #else - rc = ddi_create_priv_minor_node(pDip, DEVICE_NAME, S_IFCHR, instance, DDI_PSEUDO, + rc = ddi_create_priv_minor_node(pDip, DEVICE_NAME_SYS, S_IFCHR, 0 /*minor*/, DDI_PSEUDO, 0, "none", "none", 0666); #endif if (rc == DDI_SUCCESS) { + rc = ddi_create_priv_minor_node(pDip, DEVICE_NAME_USR, S_IFCHR, 1 /*minor*/, DDI_PSEUDO, + 0, "none", "none", 0666); + if (rc == DDI_SUCCESS) + { #ifdef USE_SESSION_HASH - pState->pDip = pDip; + pState->pDip = pDip; #endif - ddi_report_dev(pDip); - return DDI_SUCCESS; + ddi_report_dev(pDip); + return DDI_SUCCESS; + } + ddi_remove_minor_node(pDip, NULL); } return DDI_FAILURE; @@ -371,7 +379,7 @@ static int VBoxDrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd) RTSemFastMutexRelease(g_DevExt.mtxGip); #endif RTPowerSignalEvent(RTPOWEREVENT_RESUME); - LogFlow((DEVICE_NAME ": Awakened from suspend.\n")); + LogFlow(("vboxdrv: Awakened from suspend.\n")); return DDI_SUCCESS; } @@ -393,7 +401,7 @@ static int VBoxDrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd) */ static int VBoxDrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd) { - LogFlowFunc((DEVICE_NAME ":VBoxDrvSolarisDetach\n")); + LogFlowFunc(("VBoxDrvSolarisDetach\n")); switch (enmCmd) { case DDI_DETACH: @@ -420,7 +428,7 @@ static int VBoxDrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd) RTSemFastMutexRelease(g_DevExt.mtxGip); #endif RTPowerSignalEvent(RTPOWEREVENT_SUSPEND); - LogFlow((DEVICE_NAME ": Falling to suspend mode.\n")); + LogFlow(("vboxdrv: Falling to suspend mode.\n")); return DDI_SUCCESS; } @@ -433,13 +441,22 @@ static int VBoxDrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd) /** - * User context entry points + * open() worker. */ static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) { - int rc; + const bool fUnrestricted = getminor(*pDev) == 0; PSUPDRVSESSION pSession; - LogFlowFunc((DEVICE_NAME ":VBoxDrvSolarisOpen: pDev=%p:%#x\n", pDev, *pDev)); + int rc; + + LogFlowFunc(("VBoxDrvSolarisOpen: pDev=%p:%#x\n", pDev, *pDev)); + + /* + * Validate input + */ + if ( (getminor(*pDev) != 0 && getminor(*pDev) != 1) + || fType != OTYP_CHR) + return EINVAL; /* See mmopen for precedent. */ #ifndef USE_SESSION_HASH /* @@ -461,14 +478,14 @@ static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) } if (!pState) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisOpen: too many open instances.\n")); + LogRel(("VBoxDrvSolarisOpen: too many open instances.\n")); return ENXIO; } /* * Create a new session. */ - rc = supdrvCreateSession(&g_DevExt, true /* fUser */, &pSession); + rc = supdrvCreateSession(&g_DevExt, true /* fUser */, fUnrestricted, &pSession); if (RT_SUCCESS(rc)) { pSession->Uid = crgetruid(pCred); @@ -476,8 +493,8 @@ static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) pState->pSession = pSession; *pDev = makedevice(getmajor(*pDev), iOpenInstance); - LogFlow((DEVICE_NAME ":VBoxDrvSolarisOpen: Dev=%#x pSession=%p pid=%d r0proc=%p thread=%p\n", - *pDev, pSession, RTProcSelf(), RTR0ProcHandleSelf(), RTThreadNativeSelf() )); + LogFlow(("VBoxDrvSolarisOpen: Dev=%#x pSession=%p pid=%d r0proc=%p thread=%p\n", + *pDev, pSession, RTProcSelf(), RTR0ProcHandleSelf(), RTThreadNativeSelf() )); return 0; } @@ -490,7 +507,7 @@ static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) * Sessions in Solaris driver are mostly useless. It's however needed * in VBoxDrvSolarisIOCtlSlow() while calling supdrvIOCtl() */ - rc = supdrvCreateSession(&g_DevExt, true /* fUser */, &pSession); + rc = supdrvCreateSession(&g_DevExt, true /* fUser */, fUnrestricted, &pSession); if (RT_SUCCESS(rc)) { unsigned iHash; @@ -501,12 +518,13 @@ static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) /* * Insert it into the hash table. */ +# error "Only one entry per process!" iHash = SESSION_HASH(pSession->Process); RTSpinlockAcquire(g_Spinlock); pSession->pNextHash = g_apSessionHashTab[iHash]; g_apSessionHashTab[iHash] = pSession; RTSpinlockReleaseNoInts(g_Spinlock); - LogFlow((DEVICE_NAME ":VBoxDrvSolarisOpen success\n")); + LogFlow(("VBoxDrvSolarisOpen success\n")); } int instance; @@ -519,7 +537,7 @@ static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) if (instance >= DEVICE_MAXINSTANCES) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisOpen: All instances exhausted\n")); + LogRel(("VBoxDrvSolarisOpen: All instances exhausted\n")); return ENXIO; } @@ -532,7 +550,7 @@ static int VBoxDrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) static int VBoxDrvSolarisClose(dev_t Dev, int flag, int otyp, cred_t *cred) { - LogFlowFunc((DEVICE_NAME ":VBoxDrvSolarisClose: Dev=%#x\n", Dev)); + LogFlowFunc(("VBoxDrvSolarisClose: Dev=%#x\n", Dev)); #ifndef USE_SESSION_HASH /* @@ -541,7 +559,7 @@ static int VBoxDrvSolarisClose(dev_t Dev, int flag, int otyp, cred_t *cred) vbox_devstate_t *pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, getminor(Dev)); if (!pState) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisClose: no state data for %#x (%d)\n", Dev, getminor(Dev))); + LogRel(("VBoxDrvSolarisClose: no state data for %#x (%d)\n", Dev, getminor(Dev))); return EFAULT; } @@ -551,10 +569,10 @@ static int VBoxDrvSolarisClose(dev_t Dev, int flag, int otyp, cred_t *cred) if (!pSession) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisClose: no session in state data for %#x (%d)\n", Dev, getminor(Dev))); + LogRel(("VBoxDrvSolarisClose: no session in state data for %#x (%d)\n", Dev, getminor(Dev))); return EFAULT; } - LogFlow((DEVICE_NAME ":VBoxDrvSolarisClose: Dev=%#x pSession=%p pid=%d r0proc=%p thread=%p\n", + LogFlow(("VBoxDrvSolarisClose: Dev=%#x pSession=%p pid=%d r0proc=%p thread=%p\n", Dev, pSession, RTProcSelf(), RTR0ProcHandleSelf(), RTThreadNativeSelf() )); #else @@ -596,8 +614,7 @@ static int VBoxDrvSolarisClose(dev_t Dev, int flag, int otyp, cred_t *cred) RTSpinlockReleaseNoInts(g_Spinlock); if (!pSession) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisClose: WHAT?!? pSession == NULL! This must be a mistake... pid=%d (close)\n", - (int)Process)); + LogRel(("VBoxDrvSolarisClose: WHAT?!? pSession == NULL! This must be a mistake... pid=%d (close)\n", (int)Process)); return EFAULT; } #endif @@ -605,21 +622,21 @@ static int VBoxDrvSolarisClose(dev_t Dev, int flag, int otyp, cred_t *cred) /* * Close the session. */ - supdrvCloseSession(&g_DevExt, pSession); + supdrvSessionRelease(pSession); return 0; } static int VBoxDrvSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred) { - LogFlowFunc((DEVICE_NAME ":VBoxDrvSolarisRead")); + LogFlowFunc(("VBoxDrvSolarisRead")); return 0; } static int VBoxDrvSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred) { - LogFlowFunc((DEVICE_NAME ":VBoxDrvSolarisWrite")); + LogFlowFunc(("VBoxDrvSolarisWrite")); return 0; } @@ -645,36 +662,34 @@ static int VBoxDrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArgs, int Mode, cre vbox_devstate_t *pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, getminor(Dev)); if (!pState) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtl: no state data for %#x (%d)\n", Dev, getminor(Dev))); + LogRel(("VBoxDrvSolarisIOCtl: no state data for %#x (%d)\n", Dev, getminor(Dev))); return EINVAL; } PSUPDRVSESSION pSession = pState->pSession; if (!pSession) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtl: no session in state data for %#x (%d)\n", Dev, getminor(Dev))); + LogRel(("VBoxDrvSolarisIOCtl: no session in state data for %#x (%d)\n", Dev, getminor(Dev))); return DDI_SUCCESS; } #else const RTPROCESS Process = RTProcSelf(); const unsigned iHash = SESSION_HASH(Process); PSUPDRVSESSION pSession; + const bool fUnrestricted = getminor(Dev) == 0; /* * Find the session. */ RTSpinlockAcquire(g_Spinlock); pSession = g_apSessionHashTab[iHash]; - if (pSession && pSession->Process != Process) - { - do pSession = pSession->pNextHash; - while (pSession && pSession->Process != Process); - } + while (pSession && pSession->Process != Process && pSession->fUnrestricted == fUnrestricted); + pSession = pSession->pNextHash; RTSpinlockReleaseNoInts(g_Spinlock); if (!pSession) { - LogRel((DEVICE_NAME ":VBoxSupDrvIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x\n", - (int)Process, Cmd)); + LogRel(("VBoxSupDrvIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x Dev=%#x\n", + (int)Process, Cmd, (int)Dev)); return EINVAL; } #endif @@ -683,9 +698,10 @@ static int VBoxDrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArgs, int Mode, cre * Deal with the two high-speed IOCtl that takes it's arguments from * the session and iCmd, and only returns a VBox status code. */ - if ( Cmd == SUP_IOCTL_FAST_DO_RAW_RUN - || Cmd == SUP_IOCTL_FAST_DO_HWACC_RUN - || Cmd == SUP_IOCTL_FAST_DO_NOP) + if ( ( Cmd == SUP_IOCTL_FAST_DO_RAW_RUN + || Cmd == SUP_IOCTL_FAST_DO_HM_RUN + || Cmd == SUP_IOCTL_FAST_DO_NOP) + && pSession->fUnrestricted) { *pVal = supdrvIOCtlFast(Cmd, pArgs, &g_DevExt, pSession); return 0; @@ -731,18 +747,18 @@ static int VBoxDrvSolarisIOCtlSlow(PSUPDRVSESSION pSession, int iCmd, int Mode, */ if (RT_UNLIKELY(IOCPARM_LEN(iCmd) != sizeof(StackBuf.Hdr))) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtlSlow: iCmd=%#x len %d expected %d\n", iCmd, IOCPARM_LEN(iCmd), sizeof(StackBuf.Hdr))); + LogRel(("VBoxDrvSolarisIOCtlSlow: iCmd=%#x len %d expected %d\n", iCmd, IOCPARM_LEN(iCmd), sizeof(StackBuf.Hdr))); return EINVAL; } rc = ddi_copyin((void *)iArg, &StackBuf.Hdr, sizeof(StackBuf.Hdr), Mode); if (RT_UNLIKELY(rc)) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtlSlow: ddi_copyin(,%#lx,) failed; iCmd=%#x. rc=%d\n", iArg, iCmd, rc)); + LogRel(("VBoxDrvSolarisIOCtlSlow: ddi_copyin(,%#lx,) failed; iCmd=%#x. rc=%d\n", iArg, iCmd, rc)); return EFAULT; } if (RT_UNLIKELY((StackBuf.Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC)) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtlSlow: bad header magic %#x; iCmd=%#x\n", StackBuf.Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK, iCmd)); + LogRel(("VBoxDrvSolarisIOCtlSlow: bad header magic %#x; iCmd=%#x\n", StackBuf.Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK, iCmd)); return EINVAL; } cbBuf = RT_MAX(StackBuf.Hdr.cbIn, StackBuf.Hdr.cbOut); @@ -750,7 +766,7 @@ static int VBoxDrvSolarisIOCtlSlow(PSUPDRVSESSION pSession, int iCmd, int Mode, || StackBuf.Hdr.cbOut < sizeof(StackBuf.Hdr) || cbBuf > _1M*16)) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtlSlow: max(%#x,%#x); iCmd=%#x\n", StackBuf.Hdr.cbIn, StackBuf.Hdr.cbOut, iCmd)); + LogRel(("VBoxDrvSolarisIOCtlSlow: max(%#x,%#x); iCmd=%#x\n", StackBuf.Hdr.cbIn, StackBuf.Hdr.cbOut, iCmd)); return EINVAL; } @@ -764,14 +780,14 @@ static int VBoxDrvSolarisIOCtlSlow(PSUPDRVSESSION pSession, int iCmd, int Mode, pHdr = RTMemTmpAlloc(cbBuf); if (RT_UNLIKELY(!pHdr)) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtlSlow: failed to allocate buffer of %d bytes for iCmd=%#x.\n", cbBuf, iCmd)); + LogRel(("VBoxDrvSolarisIOCtlSlow: failed to allocate buffer of %d bytes for iCmd=%#x.\n", cbBuf, iCmd)); return ENOMEM; } } rc = ddi_copyin((void *)iArg, pHdr, cbBuf, Mode); if (RT_UNLIKELY(rc)) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtlSlow: copy_from_user(,%#lx, %#x) failed; iCmd=%#x. rc=%d\n", iArg, cbBuf, iCmd, rc)); + LogRel(("VBoxDrvSolarisIOCtlSlow: copy_from_user(,%#lx, %#x) failed; iCmd=%#x. rc=%d\n", iArg, cbBuf, iCmd, rc)); if (pHdr != &StackBuf.Hdr) RTMemFree(pHdr); return EFAULT; @@ -790,14 +806,14 @@ static int VBoxDrvSolarisIOCtlSlow(PSUPDRVSESSION pSession, int iCmd, int Mode, uint32_t cbOut = pHdr->cbOut; if (RT_UNLIKELY(cbOut > cbBuf)) { - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtlSlow: too much output! %#x > %#x; iCmd=%#x!\n", cbOut, cbBuf, iCmd)); + LogRel(("VBoxDrvSolarisIOCtlSlow: too much output! %#x > %#x; iCmd=%#x!\n", cbOut, cbBuf, iCmd)); cbOut = cbBuf; } rc = ddi_copyout(pHdr, (void *)iArg, cbOut, Mode); if (RT_UNLIKELY(rc != 0)) { /* this is really bad */ - LogRel((DEVICE_NAME ":VBoxDrvSolarisIOCtlSlow: ddi_copyout(,%p,%d) failed. rc=%d\n", (void *)iArg, cbBuf, rc)); + LogRel(("VBoxDrvSolarisIOCtlSlow: ddi_copyout(,%p,%d) failed. rc=%d\n", (void *)iArg, cbBuf, rc)); rc = EFAULT; } } @@ -1177,6 +1193,10 @@ RTDECL(int) SUPR0Printf(const char *pszFormat, ...) va_list args; char szMsg[512]; + /* cmn_err() acquires adaptive mutexes. Not preemption safe, see @bugref{6657}. */ + if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD)) + return 0; + va_start(args, pszFormat); RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, args); va_end(args); diff --git a/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp b/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp index 0cb71dca..602854f4 100644 --- a/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp +++ b/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2007 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -52,6 +52,7 @@ #include <sys/fcntl.h> #include <sys/ioctl.h> +#include <sys/zone.h> #include <fcntl.h> #include <errno.h> @@ -59,17 +60,24 @@ #include <sys/mman.h> #include <stdlib.h> #include <stdio.h> +#include <zone.h> /******************************************************************************* * Defined Constants And Macros * *******************************************************************************/ -/** Solaris device link. */ -#define DEVICE_NAME "/dev/vboxdrv" +/** Solaris device link - system. */ +#define DEVICE_NAME_SYS "/devices/pseudo/vboxdrv@0:vboxdrv" +/** Solaris device link - user. */ +#define DEVICE_NAME_USR "/devices/pseudo/vboxdrv@0:vboxdrvu" +/** Solaris device link - system (non-global zone). */ +#define DEVICE_NAME_SYS_ZONE "/dev/vboxdrv" +/** Solaris device link - user (non-global zone). */ +#define DEVICE_NAME_USR_ZONE "/dev/vboxdrvu" -int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited) +int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted) { /* * Nothing to do if pre-inited. @@ -101,7 +109,12 @@ int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited) /* * Try to open the device. */ - int hDevice = open(DEVICE_NAME, O_RDWR, 0); + const char *pszDeviceNm; + if (getzoneid() == GLOBAL_ZONEID) + pszDeviceNm = fUnrestricted ? DEVICE_NAME_SYS : DEVICE_NAME_USR; + else + pszDeviceNm = fUnrestricted ? DEVICE_NAME_SYS_ZONE : DEVICE_NAME_USR_ZONE; + int hDevice = open(pszDeviceNm, O_RDWR, 0); if (hDevice < 0) { int rc; @@ -113,7 +126,7 @@ int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited) case ENOENT: rc = VERR_VM_DRIVER_NOT_INSTALLED; break; default: rc = VERR_VM_DRIVER_OPEN_ERROR; break; } - LogRel(("Failed to open \"%s\", errno=%d, rc=%Rrc\n", DEVICE_NAME, errno, rc)); + LogRel(("Failed to open \"%s\", errno=%d, rc=%Rrc\n", pszDeviceNm, errno, rc)); return rc; } @@ -133,7 +146,8 @@ int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited) return rc; } - pThis->hDevice = hDevice; + pThis->hDevice = hDevice; + pThis->fUnrestricted = fUnrestricted; return VINF_SUCCESS; } diff --git a/src/VBox/HostDrivers/Support/solaris/SUPR0IdcClient-solaris.c b/src/VBox/HostDrivers/Support/solaris/SUPR0IdcClient-solaris.c index 033fcdec..c7ca7b3f 100644 --- a/src/VBox/HostDrivers/Support/solaris/SUPR0IdcClient-solaris.c +++ b/src/VBox/HostDrivers/Support/solaris/SUPR0IdcClient-solaris.c @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2008 Oracle Corporation + * Copyright (C) 2008-2010 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; diff --git a/src/VBox/HostDrivers/Support/solaris/load.sh b/src/VBox/HostDrivers/Support/solaris/load.sh index fb204408..985c3459 100755 --- a/src/VBox/HostDrivers/Support/solaris/load.sh +++ b/src/VBox/HostDrivers/Support/solaris/load.sh @@ -26,7 +26,7 @@ # DRVNAME="vboxdrv" -DRIVERS_USING_IT="vboxusbmon vboxusb vboxnet vboxflt vboxbow" +DRIVERS_USING_IT="vboxusb vboxusbmon vboxnet vboxflt vboxbow" DRVFILE=`dirname "$0"` DRVFILE=`cd "$DRVFILE" && pwd` @@ -43,7 +43,10 @@ fi SUDO=sudo #set -x -# Unload driver that may depend on the driver we're going to (re-)load +# Disable the zone access service. +$SUDO svcadm disable svc:/application/virtualbox/zoneaccess:default + +# Unload driver that may depend on the driver we're going to (re-)load # as well as the driver itself. for drv in $DRIVERS_USING_IT $DRVNAME; do @@ -64,9 +67,9 @@ done # Reconfigure the driver so it get a major number. # # Note! We have to copy the driver and config files to somewhere the kernel can -# find them. It is searched for as drv/${DRVNAME}.conf in -# kobj_module_path, which is usually: -# /platform/i86pc/kernel /kernel /usr/kernel +# find them. It is searched for as drv/${DRVNAME}.conf in +# kobj_module_path, which is usually: +# /platform/i86pc/kernel /kernel /usr/kernel # To try prevent bad drivers from being loaded on the next boot, we remove # always the files. # diff --git a/src/VBox/HostDrivers/Support/solaris/vboxdrv.conf b/src/VBox/HostDrivers/Support/solaris/vboxdrv.conf index ed6f9cf4..cd136110 100644 --- a/src/VBox/HostDrivers/Support/solaris/vboxdrv.conf +++ b/src/VBox/HostDrivers/Support/solaris/vboxdrv.conf @@ -1,11 +1,10 @@ -# $Revision: $ +# $Id: vboxdrv.conf $ ## @file -# -# OpenSolaris Host Driver Configuration +# VirtualBox Solaris Host Driver Configuration. # # -# Copyright (C) 2007-2010 Oracle Corporation +# Copyright (C) 2007-2012 Oracle Corporation # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; @@ -31,3 +30,4 @@ # directory). After copying execute add_drv vboxdrv. # name="vboxdrv" parent="pseudo" instance=0; + |