~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to modules/linux/vmci/common/vmciQueuePair.h

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************
 
2
 * Copyright (C) 2007 VMware, Inc. All rights reserved.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License as published by the
 
6
 * Free Software Foundation version 2 and no later version.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
10
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
11
 * for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
15
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
16
 *
 
17
 *********************************************************/
 
18
 
 
19
/*
 
20
 * vmciQueuePair.h --
 
21
 *
 
22
 *    VMCI QueuePair API implementation in the host driver.
 
23
 */
 
24
 
 
25
#ifndef _VMCI_QUEUE_PAIR_H_
 
26
#define _VMCI_QUEUE_PAIR_H_
 
27
 
 
28
#define INCLUDE_ALLOW_MODULE
 
29
#define INCLUDE_ALLOW_VMMON
 
30
#define INCLUDE_ALLOW_VMCORE
 
31
#define INCLUDE_ALLOW_VMKERNEL
 
32
#include "includeCheck.h"
 
33
 
 
34
#include "vmci_defs.h"
 
35
#include "vmciContext.h"
 
36
#include "vmci_iocontrols.h"
 
37
#include "vmciQueue.h"
 
38
#ifdef VMKERNEL
 
39
#include "vm_atomic.h"
 
40
#include "util_copy_dist.h"
 
41
#include "shm.h"
 
42
 
 
43
/*
 
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.
 
48
 */
 
49
 
 
50
typedef struct QueuePairPageStore {
 
51
   Bool shared; // Indicates whether the pages are stored in shared memory
 
52
   union {
 
53
      Shm_ID   shmID;
 
54
      void    *ptr;
 
55
   } store;
 
56
} QueuePairPageStore;
 
57
 
 
58
#else
 
59
 
 
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
 
68
} QueuePairPageStore;
 
69
 
 
70
#endif // !VMKERNEL
 
71
 
 
72
#if (defined(__linux__) || defined(_WIN32) || defined(__APPLE__) || \
 
73
     defined(SOLARIS)) && !defined(VMKERNEL)
 
74
struct VMCIQueue;
 
75
 
 
76
typedef struct PageStoreAttachInfo {
 
77
   char producePageFile[VMCI_PATH_MAX];
 
78
   char consumePageFile[VMCI_PATH_MAX];
 
79
   uint64 numProducePages;
 
80
   uint64 numConsumePages;
 
81
 
 
82
   /* User VAs in the VMX task */
 
83
   VA64   produceBuffer;
 
84
   VA64   consumeBuffer;
 
85
 
 
86
   /*
 
87
    * Platform-specific references to the physical pages backing the
 
88
    * queue. These include a page for the header.
 
89
    *
 
90
    * PR361589 tracks this, too.
 
91
    */
 
92
 
 
93
#if defined(__linux__)
 
94
   struct page **producePages;
 
95
   struct page **consumePages;
 
96
#elif defined(_WIN32)
 
97
   void *kmallocPtr;
 
98
   size_t kmallocSize;
 
99
   PMDL produceMDL;
 
100
   PMDL consumeMDL;
 
101
#elif defined(__APPLE__)
 
102
   /*
 
103
    * All the Mac OS X fields are members of the VMCIQueue
 
104
    */
 
105
#endif
 
106
} PageStoreAttachInfo;
 
107
 
 
108
#endif // (__linux__ || _WIN32 || __APPLE__) && !VMKERNEL
 
109
 
 
110
 
 
111
/*
 
112
 *------------------------------------------------------------------------------
 
113
 *
 
114
 *  VMCI_QP_PAGESTORE_IS_WELLFORMED --
 
115
 *
 
116
 *     Utility function that checks whether the fields of the page
 
117
 *     store contain valid values.
 
118
 *
 
119
 *  Result:
 
120
 *     TRUE if the page store is wellformed. FALSE otherwise.
 
121
 *
 
122
 *  Side effects:
 
123
 *     None.
 
124
 *
 
125
 *------------------------------------------------------------------------------
 
126
 */
 
127
 
 
128
static INLINE Bool
 
129
VMCI_QP_PAGESTORE_IS_WELLFORMED(QueuePairPageStore *pageStore) // IN
 
130
{
 
131
#ifdef VMKERNEL
 
132
   return (pageStore->shared && pageStore->store.shmID != SHM_INVALID_ID) ||
 
133
          (!pageStore->shared && pageStore->store.ptr != NULL);
 
134
#else
 
135
   return pageStore->producePageFile && pageStore->consumePageFile &&
 
136
          pageStore->producePageFileSize && pageStore->consumePageFileSize;
 
137
#endif // !VMKERNEL
 
138
}
 
139
 
 
140
int VMCIQPBroker_Init(void);
 
141
void VMCIQPBroker_Exit(void);
 
142
void VMCIQPBroker_Lock(void);
 
143
void VMCIQPBroker_Unlock(void);
 
144
int VMCIQPBroker_Alloc(VMCIHandle handle, VMCIId peer, uint32 flags,
 
145
                       VMCIPrivilegeFlags privFlags,
 
146
                       uint64 produceSize, uint64 consumeSize,
 
147
                       QueuePairPageStore *pageStore,
 
148
                       VMCIContext *context);
 
149
int VMCIQPBroker_SetPageStore(VMCIHandle handle,
 
150
                              QueuePairPageStore *pageStore,
 
151
                              VMCIContext *context);
 
152
int VMCIQPBroker_Detach(VMCIHandle handle, VMCIContext *context, Bool detach);
 
153
 
 
154
void VMCIQPGuestEndpoints_Init(void);
 
155
void VMCIQPGuestEndpoints_Exit(void);
 
156
void VMCIQPGuestEndpoints_Sync(void);
 
157
void VMCIQPGuestEndpoints_Convert(Bool toLocal, Bool deviceReset);
 
158
 
 
159
int VMCIQueuePair_Alloc(VMCIHandle *handle, VMCIQueue **produceQ,
 
160
                        uint64 produceSize, VMCIQueue **consumeQ,
 
161
                        uint64 consumeSize, VMCIId peer, uint32 flags,
 
162
                        VMCIPrivilegeFlags privFlags, Bool guestEndpoint);
 
163
int VMCIQueuePair_Detach(VMCIHandle handle, Bool guestEndpoint);
 
164
 
 
165
 
 
166
#endif /* !_VMCI_QUEUE_PAIR_H_ */
 
167