#if defined(linux) && !defined(VMKERNEL)
# include <linux/wait.h>
-# include "compat_version.h"
-# include "compat_spinlock.h"
+# include "compat_cred.h"
# include "compat_semaphore.h"
+# include "compat_spinlock.h"
+# include "compat_version.h"
#endif // linux
#ifdef __APPLE__
# include <IOKit/IOLib.h>
# include <mach/task.h>
# include <mach/semaphore.h>
+# include <sys/kauth.h>
#endif
#ifdef VMKERNEL
typedef Semaphore VMCIEvent;
typedef Semaphore VMCIMutex;
typedef World_ID VMCIHostVmID;
+ typedef uint32 VMCIHostUser;
#elif defined(linux)
typedef spinlock_t VMCILock;
typedef unsigned long VMCILockFlags;
typedef wait_queue_head_t VMCIEvent;
typedef struct semaphore VMCIMutex;
typedef PPN *VMCIPpnList; /* List of PPNs in produce/consume queue. */
+ typedef uid_t VMCIHostUser;
#elif defined(__APPLE__)
typedef IOLock *VMCILock;
typedef unsigned long VMCILockFlags;
} VMCIEvent;
typedef IOLock *VMCIMutex;
typedef void *VMCIPpnList; /* Actually a pointer to the C++ Object IOMemoryDescriptor */
+ typedef uid_t VMCIHostUser;
#elif defined(_WIN32)
typedef KSPIN_LOCK VMCILock;
typedef KIRQL VMCILockFlags;
typedef KEVENT VMCIEvent;
typedef FAST_MUTEX VMCIMutex;
typedef PMDL VMCIPpnList; /* MDL to map the produce/consume queue. */
+ typedef PSID VMCIHostUser;
#elif defined(SOLARIS)
typedef kmutex_t VMCILock;
typedef unsigned long VMCILockFlags;
typedef ksema_t VMCIEvent;
typedef kmutex_t VMCIMutex;
typedef PPN *VMCIPpnList; /* List of PPNs in produce/consume queue. */
+ typedef uid_t VMCIHostUser;
#endif // VMKERNEL
/* Callback needed for correctly waiting on events. */
VMCIPrivilegeFlags privFlags);
#endif
+int VMCIHost_CompareUser(VMCIHostUser *user1, VMCIHostUser *user2);
+
void VMCI_CreateEvent(VMCIEvent *event);
void VMCI_DestroyEvent(VMCIEvent *event);
void VMCI_SignalEvent(VMCIEvent *event);
* VMCI_GrabLock_BH
*
* Grabs the given lock and for linux kernels disables bottom half execution.
- * . This should be used with locks accessed both from bottom half/tasklet
+ * This should be used with locks accessed both from bottom half/tasklet
* contexts, ie. guestcall handlers, and from process contexts to avoid
* deadlocks where the process has the lock and gets descheduled due to a
* bh/tasklet coming in.
*
* VMCI_ReleaseLock_BH
*
- * Releases the given lock and for linux kernels reenables bottom half
+ * Releases the given lock and for linux kernels reenables bottom half
* execution.
- * . This should be used with locks accessed both from bottom half/tasklet
+ * This should be used with locks accessed both from bottom half/tasklet
* contexts, ie. guestcall handlers, and from process contexts to avoid
* deadlocks where the process has the lock and get descheduled due to a
* bh/tasklet coming in.
{
DECLARE_WAITQUEUE(wait, current);
- /*
+ /*
* The thread must be added to the wait queue and have its state
* changed while holding the lock - otherwise a signal may change
* the state in between and have it overwritten causing a loss of
* the event.
- */
+ */
add_wait_queue(&hostContext->waitQueue, &wait);
current->state = TASK_INTERRUPTIBLE;
{
}
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMCIHost_CompareUser --
+ *
+ * Determines whether the two users are the same.
+ *
+ * Results:
+ * VMCI_SUCCESS if equal, error code otherwise.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int VMCIHost_CompareUser(VMCIHostUser *user1,
+ VMCIHostUser *user2)
+{
+ if (!user1 || !user2) {
+ return VMCI_ERROR_INVALID_ARGS;
+ }
+
+ if (*user1 == *user2) {
+ return VMCI_SUCCESS;
+ } else {
+ return VMCI_ERROR_GENERIC;
+ }
+}
+
+
/*
*----------------------------------------------------------------------
*
* VMCI_AllocKernelMem
*
- * Allocate some kernel memory for the VMCI driver.
+ * Allocate some kernel memory for the VMCI driver.
*
* Results:
- * The address allocated or NULL on error.
- *
+ * The address allocated or NULL on error.
+ *
*
* Side effects:
* memory is malloced
*
* VMCI_FreeKernelMem
*
- * Free kernel memory allocated for the VMCI driver.
+ * Free kernel memory allocated for the VMCI driver.
*
* Results:
* None.
add_wait_queue(event, &wait);
current->state = TASK_INTERRUPTIBLE;
- /*
- * Release the lock or other primitive that makes it possible for us to
- * put the current thread on the wait queue without missing the signal.
+ /*
+ * Release the lock or other primitive that makes it possible for us to
+ * put the current thread on the wait queue without missing the signal.
* Ie. on Linux we need to put ourselves on the wait queue and set our
* stateto TASK_INTERRUPTIBLE without another thread signalling us.
* The releaseCB is used to synchronize this.
*/
releaseCB(clientData);
-
+
schedule();
current->state = TASK_RUNNING;
remove_wait_queue(event, &wait);
}
-
#ifndef VMX86_TOOLS
/*