From: VMware, Inc <> Date: Tue, 19 Oct 2010 18:39:07 +0000 (-0700) Subject: Extend VMCI kernel interface on Windows to full API. X-Git-Tag: 2010.10.18-313025~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96941cb2f364d938543d11a0102bc86e83763e25;p=thirdparty%2Fopen-vm-tools.git Extend VMCI kernel interface on Windows to full API. We also add API versioning. There is now vmciKernelAPI1.h and vmciKernelAPI2.h, specifying version 1 and 2 of the API, respectively. vmciKernelAPI includes both of them and thus exports the latest API. Clients can include that file or a specific version. We define VMCI_KERNEL_API_VERSION in each header as appropriate. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/modules/linux/shared/vmciKernelAPI.h b/open-vm-tools/modules/linux/shared/vmciKernelAPI.h index 7488dfbc6..d03ac3ced 100644 --- a/open-vm-tools/modules/linux/shared/vmciKernelAPI.h +++ b/open-vm-tools/modules/linux/shared/vmciKernelAPI.h @@ -19,7 +19,7 @@ /* * vmciKernelAPI.h -- * - * Kernel API exported from the VMCI host and guest drivers. + * Kernel API (current) exported from the VMCI host and guest drivers. */ #ifndef __VMCI_KERNELAPI_H__ @@ -31,124 +31,10 @@ #include "includeCheck.h" -/* Macros to operate on the driver version number. */ -#define VMCI_MAJOR_VERSION(v) (((v) >> 16) & 0xffff) -#define VMCI_MINOR_VERSION(v) ((v) & 0xffff) +/* With this file you always get the latest version. */ +#include "vmciKernelAPI1.h" +#include "vmciKernelAPI2.h" -#include "vmci_defs.h" -#include "vmci_call_defs.h" - - -/* PUBLIC: VMCI Device Usage API. */ - -Bool VMCI_DeviceGet(void); -void VMCI_DeviceRelease(void); - -/* PUBLIC: VMCI Datagram API. */ - -int VMCIDatagram_CreateHnd(VMCIId resourceID, uint32 flags, - VMCIDatagramRecvCB recvCB, void *clientData, - VMCIHandle *outHandle); -int VMCIDatagram_CreateHndPriv(VMCIId resourceID, uint32 flags, - VMCIPrivilegeFlags privFlags, - VMCIDatagramRecvCB recvCB, void *clientData, - VMCIHandle *outHandle); -int VMCIDatagram_DestroyHnd(VMCIHandle handle); -int VMCIDatagram_Send(VMCIDatagram *msg); - -/* VMCI Utility API. */ - -VMCIId VMCI_GetContextID(void); -uint32 VMCI_Version(void); -int VMCI_ContextID2HostVmID(VMCIId contextID, void *hostVmID, - size_t hostVmIDLen); - -/* VMCI Event API. */ - -typedef void (*VMCI_EventCB)(VMCIId subID, VMCI_EventData *ed, - void *clientData); - -int VMCIEvent_Subscribe(VMCI_Event event, uint32 flags, VMCI_EventCB callback, - void *callbackData, VMCIId *subID); -int VMCIEvent_Unsubscribe(VMCIId subID); - -/* VMCI Context API */ - -VMCIPrivilegeFlags VMCIContext_GetPrivFlags(VMCIId contextID); - -/* VMCI Discovery Service API. */ - -int VMCIDs_Lookup(const char *name, VMCIHandle *out); - -/* VMCI Doorbell API. */ - -#define VMCI_FLAG_DELAYED_CB 0x01 - -typedef void (*VMCICallback)(void *clientData); - -int VMCIDoorbell_Create(VMCIHandle *handle, uint32 flags, - VMCIPrivilegeFlags privFlags, - VMCICallback notifyCB, void *clientData); -int VMCIDoorbell_Destroy(VMCIHandle handle); -int VMCIDoorbell_Notify(VMCIHandle handle, - VMCIPrivilegeFlags privFlags); - -/* VMCI Queue Pair API. */ - -typedef struct VMCIQPair VMCIQPair; - -int VMCIQPair_Alloc(VMCIQPair **qpair, - VMCIHandle *handle, - uint64 produceQSize, - uint64 consumeQSize, - VMCIId peer, - uint32 flags, - VMCIPrivilegeFlags privFlags); - -int VMCIQPair_Detach(VMCIQPair **qpair); - -int VMCIQPair_GetProduceIndexes(const VMCIQPair *qpair, - uint64 *producerTail, - uint64 *consumerHead); -int VMCIQPair_GetConsumeIndexes(const VMCIQPair *qpair, - uint64 *consumerTail, - uint64 *producerHead); -int64 VMCIQPair_ProduceFreeSpace(const VMCIQPair *qpair); -int64 VMCIQPair_ProduceBufReady(const VMCIQPair *qpair); -int64 VMCIQPair_ConsumeFreeSpace(const VMCIQPair *qpair); -int64 VMCIQPair_ConsumeBufReady(const VMCIQPair *qpair); -ssize_t VMCIQPair_Enqueue(VMCIQPair *qpair, - const void *buf, - size_t bufSize, - int mode); -ssize_t VMCIQPair_Dequeue(VMCIQPair *qpair, - void *buf, - size_t bufSize, - int mode); -ssize_t VMCIQPair_Peek(VMCIQPair *qpair, - void *buf, - size_t bufSize, - int mode); - -#if defined (SOLARIS) || (defined(__APPLE__) && !defined (VMX86_TOOLS)) || \ - (defined(__linux__) && defined(__KERNEL__)) || \ - (defined(_WIN32) && defined(WINNT_DDK)) -/* - * Environments that support struct iovec - */ - -ssize_t VMCIQPair_EnqueueV(VMCIQPair *qpair, - void *iov, - size_t iovSize, - int mode); -ssize_t VMCIQPair_DequeueV(VMCIQPair *qpair, - void *iov, - size_t iovSize, - int mode); -ssize_t VMCIQPair_PeekV(VMCIQPair *qpair, - void *iov, - size_t iovSize, - int mode); -#endif /* Systems that support struct iovec */ #endif /* !__VMCI_KERNELAPI_H__ */ + diff --git a/open-vm-tools/modules/linux/shared/vmciKernelAPI1.h b/open-vm-tools/modules/linux/shared/vmciKernelAPI1.h new file mode 100644 index 000000000..dd7f9eaab --- /dev/null +++ b/open-vm-tools/modules/linux/shared/vmciKernelAPI1.h @@ -0,0 +1,183 @@ +/********************************************************* + * Copyright (C) 2010 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 + * + *********************************************************/ + +/* + * vmciKernelAPI1.h -- + * + * Kernel API (v1) exported from the VMCI host and guest drivers. + */ + +#ifndef __VMCI_KERNELAPI_1_H__ +#define __VMCI_KERNELAPI_1_H__ + +#define INCLUDE_ALLOW_MODULE +#define INCLUDE_ALLOW_VMK_MODULE +#define INCLUDE_ALLOW_VMKERNEL +#include "includeCheck.h" + +#include "vmci_defs.h" +#include "vmci_call_defs.h" + + +/* Define version 1. */ + +#undef VMCI_KERNEL_API_VERSION +#define VMCI_KERNEL_API_VERSION_1 1 +#define VMCI_KERNEL_API_VERSION VMCI_KERNEL_API_VERSION_1 + +/* Macros to operate on the driver version number. */ + +#define VMCI_MAJOR_VERSION(v) (((v) >> 16) & 0xffff) +#define VMCI_MINOR_VERSION(v) ((v) & 0xffff) + +/* VMCI Device Usage API. */ + +Bool VMCI_DeviceGet(uint32 *apiVersion); +void VMCI_DeviceRelease(void); + +/* VMCI Datagram API. */ + +int VMCIDatagram_CreateHnd(VMCIId resourceID, uint32 flags, + VMCIDatagramRecvCB recvCB, void *clientData, + VMCIHandle *outHandle); +int VMCIDatagram_CreateHndPriv(VMCIId resourceID, uint32 flags, + VMCIPrivilegeFlags privFlags, + VMCIDatagramRecvCB recvCB, void *clientData, + VMCIHandle *outHandle); +int VMCIDatagram_DestroyHnd(VMCIHandle handle); +int VMCIDatagram_Send(VMCIDatagram *msg); + +/* VMCI Utility API. */ + +VMCIId VMCI_GetContextID(void); +uint32 VMCI_Version(void); +int VMCI_ContextID2HostVmID(VMCIId contextID, void *hostVmID, + size_t hostVmIDLen); + +/* VMCI Event API. */ + +typedef void (*VMCI_EventCB)(VMCIId subID, VMCI_EventData *ed, + void *clientData); + +int VMCIEvent_Subscribe(VMCI_Event event, uint32 flags, VMCI_EventCB callback, + void *callbackData, VMCIId *subID); +int VMCIEvent_Unsubscribe(VMCIId subID); + +/* VMCI Context API */ + +VMCIPrivilegeFlags VMCIContext_GetPrivFlags(VMCIId contextID); + +/* VMCI Discovery Service API. */ + +int VMCIDs_Lookup(const char *name, VMCIHandle *out); + +/* VMCI Queue Pair API. */ + +typedef struct VMCIQPair VMCIQPair; + +int VMCIQPair_Alloc(VMCIQPair **qpair, + VMCIHandle *handle, + uint64 produceQSize, + uint64 consumeQSize, + VMCIId peer, + uint32 flags, + VMCIPrivilegeFlags privFlags); + +int VMCIQPair_Detach(VMCIQPair **qpair); + +int VMCIQPair_GetProduceIndexes(const VMCIQPair *qpair, + uint64 *producerTail, + uint64 *consumerHead); +int VMCIQPair_GetConsumeIndexes(const VMCIQPair *qpair, + uint64 *consumerTail, + uint64 *producerHead); +int64 VMCIQPair_ProduceFreeSpace(const VMCIQPair *qpair); +int64 VMCIQPair_ProduceBufReady(const VMCIQPair *qpair); +int64 VMCIQPair_ConsumeFreeSpace(const VMCIQPair *qpair); +int64 VMCIQPair_ConsumeBufReady(const VMCIQPair *qpair); +ssize_t VMCIQPair_Enqueue(VMCIQPair *qpair, + const void *buf, + size_t bufSize, + int mode); +ssize_t VMCIQPair_Dequeue(VMCIQPair *qpair, + void *buf, + size_t bufSize, + int mode); +ssize_t VMCIQPair_Peek(VMCIQPair *qpair, + void *buf, + size_t bufSize, + int mode); + +#if defined (SOLARIS) || (defined(__APPLE__) && !defined (VMX86_TOOLS)) || \ + (defined(__linux__) && defined(__KERNEL__)) || \ + (defined(_WIN32) && defined(WINNT_DDK)) +/* + * Environments that support struct iovec + */ + +ssize_t VMCIQPair_EnqueueV(VMCIQPair *qpair, + void *iov, + size_t iovSize, + int mode); +ssize_t VMCIQPair_DequeueV(VMCIQPair *qpair, + void *iov, + size_t iovSize, + int mode); +ssize_t VMCIQPair_PeekV(VMCIQPair *qpair, + void *iov, + size_t iovSize, + int mode); +#endif /* Systems that support struct iovec */ + + +/* Typedefs for all of the above, used by the IOCTLs and the kernel library. */ + +typedef void (VMCI_DeviceReleaseFct)(void); +typedef int (VMCIDatagram_CreateHndFct)(VMCIId, uint32, VMCIDatagramRecvCB, + void *, VMCIHandle *); +typedef int (VMCIDatagram_CreateHndPrivFct)(VMCIId, uint32, VMCIPrivilegeFlags, + VMCIDatagramRecvCB, void *, + VMCIHandle *); +typedef int (VMCIDatagram_DestroyHndFct)(VMCIHandle); +typedef int (VMCIDatagram_SendFct)(VMCIDatagram *); +typedef VMCIId (VMCI_GetContextIDFct)(void); +typedef uint32 (VMCI_VersionFct)(void); +typedef int (VMCIEvent_SubscribeFct)(VMCI_Event, uint32, VMCI_EventCB, void *, + VMCIId *); +typedef int (VMCIEvent_UnsubscribeFct)(VMCIId); +typedef int (VMCIQPair_AllocFct)(VMCIQPair **, VMCIHandle *, uint64, uint64, + VMCIId, uint32, VMCIPrivilegeFlags); +typedef int (VMCIQPair_DetachFct)(VMCIQPair **); +typedef int (VMCIQPair_GetProduceIndexesFct)(const VMCIQPair *, uint64 *, + uint64 *); +typedef int (VMCIQPair_GetConsumeIndexesFct)(const VMCIQPair *, uint64 *, + uint64 *); +typedef int64 (VMCIQPair_ProduceFreeSpaceFct)(const VMCIQPair *); +typedef int64 (VMCIQPair_ProduceBufReadyFct)(const VMCIQPair *); +typedef int64 (VMCIQPair_ConsumeFreeSpaceFct)(const VMCIQPair *); +typedef int64 (VMCIQPair_ConsumeBufReadyFct)(const VMCIQPair *); +typedef ssize_t (VMCIQPair_EnqueueFct)(VMCIQPair *, const void *, size_t, int); +typedef ssize_t (VMCIQPair_DequeueFct)(VMCIQPair *, void *, size_t, int); +typedef ssize_t (VMCIQPair_PeekFct)(VMCIQPair *, void *, size_t, int); +typedef ssize_t (VMCIQPair_EnqueueVFct)(VMCIQPair *qpair, void *, size_t, int); +typedef ssize_t (VMCIQPair_DequeueVFct)(VMCIQPair *qpair, void *, size_t, int); +typedef ssize_t (VMCIQPair_PeekVFct)(VMCIQPair *qpair, void *, size_t, int); + + +#endif /* !__VMCI_KERNELAPI_1_H__ */ + diff --git a/open-vm-tools/modules/linux/shared/vmciKernelAPI2.h b/open-vm-tools/modules/linux/shared/vmciKernelAPI2.h new file mode 100644 index 000000000..9622b840d --- /dev/null +++ b/open-vm-tools/modules/linux/shared/vmciKernelAPI2.h @@ -0,0 +1,67 @@ +/********************************************************* + * Copyright (C) 2010 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 + * + *********************************************************/ + +/* + * vmciKernelAPI2.h -- + * + * Kernel API (v2) exported from the VMCI host and guest drivers. + */ + +#ifndef __VMCI_KERNELAPI_2_H__ +#define __VMCI_KERNELAPI_2_H__ + +#define INCLUDE_ALLOW_MODULE +#define INCLUDE_ALLOW_VMK_MODULE +#define INCLUDE_ALLOW_VMKERNEL +#include "includeCheck.h" + + +#include "vmciKernelAPI1.h" + + +/* Define version 2. */ + +#undef VMCI_KERNEL_API_VERSION +#define VMCI_KERNEL_API_VERSION_2 2 +#define VMCI_KERNEL_API_VERSION VMCI_KERNEL_API_VERSION_2 + + +/* VMCI Doorbell API. */ + +#define VMCI_FLAG_DELAYED_CB 0x01 + +typedef void (*VMCICallback)(void *clientData); + +int VMCIDoorbell_Create(VMCIHandle *handle, uint32 flags, + VMCIPrivilegeFlags privFlags, + VMCICallback notifyCB, void *clientData); +int VMCIDoorbell_Destroy(VMCIHandle handle); +int VMCIDoorbell_Notify(VMCIHandle handle, + VMCIPrivilegeFlags privFlags); + + +/* Typedefs for all of the above, used by the IOCTLs and the kernel library. */ + +typedef int (VMCIDoorbell_CreateFct)(VMCIHandle *, uint32, VMCIPrivilegeFlags, + VMCICallback, void *); +typedef int (VMCIDoorbell_DestroyFct)(VMCIHandle); +typedef int (VMCIDoorbell_NotifyFct)(VMCIHandle, VMCIPrivilegeFlags); + + +#endif /* !__VMCI_KERNELAPI_2_H__ */ + diff --git a/open-vm-tools/modules/linux/shared/vmci_iocontrols.h b/open-vm-tools/modules/linux/shared/vmci_iocontrols.h index 02dcb7af1..028ce12f4 100644 --- a/open-vm-tools/modules/linux/shared/vmci_iocontrols.h +++ b/open-vm-tools/modules/linux/shared/vmci_iocontrols.h @@ -33,8 +33,13 @@ #define INCLUDE_ALLOW_VMKERNEL #include "includeCheck.h" -#include "vmci_defs.h" #include "vm_assert.h" +#include "vmci_defs.h" + +#if defined(_WIN32) && defined(WINNT_DDK) +/* We need to expose the API through an IOCTL on Windows. Use latest API. */ +#include "vmciKernelAPI.h" +#endif // _WIN32 && WINNT_DDK /* @@ -182,13 +187,11 @@ enum IOCTLCmd_VMCI { IOCTLCMD(CREATE_DATAGRAM_PROCESS), /* - * The following two used to be for shared memory. An old WS6 user-mode - * client might try to use them with the new driver. Since they are issued - * in user-mode they will fail, since the IOCTLs replacing them are - * kernel-mode only. + * The following two used to be for shared memory. They are now unused and + * and are reserved for future use. They will fail if issued. */ - IOCTLCMD(CREATE_DATAGRAM_HANDLE), - IOCTLCMD(DESTROY_DATAGRAM_HANDLE), + IOCTLCMD(RESERVED1), + IOCTLCMD(RESERVED2), /* * The follwoing two were also used to be for shared memory. An old @@ -322,14 +325,21 @@ enum IOCTLCmd_VMCIMacOS { METHOD_NEITHER, \ FILE_ANY_ACCESS) -#define IOCTL_VMCI_VERSION VMCIIOCTL_BUFFERED(VERSION) +enum IOCTLCmd_VMCIWin32 { + IOCTLCMD(DEVICE_GET) = IOCTLCMD(LAST2) + 1, +}; + +#define IOCTL_VMCI_VERSION VMCIIOCTL_BUFFERED(VERSION) /* BEGIN VMCI */ -#define IOCTL_VMCI_INIT_CONTEXT VMCIIOCTL_BUFFERED(INIT_CONTEXT) -#define IOCTL_VMCI_CREATE_PROCESS VMCIIOCTL_BUFFERED(CREATE_PROCESS) +#define IOCTL_VMCI_INIT_CONTEXT \ + VMCIIOCTL_BUFFERED(INIT_CONTEXT) +#define IOCTL_VMCI_CREATE_PROCESS \ + VMCIIOCTL_BUFFERED(CREATE_PROCESS) #define IOCTL_VMCI_CREATE_DATAGRAM_PROCESS \ VMCIIOCTL_BUFFERED(CREATE_DATAGRAM_PROCESS) -#define IOCTL_VMCI_HYPERCALL VMCIIOCTL_BUFFERED(HYPERCALL) +#define IOCTL_VMCI_HYPERCALL \ + VMCIIOCTL_BUFFERED(HYPERCALL) #define IOCTL_VMCI_CREATE_DATAGRAM_HANDLE \ VMCIIOCTL_BUFFERED(CREATE_DATAGRAM_HANDLE) #define IOCTL_VMCI_DESTROY_DATAGRAM_HANDLE \ @@ -338,18 +348,24 @@ enum IOCTLCmd_VMCIMacOS { VMCIIOCTL_BUFFERED(NOTIFY_RESOURCE) #define IOCTL_VMCI_NOTIFICATIONS_RECEIVE \ VMCIIOCTL_BUFFERED(NOTIFICATIONS_RECEIVE) -#define IOCTL_VMCI_VERSION2 VMCIIOCTL_BUFFERED(VERSION2) +#define IOCTL_VMCI_VERSION2 \ + VMCIIOCTL_BUFFERED(VERSION2) #define IOCTL_VMCI_QUEUEPAIR_ALLOC \ VMCIIOCTL_BUFFERED(QUEUEPAIR_ALLOC) #define IOCTL_VMCI_QUEUEPAIR_SETPAGEFILE \ VMCIIOCTL_BUFFERED(QUEUEPAIR_SETPAGEFILE) #define IOCTL_VMCI_QUEUEPAIR_DETACH \ VMCIIOCTL_BUFFERED(QUEUEPAIR_DETACH) -#define IOCTL_VMCI_DATAGRAM_SEND VMCIIOCTL_BUFFERED(DATAGRAM_SEND) -#define IOCTL_VMCI_DATAGRAM_RECEIVE VMCIIOCTL_NEITHER(DATAGRAM_RECEIVE) -#define IOCTL_VMCI_DATAGRAM_REQUEST_MAP VMCIIOCTL_BUFFERED(DATAGRAM_REQUEST_MAP) -#define IOCTL_VMCI_DATAGRAM_REMOVE_MAP VMCIIOCTL_BUFFERED(DATAGRAM_REMOVE_MAP) -#define IOCTL_VMCI_CTX_ADD_NOTIFICATION VMCIIOCTL_BUFFERED(CTX_ADD_NOTIFICATION) +#define IOCTL_VMCI_DATAGRAM_SEND \ + VMCIIOCTL_BUFFERED(DATAGRAM_SEND) +#define IOCTL_VMCI_DATAGRAM_RECEIVE \ + VMCIIOCTL_NEITHER(DATAGRAM_RECEIVE) +#define IOCTL_VMCI_DATAGRAM_REQUEST_MAP \ + VMCIIOCTL_BUFFERED(DATAGRAM_REQUEST_MAP) +#define IOCTL_VMCI_DATAGRAM_REMOVE_MAP \ + VMCIIOCTL_BUFFERED(DATAGRAM_REMOVE_MAP) +#define IOCTL_VMCI_CTX_ADD_NOTIFICATION \ + VMCIIOCTL_BUFFERED(CTX_ADD_NOTIFICATION) #define IOCTL_VMCI_CTX_REMOVE_NOTIFICATION \ VMCIIOCTL_BUFFERED(CTX_REMOVE_NOTIFICATION) #define IOCTL_VMCI_CTX_GET_CPT_STATE \ @@ -358,6 +374,8 @@ enum IOCTLCmd_VMCIMacOS { VMCIIOCTL_BUFFERED(CTX_SET_CPT_STATE) #define IOCTL_VMCI_GET_CONTEXT_ID \ VMCIIOCTL_BUFFERED(GET_CONTEXT_ID) +#define IOCTL_VMCI_DEVICE_GET \ + VMCIIOCTL_BUFFERED(DEVICE_GET) /* END VMCI */ /* BEGIN VMCI SOCKETS */ @@ -512,40 +530,18 @@ typedef struct VMCIDatagramCreateProcessInfo { VMCIHandle handle; // handle if successfull } VMCIDatagramCreateProcessInfo; -/* - * Used to create datagram endpoints in guest or host kernel-mode. Note - * that because this is kernel-mode only, we use pointers directly, rather - * than VA64. - */ -typedef struct VMCIDatagramCreateHandleInfo { - VMCIId resourceID; - uint32 flags; - void *recvCB; - void *clientData; - int result; - VMCIHandle handle; -} VMCIDatagramCreateHandleInfo; - -/* Used to destroy datagram endpoints in guest or host kernel-mode. */ -typedef struct VMCIDatagramDestroyHandleInfo { - int result; - VMCIHandle handle; -} VMCIDatagramDestroyHandleInfo; - /* Used to add/remove well-known datagram mappings. */ typedef struct VMCIDatagramMapInfo { VMCIId wellKnownID; int result; } VMCIDatagramMapInfo; - /* Used to add/remove remote context notifications. */ typedef struct VMCINotifyAddRemoveInfo { VMCIId remoteCID; int result; } VMCINotifyAddRemoveInfo; - /* Used to set/get current context's checkpoint state. */ typedef struct VMCICptBufInfo { VA64 cptBuf; @@ -595,6 +591,60 @@ typedef struct VMCINotificationReceiveInfo { uint32 _pad; } VMCINotificationReceiveInfo; +#if defined(_WIN32) && defined(WINNT_DDK) +/* + * Used on Windows to expose the API calls that are no longer exported. This + * is kernel-mode only, and both sides will have the same bitness, so we can + * use pointers directly. + */ + +/* Version 1. */ +typedef struct VMCIDeviceGetInfoVer1 { + VMCI_DeviceReleaseFct *deviceRelease; + VMCIDatagram_CreateHndFct *dgramCreateHnd; + VMCIDatagram_CreateHndPrivFct *dgramCreateHndPriv; + VMCIDatagram_DestroyHndFct *dgramDestroyHnd; + VMCIDatagram_SendFct *dgramSend; + VMCI_GetContextIDFct *getContextId; + VMCI_VersionFct *version; + VMCIEvent_SubscribeFct *eventSubscribe; + VMCIEvent_UnsubscribeFct *eventUnsubscribe; + VMCIQPair_AllocFct *qpairAlloc; + VMCIQPair_DetachFct *qpairDetach; + VMCIQPair_GetProduceIndexesFct *qpairGetProduceIndexes; + VMCIQPair_GetConsumeIndexesFct *qpairGetConsumeIndexes; + VMCIQPair_ProduceFreeSpaceFct *qpairProduceFreeSpace; + VMCIQPair_ProduceBufReadyFct *qpairProduceBufReady; + VMCIQPair_ConsumeFreeSpaceFct *qpairConsumeFreeSpace; + VMCIQPair_ConsumeBufReadyFct *qpairConsumeBufReady; + VMCIQPair_EnqueueFct *qpairEnqueue; + VMCIQPair_DequeueFct *qpairDequeue; + VMCIQPair_PeekFct *qpairPeek; + VMCIQPair_EnqueueVFct *qpairEnqueueV; + VMCIQPair_DequeueVFct *qpairDequeueV; + VMCIQPair_PeekVFct *qpairPeekV; +} VMCIDeviceGetInfoVer1; + +/* Version 2. */ +typedef struct VMCIDeviceGetInfoVer2 { + VMCIDoorbell_CreateFct *doorbellCreate; + VMCIDoorbell_DestroyFct *doorbellDestroy; + VMCIDoorbell_NotifyFct *doorbellNotify; +} VMCIDeviceGetInfoVer2; + +/* Combination of all versions. */ +typedef struct VMCIDeviceGetInfoHdr { + /* Requested API version on input, supported version on output. */ + uint32 apiVersion; +} VMCIDeviceGetInfoHdr; + +typedef struct VMCIDeviceGetInfo { + VMCIDeviceGetInfoHdr hdr; + VMCIDeviceGetInfoVer1 ver1; + VMCIDeviceGetInfoVer2 ver2; +} VMCIDeviceGetInfo; +#endif // _WIN32 && WINNT_DDK + #ifdef __APPLE__ /* @@ -615,8 +665,6 @@ enum VMCrossTalkSockOpt { VMCI_SO_CONTEXT = IOCTL_VMCI_INIT_CONTEXT, VMCI_SO_PROCESS = IOCTL_VMCI_CREATE_PROCESS, VMCI_SO_DATAGRAM_PROCESS = IOCTL_VMCI_CREATE_DATAGRAM_PROCESS, - VMCI_SO_DATAGRAM_HANDLE = IOCTL_VMCI_CREATE_DATAGRAM_HANDLE, - VMCI_SO_DATAGRAM_DESTROY = IOCTL_VMCI_DESTROY_DATAGRAM_HANDLE, VMCI_SO_NOTIFY_RESOURCE = IOCTL_VMCI_NOTIFY_RESOURCE, VMCI_SO_NOTIFICATIONS_RECEIVE = IOCTL_VMCI_NOTIFICATIONS_RECEIVE, VMCI_SO_VERSION2 = IOCTL_VMCI_VERSION2, diff --git a/open-vm-tools/modules/linux/vmci/vmciUtil.c b/open-vm-tools/modules/linux/vmci/vmciUtil.c index 6c5dfb307..2024f5c7b 100644 --- a/open-vm-tools/modules/linux/vmci/vmciUtil.c +++ b/open-vm-tools/modules/linux/vmci/vmciUtil.c @@ -362,8 +362,12 @@ VMCI_InInterrupt() VMCI_EXPORT_SYMBOL(VMCI_DeviceGet) Bool -VMCI_DeviceGet(void) +VMCI_DeviceGet(uint32 *apiVersion) { + if (*apiVersion > VMCI_KERNEL_API_VERSION) { + *apiVersion = VMCI_KERNEL_API_VERSION; + return FALSE; + } return VMCI_DeviceEnabled(); } diff --git a/open-vm-tools/modules/linux/vmhgfs/vmci.c b/open-vm-tools/modules/linux/vmhgfs/vmci.c index b02c7673d..04dd89bd5 100644 --- a/open-vm-tools/modules/linux/vmhgfs/vmci.c +++ b/open-vm-tools/modules/linux/vmhgfs/vmci.c @@ -39,7 +39,7 @@ #include "vm_assert.h" #include "vmci_call_defs.h" #include "vmci_defs.h" -#include "vmciKernelAPI.h" +#include "vmciKernelAPI1.h" static Bool HgfsVmciChannelOpen(HgfsTransportChannel *channel); static void HgfsVmciChannelClose(HgfsTransportChannel *channel); diff --git a/open-vm-tools/modules/linux/vsock/linux/af_vsock.c b/open-vm-tools/modules/linux/vsock/linux/af_vsock.c index b8acbcd48..2fd95c600 100644 --- a/open-vm-tools/modules/linux/vsock/linux/af_vsock.c +++ b/open-vm-tools/modules/linux/vsock/linux/af_vsock.c @@ -367,9 +367,7 @@ static compat_define_mutex(registrationMutex); static int devOpenCount = 0; static int vsockVmciSocketCount = 0; static int vsockVmciKernClientCount = 0; -#ifdef VMX86_TOOLS static Bool vmciDevicePresent = FALSE; -#endif static VMCIHandle vmciStreamHandle = { VMCI_INVALID_ID, VMCI_INVALID_ID }; static VMCIId qpResumedSubId = VMCI_INVALID_ID; @@ -3025,18 +3023,19 @@ VSockVmciRegisterAddressFamily(void) { int err = 0; int i; + uint32 apiVersion; -#ifdef VMX86_TOOLS /* * We don't call into the vmci module or register our socket family if the * vmci device isn't present. */ - vmciDevicePresent = VMCI_DeviceGet(); + apiVersion = VMCI_KERNEL_API_VERSION_1; + vmciDevicePresent = VMCI_DeviceGet(&apiVersion); if (!vmciDevicePresent) { - Log("Could not register VMCI Sockets because VMCI device is not present.\n"); + Log("Could not register VMCI Sockets because VMCI device is not present " + "or API version is unsupported.\n"); return -1; } -#endif /* * Create the datagram handle that we will use to send and receive all @@ -3128,12 +3127,10 @@ error: static void VSockVmciUnregisterAddressFamily(void) { -#ifdef VMX86_TOOLS if (!vmciDevicePresent) { /* Nothing was registered. */ return; } -#endif if (!VMCI_HANDLE_INVALID(vmciStreamHandle)) { if (VMCIDatagram_DestroyHnd(vmciStreamHandle) != VMCI_SUCCESS) { @@ -3153,6 +3150,7 @@ VSockVmciUnregisterAddressFamily(void) vsockVmciDgramOps.family = vsockVmciFamilyOps.family = VSOCK_INVALID_FAMILY; vsockVmciStreamOps.family = vsockVmciFamilyOps.family; + VMCI_DeviceRelease(); }