1
/*********************************************************
2
* Copyright (C) 2006 VMware, Inc. All rights reserved.
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.
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
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
17
*********************************************************/
22
* Struct definitions for VMCI internal common code.
25
#ifndef _VMCI_COMMONINT_H_
26
#define _VMCI_COMMONINT_H_
28
#define INCLUDE_ALLOW_MODULE
29
#define INCLUDE_ALLOW_VMMON
30
#define INCLUDE_ALLOW_VMCORE
31
#define INCLUDE_ALLOW_VMKERNEL
32
#include "includeCheck.h"
34
#include "vm_atomic.h"
35
#include "vmci_defs.h"
36
#include "vmci_call_defs.h"
37
#include "vmci_infrastructure.h"
38
#include "vmci_handle_array.h"
39
#include "vmci_kernel_if.h"
43
* The DatagramQueueEntry is a queue header for the in-kernel VMCI
44
* datagram queues. It is allocated in non-paged memory, as the
45
* content is accessed while holding a spinlock. The pending datagram
46
* itself may be allocated from paged memory. We shadow the size of
47
* the datagram in the non-paged queue entry as this size is used
48
* while holding the same spinlock as above.
51
typedef struct DatagramQueueEntry {
52
VMCIListItem listItem; /* For queuing. */
53
size_t dgSize; /* Size of datagram. */
54
VMCIDatagram *dg; /* Pending datagram. */
59
VMCIListItem listItem; /* For global VMCI list. */
61
Atomic_uint32 refCount;
62
VMCIList datagramQueue; /* Head of per VM queue. */
63
uint32 pendingDatagrams;
64
size_t datagramQueueSize;/* Size of datagram queue in bytes. */
66
* Version of the code that created
67
* this context; e.g., VMX.
69
VMCILock lock; /* Locks callQueue and handleArrays. */
70
VMCIHandleArray *wellKnownArray; /* WellKnown mappings owned by context. */
71
VMCIHandleArray *queuePairArray; /*
72
* QueuePairs attached to. The array of
73
* handles for queue pairs is accessed
74
* from the code for QP API, and there
75
* it is protected by the QP lock. It
76
* is also accessed from the context
77
* clean up path, which does not
78
* require a lock. VMCILock is not
79
* used to protect the QP array field.
81
VMCIHandleArray *doorbellArray; /* Doorbells created by context. */
82
VMCIHandleArray *pendingDoorbellArray; /* Doorbells pending for context. */
83
VMCIHandleArray *notifierArray; /* Contexts current context is subscribing to. */
85
VMCIPrivilegeFlags privFlags;
89
char domainName[VMCI_DOMAIN_NAME_MAXLEN];
90
Bool isQuiesced; /* Whether current VM is quiesced */
91
VMCIId migrateCid; /* The migrate cid if it is migrating */
94
Bool *notify; /* Notify flag pointer - hosted only. */
96
struct page *notifyPage; /* Page backing the notify UVA. */
103
*------------------------------------------------------------------------------
105
* VMCIDenyInteraction --
107
* Utilility function that checks whether two entities are allowed
108
* to interact. If one of them is restricted, the other one must
109
* be trusted. On ESX, the vmci domain must match for unrestricted
113
* TRUE if the two entities are not allowed to interact. FALSE otherwise.
118
*------------------------------------------------------------------------------
122
VMCIDenyInteraction(VMCIPrivilegeFlags partOne, // IN
123
VMCIPrivilegeFlags partTwo, // IN
124
const char *srcDomain, // IN: Unused on hosted
125
const char *dstDomain) // IN: Unused on hosted
128
return (((partOne & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
129
!(partTwo & VMCI_PRIVILEGE_FLAG_TRUSTED)) ||
130
((partTwo & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
131
!(partOne & VMCI_PRIVILEGE_FLAG_TRUSTED)));
134
* If source or destination is trusted (hypervisor), we allow the
137
if ((partOne & VMCI_PRIVILEGE_FLAG_TRUSTED) ||
138
(partTwo & VMCI_PRIVILEGE_FLAG_TRUSTED)) {
142
* If source or destination is restricted, we deny the communication.
144
if ((partOne & VMCI_PRIVILEGE_FLAG_RESTRICTED) ||
145
(partTwo & VMCI_PRIVILEGE_FLAG_RESTRICTED)) {
149
* We are here, means that neither of source or destination are trusted, and
150
* both are unrestricted.
152
ASSERT(!(partOne & VMCI_PRIVILEGE_FLAG_TRUSTED) &&
153
!(partTwo & VMCI_PRIVILEGE_FLAG_TRUSTED));
154
ASSERT(!(partOne & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
155
!(partTwo & VMCI_PRIVILEGE_FLAG_RESTRICTED));
157
* We now compare the source and destination domain names, and allow
158
* communication iff they match.
160
return strcmp(srcDomain, dstDomain) ? TRUE : /* Deny. */
165
#endif /* _VMCI_COMMONINT_H_ */