+++ /dev/null
-/*********************************************************
- * Copyright (C) 2006 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- *********************************************************/
-
-/*
- * vmciCommonInt.h --
- *
- * Struct definitions for VMCI internal common code.
- */
-
-#ifndef _VMCI_COMMONINT_H_
-#define _VMCI_COMMONINT_H_
-
-#define INCLUDE_ALLOW_MODULE
-#include "includeCheck.h"
-
-#include "vm_atomic.h"
-#include "vmci_defs.h"
-#include "vmci_call_defs.h"
-#include "vmci_infrastructure.h"
-#include "vmci_handle_array.h"
-#include "vmci_kernel_if.h"
-#include "circList.h"
-
-struct DatagramQueueEntry {
- ListItem listItem; /* For queuing. */
- VMCIDatagram *dg; /* Pending datagram. */
-};
-
-struct VMCIProcess {
- ListItem listItem; /* For global process list. */
- VMCIId pid; /* Process id. */
-};
-
-struct VMCIDatagramProcess {
- VMCILock datagramQueueLock;
- VMCIHandle handle;
- VMCIHost host;
- uint32 pendingDatagrams;
- size_t datagramQueueSize;
- ListItem *datagramQueue;
-};
-
-#endif /* _VMCI_COMMONINT_H_ */
#ifdef __linux__
# include "driver-config.h"
-
-# define EXPORT_SYMTAB
-
# include <linux/module.h>
# include "compat_kernel.h"
# include "compat_pci.h"
#include "vm_assert.h"
#include "vmci_defs.h"
#include "vmci_infrastructure.h"
-#include "vmciInt.h"
-#include "vmciUtil.h"
#include "vmciDatagram.h"
-#include "vmciCommonInt.h"
+#include "vmciInt.h"
#include "vmciKernelAPI.h"
+#include "vmciUtil.h"
typedef struct DatagramHashEntry {
struct DatagramHashEntry *next;
static DatagramHashEntry *DatagramHashGetEntryAnyCid(VMCIHandle handle);
static void DatagramHashReleaseEntry(DatagramHashEntry *entry);
static Bool DatagramHandleUniqueLockedAnyCid(VMCIHandle handle);
-static int DatagramProcessNotify(void *clientData, VMCIDatagram *msg);
DatagramHashTable hashTable;
{
return TRUE;
}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * DatagramProcessNotify --
- *
- * Callback to send a notificaton to a vmci process. Creates datagram
- * copy and signals the process.
- *
- * Results:
- * VMCI_SUCCESS on success, appropriate error code otherwise.
- *
- * Side effects:
- * None.
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-DatagramProcessNotify(void *clientData, // IN:
- VMCIDatagram *msg) // IN:
-{
- VMCIDatagramProcess *dgmProc = (VMCIDatagramProcess *) clientData;
- size_t dgmSize;
- VMCIDatagram *dgm;
- DatagramQueueEntry *dqEntry;
- VMCILockFlags flags;
-
- ASSERT(dgmProc != NULL && msg != NULL);
- dgmSize = VMCI_DG_SIZE(msg);
- ASSERT(dgmSize <= VMCI_MAX_DG_SIZE);
-
- dgm = VMCI_AllocKernelMem(dgmSize,
- VMCI_MEMORY_NONPAGED | VMCI_MEMORY_ATOMIC);
- if (!dgm) {
- VMCI_WARNING((LGPFX"Failed to allocate datagram of size %d bytes.\n",
- (uint32)dgmSize));
- return VMCI_ERROR_NO_MEM;
- }
- memcpy(dgm, msg, dgmSize);
-
- /* Allocate datagram queue entry and add it to the target fd's queue. */
- dqEntry = VMCI_AllocKernelMem(sizeof *dqEntry,
- VMCI_MEMORY_NONPAGED | VMCI_MEMORY_ATOMIC);
- if (dqEntry == NULL) {
- VMCI_FreeKernelMem(dgm, dgmSize);
- VMCI_WARNING((LGPFX"Failed to allocate memory for process datagram.\n"));
- return VMCI_ERROR_NO_MEM;
- }
- dqEntry->dg = dgm;
-
- VMCI_GrabLock_BH(&dgmProc->datagramQueueLock, &flags);
- if (dgmProc->datagramQueueSize + dgmSize >= VMCI_MAX_DATAGRAM_QUEUE_SIZE) {
- VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
- VMCI_FreeKernelMem(dgm, dgmSize);
- VMCI_FreeKernelMem(dqEntry, sizeof *dqEntry);
- VMCI_LOG((LGPFX"Datagram process receive queue is full.\n"));
- return VMCI_ERROR_NO_RESOURCES;
- }
-
- LIST_QUEUE(&dqEntry->listItem, &dgmProc->datagramQueue);
- dgmProc->pendingDatagrams++;
- dgmProc->datagramQueueSize += dgmSize;
-#ifdef SOLARIS
- /*
- * Release the lock here for Solaris. Otherwise, a deadlock
- * may occur since pollwakeup(9F) (invoked from VMCIHost_SignalCall)
- * and poll_common (invoked from poll(2)) try to grab a common lock.
- * The man pages of pollwakeup(9F) and chpoll(9E) talk about this.
- */
- VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
-#endif
- VMCIHost_SignalCall(&dgmProc->host);
-#ifndef SOLARIS
- /* For platforms other than Solaris, release the lock here. */
- VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
-#endif
-
- VMCI_DEBUG_LOG(10, (LGPFX"Sent datagram with resource id %d and size %u.\n",
- msg->dst.resource, (uint32)dgmSize));
- /* dqEntry and dgm are freed when user reads call.. */
-
- return VMCI_SUCCESS;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * VMCIDatagramProcess_Create --
- *
- * Creates a new VMCIDatagramProcess object.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-VMCIDatagramProcess_Create(VMCIDatagramProcess **outDgmProc, // OUT:
- VMCIDatagramCreateProcessInfo *createInfo, // IN:
- uintptr_t eventHnd) // IN:
-{
- VMCIDatagramProcess *dgmProc;
-
- ASSERT(createInfo);
- ASSERT(outDgmProc);
- dgmProc = VMCI_AllocKernelMem(sizeof *dgmProc, VMCI_MEMORY_NONPAGED);
- if (dgmProc == NULL) {
- return VMCI_ERROR_NO_MEM;
- }
-
- VMCI_InitLock(&dgmProc->datagramQueueLock, "VMCIDgmProc",
- VMCI_LOCK_RANK_MIDDLE_BH);
- VMCIHost_InitContext(&dgmProc->host, eventHnd);
- dgmProc->pendingDatagrams = 0;
- dgmProc->datagramQueueSize = 0;
- dgmProc->datagramQueue = NULL;
-
- /*
- * We pass the result and corresponding handle to user level via the
- * createInfo.
- */
- createInfo->result = VMCIDatagram_CreateHnd(createInfo->resourceID,
- createInfo->flags,
- DatagramProcessNotify,
- (void *)dgmProc,
- &dgmProc->handle);
- if (createInfo->result < VMCI_SUCCESS) {
- VMCI_FreeKernelMem(dgmProc, sizeof *dgmProc);
- return createInfo->result;
- }
- createInfo->handle = dgmProc->handle;
-
- *outDgmProc = dgmProc;
- return VMCI_SUCCESS;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * VMCIDatagramProcess_Destroy --
- *
- * Destroys a VMCIDatagramProcess object.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-VMCIDatagramProcess_Destroy(VMCIDatagramProcess *dgmProc) // IN:
-{
- ListItem *curr, *next;
- DatagramQueueEntry *dqEntry;
- VMCILockFlags flags;
-
- if (!dgmProc) {
- return;
- }
-
- if (!VMCI_HANDLE_EQUAL(dgmProc->handle, VMCI_INVALID_HANDLE)) {
-
- /*
- * We block in destroy so we know that there can be no more
- * callbacks to DatagramProcessNotifyCB when we return from
- * this call.
- */
- VMCIDatagram_DestroyHnd(dgmProc->handle);
- dgmProc->handle = VMCI_INVALID_HANDLE;
- }
-
- /* Flush dgmProc's call queue. */
- VMCI_GrabLock_BH(&dgmProc->datagramQueueLock, &flags);
- LIST_SCAN_SAFE(curr, next, dgmProc->datagramQueue) {
- dqEntry = LIST_CONTAINER(curr, DatagramQueueEntry, listItem);
- LIST_DEL(curr, &dgmProc->datagramQueue);
- ASSERT(dqEntry && dqEntry->dg);
- VMCI_FreeKernelMem(dqEntry->dg, VMCI_DG_SIZE(dqEntry->dg));
- VMCI_FreeKernelMem(dqEntry, sizeof *dqEntry);
- }
- VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
- VMCIHost_ReleaseContext(&dgmProc->host);
- VMCI_CleanupLock(&dgmProc->datagramQueueLock);
- VMCI_FreeKernelMem(dgmProc, sizeof *dgmProc);
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * VMCIDatagramProcess_ReadCall --
- *
- * Dequeues the next guest call and returns it to user level.
- *
- * Results:
- * 0 on success, appropriate error code otherwise.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-VMCIDatagramProcess_ReadCall(VMCIDatagramProcess *dgmProc, // IN:
- size_t maxSize, // IN: max size of dg
- VMCIDatagram **dg) // OUT:
-{
- DatagramQueueEntry *dqEntry;
- ListItem *listItem;
- VMCILockFlags flags;
-
- ASSERT(dgmProc);
- ASSERT(dg);
-
- /* Dequeue the next dgmProc datagram queue entry. */
- VMCI_GrabLock_BH(&dgmProc->datagramQueueLock, &flags);
-
- /*
- * Currently, we do not support blocking read of datagrams on Mac and
- * Solaris. XXX: This will go away soon.
- */
-
-#if defined(SOLARIS) || defined(__APPLE__)
- if (dgmProc->pendingDatagrams == 0) {
- VMCIHost_ClearCall(&dgmProc->host);
- VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
- VMCI_DEBUG_LOG(4, (LGPFX"No datagrams pending.\n"));
- return VMCI_ERROR_NO_MORE_DATAGRAMS;
- }
-#else
- while (dgmProc->pendingDatagrams == 0) {
- VMCIHost_ClearCall(&dgmProc->host);
- if (!VMCIHost_WaitForCallLocked(&dgmProc->host,
- &dgmProc->datagramQueueLock,
- &flags, TRUE)) {
- VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
- VMCI_DEBUG_LOG(4, (LGPFX"Blocking read of datagram interrupted.\n"));
- return VMCI_ERROR_NO_MORE_DATAGRAMS;
- }
- }
-#endif
-
- listItem = LIST_FIRST(dgmProc->datagramQueue);
- ASSERT (listItem != NULL);
-
- dqEntry = LIST_CONTAINER(listItem, DatagramQueueEntry, listItem);
- ASSERT(dqEntry->dg);
-
- /* Check the size of the userland buffer. */
- if (maxSize < VMCI_DG_SIZE(dqEntry->dg)) {
- VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
- VMCI_DEBUG_LOG(4, (LGPFX"Caller's buffer is too small.\n"));
- return VMCI_ERROR_NO_MEM;
- }
-
- LIST_DEL(listItem, &dgmProc->datagramQueue);
- dgmProc->pendingDatagrams--;
- dgmProc->datagramQueueSize -= VMCI_DG_SIZE(dqEntry->dg);
- if (dgmProc->pendingDatagrams == 0) {
- VMCIHost_ClearCall(&dgmProc->host);
- }
- VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
-
- *dg = dqEntry->dg;
- VMCI_FreeKernelMem(dqEntry, sizeof *dqEntry);
-
- return VMCI_SUCCESS;
-}
-
#include "vmci_infrastructure.h"
#include "vmci_iocontrols.h"
-typedef struct DatagramQueueEntry DatagramQueueEntry;
-typedef struct VMCIDatagramProcess VMCIDatagramProcess;
-
void VMCIDatagram_Init(void);
Bool VMCIDatagram_CheckHostCapabilities(void);
int VMCIDatagram_Dispatch(VMCIId contextID, VMCIDatagram *msg);
-int VMCIDatagramProcess_Create(VMCIDatagramProcess **outDgmProc,
- VMCIDatagramCreateProcessInfo *createInfo,
- uintptr_t eventHnd);
-void VMCIDatagramProcess_Destroy(VMCIDatagramProcess *dgmProc);
-int VMCIDatagramProcess_ReadCall(VMCIDatagramProcess *dgmProc,
- size_t maxSize, VMCIDatagram **dg);
-
#endif //__VMCI_DATAGRAM_H__
#include "vm_basic_types.h"
#include "vmci_call_defs.h"
-#include "vmciProcess.h"
#define DODEBUGLOG(...) printk(KERN_DEBUG __VA_ARGS__)
#define DOLOG(...) printk(KERN_INFO __VA_ARGS__)
+++ /dev/null
-/*********************************************************
- * Copyright (C) 2006 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- *********************************************************/
-
-/*
- * vmciProcess.c --
- *
- * VMCI Process code for guest driver.
- */
-
-#ifdef __linux__
-# include "driver-config.h"
-
-# define EXPORT_SYMTAB
-
-# include <linux/module.h>
-# include "compat_kernel.h"
-# include "compat_pci.h"
-#endif // __linux__
-
-#include "vmci_kernel_if.h"
-#include "vmci_defs.h"
-#include "vmciInt.h"
-#include "vmciProcess.h"
-#include "vmciDatagram.h"
-#include "vmci_infrastructure.h"
-#include "circList.h"
-#include "vmciUtil.h"
-#include "vmciCommonInt.h"
-
-static ListItem *processList = NULL;
-static VMCILock processLock;
-
-/*
- *----------------------------------------------------------------------
- *
- * VMCIProcess_Init --
- *
- * General init code.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-VMCIProcess_Init(void)
-{
- VMCI_InitLock(&processLock, "VMCIProcessListLock", VMCI_LOCK_RANK_HIGH);
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * VMCIProcess_Exit --
- *
- * General init code.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-VMCIProcess_Exit(void)
-{
- VMCI_CleanupLock(&processLock);
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * VMCIProcess_CheckHostCapabilities --
- *
- * Verify that the host supports the hypercalls we need. If it does not,
- * try to find fallback hypercalls and use those instead.
- *
- * Results:
- * TRUE if required hypercalls (or fallback hypercalls) are
- * supported by the host, FALSE otherwise.
- *
- * Side effects:
- * None.
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-VMCIProcess_CheckHostCapabilities(void)
-{
- /* VMCIProcess does not require any hypercalls. */
- return TRUE;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * VMCIProcess_Create --
- *
- * Creates a new VMCI process.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-VMCIProcess_Create(VMCIProcess **outProcess) // IN
-{
- VMCIProcess *process;
- VMCILockFlags flags;
-
- process = VMCI_AllocKernelMem(sizeof *process, VMCI_MEMORY_NONPAGED);
- if (process == NULL) {
- return VMCI_ERROR_NO_MEM;
- }
-
- process->pid = (VMCIId)(uintptr_t)process >> 1;
-
- VMCI_GrabLock(&processLock, &flags);
- LIST_QUEUE(&process->listItem, &processList);
- VMCI_ReleaseLock(&processLock, flags);
-
- *outProcess = process;
- return 0;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * VMCIProcess_Destroy --
- *
- * Destroys a VMCI process.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-VMCIProcess_Destroy(VMCIProcess *process)
-{
- VMCILockFlags flags;
-
- /* Dequeue process. */
- VMCI_GrabLock(&processLock, &flags);
- LIST_DEL(&process->listItem, &processList);
- VMCI_ReleaseLock(&processLock, flags);
-
- VMCI_FreeKernelMem(process, sizeof *process);
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * VMCIProcess_Get --
- *
- * Get the process corresponding to the pid.
- *
- * Results:
- * VMCI process on success, NULL otherwise.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-VMCIProcess *
-VMCIProcess_Get(VMCIId processID) // IN
-{
- VMCIProcess *process = NULL;
- ListItem *next;
- VMCILockFlags flags;
-
- VMCI_GrabLock(&processLock, &flags);
- if (processList == NULL) {
- goto out;
- }
-
- LIST_SCAN(next, processList) {
- process = LIST_CONTAINER(next, VMCIProcess, listItem);
- if (process->pid == processID) {
- break;
- }
- }
-
-out:
- VMCI_ReleaseLock(&processLock, flags);
- return (process && process->pid == processID) ? process : NULL;
-}
+++ /dev/null
-/*********************************************************
- * Copyright (C) 2006 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- *********************************************************/
-
-/*
- * vmciProcess.h --
- *
- * Process code for the Linux guest driver
- */
-
-#ifndef __VMCI_PROCESS_H__
-#define __VMCI_PROCESS_H__
-
-#define INCLUDE_ALLOW_MODULE
-#include "includeCheck.h"
-
-#include "vm_basic_types.h"
-
-#include "vmci_defs.h"
-#include "vmci_handle_array.h"
-
-typedef struct VMCIProcess VMCIProcess;
-
-void VMCIProcess_Init(void);
-void VMCIProcess_Exit(void);
-Bool VMCIProcess_CheckHostCapabilities(void);
-int VMCIProcess_Create(VMCIProcess **outProcess);
-void VMCIProcess_Destroy(VMCIProcess *process);
-VMCIProcess *VMCIProcess_Get(VMCIId processID);
-
-#endif //__VMCI_PROCESS_H__
#include "vmci_kernel_if.h"
#include "vmciGuestKernelIf.h"
#include "vmciInt.h"
-#include "vmciProcess.h"
#include "vmciDatagram.h"
#include "vmciUtil.h"
#include "vmciEvent.h"
VMCI_CheckHostCapabilities(void)
{
Bool result = VMCIEvent_CheckHostCapabilities();
- result &= VMCIProcess_CheckHostCapabilities();
result &= VMCIDatagram_CheckHostCapabilities();
result &= VMCIUtil_CheckHostCapabilities();
#include <linux/moduleparam.h>
#include <linux/poll.h>
-#include "compat_kernel.h"
-#include "compat_module.h"
-#include "compat_pci.h"
#include "compat_init.h"
-#include "compat_ioport.h"
#include "compat_interrupt.h"
-#include "compat_page.h"
+#include "compat_ioport.h"
+#include "compat_kernel.h"
+#include "compat_module.h"
#include "compat_mutex.h"
+#include "compat_page.h"
+#include "compat_pci.h"
+
+#include "kernelStubs.h"
+
#include "vm_basic_types.h"
#include "vm_device_version.h"
-#include "kernelStubs.h"
-#include "vmci_iocontrols.h"
+
#include "vmci_defs.h"
-#include "vmciInt.h"
#include "vmci_infrastructure.h"
+#include "vmci_iocontrols.h"
+#include "vmci_version.h"
#include "vmciDatagram.h"
-#include "vmciProcess.h"
-#include "vmciUtil.h"
#include "vmciEvent.h"
+#include "vmciInt.h"
#include "vmciNotifications.h"
#include "vmciQueuePairInt.h"
-#include "vmci_version.h"
-#include "vmciCommonInt.h"
+#include "vmciUtil.h"
#define LGPFX "VMCI: "
#define VMCI_DEVICE_MINOR_NUM 0
* components, and it may be invoked once request_irq() has
* registered the handler (as the irq line may be shared).
*/
- VMCIProcess_Init();
VMCIDatagram_Init();
VMCIEvent_Init();
VMCIUtil_Init();
VMCINotifications_Exit();
VMCIUtil_Exit();
VMCIEvent_Exit();
- VMCIProcess_Exit();
if (vmci_dev.intr_type == VMCI_INTR_TYPE_MSIX) {
pci_disable_msix(pdev);
} else if (vmci_dev.intr_type == VMCI_INTR_TYPE_MSI) {
VMCIUtil_Exit();
VMCIEvent_Exit();
//VMCIDatagram_Exit();
- VMCIProcess_Exit();
compat_mutex_lock(&dev->lock);
printk(KERN_INFO "Resetting vmci device\n");
(VMCIGuestDeviceHandle *) file->private_data;
if (devHndl) {
- if (devHndl->objType == VMCIOBJ_PROCESS) {
- VMCIProcess_Destroy((VMCIProcess *) devHndl->obj);
- } else if (devHndl->objType == VMCIOBJ_DATAGRAM_PROCESS) {
- VMCIDatagramProcess_Destroy((VMCIDatagramProcess *) devHndl->obj);
- }
VMCI_FreeKernelMem(devHndl, sizeof *devHndl);
file->private_data = NULL;
}
unsigned int cmd, // IN
unsigned long arg) // IN
{
-#ifndef VMX86_DEVEL
return -ENOTTY;
-#else
- int retval;
- VMCIGuestDeviceHandle *devHndl = file->private_data;
-
- if (devHndl == NULL) {
- return -EINVAL;
- }
-
- compat_mutex_lock(&vmci_dev.lock);
-
- /*
- * When adding new ioctls make sure that their data structures are same
- * for i386 and x86_64 architectures, as this handler is used for both ia32
- * and x86_64 ioctls.
- */
- switch (cmd) {
- case IOCTL_VMCI_CREATE_PROCESS: {
- if (devHndl->objType != VMCIOBJ_NOT_SET) {
- printk("VMCI: Received IOCTLCMD_VMCI_CREATE_PROCESS on "
- "initialized handle.\n");
- retval = -EINVAL;
- break;
- }
- ASSERT(!devHndl->obj);
- retval = VMCIProcess_Create((VMCIProcess **) &devHndl->obj);
- if (retval != 0) {
- printk("VMCI: Failed to create process.\n");
- break;
- }
- devHndl->objType = VMCIOBJ_PROCESS;
- break;
- }
-
- case IOCTL_VMCI_CREATE_DATAGRAM_PROCESS: {
- VMCIDatagramCreateProcessInfo createInfo;
- VMCIDatagramProcess *dgmProc;
-
- if (devHndl->objType != VMCIOBJ_NOT_SET) {
- printk("VMCI: Received IOCTLCMD_VMCI_CREATE_DATAGRAM_PROCESS on "
- "initialized handle.\n");
- retval = -EINVAL;
- break;
- }
- ASSERT(!devHndl->obj);
-
- retval = copy_from_user(&createInfo, (void *)arg, sizeof createInfo);
- if (retval != 0) {
- printk("VMCI: Error getting datagram create info, %d.\n", retval);
- retval = -EFAULT;
- break;
- }
-
- if (VMCIDatagramProcess_Create(&dgmProc, &createInfo,
- 0 /* Unused */) < VMCI_SUCCESS) {
- retval = -EINVAL;
- break;
- }
-
- retval = copy_to_user((void *)arg, &createInfo, sizeof createInfo);
- if (retval != 0) {
- VMCIDatagramProcess_Destroy(dgmProc);
- printk("VMCI: Failed to create datagram process.\n");
- retval = -EFAULT;
- break;
- }
- devHndl->obj = dgmProc;
- devHndl->objType = VMCIOBJ_DATAGRAM_PROCESS;
- break;
- }
-
- case IOCTL_VMCI_DATAGRAM_SEND: {
- VMCIDatagramSendRecvInfo sendInfo;
- VMCIDatagram *dg;
-
- if (devHndl->objType != VMCIOBJ_DATAGRAM_PROCESS) {
- printk("VMCI: Ioctl %d only valid for process datagram handle.\n",
- cmd);
- retval = -EINVAL;
- break;
- }
-
- retval = copy_from_user(&sendInfo, (void *) arg, sizeof sendInfo);
- if (retval) {
- printk("VMCI: copy_from_user failed.\n");
- retval = -EFAULT;
- break;
- }
-
- if (sendInfo.len > VMCI_MAX_DG_SIZE) {
- printk("VMCI: datagram size too big.\n");
- retval = -EINVAL;
- break;
- }
-
- dg = VMCI_AllocKernelMem(sendInfo.len, VMCI_MEMORY_NORMAL);
- if (dg == NULL) {
- printk("VMCI: Cannot allocate memory to dispatch datagram.\n");
- retval = -ENOMEM;
- break;
- }
-
- retval = copy_from_user(dg, (char *)(VA)sendInfo.addr, sendInfo.len);
- if (retval != 0) {
- printk("VMCI: Error getting datagram: %d\n", retval);
- VMCI_FreeKernelMem(dg, sendInfo.len);
- retval = -EFAULT;
- break;
- }
-
- DEBUG_ONLY(printk("VMCI: Datagram dst handle 0x%x:0x%x, src handle "
- "0x%x:0x%x, payload size %"FMT64"u.\n",
- dg->dst.context, dg->dst.resource,
- dg->src.context, dg->src.resource, dg->payloadSize));
-
- sendInfo.result = VMCIDatagram_Send(dg);
- VMCI_FreeKernelMem(dg, sendInfo.len);
-
- retval = copy_to_user((void *)arg, &sendInfo, sizeof sendInfo);
- break;
- }
-
- case IOCTL_VMCI_DATAGRAM_RECEIVE: {
- VMCIDatagramSendRecvInfo recvInfo;
- VMCIDatagram *dg = NULL;
-
- if (devHndl->objType != VMCIOBJ_DATAGRAM_PROCESS) {
- printk("VMCI: Ioctl %d only valid for process datagram handle.\n",
- cmd);
- retval = -EINVAL;
- break;
- }
-
- retval = copy_from_user(&recvInfo, (void *) arg, sizeof recvInfo);
- if (retval) {
- printk("VMCI: copy_from_user failed.\n");
- retval = -EFAULT;
- break;
- }
-
- ASSERT(devHndl->obj);
- recvInfo.result =
- VMCIDatagramProcess_ReadCall((VMCIDatagramProcess *)devHndl->obj,
- recvInfo.len, &dg);
- if (recvInfo.result < VMCI_SUCCESS) {
- retval = -EINVAL;
- break;
- }
- ASSERT(dg);
- retval = copy_to_user((void *) ((uintptr_t) recvInfo.addr), dg,
- VMCI_DG_SIZE(dg));
- VMCI_FreeKernelMem(dg, VMCI_DG_SIZE(dg));
- if (retval != 0) {
- break;
- }
- retval = copy_to_user((void *)arg, &recvInfo, sizeof recvInfo);
- break;
- }
-
- case IOCTL_VMCI_GET_CONTEXT_ID: {
- VMCIId cid = VMCI_GetContextID();
-
- retval = copy_to_user((void *)arg, &cid, sizeof cid);
- break;
- }
-
- default:
- printk(KERN_DEBUG "vmci_ioctl(): unknown ioctl 0x%x.\n", cmd);
- retval = -EINVAL;
- break;
- }
-
- compat_mutex_unlock(&vmci_dev.lock);
-
- return retval;
-#endif
}
vmci_poll(struct file *file, // IN
poll_table *wait) // IN
{
- VMCILockFlags flags;
- unsigned int mask = 0;
- VMCIGuestDeviceHandle *devHndl =
- (VMCIGuestDeviceHandle *) file->private_data;
-
- /*
- * Check for call to this VMCI process.
- */
-
- if (!devHndl) {
- return mask;
- }
- if (devHndl->objType == VMCIOBJ_DATAGRAM_PROCESS) {
- VMCIDatagramProcess *dgmProc = (VMCIDatagramProcess *) devHndl->obj;
- ASSERT(dgmProc);
-
- if (wait != NULL) {
- poll_wait(file, &dgmProc->host.waitQueue, wait);
- }
-
- VMCI_GrabLock_BH(&dgmProc->datagramQueueLock, &flags);
- if (dgmProc->pendingDatagrams > 0) {
- mask = POLLIN;
- }
- VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
- }
-
- return mask;
+ return 0;
}
#ifndef _VMCI_VERSION_H_
#define _VMCI_VERSION_H_
-#define VMCI_DRIVER_VERSION 9.1.0.0
-#define VMCI_DRIVER_VERSION_COMMAS 9,1,0,0
-#define VMCI_DRIVER_VERSION_STRING "9.1.0.0"
+#define VMCI_DRIVER_VERSION 9.1.1.0
+#define VMCI_DRIVER_VERSION_COMMAS 9,1,1,0
+#define VMCI_DRIVER_VERSION_STRING "9.1.1.0"
#endif /* _VMCI_VERSION_H_ */