]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Make the VMCI host driver remember the owner of a context ID.
authorVMware, Inc <>
Thu, 24 Feb 2011 22:56:58 +0000 (14:56 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 24 Feb 2011 22:56:58 +0000 (14:56 -0800)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/modules/linux/shared/vmciKernelAPI1.h
open-vm-tools/modules/linux/shared/vmci_kernel_if.h
open-vm-tools/modules/linux/vmci/vmciKernelIf.c
open-vm-tools/modules/linux/vmci/vmciUtil.c

index 55a7ba4d608f94fab38a9e22e010957a28e30870..51fc81da12f03eb95641d34c2d295012a6a88940 100644 (file)
@@ -72,6 +72,7 @@ VMCIId VMCI_GetContextID(void);
 uint32 VMCI_Version(void);
 int VMCI_ContextID2HostVmID(VMCIId contextID, void *hostVmID,
                             size_t hostVmIDLen);
+int VMCI_IsContextOwner(VMCIId contextID, void *hostUser);
 
 /* VMCI Event API. */
 
index 455f085d21a343d2ed3a7371ad5c971cc88a21a3..a03864b1cea971a4d4cd06931ef84f2cf04ffb6c 100644 (file)
 
 #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. */
@@ -262,6 +269,8 @@ Bool VMCIWellKnownID_AllowMap(VMCIId wellKnownID,
                               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);
index 9bd5c203c2ee0adc4566f0e2e7b2cf7261dd70c5..2ebc61f7bd343c4d54a1c78ff04102bbb959a5d7 100644 (file)
@@ -187,7 +187,7 @@ VMCI_ReleaseLock(VMCILock *lock,      // IN
  * 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.
@@ -214,9 +214,9 @@ VMCI_GrabLock_BH(VMCILock *lock,        // 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.
@@ -338,12 +338,12 @@ VMCIHost_WaitForCallLocked(VMCIHost *hostContext, // 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;
@@ -395,16 +395,48 @@ VMCIHost_ClearCall(VMCIHost *hostContext)     // IN
 {
 }
 
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * 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
@@ -431,7 +463,7 @@ VMCI_AllocKernelMem(size_t size, int flags)
  *
  * VMCI_FreeKernelMem
  *
- *      Free kernel memory allocated for the VMCI driver. 
+ *      Free kernel memory allocated for the VMCI driver.
  *
  * Results:
  *      None.
@@ -719,15 +751,15 @@ VMCI_WaitOnEventInterruptible(VMCIEvent *event,              // IN:
    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);
@@ -1378,7 +1410,6 @@ VMCIWellKnownID_AllowMap(VMCIId wellKnownID,           // IN:
 }
 
 
-
 #ifndef VMX86_TOOLS
 
 /*
index e0ad2025c169a606fe3b1a55554fd659ffbc86fa..d1135c6be699a49455913e098b1b898f32fe9a10 100644 (file)
@@ -626,3 +626,29 @@ VMCI_ContextID2HostVmID(VMCIId contextID,    // IN
 {
    return VMCI_ERROR_UNAVAILABLE;
 }
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCI_IsContextOwner --
+ *
+ *      Provided for compatibility with the host VMCI API.
+ *
+ * Results:
+ *      Returns VMCI_ERROR_UNAVAILABLE.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+VMCI_EXPORT_SYMBOL(VMCI_IsContextOwner)
+int
+VMCI_IsContextOwner(VMCIId contextID,   // IN
+                    void *hostUser)     // IN
+{
+   return VMCI_ERROR_UNAVAILABLE;
+}
+