summaryrefslogtreecommitdiff
path: root/src/VBox/HostDrivers/Support/freebsd
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/HostDrivers/Support/freebsd')
-rw-r--r--src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c74
-rw-r--r--src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp17
-rw-r--r--src/VBox/HostDrivers/Support/freebsd/SUPR0IdcClient-freebsd.c2
-rwxr-xr-xsrc/VBox/HostDrivers/Support/freebsd/files_vboxdrv5
4 files changed, 66 insertions, 32 deletions
diff --git a/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c b/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
index d5e38de2..f0166b98 100644
--- a/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
+++ b/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
@@ -70,7 +70,8 @@ static int VBoxDrvFreeBSDModuleEvent(struct module *pMod, int enmEventType, void
static int VBoxDrvFreeBSDLoad(void);
static int VBoxDrvFreeBSDUnload(void);
-static d_open_t VBoxDrvFreeBSDOpen;
+static d_open_t VBoxDrvFreeBSDOpenUsr;
+static d_open_t VBoxDrvFreeBSDOpenSys;
static void VBoxDrvFreeBSDDtr(void *pData);
static d_ioctl_t VBoxDrvFreeBSDIOCtl;
static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSession, u_long ulCmd, caddr_t pvData, struct thread *pTd);
@@ -96,16 +97,29 @@ MODULE_VERSION(vboxdrv, 1);
/**
* The /dev/vboxdrv character device entry points.
*/
-static struct cdevsw g_VBoxDrvFreeBSDChrDevSW =
+static struct cdevsw g_VBoxDrvFreeBSDChrDevSwSys =
{
.d_version = D_VERSION,
- .d_open = VBoxDrvFreeBSDOpen,
+ .d_open = VBoxDrvFreeBSDOpenSys,
.d_ioctl = VBoxDrvFreeBSDIOCtl,
.d_name = "vboxdrv"
};
-
/** The /dev/vboxdrv character device. */
-static struct cdev *g_pVBoxDrvFreeBSDChrDev;
+static struct cdev *g_pVBoxDrvFreeBSDChrDevSys;
+
+/**
+ * The /dev/vboxdrvu character device entry points.
+ */
+static struct cdevsw g_VBoxDrvFreeBSDChrDevSwUsr =
+{
+ .d_version = D_VERSION,
+ .d_open = VBoxDrvFreeBSDOpenUsr,
+ .d_ioctl = VBoxDrvFreeBSDIOCtl,
+ .d_name = "vboxdrvu"
+};
+/** The /dev/vboxdrvu character device. */
+static struct cdev *g_pVBoxDrvFreeBSDChrDevUsr;
+
/** Reference counter. */
static volatile uint32_t g_cUsers;
@@ -167,13 +181,14 @@ static int VBoxDrvFreeBSDLoad(void)
if (RT_SUCCESS(rc))
{
/*
- * Configure character device. Add symbolic link for compatibility.
+ * Configure character devices. Add symbolic links for compatibility.
*/
- g_pVBoxDrvFreeBSDChrDev = make_dev(&g_VBoxDrvFreeBSDChrDevSW, 0, UID_ROOT, GID_WHEEL, VBOXDRV_PERM, "vboxdrv");
+ g_pVBoxDrvFreeBSDChrDevSys = make_dev(&g_VBoxDrvFreeBSDChrDevSwSys, 0, UID_ROOT, GID_WHEEL, VBOXDRV_PERM, "vboxdrv");
+ g_pVBoxDrvFreeBSDChrDevUsr = make_dev(&g_VBoxDrvFreeBSDChrDevSwUsr, 1, UID_ROOT, GID_WHEEL, 0666, "vboxdrvu");
return VINF_SUCCESS;
}
- else
- printf("vboxdrv: supdrvInitDevExt failed, rc=%d\n", rc);
+
+ printf("vboxdrv: supdrvInitDevExt failed, rc=%d\n", rc);
RTR0Term();
}
else
@@ -191,7 +206,8 @@ static int VBoxDrvFreeBSDUnload(void)
/*
* Reserve what we did in VBoxDrvFreeBSDInit.
*/
- destroy_dev(g_pVBoxDrvFreeBSDChrDev);
+ destroy_dev(g_pVBoxDrvFreeBSDChrDevUsr);
+ destroy_dev(g_pVBoxDrvFreeBSDChrDevSys);
supdrvDeleteDevExt(&g_VBoxDrvFreeBSDDevExt);
@@ -206,13 +222,12 @@ static int VBoxDrvFreeBSDUnload(void)
*
* @returns 0 on success, errno on failure.
* EBUSY if the device is used by someone else.
- * @param pDev The device node.
- * @param fOpen The open flags.
- * @param pTd The thread.
- * @param pFd The file descriptor. FreeBSD 7.0 and later.
- * @param iFd The file descriptor index(?). Pre FreeBSD 7.0.
+ * @param pDev The device node.
+ * @param fOpen The open flags.
+ * @param pTd The thread.
+ * @param iDevType ???
*/
-static int VBoxDrvFreeBSDOpen(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd)
+static int vboxdrvFreeBSDOpenCommon(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd, bool fUnrestricted)
{
PSUPDRVSESSION pSession;
int rc;
@@ -220,7 +235,7 @@ static int VBoxDrvFreeBSDOpen(struct cdev *pDev, int fOpen, int iDevtype, struct
/*
* Let's be a bit picky about the flags...
*/
- if (fOpen != (FREAD|FWRITE /*=O_RDWR*/))
+ if (fOpen != (FREAD | FWRITE /*=O_RDWR*/))
{
Log(("VBoxDrvFreeBSDOpen: fOpen=%#x expected %#x\n", fOpen, O_RDWR));
return EINVAL;
@@ -229,7 +244,7 @@ static int VBoxDrvFreeBSDOpen(struct cdev *pDev, int fOpen, int iDevtype, struct
/*
* Create a new session.
*/
- rc = supdrvCreateSession(&g_VBoxDrvFreeBSDDevExt, true /* fUser */, &pSession);
+ rc = supdrvCreateSession(&g_VBoxDrvFreeBSDDevExt, true /* fUser */, fUnrestricted, &pSession);
if (RT_SUCCESS(rc))
{
/** @todo get (r)uid and (r)gid.
@@ -245,6 +260,20 @@ static int VBoxDrvFreeBSDOpen(struct cdev *pDev, int fOpen, int iDevtype, struct
}
+/** For vboxdrv. */
+static int VBoxDrvFreeBSDOpenSys(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd)
+{
+ return vboxdrvFreeBSDOpenCommon(pDev, fOpen, iDevtype, pTd, true);
+}
+
+
+/** For vboxdrvu. */
+static int VBoxDrvFreeBSDOpenUsr(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd)
+{
+ return vboxdrvFreeBSDOpenCommon(pDev, fOpen, iDevtype, pTd, false);
+}
+
+
/**
* Close a file device previously opened by VBoxDrvFreeBSDOpen
*
@@ -262,7 +291,7 @@ static void VBoxDrvFreeBSDDtr(void *pData)
/*
* Close the session.
*/
- supdrvCloseSession(&g_VBoxDrvFreeBSDDevExt, pSession);
+ supdrvSessionRelease(pSession);
ASMAtomicDecU32(&g_cUsers);
}
@@ -285,9 +314,10 @@ static int VBoxDrvFreeBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData,
/*
* Deal with the fast ioctl path first.
*/
- if ( ulCmd == SUP_IOCTL_FAST_DO_RAW_RUN
- || ulCmd == SUP_IOCTL_FAST_DO_HWACC_RUN
- || ulCmd == SUP_IOCTL_FAST_DO_NOP)
+ if ( ( ulCmd == SUP_IOCTL_FAST_DO_RAW_RUN
+ || ulCmd == SUP_IOCTL_FAST_DO_HM_RUN
+ || ulCmd == SUP_IOCTL_FAST_DO_NOP)
+ && pSession->fUnrestricted == true)
return supdrvIOCtlFast(ulCmd, *(uint32_t *)pvData, &g_VBoxDrvFreeBSDDevExt, pSession);
return VBoxDrvFreeBSDIOCtlSlow(pSession, ulCmd, pvData, pTd);
diff --git a/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp b/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp
index 6c16f5e9..c5ca90da 100644
--- a/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp
+++ b/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.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;
@@ -60,12 +60,14 @@
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
-/** FreeBSD base device name. */
-#define DEVICE_NAME "/dev/vboxdrv"
+/** System device name. */
+#define DEVICE_NAME_SYS "/dev/vboxdrv"
+/** User device name. */
+#define DEVICE_NAME_USR "/dev/vboxdrvu"
-int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited)
+int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted)
{
/*
* Nothing to do if pre-inited.
@@ -76,7 +78,7 @@ int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited)
/*
* Try open the BSD device.
*/
- int hDevice = open(DEVICE_NAME, O_RDWR, 0);
+ int hDevice = open(fUnrestricted ? DEVICE_NAME_SYS : DEVICE_NAME_USR, O_RDWR, 0);
if (hDevice < 0)
{
int rc;
@@ -88,7 +90,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", fUnrestricted ? DEVICE_NAME_SYS : DEVICE_NAME_USR, errno, rc));
return rc;
}
@@ -111,7 +113,8 @@ int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited)
/*
* We're done.
*/
- pThis->hDevice = hDevice;
+ pThis->hDevice = hDevice;
+ pThis->fUnrestricted = fUnrestricted;
return VINF_SUCCESS;
}
diff --git a/src/VBox/HostDrivers/Support/freebsd/SUPR0IdcClient-freebsd.c b/src/VBox/HostDrivers/Support/freebsd/SUPR0IdcClient-freebsd.c
index b0e39038..ed080886 100644
--- a/src/VBox/HostDrivers/Support/freebsd/SUPR0IdcClient-freebsd.c
+++ b/src/VBox/HostDrivers/Support/freebsd/SUPR0IdcClient-freebsd.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/freebsd/files_vboxdrv b/src/VBox/HostDrivers/Support/freebsd/files_vboxdrv
index d597425c..b02e35ca 100755
--- a/src/VBox/HostDrivers/Support/freebsd/files_vboxdrv
+++ b/src/VBox/HostDrivers/Support/freebsd/files_vboxdrv
@@ -81,8 +81,8 @@ FILES_VBOXDRV_NOBIN=" \
${PATH_ROOT}/include/VBox/version.h=>include/VBox/version.h \
${PATH_ROOT}/include/VBox/SUPDrvMangling.h=>include/VBox/SUPDrvMangling.h \
${PATH_ROOT}/include/VBox/VBoxTpG.h=>include/VBox/VBoxTpG.h \
- ${PATH_ROOT}/include/VBox/vmm/hwacc_vmx.h=>include/VBox/vmm/hwacc_vmx.h \
- ${PATH_ROOT}/include/VBox/vmm/hwacc_svm.h=>include/VBox/vmm/hwacc_svm.h \
+ ${PATH_ROOT}/include/VBox/vmm/hm_vmx.h=>include/VBox/vmm/hm_vmx.h \
+ ${PATH_ROOT}/include/VBox/vmm/hm_svm.h=>include/VBox/vmm/hm_svm.h \
${PATH_ROOT}/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c=>freebsd/SUPDrv-freebsd.c \
${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrv.c=>SUPDrv.c \
${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrvSem.c=>SUPDrvSem.c \
@@ -193,6 +193,7 @@ FILES_VBOXDRV_NOBIN=" \
${PATH_ROOT}/src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h=>r0drv/freebsd/sleepqueue-r0drv-freebsd.h \
${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/semspinmutex-r0drv-generic.c=>r0drv/generic/semspinmutex-r0drv-generic.c \
${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/mpnotification-r0drv-generic.cpp=>r0drv/generic/mpnotification-r0drv-generic.c \
+ ${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/threadctxhooks-r0drv-generic.cpp=>r0drv/generic/threadctxhooks-r0drv-generic.c \
${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/RTMpIsCpuWorkPending-r0drv-generic.cpp=>r0drv/generic/RTMpIsCpuWorkPending-r0drv-generic.c \
${PATH_ROOT}/src/VBox/Runtime/r0drv/memobj-r0drv.cpp=>r0drv/memobj-r0drv.c \
${PATH_ROOT}/src/VBox/Runtime/VBox/log-vbox.cpp=>VBox/log-vbox.c \