32
32
#include "includeCheck.h"
34
34
#include "vmci_defs.h"
35
#include "vmci_iocontrols.h"
36
#include "vmci_kernel_if.h"
35
37
#include "vmciContext.h"
36
#include "vmci_iocontrols.h"
37
38
#include "vmciQueue.h"
39
#include "vm_atomic.h"
40
#include "util_copy_dist.h"
44
* On vmkernel, the queue pairs are either backed by shared memory or
45
* kernel memory allocated on the VMCI heap. Shared memory is used for
46
* guest to guest and guest to host queue pairs, whereas the heap
47
* allocated queue pairs are used for host local queue pairs.
41
* QueuePairPageStore describes how the memory of a given queue pair
42
* is backed. When the queue pair is between the host and a guest, the
43
* page store consists of references to the guest pages. On vmkernel,
44
* this is a list of PPNs, and on hosted, it is a user VA where the
45
* queue pair is mapped into the VMX address space.
50
48
typedef struct QueuePairPageStore {
51
Bool shared; // Indicates whether the pages are stored in shared memory
60
typedef struct QueuePairPageStore {
61
Bool user; // Whether the page file strings are userspace pointers
62
VA64 producePageFile; // Name of the file
63
VA64 consumePageFile; // Name of the file
64
uint64 producePageFileSize; // Size of the string
65
uint64 consumePageFileSize; // Size of the string
66
VA64 producePageUVA; // User space VA of the mapped file in VMX
67
VA64 consumePageUVA; // User space VA of the mapped file in VMX
72
#if (defined(__linux__) || defined(_WIN32) || defined(__APPLE__) || \
73
defined(SOLARIS)) && !defined(VMKERNEL)
76
typedef struct PageStoreAttachInfo {
77
char producePageFile[VMCI_PATH_MAX];
78
char consumePageFile[VMCI_PATH_MAX];
79
uint64 numProducePages;
80
uint64 numConsumePages;
82
/* User VAs in the VMX task */
87
* Platform-specific references to the physical pages backing the
88
* queue. These include a page for the header.
90
* PR361589 tracks this, too.
93
#if defined(__linux__)
94
struct page **producePages;
95
struct page **consumePages;
101
#elif defined(__APPLE__)
103
* All the Mac OS X fields are members of the VMCIQueue
106
} PageStoreAttachInfo;
108
#endif // (__linux__ || _WIN32 || __APPLE__) && !VMKERNEL
49
VMCIQPGuestMem pages; // Reference to pages backing the queue pair.
50
uint32 len; // Length of pageList/virtual addres range (in pages).
128
71
static INLINE Bool
129
72
VMCI_QP_PAGESTORE_IS_WELLFORMED(QueuePairPageStore *pageStore) // IN
132
return (pageStore->shared && pageStore->store.shmID != SHM_INVALID_ID) ||
133
(!pageStore->shared && pageStore->store.ptr != NULL);
135
return pageStore->producePageFile && pageStore->consumePageFile &&
136
pageStore->producePageFileSize && pageStore->consumePageFileSize;
74
return pageStore->len >= 2;
140
77
int VMCIQPBroker_Init(void);
141
78
void VMCIQPBroker_Exit(void);
142
void VMCIQPBroker_Lock(void);
143
void VMCIQPBroker_Unlock(void);
144
79
int VMCIQPBroker_Alloc(VMCIHandle handle, VMCIId peer, uint32 flags,
145
80
VMCIPrivilegeFlags privFlags,
146
81
uint64 produceSize, uint64 consumeSize,
147
82
QueuePairPageStore *pageStore,
148
83
VMCIContext *context);
149
int VMCIQPBroker_SetPageStore(VMCIHandle handle,
150
QueuePairPageStore *pageStore,
84
int VMCIQPBroker_SetPageStore(VMCIHandle handle, VA64 produceUVA, VA64 consumeUVA,
151
85
VMCIContext *context);
152
int VMCIQPBroker_Detach(VMCIHandle handle, VMCIContext *context, Bool detach);
86
int VMCIQPBroker_Detach(VMCIHandle handle, VMCIContext *context);
154
88
int VMCIQPGuestEndpoints_Init(void);
155
89
void VMCIQPGuestEndpoints_Exit(void);
159
93
int VMCIQueuePair_Alloc(VMCIHandle *handle, VMCIQueue **produceQ,
160
94
uint64 produceSize, VMCIQueue **consumeQ,
161
95
uint64 consumeSize, VMCIId peer, uint32 flags,
162
VMCIPrivilegeFlags privFlags, Bool guestEndpoint);
96
VMCIPrivilegeFlags privFlags, Bool guestEndpoint,
97
VMCIEventReleaseCB wakeupCB, void *clientData);
163
98
int VMCIQueuePair_Detach(VMCIHandle handle, Bool guestEndpoint);
99
int VMCIQPBroker_Map(VMCIHandle handle, VMCIContext *context, VMCIQPGuestMem guestMem);
100
int VMCIQPBroker_Unmap(VMCIHandle handle, VMCIContext *context, VMCIGuestMemID gid);
166
103
#endif /* !_VMCI_QUEUE_PAIR_H_ */