Merge lp:~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.quantal-modules.backport into lp:ubuntu/precise/open-vm-tools

Proposed by Nate Muench (Mink)
Status: Work in progress
Proposed branch: lp:~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.quantal-modules.backport
Merge into: lp:ubuntu/precise/open-vm-tools
Diff against target: 44916 lines (+42289/-487)
84 files modified
.pc/.quilt_patches (+1/-0)
.pc/.quilt_series (+1/-0)
.pc/04-quantal-module-backport.patch/modules/Makefile.in (+588/-0)
.pc/04-quantal-module-backport.patch/modules/linux/dkms.conf (+39/-0)
.pc/04-quantal-module-backport.patch/modules/linux/dkms.sh (+118/-0)
.pc/04-quantal-module-backport.patch/modules/linux/shared/compat_ethtool.h (+54/-0)
.pc/04-quantal-module-backport.patch/modules/linux/shared/compat_fs.h (+251/-0)
.pc/04-quantal-module-backport.patch/modules/linux/shared/compat_netdevice.h (+334/-0)
.pc/04-quantal-module-backport.patch/modules/linux/shared/vmciKernelAPI1.h (+191/-0)
.pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_defs.h (+831/-0)
.pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_iocontrols.h (+752/-0)
.pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_kernel_if.h (+462/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmblock/linux/filesystem.c (+626/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciCommonInt.h (+133/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciContext.c (+2542/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciContext.h (+120/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciDriver.c (+679/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciPageChannel.c (+1472/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciRoute.c (+275/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmci/linux/driver.c (+2511/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmci/linux/vmci_version.h (+32/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmci/shared/vmci_page_channel.h (+240/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmhgfs/Makefile.kernel (+132/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmhgfs/dentry.c (+90/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmhgfs/file.c (+1280/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmhgfs/filesystem.c (+726/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmhgfs/inode.c (+2115/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmxnet/vmxnet.c (+3121/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vmxnet/vmxnet_version.h (+32/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vsock/linux/af_vsock.c (+5420/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vsock/linux/af_vsock.h (+183/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vsock/linux/stats.c (+37/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vsock/linux/stats.h (+223/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vsock/linux/util.c (+854/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vsock/linux/util.h (+382/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vsock/linux/vsockPacket.h (+322/-0)
.pc/04-quantal-module-backport.patch/modules/linux/vsock/linux/vsock_version.h (+32/-0)
.pc/04-quantal-module-backport.patch/modules/shared/vmxnet/eth_public.h (+1236/-0)
.pc/04-quantal-module-backport.patch/modules/shared/vmxnet/vmnet_def.h (+92/-0)
.pc/05-vsock-cve.patch/modules/linux/vsock/linux/af_vsock.c (+6072/-0)
.pc/applied-patches (+2/-0)
debian/changelog (+11/-0)
debian/patches/04-quantal-module-backport.patch (+4991/-0)
debian/patches/05-vsock-cve.patch (+18/-0)
debian/patches/series (+2/-0)
modules/Makefile.in (+3/-1)
modules/linux/dkms.conf (+1/-1)
modules/linux/dkms.sh (+2/-2)
modules/linux/shared/autoconf/file_operations_fsync.c (+47/-0)
modules/linux/shared/compat_ethtool.h (+6/-0)
modules/linux/shared/compat_fs.h (+15/-0)
modules/linux/shared/compat_netdevice.h (+6/-0)
modules/linux/shared/vmciKernelAPI1.h (+10/-0)
modules/linux/shared/vmci_defs.h (+80/-3)
modules/linux/shared/vmci_iocontrols.h (+1/-1)
modules/linux/shared/vmci_kernel_if.h (+0/-2)
modules/linux/vmblock/linux/filesystem.c (+2/-3)
modules/linux/vmci/common/vmciCommonInt.h (+22/-5)
modules/linux/vmci/common/vmciContext.c (+109/-11)
modules/linux/vmci/common/vmciContext.h (+3/-2)
modules/linux/vmci/common/vmciDriver.c (+8/-3)
modules/linux/vmci/common/vmciPageChannel.c (+430/-171)
modules/linux/vmci/common/vmciRoute.c (+27/-1)
modules/linux/vmci/linux/driver.c (+15/-4)
modules/linux/vmci/linux/vmci_version.h (+4/-4)
modules/linux/vmci/shared/vmci_page_channel.h (+532/-39)
modules/linux/vmhgfs/Makefile.kernel (+1/-0)
modules/linux/vmhgfs/dentry.c (+13/-0)
modules/linux/vmhgfs/file.c (+2/-2)
modules/linux/vmhgfs/filesystem.c (+72/-47)
modules/linux/vmhgfs/inode.c (+6/-6)
modules/linux/vmxnet/vmxnet.c (+35/-5)
modules/linux/vmxnet/vmxnet_version.h (+3/-3)
modules/linux/vsock/linux/af_vsock.c (+706/-52)
modules/linux/vsock/linux/af_vsock.h (+2/-1)
modules/linux/vsock/linux/stats.c (+2/-0)
modules/linux/vsock/linux/stats.h (+66/-26)
modules/linux/vsock/linux/util.c (+102/-0)
modules/linux/vsock/linux/util.h (+112/-0)
modules/linux/vsock/linux/vmci_sockets_packet.h (+158/-0)
modules/linux/vsock/linux/vsockPacket.h (+50/-84)
modules/linux/vsock/linux/vsock_version.h (+4/-4)
modules/shared/vmxnet/eth_public.h (+1/-1)
modules/shared/vmxnet/vmnet_def.h (+6/-3)
To merge this branch: bzr merge lp:~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.quantal-modules.backport
Reviewer Review Type Date Requested Status
Jamie Strandboge Needs Fixing
Nate Muench (Mink) Pending
Ubuntu Security Sponsors Team Pending
Ubuntu Sponsors Pending
Review via email: mp+172158@code.launchpad.net

This proposal supersedes a proposal from 2013-06-07.

Description of the change

Looking at what's been uploaded to Ubuntu. I noticed that Quantal has the 3.5 kernel.

So I've created a patch that takes all the modules from Quantal and upgrades the Precise ones. I've done a diff of the modules folders from the Precise packaging and the Quantal packaging (excluding the FreeBSD and solaris folders, because we don't use them)

This time there is no backporting any packaging, just cherry-picking the modules from Quantal.

To post a comment you must log in.
Revision history for this message
Robie Basak (racb) wrote : Posted in a previous version of this proposal

(I am not a sponsor and cannot merge your changes; just an interested bystander. I appreciate your efforts in getting this fixed)

> You mean I have to revert the (/debian) DKMS files from Raring->Precise. Yeah I figured that out.

No, that's not what I meant. Explanation below. Sorry, I've just seen your message; I'd like to have responded to you earlier.

You seem to have backported the entire module but not the packaging, so I'd say that this *is* a backport, which I think carries a higher risk of regression.

IIRC, it is possible to make DKMS packages build different sources depending on the kernel version. So you could arrange for the actual module itself to be based on an identical source for those running the original Precise kernel, and only apply your changes when using the backport kernel.

This way, you could minimise the chance of regressions for those using the original Precise kernel, since although you would be bumping their DKMS packages the actual module source wouldn't change for them. And you'd enhance the package for users of the backport kernel, since the DKMS package doesn't build for them anyway.

See the PATCH and PATCH_MATCH configuration options in dkms.conf for details. Annoyingly it means that you have to carry a full source and a delta, instead of two full sources for two different versions. But the delta can be constructed and the effect is the same.

This is neither a +1 nor a -1; just a note to say that there may be a safer way. I'm not sure what the appropriate approach here should be.

review: Abstain
Revision history for this message
Nate Muench (Mink) (n-muench) wrote : Posted in a previous version of this proposal

Nothing has changed in the /debian folder. In fact I originally planned on using the whole Raring packaging, and just downgrading, like you seem to be saying. But it didn't turn out as planned.

Then, I tried to use the upstream packaging used for Raring, along with the /debian folder from Precise. And sure enough it built successfully.

I guess I'm assuming if there are problems (after approval), could fix them. Honestly, I'm just sick of people file bug reports saying that the package in Precise won't build against the 3.5 kernel

Revision history for this message
Dmitry Shachnev (mitya57) wrote : Posted in a previous version of this proposal

Can you cherry-pick the changes needed to support 3.5 instead of upgrading to a new upstream version?

Also, as this contains a fix for a CVE, it would be nice if someone from security team reviewed it (maybe it should also go to -security pocket).

review: Abstain
Revision history for this message
Dmitry Shachnev (mitya57) wrote : Posted in a previous version of this proposal

Looks like I can't add ~ubuntu-security-sponsors to the reviewers, can you please do that yourself?

Revision history for this message
Nate Muench (Mink) (n-muench) wrote : Posted in a previous version of this proposal

> Can you cherry-pick the changes needed to support 3.5 instead of upgrading to
> a new upstream version?
>
> Also, as this contains a fix for a CVE, it would be nice if someone from
> security team reviewed it (maybe it should also go to -security pocket).
Honestly, I don't know what changes were needed for 3.5 support (I'm not able to access VMware git repo for the packaging at the moment).

The reason for upgrading over cherry-picking is because the package has a less likely chance of breakage. I've tested it on Precise, it works to the best of my knowledge.

Revision history for this message
Nate Muench (Mink) (n-muench) wrote : Posted in a previous version of this proposal

Gonna redo it, with a patch based on Quantal's modules

review: Needs Resubmitting
28. By Nate Muench (Mink)

* Added 04-quantal-module-backport.patch
  - Backports kernel modules from Quantal packaging to Precise.
    + Fixes building on Precise backport kernels. (LP: #1083719)

* Adding patch from Mathias Krause <email address hidden> to fix
  kernel stack memory leack in vsock module [CVE-2013-3237].

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Thanks for the patch, but it can't be applied in its current form. Please see https://bugs.launchpad.net/ubuntu/+source/open-vm-tools/+bug/1083719/comments/18 for details.

review: Needs Fixing
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

based on last comment, setting this merge proposal to work in progress.

Unmerged revisions

28. By Nate Muench (Mink)

* Added 04-quantal-module-backport.patch
  - Backports kernel modules from Quantal packaging to Precise.
    + Fixes building on Precise backport kernels. (LP: #1083719)

* Adding patch from Mathias Krause <email address hidden> to fix
  kernel stack memory leack in vsock module [CVE-2013-3237].

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.pc/.quilt_patches'
2--- .pc/.quilt_patches 1970-01-01 00:00:00 +0000
3+++ .pc/.quilt_patches 2013-06-28 21:11:42 +0000
4@@ -0,0 +1,1 @@
5+debian/patches
6
7=== added file '.pc/.quilt_series'
8--- .pc/.quilt_series 1970-01-01 00:00:00 +0000
9+++ .pc/.quilt_series 2013-06-28 21:11:42 +0000
10@@ -0,0 +1,1 @@
11+series
12
13=== added directory '.pc/04-quantal-module-backport.patch'
14=== added directory '.pc/04-quantal-module-backport.patch/modules'
15=== added file '.pc/04-quantal-module-backport.patch/modules/Makefile.in'
16--- .pc/04-quantal-module-backport.patch/modules/Makefile.in 1970-01-01 00:00:00 +0000
17+++ .pc/04-quantal-module-backport.patch/modules/Makefile.in 2013-06-28 21:11:42 +0000
18@@ -0,0 +1,588 @@
19+# Makefile.in generated by automake 1.11.1 from Makefile.am.
20+# @configure_input@
21+
22+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
23+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
24+# Inc.
25+# This Makefile.in is free software; the Free Software Foundation
26+# gives unlimited permission to copy and/or distribute it,
27+# with or without modifications, as long as this notice is preserved.
28+
29+# This program is distributed in the hope that it will be useful,
30+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
31+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
32+# PARTICULAR PURPOSE.
33+
34+@SET_MAKE@
35+
36+VPATH = @srcdir@
37+pkgdatadir = $(datadir)/@PACKAGE@
38+pkgincludedir = $(includedir)/@PACKAGE@
39+pkglibdir = $(libdir)/@PACKAGE@
40+pkglibexecdir = $(libexecdir)/@PACKAGE@
41+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
42+install_sh_DATA = $(install_sh) -c -m 644
43+install_sh_PROGRAM = $(install_sh) -c
44+install_sh_SCRIPT = $(install_sh) -c
45+INSTALL_HEADER = $(INSTALL_DATA)
46+transform = $(program_transform_name)
47+NORMAL_INSTALL = :
48+PRE_INSTALL = :
49+POST_INSTALL = :
50+NORMAL_UNINSTALL = :
51+PRE_UNINSTALL = :
52+POST_UNINSTALL = :
53+build_triplet = @build@
54+host_triplet = @host@
55+subdir = modules
56+DIST_COMMON = $(am__include_HEADERS_DIST) $(srcdir)/Makefile.am \
57+ $(srcdir)/Makefile.in
58+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
59+am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
60+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
61+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
62+ $(top_srcdir)/m4/vmtools.m4 $(top_srcdir)/configure.ac
63+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
64+ $(ACLOCAL_M4)
65+mkinstalldirs = $(install_sh) -d
66+CONFIG_CLEAN_FILES =
67+CONFIG_CLEAN_VPATH_FILES =
68+SOURCES =
69+DIST_SOURCES =
70+am__include_HEADERS_DIST = $(top_srcdir)/lib/include/vmci_sockets.h
71+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
72+am__vpath_adj = case $$p in \
73+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
74+ *) f=$$p;; \
75+ esac;
76+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
77+am__install_max = 40
78+am__nobase_strip_setup = \
79+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
80+am__nobase_strip = \
81+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
82+am__nobase_list = $(am__nobase_strip_setup); \
83+ for p in $$list; do echo "$$p $$p"; done | \
84+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
85+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
86+ if (++n[$$2] == $(am__install_max)) \
87+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
88+ END { for (dir in files) print dir, files[dir] }'
89+am__base_list = \
90+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
91+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
92+am__installdirs = "$(DESTDIR)$(includedir)"
93+HEADERS = $(include_HEADERS)
94+ETAGS = etags
95+CTAGS = ctags
96+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
97+ACLOCAL = @ACLOCAL@
98+AMTAR = @AMTAR@
99+AR = @AR@
100+AUTOCONF = @AUTOCONF@
101+AUTOHEADER = @AUTOHEADER@
102+AUTOMAKE = @AUTOMAKE@
103+AWK = @AWK@
104+CC = @CC@
105+CCDEPMODE = @CCDEPMODE@
106+CFLAGS = @CFLAGS@
107+COMMON_PLUGIN_INSTALLDIR = @COMMON_PLUGIN_INSTALLDIR@
108+COMMON_XLIBS = @COMMON_XLIBS@
109+CPP = @CPP@
110+CPPFLAGS = @CPPFLAGS@
111+CUNIT_CPPFLAGS = @CUNIT_CPPFLAGS@
112+CUNIT_LIBS = @CUNIT_LIBS@
113+CXX = @CXX@
114+CXXCPP = @CXXCPP@
115+CXXDEPMODE = @CXXDEPMODE@
116+CXXFLAGS = @CXXFLAGS@
117+CYGPATH_W = @CYGPATH_W@
118+DEFS = @DEFS@
119+DEPDIR = @DEPDIR@
120+DNET_CPPFLAGS = @DNET_CPPFLAGS@
121+DNET_LIBS = @DNET_LIBS@
122+DOT = @DOT@
123+DSYMUTIL = @DSYMUTIL@
124+DUMPBIN = @DUMPBIN@
125+ECHO_C = @ECHO_C@
126+ECHO_N = @ECHO_N@
127+ECHO_T = @ECHO_T@
128+EGREP = @EGREP@
129+EXEEXT = @EXEEXT@
130+FGREP = @FGREP@
131+FUSE_CPPFLAGS = @FUSE_CPPFLAGS@
132+FUSE_LIBS = @FUSE_LIBS@
133+GLIB2_CPPFLAGS = @GLIB2_CPPFLAGS@
134+GLIB2_LIBS = @GLIB2_LIBS@
135+GMODULE_CPPFLAGS = @GMODULE_CPPFLAGS@
136+GMODULE_LIBS = @GMODULE_LIBS@
137+GOBJECT_CPPFLAGS = @GOBJECT_CPPFLAGS@
138+GOBJECT_LIBS = @GOBJECT_LIBS@
139+GREP = @GREP@
140+GTHREAD_CPPFLAGS = @GTHREAD_CPPFLAGS@
141+GTHREAD_LIBS = @GTHREAD_LIBS@
142+GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@
143+GTKMM_LIBS = @GTKMM_LIBS@
144+GTK_CPPFLAGS = @GTK_CPPFLAGS@
145+GTK_LIBS = @GTK_LIBS@
146+HAVE_DOT = @HAVE_DOT@
147+HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@
148+HGFS_LIBS = @HGFS_LIBS@
149+ICU_CPPFLAGS = @ICU_CPPFLAGS@
150+ICU_LIBS = @ICU_LIBS@
151+INSTALL = @INSTALL@
152+INSTALL_DATA = @INSTALL_DATA@
153+INSTALL_PROGRAM = @INSTALL_PROGRAM@
154+INSTALL_SCRIPT = @INSTALL_SCRIPT@
155+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
156+INSTVMSG = @INSTVMSG@
157+KERNEL_RELEASE = @KERNEL_RELEASE@
158+LD = @LD@
159+LDFLAGS = @LDFLAGS@
160+LIBOBJS = @LIBOBJS@
161+LIBS = @LIBS@
162+LIBTOOL = @LIBTOOL@
163+LIBVMTOOLS_LIBADD = @LIBVMTOOLS_LIBADD@
164+LIB_AUTH_CPPFLAGS = @LIB_AUTH_CPPFLAGS@
165+LIB_IMPERSONATE_CPPFLAGS = @LIB_IMPERSONATE_CPPFLAGS@
166+LIB_USER_CPPFLAGS = @LIB_USER_CPPFLAGS@
167+LINUXINCLUDE = @LINUXINCLUDE@
168+LIPO = @LIPO@
169+LN_S = @LN_S@
170+LTLIBOBJS = @LTLIBOBJS@
171+MAKEINFO = @MAKEINFO@
172+MKDIR_P = @MKDIR_P@
173+MODULES = @MODULES@
174+MODULES_DIR = @MODULES_DIR@
175+MODULES_OS = @MODULES_OS@
176+MSCGEN = @MSCGEN@
177+MSCGEN_DIR = @MSCGEN_DIR@
178+NM = @NM@
179+NMEDIT = @NMEDIT@
180+OBJDUMP = @OBJDUMP@
181+OBJEXT = @OBJEXT@
182+OTOOL = @OTOOL@
183+OTOOL64 = @OTOOL64@
184+PACKAGE = @PACKAGE@
185+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
186+PACKAGE_NAME = @PACKAGE_NAME@
187+PACKAGE_STRING = @PACKAGE_STRING@
188+PACKAGE_TARNAME = @PACKAGE_TARNAME@
189+PACKAGE_URL = @PACKAGE_URL@
190+PACKAGE_VERSION = @PACKAGE_VERSION@
191+PAM_CPPFLAGS = @PAM_CPPFLAGS@
192+PAM_LIBS = @PAM_LIBS@
193+PAM_PREFIX = @PAM_PREFIX@
194+PATH_SEPARATOR = @PATH_SEPARATOR@
195+PLUGIN_CPPFLAGS = @PLUGIN_CPPFLAGS@
196+PLUGIN_LDFLAGS = @PLUGIN_LDFLAGS@
197+PROCPS_CPPFLAGS = @PROCPS_CPPFLAGS@
198+PROCPS_LIBS = @PROCPS_LIBS@
199+RANLIB = @RANLIB@
200+RPCGEN = @RPCGEN@
201+RPCGENFLAGS = @RPCGENFLAGS@
202+RPCGEN_WRAPPER = @RPCGEN_WRAPPER@
203+SED = @SED@
204+SET_MAKE = @SET_MAKE@
205+SHELL = @SHELL@
206+STRIP = @STRIP@
207+SYSDIR = @SYSDIR@
208+TARGET_OS = @TARGET_OS@
209+TEST_PLUGIN_INSTALLDIR = @TEST_PLUGIN_INSTALLDIR@
210+TOOLS_VERSION = @TOOLS_VERSION@
211+VERSION = @VERSION@
212+VIX_LIBADD = @VIX_LIBADD@
213+VMSVC_PLUGIN_INSTALLDIR = @VMSVC_PLUGIN_INSTALLDIR@
214+VMTOOLS_CPPFLAGS = @VMTOOLS_CPPFLAGS@
215+VMTOOLS_LIBS = @VMTOOLS_LIBS@
216+VMUSR_PLUGIN_INSTALLDIR = @VMUSR_PLUGIN_INSTALLDIR@
217+XCOMPOSITE_LIBS = @XCOMPOSITE_LIBS@
218+XDR_LIBS = @XDR_LIBS@
219+XMKMF = @XMKMF@
220+XSM_LIBS = @XSM_LIBS@
221+X_CFLAGS = @X_CFLAGS@
222+X_EXTRA_LIBS = @X_EXTRA_LIBS@
223+X_LIBS = @X_LIBS@
224+X_PRE_LIBS = @X_PRE_LIBS@
225+abs_builddir = @abs_builddir@
226+abs_srcdir = @abs_srcdir@
227+abs_top_builddir = @abs_top_builddir@
228+abs_top_srcdir = @abs_top_srcdir@
229+ac_ct_CC = @ac_ct_CC@
230+ac_ct_CXX = @ac_ct_CXX@
231+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
232+ac_vmw_lib_cfg = @ac_vmw_lib_cfg@
233+am__include = @am__include@
234+am__leading_dot = @am__leading_dot@
235+am__quote = @am__quote@
236+am__tar = @am__tar@
237+am__untar = @am__untar@
238+bindir = @bindir@
239+build = @build@
240+build_alias = @build_alias@
241+build_cpu = @build_cpu@
242+build_os = @build_os@
243+build_vendor = @build_vendor@
244+builddir = @builddir@
245+datadir = @datadir@
246+datarootdir = @datarootdir@
247+docdir = @docdir@
248+dvidir = @dvidir@
249+exec_prefix = @exec_prefix@
250+have_cxx = @have_cxx@
251+have_doxygen = @have_doxygen@
252+have_genmarshal = @have_genmarshal@
253+host = @host@
254+host_alias = @host_alias@
255+host_cpu = @host_cpu@
256+host_os = @host_os@
257+host_vendor = @host_vendor@
258+htmldir = @htmldir@
259+includedir = @includedir@
260+infodir = @infodir@
261+install_sh = @install_sh@
262+libdir = @libdir@
263+libexecdir = @libexecdir@
264+localedir = @localedir@
265+localstatedir = @localstatedir@
266+lt_ECHO = @lt_ECHO@
267+mandir = @mandir@
268+mkdir_p = @mkdir_p@
269+oldincludedir = @oldincludedir@
270+pdfdir = @pdfdir@
271+prefix = @prefix@
272+program_transform_name = @program_transform_name@
273+psdir = @psdir@
274+sbindir = @sbindir@
275+sharedstatedir = @sharedstatedir@
276+srcdir = @srcdir@
277+sysconfdir = @sysconfdir@
278+target_alias = @target_alias@
279+top_build_prefix = @top_build_prefix@
280+top_builddir = @top_builddir@
281+top_srcdir = @top_srcdir@
282+modulesrc = $(abs_top_srcdir)/modules
283+@FREEBSD_CUSTOM_SYSDIR_TRUE@EXTRA_ARGS = "SYSDIR=@SYSDIR@"
284+# Solaris does not have Kbuild-like system so we need to supply
285+# compiler and linker and other items discovered by configure
286+# script.
287+@SOLARIS_TRUE@EXTRA_ARGS = "CC=$(CC)" "CC_WARNINGS=$(CC_WARNINGS)" \
288+@SOLARIS_TRUE@ "GLOBAL_DEFS=$(GLOBAL_DEFS)" "LD=$(LD)" \
289+@SOLARIS_TRUE@ "HAVE_GNU_LD=$(HAVE_GNU_LD)"
290+@LINUX_TRUE@include_HEADERS = $(top_srcdir)/lib/include/vmci_sockets.h
291+all: all-am
292+
293+.SUFFIXES:
294+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
295+ @for dep in $?; do \
296+ case '$(am__configure_deps)' in \
297+ *$$dep*) \
298+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
299+ && { if test -f $@; then exit 0; else break; fi; }; \
300+ exit 1;; \
301+ esac; \
302+ done; \
303+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu modules/Makefile'; \
304+ $(am__cd) $(top_srcdir) && \
305+ $(AUTOMAKE) --gnu modules/Makefile
306+.PRECIOUS: Makefile
307+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
308+ @case '$?' in \
309+ *config.status*) \
310+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
311+ *) \
312+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
313+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
314+ esac;
315+
316+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
317+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
318+
319+$(top_srcdir)/configure: $(am__configure_deps)
320+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
321+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
322+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
323+$(am__aclocal_m4_deps):
324+
325+mostlyclean-libtool:
326+ -rm -f *.lo
327+
328+clean-libtool:
329+ -rm -rf .libs _libs
330+install-includeHEADERS: $(include_HEADERS)
331+ @$(NORMAL_INSTALL)
332+ test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
333+ @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
334+ for p in $$list; do \
335+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
336+ echo "$$d$$p"; \
337+ done | $(am__base_list) | \
338+ while read files; do \
339+ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
340+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
341+ done
342+
343+uninstall-includeHEADERS:
344+ @$(NORMAL_UNINSTALL)
345+ @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
346+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
347+ test -n "$$files" || exit 0; \
348+ echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
349+ cd "$(DESTDIR)$(includedir)" && rm -f $$files
350+
351+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
352+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
353+ unique=`for i in $$list; do \
354+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
355+ done | \
356+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
357+ END { if (nonempty) { for (i in files) print i; }; }'`; \
358+ mkid -fID $$unique
359+tags: TAGS
360+
361+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
362+ $(TAGS_FILES) $(LISP)
363+ set x; \
364+ here=`pwd`; \
365+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
366+ unique=`for i in $$list; do \
367+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
368+ done | \
369+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
370+ END { if (nonempty) { for (i in files) print i; }; }'`; \
371+ shift; \
372+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
373+ test -n "$$unique" || unique=$$empty_fix; \
374+ if test $$# -gt 0; then \
375+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
376+ "$$@" $$unique; \
377+ else \
378+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
379+ $$unique; \
380+ fi; \
381+ fi
382+ctags: CTAGS
383+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
384+ $(TAGS_FILES) $(LISP)
385+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
386+ unique=`for i in $$list; do \
387+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
388+ done | \
389+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
390+ END { if (nonempty) { for (i in files) print i; }; }'`; \
391+ test -z "$(CTAGS_ARGS)$$unique" \
392+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
393+ $$unique
394+
395+GTAGS:
396+ here=`$(am__cd) $(top_builddir) && pwd` \
397+ && $(am__cd) $(top_srcdir) \
398+ && gtags -i $(GTAGS_ARGS) "$$here"
399+
400+distclean-tags:
401+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
402+
403+distdir: $(DISTFILES)
404+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
405+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
406+ list='$(DISTFILES)'; \
407+ dist_files=`for file in $$list; do echo $$file; done | \
408+ sed -e "s|^$$srcdirstrip/||;t" \
409+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
410+ case $$dist_files in \
411+ */*) $(MKDIR_P) `echo "$$dist_files" | \
412+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
413+ sort -u` ;; \
414+ esac; \
415+ for file in $$dist_files; do \
416+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
417+ if test -d $$d/$$file; then \
418+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
419+ if test -d "$(distdir)/$$file"; then \
420+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
421+ fi; \
422+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
423+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
424+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
425+ fi; \
426+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
427+ else \
428+ test -f "$(distdir)/$$file" \
429+ || cp -p $$d/$$file "$(distdir)/$$file" \
430+ || exit 1; \
431+ fi; \
432+ done
433+check-am: all-am
434+check: check-am
435+all-am: Makefile $(HEADERS)
436+installdirs:
437+ for dir in "$(DESTDIR)$(includedir)"; do \
438+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
439+ done
440+install: install-am
441+install-exec: install-exec-am
442+install-data: install-data-am
443+uninstall: uninstall-am
444+
445+install-am: all-am
446+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
447+
448+installcheck: installcheck-am
449+install-strip:
450+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
451+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
452+ `test -z '$(STRIP)' || \
453+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
454+mostlyclean-generic:
455+
456+clean-generic:
457+
458+distclean-generic:
459+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
460+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
461+
462+maintainer-clean-generic:
463+ @echo "This command is intended for maintainers to use"
464+ @echo "it deletes files that may require special tools to rebuild."
465+clean: clean-am
466+
467+clean-am: clean-generic clean-libtool clean-local mostlyclean-am
468+
469+distclean: distclean-am
470+ -rm -f Makefile
471+distclean-am: clean-am distclean-generic distclean-tags
472+
473+dvi: dvi-am
474+
475+dvi-am:
476+
477+html: html-am
478+
479+html-am:
480+
481+info: info-am
482+
483+info-am:
484+
485+install-data-am: install-includeHEADERS
486+
487+install-dvi: install-dvi-am
488+
489+install-dvi-am:
490+
491+install-exec-am:
492+ @$(NORMAL_INSTALL)
493+ $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
494+install-html: install-html-am
495+
496+install-html-am:
497+
498+install-info: install-info-am
499+
500+install-info-am:
501+
502+install-man:
503+
504+install-pdf: install-pdf-am
505+
506+install-pdf-am:
507+
508+install-ps: install-ps-am
509+
510+install-ps-am:
511+
512+installcheck-am:
513+
514+maintainer-clean: maintainer-clean-am
515+ -rm -f Makefile
516+maintainer-clean-am: distclean-am maintainer-clean-generic
517+
518+mostlyclean: mostlyclean-am
519+
520+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
521+
522+pdf: pdf-am
523+
524+pdf-am:
525+
526+ps: ps-am
527+
528+ps-am:
529+
530+uninstall-am: uninstall-includeHEADERS
531+ @$(NORMAL_INSTALL)
532+ $(MAKE) $(AM_MAKEFLAGS) uninstall-hook
533+.MAKE: install-am install-exec-am install-strip uninstall-am
534+
535+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
536+ clean-libtool clean-local ctags distclean distclean-generic \
537+ distclean-libtool distclean-tags distdir dvi dvi-am html \
538+ html-am info info-am install install-am install-data \
539+ install-data-am install-dvi install-dvi-am install-exec \
540+ install-exec-am install-exec-hook install-html install-html-am \
541+ install-includeHEADERS install-info install-info-am \
542+ install-man install-pdf install-pdf-am install-ps \
543+ install-ps-am install-strip installcheck installcheck-am \
544+ installdirs maintainer-clean maintainer-clean-generic \
545+ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
546+ ps ps-am tags uninstall uninstall-am uninstall-hook \
547+ uninstall-includeHEADERS
548+
549+all: modules
550+
551+.PHONY: modules $(MODULES)
552+modules: $(MODULES)
553+
554+$(MODULES):
555+ $(MAKE) VM_UNAME=$(KERNEL_RELEASE) MV=mv RM=rm \
556+ OVT_SOURCE_DIR=$(abs_top_srcdir) \
557+ MODULEBUILDDIR=$(modulesrc)/$(MODULES_OS) \
558+ $(EXTRA_ARGS) -C "$(modulesrc)/$(MODULES_OS)/$@"
559+
560+@LINUX_TRUE@export LINUXINCLUDE := @LINUXINCLUDE@
561+@LINUX_TRUE@export vmblockdir := $(MODULES_DIR)/fs/vmblock
562+@LINUX_TRUE@export vmcidir := $(MODULES_DIR)/drivers/misc
563+@LINUX_TRUE@export vmhgfsdir := $(MODULES_DIR)/fs/vmhgfs
564+@LINUX_TRUE@export vmsyncdir := $(MODULES_DIR)/drivers/misc
565+@LINUX_TRUE@export vmxnetdir := $(MODULES_DIR)/drivers/net
566+@LINUX_TRUE@export vsockdir := $(MODULES_DIR)/net/vsock
567+@LINUX_TRUE@@WITH_ROOT_PRIVILEGES_TRUE@export DEPMOD := depmod -a
568+
569+@SOLARIS_TRUE@export vmhgfsdir := $(MODULES_DIR)
570+
571+clean-local:
572+ for MOD in $(MODULES); do \
573+ if [ -d "$(modulesrc)/$(MODULES_OS)/$$MOD" ]; then \
574+ $(MAKE) VM_UNAME=$(KERNEL_RELEASE) MV=mv RM=rm \
575+ -C "$(modulesrc)/$(MODULES_OS)/$$MOD" clean || exit 1; \
576+ fi \
577+ done
578+ rm -f $(modulesrc)/$(MODULES_OS)/*.o $(modulesrc)/$(MODULES_OS)/*.ko
579+ rm -f $(modulesrc)/$(MODULES_OS)/VMwareVMCIModule.symvers
580+
581+install-exec-hook:
582+@SOLARIS_TRUE@ for MOD in $(MODULES); do \
583+@SOLARIS_TRUE@ $(MAKE) VM_UNAME=$(KERNEL_RELEASE) MV=mv RM=rm \
584+@SOLARIS_TRUE@ -C "$(modulesrc)/$(MODULES_OS)/$$MOD" install || exit 1; \
585+@SOLARIS_TRUE@ done
586+@FREEBSD_TRUE@ for MOD in $(MODULES); do \
587+@FREEBSD_TRUE@ $(INSTALL) -d $(DESTDIR)$(MODULES_DIR); \
588+@FREEBSD_TRUE@ $(INSTALL) -m644 $(modulesrc)/$(MODULES_OS)/$$MOD.ko \
589+@FREEBSD_TRUE@ $(DESTDIR)$(MODULES_DIR); \
590+@FREEBSD_TRUE@ done
591+@LINUX_TRUE@ for MOD in $(MODULES); do \
592+@LINUX_TRUE@ $(INSTALL) -d $(DESTDIR)`eval echo '$$'$${MOD}dir`; \
593+@LINUX_TRUE@ $(INSTALL) -m644 $(modulesrc)/$(MODULES_OS)/$$MOD/$$MOD.ko \
594+@LINUX_TRUE@ $(DESTDIR)`eval echo '$$'$${MOD}dir`; \
595+@LINUX_TRUE@ done
596+@LINUX_TRUE@ eval "$$DEPMOD"
597+
598+uninstall-hook:
599+ for MOD in $(MODULES); do \
600+ rm -f $(DESTDIR)`eval echo '$$'$${MOD}dir`/$$MOD.ko &> /dev/null;\
601+ done
602+ eval "$$DEPMOD"
603+
604+# Tell versions [3.59,3.63) of GNU make to not export all variables.
605+# Otherwise a system limit (for SysV at least) may be exceeded.
606+.NOEXPORT:
607
608=== added directory '.pc/04-quantal-module-backport.patch/modules/linux'
609=== added file '.pc/04-quantal-module-backport.patch/modules/linux/dkms.conf'
610--- .pc/04-quantal-module-backport.patch/modules/linux/dkms.conf 1970-01-01 00:00:00 +0000
611+++ .pc/04-quantal-module-backport.patch/modules/linux/dkms.conf 2013-06-28 21:11:42 +0000
612@@ -0,0 +1,39 @@
613+PACKAGE_NAME=open-vm-tools
614+PACKAGE_VERSION=2011.12.20
615+MAKE_CMD_TMPL="make VM_UNAME=\$kernelver \
616+ MODULEBUILDDIR=$dkms_tree/$PACKAGE_NAME/$PACKAGE_VERSION/build"
617+
618+# The vsock module depends on symbols exported by the vmci module, so it
619+# needs to be built afterwards; the MODULEBUILDDIR variable tells the makefiles
620+# where to store / retrive those symbol files.
621+MAKE[0]="$MAKE_CMD_TMPL -C vmblock; \
622+ $MAKE_CMD_TMPL -C vmci; \
623+ $MAKE_CMD_TMPL -C vmhgfs; \
624+ $MAKE_CMD_TMPL -C vmsync; \
625+ $MAKE_CMD_TMPL -C vmxnet; \
626+ $MAKE_CMD_TMPL -C vsock"
627+CLEAN[0]="$MAKE_CMD_TMPL -C vmblock clean; \
628+ $MAKE_CMD_TMPL -C vmci clean; \
629+ $MAKE_CMD_TMPL -C vmhgfs clean; \
630+ $MAKE_CMD_TMPL -C vmsync clean; \
631+ $MAKE_CMD_TMPL -C vmxnet clean; \
632+ $MAKE_CMD_TMPL -C vsock clean"
633+BUILT_MODULE_NAME[0]="vmblock"
634+BUILT_MODULE_NAME[1]="vmci"
635+BUILT_MODULE_NAME[2]="vmhgfs"
636+BUILT_MODULE_NAME[3]="vmsync"
637+BUILT_MODULE_NAME[4]="vmxnet"
638+BUILT_MODULE_NAME[5]="vsock"
639+BUILT_MODULE_LOCATION[0]="vmblock/"
640+BUILT_MODULE_LOCATION[1]="vmci/"
641+BUILT_MODULE_LOCATION[2]="vmhgfs/"
642+BUILT_MODULE_LOCATION[3]="vmsync/"
643+BUILT_MODULE_LOCATION[4]="vmxnet/"
644+BUILT_MODULE_LOCATION[5]="vsock/"
645+DEST_MODULE_LOCATION[0]="/kernel/fs/vmblock"
646+DEST_MODULE_LOCATION[1]="/kernel/drivers/misc"
647+DEST_MODULE_LOCATION[2]="/kernel/fs/vmhgfs"
648+DEST_MODULE_LOCATION[3]="/kernel/drivers/misc"
649+DEST_MODULE_LOCATION[4]="/kernel/drivers/net"
650+DEST_MODULE_LOCATION[5]="/kernel/net/vsock"
651+AUTOINSTALL="YES"
652
653=== added file '.pc/04-quantal-module-backport.patch/modules/linux/dkms.sh'
654--- .pc/04-quantal-module-backport.patch/modules/linux/dkms.sh 1970-01-01 00:00:00 +0000
655+++ .pc/04-quantal-module-backport.patch/modules/linux/dkms.sh 2013-06-28 21:11:42 +0000
656@@ -0,0 +1,118 @@
657+#!/bin/sh
658+################################################################################
659+### Copyright 2009 VMware, Inc. All rights reserved.
660+###
661+### Script for creating a dmks-compliant source tree from an open-vm-tools
662+### distribution.
663+###
664+###
665+### This program is free software; you can redistribute it and/or modify
666+### it under the terms of version 2 of the GNU General Public License as
667+### published by the Free Software Foundation.
668+###
669+### This program is distributed in the hope that it will be useful,
670+### but WITHOUT ANY WARRANTY; without even the implied warranty of
671+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
672+### GNU General Public License for more details.
673+###
674+### You should have received a copy of the GNU General Public License
675+### along with this program; if not, write to the Free Software
676+### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
677+################################################################################
678+
679+if test -z "$1" -o -z "$2"
680+then
681+ echo "usage: $0 src dst"
682+ echo
683+ echo "Where:"
684+ echo " src: root of unpacked open-vm-tools package"
685+ echo " dst: where to create the dkms tree"
686+ echo
687+ echo "The script will create an 'open-vm-tools' module with version 2011.12.20."
688+ exit 1
689+fi
690+
691+src=$1
692+dst=$2/open-vm-tools-2011.12.20
693+
694+SHARED_HEADERS="backdoor_def.h"
695+SHARED_HEADERS="$SHARED_HEADERS backdoor_types.h"
696+SHARED_HEADERS="$SHARED_HEADERS circList.h"
697+SHARED_HEADERS="$SHARED_HEADERS community_source.h"
698+SHARED_HEADERS="$SHARED_HEADERS dbllnklst.h"
699+SHARED_HEADERS="$SHARED_HEADERS guest_msg_def.h"
700+SHARED_HEADERS="$SHARED_HEADERS includeCheck.h"
701+SHARED_HEADERS="$SHARED_HEADERS vm_assert.h"
702+SHARED_HEADERS="$SHARED_HEADERS vm_atomic.h"
703+SHARED_HEADERS="$SHARED_HEADERS vm_basic_asm.h"
704+SHARED_HEADERS="$SHARED_HEADERS vm_basic_asm_x86.h"
705+SHARED_HEADERS="$SHARED_HEADERS vm_basic_asm_x86_64.h"
706+SHARED_HEADERS="$SHARED_HEADERS vm_basic_defs.h"
707+SHARED_HEADERS="$SHARED_HEADERS vm_basic_math.h"
708+SHARED_HEADERS="$SHARED_HEADERS vm_basic_types.h"
709+SHARED_HEADERS="$SHARED_HEADERS vm_device_version.h"
710+SHARED_HEADERS="$SHARED_HEADERS vmci_sockets.h"
711+SHARED_HEADERS="$SHARED_HEADERS vmware.h"
712+SHARED_HEADERS="$SHARED_HEADERS vmware_pack_begin.h"
713+SHARED_HEADERS="$SHARED_HEADERS vmware_pack_end.h"
714+SHARED_HEADERS="$SHARED_HEADERS vmware_pack_init.h"
715+SHARED_HEADERS="$SHARED_HEADERS x86cpuid.h"
716+SHARED_HEADERS="$SHARED_HEADERS x86vendor.h"
717+SHARED_HEADERS="$SHARED_HEADERS x86cpuid_asm.h"
718+
719+rm -rf $dst
720+mkdir -p $dst
721+cp -f `dirname $0`/dkms.conf $dst
722+
723+for m in vmblock vmci vmhgfs vmsync vmxnet vsock
724+do
725+ mdst="$dst/$m"
726+
727+ cp -rf $src/modules/linux/$m $mdst
728+ cp -rf $src/modules/linux/shared $mdst
729+ for h in $SHARED_HEADERS
730+ do
731+ cp -f $src/lib/include/$h $mdst/shared
732+ done
733+
734+ # Shared vmblock code.
735+ if test $m = vmblock
736+ then
737+ cp -f $src/lib/include/vmblock.h $mdst/linux
738+ cp -rf $src/modules/shared/vmblock/* $mdst/linux
739+ fi
740+
741+ # Backdoor library (for vmhgfs and vmmemctl).
742+ if test $m = vmhgfs -o $m = vmmemctl
743+ then
744+ cp -f $src/lib/include/backdoor.h $mdst
745+ cp -f $src/lib/backdoor/*.c $src/lib/backdoor/*.h $mdst
746+ fi
747+
748+ # Other libraries used by vmhgfs
749+ if test $m = vmhgfs
750+ then
751+ cp -f $src/lib/include/cpName*.h $mdst
752+ cp -f $src/lib/include/escBitvector.h $mdst
753+ cp -f $src/lib/include/hgfs*.h $mdst
754+ cp -f $src/lib/include/message.h $mdst
755+ cp -f $src/lib/include/rpcout.h $mdst
756+ cp -f $src/lib/hgfs/*.c $src/lib/hgfs/*.h $mdst
757+ cp -f $src/lib/hgfsBd/*.c $mdst
758+ cp -f $src/lib/message/*.c $mdst
759+ cp -f $src/lib/rpcOut/*.c $mdst
760+ fi
761+
762+ # Extra header file for vmsync.
763+ if test $m = vmsync
764+ then
765+ cp -f $src/lib/include/syncDriverIoc.h $mdst
766+ fi
767+
768+ # Shared vmxnet headers.
769+ if test $m = vmxnet
770+ then
771+ cp -f $src/modules/shared/vmxnet/* $mdst/shared
772+ fi
773+done
774+
775
776=== added directory '.pc/04-quantal-module-backport.patch/modules/linux/shared'
777=== added directory '.pc/04-quantal-module-backport.patch/modules/linux/shared/autoconf'
778=== added file '.pc/04-quantal-module-backport.patch/modules/linux/shared/autoconf/file_operations_fsync.c'
779=== added file '.pc/04-quantal-module-backport.patch/modules/linux/shared/compat_ethtool.h'
780--- .pc/04-quantal-module-backport.patch/modules/linux/shared/compat_ethtool.h 1970-01-01 00:00:00 +0000
781+++ .pc/04-quantal-module-backport.patch/modules/linux/shared/compat_ethtool.h 2013-06-28 21:11:42 +0000
782@@ -0,0 +1,54 @@
783+/*********************************************************
784+ * Copyright (C) 2007 VMware, Inc. All rights reserved.
785+ *
786+ * This program is free software; you can redistribute it and/or modify it
787+ * under the terms of the GNU General Public License as published by the
788+ * Free Software Foundation version 2 and no later version.
789+ *
790+ * This program is distributed in the hope that it will be useful, but
791+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
792+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
793+ * for more details.
794+ *
795+ * You should have received a copy of the GNU General Public License along
796+ * with this program; if not, write to the Free Software Foundation, Inc.,
797+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
798+ *
799+ *********************************************************/
800+
801+#ifndef _COMPAT_ETHTOOL_H
802+#define _COMPAT_ETHTOOL_H
803+
804+/*
805+ * ethtool is a userspace utility for getting and setting ethernet device
806+ * settings. Kernel support for it was first published in 2.4.0-test11, but
807+ * only in 2.4.15 were the ethtool_value struct and the ETHTOOL_GLINK ioctl
808+ * added to ethtool.h (together, because the ETHTOOL_GLINK ioctl expects a
809+ * single value response).
810+ *
811+ * Likewise, ioctls for getting and setting TSO were published in 2.4.22.
812+ */
813+
814+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
815+# include <linux/ethtool.h>
816+
817+# ifndef ETHTOOL_GLINK
818+# define ETHTOOL_GLINK 0x0a
819+
820+typedef struct {
821+ __u32 cmd;
822+ __u32 data;
823+} compat_ethtool_value;
824+
825+# else
826+
827+typedef struct ethtool_value compat_ethtool_value;
828+# endif
829+
830+# ifndef ETHTOOL_GTSO
831+# define ETHTOOL_GTSO 0x1E
832+# define ETHTOOL_STSO 0x1F
833+# endif
834+#endif
835+
836+#endif /* _COMPAT_ETHTOOL_H */
837
838=== added file '.pc/04-quantal-module-backport.patch/modules/linux/shared/compat_fs.h'
839--- .pc/04-quantal-module-backport.patch/modules/linux/shared/compat_fs.h 1970-01-01 00:00:00 +0000
840+++ .pc/04-quantal-module-backport.patch/modules/linux/shared/compat_fs.h 2013-06-28 21:11:42 +0000
841@@ -0,0 +1,251 @@
842+/*********************************************************
843+ * Copyright (C) 2006 VMware, Inc. All rights reserved.
844+ *
845+ * This program is free software; you can redistribute it and/or modify it
846+ * under the terms of the GNU General Public License as published by the
847+ * Free Software Foundation version 2 and no later version.
848+ *
849+ * This program is distributed in the hope that it will be useful, but
850+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
851+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
852+ * for more details.
853+ *
854+ * You should have received a copy of the GNU General Public License along
855+ * with this program; if not, write to the Free Software Foundation, Inc.,
856+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
857+ *
858+ *********************************************************/
859+
860+#ifndef __COMPAT_FS_H__
861+# define __COMPAT_FS_H__
862+
863+#include <linux/fs.h>
864+
865+/*
866+ * 2.6.5+ kernels define FS_BINARY_MOUNTDATA. Since it didn't exist and
867+ * wasn't used prior, it's safe to define it to zero.
868+ */
869+
870+#ifndef FS_BINARY_MOUNTDATA
871+#define FS_BINARY_MOUNTDATA 0
872+#endif
873+
874+/*
875+ * MAX_LFS_FILESIZE wasn't defined until 2.5.4.
876+ */
877+#ifndef MAX_LFS_FILESIZE
878+# include <linux/pagemap.h>
879+# if BITS_PER_LONG == 32
880+# define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG - 1)) - 1)
881+# elif BITS_PER_LONG == 64
882+# define MAX_LFS_FILESIZE 0x7fffffffffffffffUL
883+# endif
884+#endif
885+
886+
887+/*
888+ * sendfile as a VFS op was born in 2.5.30. Unfortunately, it also changed
889+ * signatures, first in 2.5.47, then again in 2.5.70, then again in 2.6.8.
890+ * Luckily, the 2.6.8+ signature is the same as the 2.5.47 signature. And
891+ * as of 2.6.23-rc1 sendfile is gone, replaced by splice_read...
892+ *
893+ * Let's not support sendfile from 2.5.30 to 2.5.47, because the 2.5.30
894+ * signature is much different and file_send_actor isn't externed.
895+ */
896+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23)
897+#define VMW_SENDFILE_NONE
898+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
899+#define VMW_SENDFILE_NEW
900+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 70)
901+#define VMW_SENDFILE_OLD
902+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 47)
903+#define VMW_SENDFILE_NEW
904+#else
905+#define VMW_SENDFILE_NONE
906+#endif
907+
908+/*
909+ * splice_read is there since 2.6.17, but let's avoid 2.6.17-rcX kernels...
910+ * After all nobody is using splice system call until 2.6.23 using it to
911+ * implement sendfile.
912+ */
913+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
914+#define VMW_SPLICE_READ 1
915+#endif
916+
917+/*
918+ * Filesystems wishing to use generic page cache read/write routines are
919+ * supposed to implement aio_read and aio_write (calling into
920+ * generic_file_aio_read() and generic_file_aio_write() if necessary).
921+ *
922+ * The VFS exports do_sync_read() and do_sync_write() as the "new"
923+ * generic_file_read() and generic_file_write(), but filesystems need not
924+ * actually implement read and write- the VFS will automatically call
925+ * do_sync_write() and do_sync_read() when applications invoke the standard
926+ * read() and write() system calls.
927+ *
928+ * In 2.6.19, generic_file_read() and generic_file_write() were removed,
929+ * necessitating this change. AIO dates as far back as 2.5.42, but the API has
930+ * changed over time, so for simplicity, we'll only enable it from 2.6.19 and
931+ * on.
932+ */
933+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
934+# define VMW_USE_AIO
935+#endif
936+
937+
938+/*
939+ * The alloc_inode and destroy_inode VFS ops didn't exist prior to 2.4.21.
940+ * Without these functions, file systems can't embed inodes.
941+ */
942+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 21)
943+# define VMW_EMBED_INODE
944+#endif
945+
946+
947+/*
948+ * iget() was removed from the VFS as of 2.6.25-rc1. The replacement for iget()
949+ * is iget_locked() which was added in 2.5.17.
950+ */
951+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 17)
952+# define VMW_USE_IGET_LOCKED
953+#endif
954+
955+/*
956+ * parent_ino was born in 2.5.5. For older kernels, let's use 2.5.5
957+ * implementation. It uses the dcache lock which is OK because per-dentry
958+ * locking appeared after 2.5.5.
959+ */
960+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 5)
961+#define compat_parent_ino(dentry) parent_ino(dentry)
962+#else
963+#define compat_parent_ino(dentry) \
964+({ \
965+ ino_t res; \
966+ spin_lock(&dcache_lock); \
967+ res = dentry->d_parent->d_inode->i_ino; \
968+ spin_unlock(&dcache_lock); \
969+ res; \
970+})
971+#endif
972+
973+
974+/*
975+ * putname changed to __putname in 2.6.6.
976+ */
977+#define compat___getname() __getname()
978+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 6)
979+#define compat___putname(name) putname(name)
980+#else
981+#define compat___putname(name) __putname(name)
982+#endif
983+
984+
985+/*
986+ * inc_nlink, drop_nlink, and clear_nlink were added in 2.6.19.
987+ */
988+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
989+#define compat_inc_nlink(inode) ((inode)->i_nlink++)
990+#define compat_drop_nlink(inode) ((inode)->i_nlink--)
991+#define compat_clear_nlink(inode) ((inode)->i_nlink = 0)
992+#else
993+#define compat_inc_nlink(inode) inc_nlink(inode)
994+#define compat_drop_nlink(inode) drop_nlink(inode)
995+#define compat_clear_nlink(inode) clear_nlink(inode)
996+#endif
997+
998+
999+/*
1000+ * i_size_write and i_size_read were introduced in 2.6.0-test1
1001+ * (though we'll look for them as of 2.6.1). They employ slightly different
1002+ * locking in order to guarantee atomicity, depending on the length of a long,
1003+ * whether the kernel is SMP, or whether the kernel is preemptible. Prior to
1004+ * i_size_write and i_size_read, there was no such locking, so that's the
1005+ * behavior we'll emulate.
1006+ */
1007+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 1)
1008+#define compat_i_size_read(inode) ((inode)->i_size)
1009+#define compat_i_size_write(inode, size) ((inode)->i_size = size)
1010+#else
1011+#define compat_i_size_read(inode) i_size_read(inode)
1012+#define compat_i_size_write(inode, size) i_size_write(inode, size)
1013+#endif
1014+
1015+
1016+/*
1017+ * filemap_fdatawrite was introduced in 2.5.12. Prior to that, modules used
1018+ * filemap_fdatasync instead. In 2.4.18, both filemap_fdatawrite and
1019+ * filemap_fdatawait began returning status codes. Prior to that, they were
1020+ * void functions, so we'll just have them return 0.
1021+ */
1022+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 18)
1023+#define compat_filemap_fdatawrite(mapping) \
1024+({ \
1025+ int result = 0; \
1026+ filemap_fdatasync(mapping); \
1027+ result; \
1028+})
1029+#define compat_filemap_fdatawait(mapping) \
1030+({ \
1031+ int result = 0; \
1032+ filemap_fdatawait(mapping); \
1033+ result; \
1034+})
1035+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 12)
1036+#define compat_filemap_fdatawrite(mapping) filemap_fdatasync(mapping)
1037+#define compat_filemap_fdatawait(mapping) filemap_fdatawait(mapping)
1038+#else
1039+#define compat_filemap_fdatawrite(mapping) filemap_fdatawrite(mapping)
1040+#define compat_filemap_fdatawait(mapping) filemap_fdatawait(mapping)
1041+#endif
1042+
1043+
1044+/*
1045+ * filemap_write_and_wait was introduced in 2.6.6 and exported for module use
1046+ * in 2.6.16. It's really just a simple wrapper around filemap_fdatawrite and
1047+ * and filemap_fdatawait, which initiates a flush of all dirty pages, then
1048+ * waits for the pages to flush. The implementation here is a simplified form
1049+ * of the one found in 2.6.20-rc3.
1050+ *
1051+ * Unfortunately, it just isn't possible to implement this prior to 2.4.5, when
1052+ * neither filemap_fdatawait nor filemap_fdatasync were exported for module
1053+ * use. So we'll define it out and hope for the best.
1054+ */
1055+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 5)
1056+#define compat_filemap_write_and_wait(mapping)
1057+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
1058+#define compat_filemap_write_and_wait(mapping) \
1059+({ \
1060+ int result = 0; \
1061+ if (mapping->nrpages) { \
1062+ result = compat_filemap_fdatawrite(mapping); \
1063+ if (result != -EIO) { \
1064+ int result2 = compat_filemap_fdatawait(mapping); \
1065+ if (!result) { \
1066+ result = result2; \
1067+ } \
1068+ } \
1069+ } \
1070+ result; \
1071+})
1072+#else
1073+#define compat_filemap_write_and_wait(mapping) filemap_write_and_wait(mapping)
1074+#endif
1075+
1076+
1077+/*
1078+ * invalidate_remote_inode was introduced in 2.6.0-test5. Prior to that,
1079+ * filesystems wishing to invalidate pages belonging to an inode called
1080+ * invalidate_inode_pages.
1081+ */
1082+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
1083+#define compat_invalidate_remote_inode(inode) invalidate_inode_pages(inode)
1084+#else
1085+#define compat_invalidate_remote_inode(inode) invalidate_remote_inode(inode)
1086+#endif
1087+
1088+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
1089+#define VMW_FSYNC_OLD
1090+#endif
1091+
1092+#endif /* __COMPAT_FS_H__ */
1093
1094=== added file '.pc/04-quantal-module-backport.patch/modules/linux/shared/compat_netdevice.h'
1095--- .pc/04-quantal-module-backport.patch/modules/linux/shared/compat_netdevice.h 1970-01-01 00:00:00 +0000
1096+++ .pc/04-quantal-module-backport.patch/modules/linux/shared/compat_netdevice.h 2013-06-28 21:11:42 +0000
1097@@ -0,0 +1,334 @@
1098+/*********************************************************
1099+ * Copyright (C) 2002 VMware, Inc. All rights reserved.
1100+ *
1101+ * This program is free software; you can redistribute it and/or modify it
1102+ * under the terms of the GNU General Public License as published by the
1103+ * Free Software Foundation version 2 and no later version.
1104+ *
1105+ * This program is distributed in the hope that it will be useful, but
1106+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1107+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1108+ * for more details.
1109+ *
1110+ * You should have received a copy of the GNU General Public License along
1111+ * with this program; if not, write to the Free Software Foundation, Inc.,
1112+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1113+ *
1114+ *********************************************************/
1115+
1116+#ifndef __COMPAT_NETDEVICE_H__
1117+# define __COMPAT_NETDEVICE_H__
1118+
1119+
1120+#include <linux/skbuff.h>
1121+#include <linux/rtnetlink.h>
1122+#include <linux/netdevice.h>
1123+#include <linux/etherdevice.h>
1124+#include <linux/pci.h>
1125+
1126+/*
1127+ * The enet_statistics structure moved from linux/if_ether.h to
1128+ * linux/netdevice.h and is renamed net_device_stats in 2.1.25 --hpreg
1129+ */
1130+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 1, 25)
1131+# include <linux/if_ether.h>
1132+
1133+# define net_device_stats enet_statistics
1134+#endif
1135+
1136+
1137+/* The netif_rx_ni() API appeared in 2.4.8 --hpreg */
1138+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 8)
1139+# define netif_rx_ni netif_rx
1140+#endif
1141+
1142+
1143+/* The device struct was renamed net_device in 2.3.14 --hpreg */
1144+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 14)
1145+# define net_device device
1146+#endif
1147+
1148+
1149+/*
1150+ * SET_MODULE_OWNER appeared sometime during 2.3.x. It was setting
1151+ * dev->owner = THIS_MODULE until 2.5.70, where netdevice refcounting
1152+ * was completely changed. SET_MODULE_OWNER was nop for whole
1153+ * 2.6.x series, and finally disappeared in 2.6.24.
1154+ *
1155+ * MOD_xxx_USE_COUNT wrappers are here, as they must be mutually
1156+ * exclusive with SET_MODULE_OWNER call.
1157+ */
1158+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
1159+# define COMPAT_SET_MODULE_OWNER(dev) do {} while (0)
1160+# define COMPAT_NETDEV_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
1161+# define COMPAT_NETDEV_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
1162+#else
1163+# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
1164+# define COMPAT_SET_MODULE_OWNER(dev) SET_MODULE_OWNER(dev)
1165+# else
1166+# define COMPAT_SET_MODULE_OWNER(dev) do {} while (0)
1167+# endif
1168+# define COMPAT_NETDEV_MOD_INC_USE_COUNT do {} while (0)
1169+# define COMPAT_NETDEV_MOD_DEC_USE_COUNT do {} while (0)
1170+#endif
1171+
1172+/*
1173+ * SET_NETDEV_DEV appeared sometime during 2.5.x, and later was
1174+ * crossported to various 2.4.x kernels (as dummy macro).
1175+ */
1176+#ifdef SET_NETDEV_DEV
1177+# define COMPAT_SET_NETDEV_DEV(dev, pdev) SET_NETDEV_DEV(dev, pdev)
1178+#else
1179+# define COMPAT_SET_NETDEV_DEV(dev, pdev) do {} while (0)
1180+#endif
1181+
1182+/*
1183+ * Build alloc_etherdev API on the top of init_etherdev. For 2.0.x kernels
1184+ * we must provide dummy init method, otherwise register_netdev does
1185+ * nothing.
1186+ */
1187+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3)
1188+
1189+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 0)
1190+int
1191+vmware_dummy_init(struct net_device *dev)
1192+{
1193+ return 0;
1194+}
1195+#endif
1196+
1197+
1198+static inline struct net_device*
1199+compat_alloc_etherdev(int priv_size)
1200+{
1201+ struct net_device* dev;
1202+ int size = sizeof *dev + priv_size;
1203+
1204+ /*
1205+ * The name is dynamically allocated before 2.4.0, but
1206+ * is an embedded array in later kernels.
1207+ */
1208+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
1209+ size += sizeof("ethXXXXXXX");
1210+#endif
1211+ dev = kmalloc(size, GFP_KERNEL);
1212+ if (dev) {
1213+ memset(dev, 0, size);
1214+ if (priv_size) {
1215+ dev->priv = dev + 1;
1216+ }
1217+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
1218+ dev->name = (char *)(dev + 1) + priv_size;
1219+#endif
1220+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 0)
1221+ dev->init = vmware_dummy_init;
1222+#endif
1223+ if (init_etherdev(dev, 0) != dev) {
1224+ kfree(dev);
1225+ dev = NULL;
1226+ }
1227+ }
1228+ return dev;
1229+}
1230+#else
1231+#define compat_alloc_etherdev(sz) alloc_etherdev(sz)
1232+#endif
1233+
1234+
1235+/*
1236+ * alloc_netdev and free_netdev are there since 2.4.23. Their use is mandatory
1237+ * since 2.6.24.
1238+ */
1239+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 23)
1240+static inline struct net_device *
1241+compat_alloc_netdev(int priv_size,
1242+ const char *mask,
1243+ void (*setup)(struct net_device *))
1244+{
1245+ struct net_device *dev;
1246+ int netdev_size = sizeof *dev;
1247+ int alloc_size;
1248+
1249+# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
1250+ netdev_size += IFNAMSIZ;
1251+# endif
1252+
1253+ alloc_size = netdev_size + priv_size;
1254+ dev = kmalloc(alloc_size, GFP_KERNEL);
1255+ if (dev) {
1256+ memset(dev, 0, alloc_size);
1257+ dev->priv = (char*)dev + netdev_size;
1258+ setup(dev);
1259+# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
1260+ dev->name = (char*)(dev + 1);
1261+# endif
1262+ strcpy(dev->name, mask);
1263+ }
1264+ return dev;
1265+}
1266+# define compat_free_netdev(dev) kfree(dev)
1267+#else
1268+# define compat_alloc_netdev(size, mask, setup) alloc_netdev(size, mask, setup)
1269+# define compat_free_netdev(dev) free_netdev(dev)
1270+#endif
1271+
1272+/* netdev_priv() appeared in 2.6.3 */
1273+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3)
1274+# define compat_netdev_priv(netdev) (netdev)->priv
1275+#else
1276+# define compat_netdev_priv(netdev) netdev_priv(netdev)
1277+#endif
1278+
1279+/*
1280+ * In 3.1 merge window feature maros were removed from mainline,
1281+ * so let's add back ones we care about.
1282+ */
1283+#if !defined(HAVE_NET_DEVICE_OPS) && \
1284+ LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
1285+# define HAVE_NET_DEVICE_OPS 1
1286+#endif
1287+
1288+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9)
1289+# define COMPAT_NETDEV_TX_OK NETDEV_TX_OK
1290+# define COMPAT_NETDEV_TX_BUSY NETDEV_TX_BUSY
1291+#else
1292+# define COMPAT_NETDEV_TX_OK 0
1293+# define COMPAT_NETDEV_TX_BUSY 1
1294+#endif
1295+
1296+/* unregister_netdevice_notifier was not safe prior to 2.6.17 */
1297+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17) && \
1298+ !defined(ATOMIC_NOTIFIER_INIT)
1299+/* pre 2.6.17 and not patched */
1300+static inline int compat_unregister_netdevice_notifier(struct notifier_block *nb) {
1301+ int err;
1302+
1303+ rtnl_lock();
1304+ err = unregister_netdevice_notifier(nb);
1305+ rtnl_unlock();
1306+ return err;
1307+}
1308+#else
1309+/* post 2.6.17 or patched */
1310+#define compat_unregister_netdevice_notifier(_nb) \
1311+ unregister_netdevice_notifier(_nb);
1312+#endif
1313+
1314+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) || defined(__VMKLNX__)
1315+
1316+# define compat_netif_napi_add(dev, napi, poll, quota) \
1317+ netif_napi_add(dev, napi, poll, quota)
1318+
1319+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) || \
1320+ defined VMW_NETIF_SINGLE_NAPI_PARM
1321+# define compat_napi_complete(dev, napi) napi_complete(napi)
1322+# define compat_napi_schedule(dev, napi) napi_schedule(napi)
1323+# else
1324+# define compat_napi_complete(dev, napi) netif_rx_complete(dev, napi)
1325+# define compat_napi_schedule(dev, napi) netif_rx_schedule(dev, napi)
1326+# endif
1327+
1328+# define compat_napi_enable(dev, napi) napi_enable(napi)
1329+# define compat_napi_disable(dev, napi) napi_disable(napi)
1330+
1331+#else
1332+
1333+# define compat_napi_complete(dev, napi) netif_rx_complete(dev)
1334+# define compat_napi_schedule(dev, napi) netif_rx_schedule(dev)
1335+# define compat_napi_enable(dev, napi) netif_poll_enable(dev)
1336+# define compat_napi_disable(dev, napi) netif_poll_disable(dev)
1337+
1338+/* RedHat ported GRO to 2.6.18 bringing new napi_struct with it */
1339+# if defined NETIF_F_GRO
1340+# define compat_netif_napi_add(netdev, napi, pollcb, quota) \
1341+ do { \
1342+ (netdev)->poll = (pollcb); \
1343+ (netdev)->weight = (quota);\
1344+ (napi)->dev = (netdev); \
1345+ } while (0)
1346+
1347+# else
1348+ struct napi_struct {
1349+ int dummy;
1350+ };
1351+# define compat_netif_napi_add(dev, napi, pollcb, quota) \
1352+ do { \
1353+ (dev)->poll = (pollcb); \
1354+ (dev)->weight = (quota);\
1355+ } while (0)
1356+
1357+# endif
1358+
1359+#endif
1360+
1361+#ifdef NETIF_F_TSO6
1362+# define COMPAT_NETIF_F_TSO (NETIF_F_TSO6 | NETIF_F_TSO)
1363+#else
1364+# define COMPAT_NETIF_F_TSO (NETIF_F_TSO)
1365+#endif
1366+
1367+
1368+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
1369+# define compat_netif_tx_lock(dev) netif_tx_lock(dev)
1370+# define compat_netif_tx_unlock(dev) netif_tx_unlock(dev)
1371+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
1372+# define compat_netif_tx_lock(dev) spin_lock(&dev->xmit_lock)
1373+# define compat_netif_tx_unlock(dev) spin_unlock(&dev->xmit_lock)
1374+#else
1375+/* Vendor backporting (SLES 10) has muddled the tx_lock situation. Pick whichever
1376+ * of the above works for you. */
1377+# define compat_netif_tx_lock(dev) do {} while (0)
1378+# define compat_netif_tx_unlock(dev) do {} while (0)
1379+#endif
1380+
1381+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
1382+# define COMPAT_VLAN_GROUP_ARRAY_LEN VLAN_N_VID
1383+# define compat_flush_scheduled_work(work) cancel_work_sync(work)
1384+#else
1385+# define COMPAT_VLAN_GROUP_ARRAY_LEN VLAN_GROUP_ARRAY_LEN
1386+# define compat_flush_scheduled_work(work) flush_scheduled_work()
1387+#endif
1388+
1389+
1390+
1391+/*
1392+ * For kernel versions older than 2.6.29, where pci_msi_enabled is not
1393+ * available, check if
1394+ * 1. CONFIG_PCI_MSI is present
1395+ * 2. kernel version is newer than 2.6.25 (because multiqueue is not
1396+ * supporter) in kernels older than that)
1397+ * 3. msi can be enabled. If it fails it means that MSI is not available.
1398+ * When all the above are true, return non-zero so that multiple queues will be
1399+ * allowed in the driver.
1400+ */
1401+
1402+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
1403+# define compat_multiqueue_allowed(dev) pci_msi_enabled()
1404+#else
1405+# if defined CONFIG_PCI_MSI && LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 25)
1406+static inline int
1407+compat_multiqueue_allowed(struct pci_dev *dev)
1408+{
1409+ int ret;
1410+
1411+ if (!pci_enable_msi(dev))
1412+ ret = 1;
1413+ else
1414+ ret = 0;
1415+
1416+ pci_disable_msi(dev);
1417+ return ret;
1418+}
1419+
1420+# else
1421+# define compat_multiqueue_allowed(dev) (0)
1422+# endif
1423+#endif
1424+
1425+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
1426+# define compat_vlan_get_protocol(skb) vlan_get_protocol(skb)
1427+#else
1428+# define compat_vlan_get_protocol(skb) (skb->protocol)
1429+#endif
1430+
1431+#endif /* __COMPAT_NETDEVICE_H__ */
1432
1433=== added file '.pc/04-quantal-module-backport.patch/modules/linux/shared/vmciKernelAPI1.h'
1434--- .pc/04-quantal-module-backport.patch/modules/linux/shared/vmciKernelAPI1.h 1970-01-01 00:00:00 +0000
1435+++ .pc/04-quantal-module-backport.patch/modules/linux/shared/vmciKernelAPI1.h 2013-06-28 21:11:42 +0000
1436@@ -0,0 +1,191 @@
1437+/*********************************************************
1438+ * Copyright (C) 2010 VMware, Inc. All rights reserved.
1439+ *
1440+ * This program is free software; you can redistribute it and/or modify it
1441+ * under the terms of the GNU General Public License as published by the
1442+ * Free Software Foundation version 2 and no later version.
1443+ *
1444+ * This program is distributed in the hope that it will be useful, but
1445+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1446+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1447+ * for more details.
1448+ *
1449+ * You should have received a copy of the GNU General Public License along
1450+ * with this program; if not, write to the Free Software Foundation, Inc.,
1451+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1452+ *
1453+ *********************************************************/
1454+
1455+/*
1456+ * vmciKernelAPI1.h --
1457+ *
1458+ * Kernel API (v1) exported from the VMCI host and guest drivers.
1459+ */
1460+
1461+#ifndef __VMCI_KERNELAPI_1_H__
1462+#define __VMCI_KERNELAPI_1_H__
1463+
1464+#define INCLUDE_ALLOW_MODULE
1465+#define INCLUDE_ALLOW_VMK_MODULE
1466+#define INCLUDE_ALLOW_VMKERNEL
1467+#include "includeCheck.h"
1468+
1469+#include "vmci_defs.h"
1470+#include "vmci_call_defs.h"
1471+
1472+
1473+/* VMCI module namespace on vmkernel. */
1474+
1475+#define MOD_VMCI_NAMESPACE "com.vmware.vmci"
1476+
1477+/* Define version 1. */
1478+
1479+#undef VMCI_KERNEL_API_VERSION
1480+#define VMCI_KERNEL_API_VERSION_1 1
1481+#define VMCI_KERNEL_API_VERSION VMCI_KERNEL_API_VERSION_1
1482+
1483+/* Macros to operate on the driver version number. */
1484+
1485+#define VMCI_MAJOR_VERSION(v) (((v) >> 16) & 0xffff)
1486+#define VMCI_MINOR_VERSION(v) ((v) & 0xffff)
1487+
1488+/* VMCI Device Usage API. */
1489+
1490+typedef void (VMCI_DeviceShutdownFn)(void *deviceRegistration,
1491+ void *userData);
1492+
1493+Bool VMCI_DeviceGet(uint32 *apiVersion, VMCI_DeviceShutdownFn *deviceShutdownCB,
1494+ void *userData, void **deviceRegistration);
1495+void VMCI_DeviceRelease(void *deviceRegistration);
1496+
1497+/* VMCI Datagram API. */
1498+
1499+int VMCIDatagram_CreateHnd(VMCIId resourceID, uint32 flags,
1500+ VMCIDatagramRecvCB recvCB, void *clientData,
1501+ VMCIHandle *outHandle);
1502+int VMCIDatagram_CreateHndPriv(VMCIId resourceID, uint32 flags,
1503+ VMCIPrivilegeFlags privFlags,
1504+ VMCIDatagramRecvCB recvCB, void *clientData,
1505+ VMCIHandle *outHandle);
1506+int VMCIDatagram_DestroyHnd(VMCIHandle handle);
1507+int VMCIDatagram_Send(VMCIDatagram *msg);
1508+
1509+/* VMCI Utility API. */
1510+
1511+VMCIId VMCI_GetContextID(void);
1512+uint32 VMCI_Version(void);
1513+int VMCI_ContextID2HostVmID(VMCIId contextID, void *hostVmID,
1514+ size_t hostVmIDLen);
1515+int VMCI_IsContextOwner(VMCIId contextID, void *hostUser);
1516+
1517+/* VMCI Event API. */
1518+
1519+typedef void (*VMCI_EventCB)(VMCIId subID, VMCI_EventData *ed,
1520+ void *clientData);
1521+
1522+int VMCIEvent_Subscribe(VMCI_Event event, uint32 flags, VMCI_EventCB callback,
1523+ void *callbackData, VMCIId *subID);
1524+int VMCIEvent_Unsubscribe(VMCIId subID);
1525+
1526+/* VMCI Context API */
1527+
1528+VMCIPrivilegeFlags VMCIContext_GetPrivFlags(VMCIId contextID);
1529+
1530+/* VMCI Queue Pair API. */
1531+
1532+typedef struct VMCIQPair VMCIQPair;
1533+
1534+int VMCIQPair_Alloc(VMCIQPair **qpair,
1535+ VMCIHandle *handle,
1536+ uint64 produceQSize,
1537+ uint64 consumeQSize,
1538+ VMCIId peer,
1539+ uint32 flags,
1540+ VMCIPrivilegeFlags privFlags);
1541+
1542+int VMCIQPair_Detach(VMCIQPair **qpair);
1543+
1544+int VMCIQPair_GetProduceIndexes(const VMCIQPair *qpair,
1545+ uint64 *producerTail,
1546+ uint64 *consumerHead);
1547+int VMCIQPair_GetConsumeIndexes(const VMCIQPair *qpair,
1548+ uint64 *consumerTail,
1549+ uint64 *producerHead);
1550+int64 VMCIQPair_ProduceFreeSpace(const VMCIQPair *qpair);
1551+int64 VMCIQPair_ProduceBufReady(const VMCIQPair *qpair);
1552+int64 VMCIQPair_ConsumeFreeSpace(const VMCIQPair *qpair);
1553+int64 VMCIQPair_ConsumeBufReady(const VMCIQPair *qpair);
1554+ssize_t VMCIQPair_Enqueue(VMCIQPair *qpair,
1555+ const void *buf,
1556+ size_t bufSize,
1557+ int mode);
1558+ssize_t VMCIQPair_Dequeue(VMCIQPair *qpair,
1559+ void *buf,
1560+ size_t bufSize,
1561+ int mode);
1562+ssize_t VMCIQPair_Peek(VMCIQPair *qpair,
1563+ void *buf,
1564+ size_t bufSize,
1565+ int mode);
1566+
1567+#if defined (SOLARIS) || (defined(__APPLE__) && !defined (VMX86_TOOLS)) || \
1568+ (defined(__linux__) && defined(__KERNEL__)) || \
1569+ (defined(_WIN32) && defined(WINNT_DDK))
1570+/*
1571+ * Environments that support struct iovec
1572+ */
1573+
1574+ssize_t VMCIQPair_EnqueueV(VMCIQPair *qpair,
1575+ void *iov,
1576+ size_t iovSize,
1577+ int mode);
1578+ssize_t VMCIQPair_DequeueV(VMCIQPair *qpair,
1579+ void *iov,
1580+ size_t iovSize,
1581+ int mode);
1582+ssize_t VMCIQPair_PeekV(VMCIQPair *qpair,
1583+ void *iov,
1584+ size_t iovSize,
1585+ int mode);
1586+#endif /* Systems that support struct iovec */
1587+
1588+
1589+/* Typedefs for all of the above, used by the IOCTLs and the kernel library. */
1590+
1591+typedef void (VMCI_DeviceReleaseFct)(void *);
1592+typedef int (VMCIDatagram_CreateHndFct)(VMCIId, uint32, VMCIDatagramRecvCB,
1593+ void *, VMCIHandle *);
1594+typedef int (VMCIDatagram_CreateHndPrivFct)(VMCIId, uint32, VMCIPrivilegeFlags,
1595+ VMCIDatagramRecvCB, void *,
1596+ VMCIHandle *);
1597+typedef int (VMCIDatagram_DestroyHndFct)(VMCIHandle);
1598+typedef int (VMCIDatagram_SendFct)(VMCIDatagram *);
1599+typedef VMCIId (VMCI_GetContextIDFct)(void);
1600+typedef uint32 (VMCI_VersionFct)(void);
1601+typedef int (VMCI_ContextID2HostVmIDFct)(VMCIId, void *, size_t);
1602+typedef int (VMCI_IsContextOwnerFct)(VMCIId, void *);
1603+typedef int (VMCIEvent_SubscribeFct)(VMCI_Event, uint32, VMCI_EventCB, void *,
1604+ VMCIId *);
1605+typedef int (VMCIEvent_UnsubscribeFct)(VMCIId);
1606+typedef VMCIPrivilegeFlags (VMCIContext_GetPrivFlagsFct)(VMCIId);
1607+typedef int (VMCIQPair_AllocFct)(VMCIQPair **, VMCIHandle *, uint64, uint64,
1608+ VMCIId, uint32, VMCIPrivilegeFlags);
1609+typedef int (VMCIQPair_DetachFct)(VMCIQPair **);
1610+typedef int (VMCIQPair_GetProduceIndexesFct)(const VMCIQPair *, uint64 *,
1611+ uint64 *);
1612+typedef int (VMCIQPair_GetConsumeIndexesFct)(const VMCIQPair *, uint64 *,
1613+ uint64 *);
1614+typedef int64 (VMCIQPair_ProduceFreeSpaceFct)(const VMCIQPair *);
1615+typedef int64 (VMCIQPair_ProduceBufReadyFct)(const VMCIQPair *);
1616+typedef int64 (VMCIQPair_ConsumeFreeSpaceFct)(const VMCIQPair *);
1617+typedef int64 (VMCIQPair_ConsumeBufReadyFct)(const VMCIQPair *);
1618+typedef ssize_t (VMCIQPair_EnqueueFct)(VMCIQPair *, const void *, size_t, int);
1619+typedef ssize_t (VMCIQPair_DequeueFct)(VMCIQPair *, void *, size_t, int);
1620+typedef ssize_t (VMCIQPair_PeekFct)(VMCIQPair *, void *, size_t, int);
1621+typedef ssize_t (VMCIQPair_EnqueueVFct)(VMCIQPair *qpair, void *, size_t, int);
1622+typedef ssize_t (VMCIQPair_DequeueVFct)(VMCIQPair *qpair, void *, size_t, int);
1623+typedef ssize_t (VMCIQPair_PeekVFct)(VMCIQPair *qpair, void *, size_t, int);
1624+
1625+
1626+#endif /* !__VMCI_KERNELAPI_1_H__ */
1627+
1628
1629=== added file '.pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_defs.h'
1630--- .pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_defs.h 1970-01-01 00:00:00 +0000
1631+++ .pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_defs.h 2013-06-28 21:11:42 +0000
1632@@ -0,0 +1,831 @@
1633+/*********************************************************
1634+ * Copyright (C) 2005-2011 VMware, Inc. All rights reserved.
1635+ *
1636+ * This program is free software; you can redistribute it and/or modify it
1637+ * under the terms of the GNU General Public License as published by the
1638+ * Free Software Foundation version 2 and no later version.
1639+ *
1640+ * This program is distributed in the hope that it will be useful, but
1641+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1642+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1643+ * for more details.
1644+ *
1645+ * You should have received a copy of the GNU General Public License along
1646+ * with this program; if not, write to the Free Software Foundation, Inc.,
1647+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1648+ *
1649+ *********************************************************/
1650+
1651+#ifndef _VMCI_DEF_H_
1652+#define _VMCI_DEF_H_
1653+
1654+#define INCLUDE_ALLOW_USERLEVEL
1655+#define INCLUDE_ALLOW_VMMEXT
1656+#define INCLUDE_ALLOW_MODULE
1657+#define INCLUDE_ALLOW_VMMON
1658+#define INCLUDE_ALLOW_VMCORE
1659+#define INCLUDE_ALLOW_VMK_MODULE
1660+#define INCLUDE_ALLOW_VMKERNEL
1661+#define INCLUDE_ALLOW_DISTRIBUTE
1662+#include "includeCheck.h"
1663+
1664+#include "vm_basic_types.h"
1665+#include "vm_atomic.h"
1666+#include "vm_assert.h"
1667+
1668+/* Register offsets. */
1669+#define VMCI_STATUS_ADDR 0x00
1670+#define VMCI_CONTROL_ADDR 0x04
1671+#define VMCI_ICR_ADDR 0x08
1672+#define VMCI_IMR_ADDR 0x0c
1673+#define VMCI_DATA_OUT_ADDR 0x10
1674+#define VMCI_DATA_IN_ADDR 0x14
1675+#define VMCI_CAPS_ADDR 0x18
1676+#define VMCI_RESULT_LOW_ADDR 0x1c
1677+#define VMCI_RESULT_HIGH_ADDR 0x20
1678+
1679+/* Max number of devices. */
1680+#define VMCI_MAX_DEVICES 1
1681+
1682+/* Status register bits. */
1683+#define VMCI_STATUS_INT_ON 0x1
1684+
1685+/* Control register bits. */
1686+#define VMCI_CONTROL_RESET 0x1
1687+#define VMCI_CONTROL_INT_ENABLE 0x2
1688+#define VMCI_CONTROL_INT_DISABLE 0x4
1689+
1690+/* Capabilities register bits. */
1691+#define VMCI_CAPS_HYPERCALL 0x1
1692+#define VMCI_CAPS_GUESTCALL 0x2
1693+#define VMCI_CAPS_DATAGRAM 0x4
1694+#define VMCI_CAPS_NOTIFICATIONS 0x8
1695+
1696+/* Interrupt Cause register bits. */
1697+#define VMCI_ICR_DATAGRAM 0x1
1698+#define VMCI_ICR_NOTIFICATION 0x2
1699+
1700+/* Interrupt Mask register bits. */
1701+#define VMCI_IMR_DATAGRAM 0x1
1702+#define VMCI_IMR_NOTIFICATION 0x2
1703+
1704+/* Interrupt type. */
1705+typedef enum VMCIIntrType {
1706+ VMCI_INTR_TYPE_INTX = 0,
1707+ VMCI_INTR_TYPE_MSI = 1,
1708+ VMCI_INTR_TYPE_MSIX = 2
1709+} VMCIIntrType;
1710+
1711+/*
1712+ * Maximum MSI/MSI-X interrupt vectors in the device.
1713+ */
1714+#define VMCI_MAX_INTRS 2
1715+
1716+/*
1717+ * Supported interrupt vectors. There is one for each ICR value above,
1718+ * but here they indicate the position in the vector array/message ID.
1719+ */
1720+#define VMCI_INTR_DATAGRAM 0
1721+#define VMCI_INTR_NOTIFICATION 1
1722+
1723+
1724+/*
1725+ * A single VMCI device has an upper limit of 128MB on the amount of
1726+ * memory that can be used for queue pairs.
1727+ */
1728+#define VMCI_MAX_GUEST_QP_MEMORY (128 * 1024 * 1024)
1729+
1730+/*
1731+ * Queues with pre-mapped data pages must be small, so that we don't pin
1732+ * too much kernel memory (especially on vmkernel). We limit a queuepair to
1733+ * 32 KB, or 16 KB per queue for symmetrical pairs.
1734+ */
1735+#define VMCI_MAX_PINNED_QP_MEMORY (32 * 1024)
1736+
1737+/*
1738+ * We have a fixed set of resource IDs available in the VMX.
1739+ * This allows us to have a very simple implementation since we statically
1740+ * know how many will create datagram handles. If a new caller arrives and
1741+ * we have run out of slots we can manually increment the maximum size of
1742+ * available resource IDs.
1743+ */
1744+
1745+typedef uint32 VMCI_Resource;
1746+
1747+/* VMCI reserved hypervisor datagram resource IDs. */
1748+#define VMCI_RESOURCES_QUERY 0
1749+#define VMCI_GET_CONTEXT_ID 1
1750+#define VMCI_SET_NOTIFY_BITMAP 2
1751+#define VMCI_DOORBELL_LINK 3
1752+#define VMCI_DOORBELL_UNLINK 4
1753+#define VMCI_DOORBELL_NOTIFY 5
1754+/*
1755+ * VMCI_DATAGRAM_REQUEST_MAP and VMCI_DATAGRAM_REMOVE_MAP are
1756+ * obsoleted by the removal of VM to VM communication.
1757+ */
1758+#define VMCI_DATAGRAM_REQUEST_MAP 6
1759+#define VMCI_DATAGRAM_REMOVE_MAP 7
1760+#define VMCI_EVENT_SUBSCRIBE 8
1761+#define VMCI_EVENT_UNSUBSCRIBE 9
1762+#define VMCI_QUEUEPAIR_ALLOC 10
1763+#define VMCI_QUEUEPAIR_DETACH 11
1764+/*
1765+ * VMCI_VSOCK_VMX_LOOKUP was assigned to 12 for Fusion 3.0/3.1,
1766+ * WS 7.0/7.1 and ESX 4.1
1767+ */
1768+#define VMCI_HGFS_TRANSPORT 13
1769+#define VMCI_UNITY_PBRPC_REGISTER 14
1770+/*
1771+ * The next two resources are for RPC calls from guest Tools, to replace the
1772+ * backdoor calls we used previously. Privileged is for admin/root RPCs,
1773+ * unprivileged is for RPCs from any user.
1774+ */
1775+#define VMCI_RPC_PRIVILEGED 15
1776+#define VMCI_RPC_UNPRIVILEGED 16
1777+#define VMCI_RESOURCE_MAX 17
1778+
1779+/* VMCI Ids. */
1780+typedef uint32 VMCIId;
1781+
1782+typedef struct VMCIHandle {
1783+ VMCIId context;
1784+ VMCIId resource;
1785+} VMCIHandle;
1786+
1787+static INLINE
1788+VMCIHandle VMCI_MAKE_HANDLE(VMCIId cid,
1789+ VMCIId rid)
1790+{
1791+ VMCIHandle h;
1792+ h.context = cid;
1793+ h.resource = rid;
1794+ return h;
1795+}
1796+
1797+/*
1798+ *----------------------------------------------------------------------
1799+ *
1800+ * VMCI_HANDLE_TO_UINT64 --
1801+ *
1802+ * Helper for VMCI handle to uint64 conversion.
1803+ *
1804+ * Results:
1805+ * The uint64 value.
1806+ *
1807+ * Side effects:
1808+ * None.
1809+ *
1810+ *----------------------------------------------------------------------
1811+ */
1812+
1813+static INLINE uint64
1814+VMCI_HANDLE_TO_UINT64(VMCIHandle handle) // IN:
1815+{
1816+ uint64 handle64;
1817+
1818+ handle64 = handle.context;
1819+ handle64 <<= 32;
1820+ handle64 |= handle.resource;
1821+ return handle64;
1822+}
1823+
1824+
1825+/*
1826+ *----------------------------------------------------------------------
1827+ *
1828+ * VMCI_UINT64_TO_HANDLE --
1829+ *
1830+ * Helper for uint64 to VMCI handle conversion.
1831+ *
1832+ * Results:
1833+ * The VMCI handle value.
1834+ *
1835+ * Side effects:
1836+ * None.
1837+ *
1838+ *----------------------------------------------------------------------
1839+ */
1840+
1841+static INLINE VMCIHandle
1842+VMCI_UINT64_TO_HANDLE(uint64 handle64) // IN:
1843+{
1844+ VMCIId context = (VMCIId)(handle64 >> 32);
1845+ VMCIId resource = (VMCIId)handle64;
1846+
1847+ return VMCI_MAKE_HANDLE(context, resource);
1848+}
1849+
1850+#define VMCI_HANDLE_TO_CONTEXT_ID(_handle) ((_handle).context)
1851+#define VMCI_HANDLE_TO_RESOURCE_ID(_handle) ((_handle).resource)
1852+#define VMCI_HANDLE_EQUAL(_h1, _h2) ((_h1).context == (_h2).context && \
1853+ (_h1).resource == (_h2).resource)
1854+
1855+#define VMCI_INVALID_ID 0xFFFFFFFF
1856+static const VMCIHandle VMCI_INVALID_HANDLE = {VMCI_INVALID_ID,
1857+ VMCI_INVALID_ID};
1858+
1859+#define VMCI_HANDLE_INVALID(_handle) \
1860+ VMCI_HANDLE_EQUAL((_handle), VMCI_INVALID_HANDLE)
1861+
1862+/*
1863+ * The below defines can be used to send anonymous requests.
1864+ * This also indicates that no response is expected.
1865+ */
1866+#define VMCI_ANON_SRC_CONTEXT_ID VMCI_INVALID_ID
1867+#define VMCI_ANON_SRC_RESOURCE_ID VMCI_INVALID_ID
1868+#define VMCI_ANON_SRC_HANDLE VMCI_MAKE_HANDLE(VMCI_ANON_SRC_CONTEXT_ID, \
1869+ VMCI_ANON_SRC_RESOURCE_ID)
1870+
1871+/* The lowest 16 context ids are reserved for internal use. */
1872+#define VMCI_RESERVED_CID_LIMIT 16
1873+
1874+/*
1875+ * Hypervisor context id, used for calling into hypervisor
1876+ * supplied services from the VM.
1877+ */
1878+#define VMCI_HYPERVISOR_CONTEXT_ID 0
1879+
1880+/*
1881+ * Well-known context id, a logical context that contains a set of
1882+ * well-known services. This context ID is now obsolete.
1883+ */
1884+#define VMCI_WELL_KNOWN_CONTEXT_ID 1
1885+
1886+/*
1887+ * Context ID used by host endpoints.
1888+ */
1889+#define VMCI_HOST_CONTEXT_ID 2
1890+
1891+#define VMCI_CONTEXT_IS_VM(_cid) (VMCI_INVALID_ID != _cid && \
1892+ _cid > VMCI_HOST_CONTEXT_ID)
1893+
1894+/*
1895+ * The VMCI_CONTEXT_RESOURCE_ID is used together with VMCI_MAKE_HANDLE to make
1896+ * handles that refer to a specific context.
1897+ */
1898+#define VMCI_CONTEXT_RESOURCE_ID 0
1899+
1900+
1901+/*
1902+ *-----------------------------------------------------------------------------
1903+ *
1904+ * VMCI error codes.
1905+ *
1906+ *-----------------------------------------------------------------------------
1907+ */
1908+
1909+#define VMCI_SUCCESS_QUEUEPAIR_ATTACH 5
1910+#define VMCI_SUCCESS_QUEUEPAIR_CREATE 4
1911+#define VMCI_SUCCESS_LAST_DETACH 3
1912+#define VMCI_SUCCESS_ACCESS_GRANTED 2
1913+#define VMCI_SUCCESS_ENTRY_DEAD 1
1914+#define VMCI_SUCCESS 0LL
1915+#define VMCI_ERROR_INVALID_RESOURCE (-1)
1916+#define VMCI_ERROR_INVALID_ARGS (-2)
1917+#define VMCI_ERROR_NO_MEM (-3)
1918+#define VMCI_ERROR_DATAGRAM_FAILED (-4)
1919+#define VMCI_ERROR_MORE_DATA (-5)
1920+#define VMCI_ERROR_NO_MORE_DATAGRAMS (-6)
1921+#define VMCI_ERROR_NO_ACCESS (-7)
1922+#define VMCI_ERROR_NO_HANDLE (-8)
1923+#define VMCI_ERROR_DUPLICATE_ENTRY (-9)
1924+#define VMCI_ERROR_DST_UNREACHABLE (-10)
1925+#define VMCI_ERROR_PAYLOAD_TOO_LARGE (-11)
1926+#define VMCI_ERROR_INVALID_PRIV (-12)
1927+#define VMCI_ERROR_GENERIC (-13)
1928+#define VMCI_ERROR_PAGE_ALREADY_SHARED (-14)
1929+#define VMCI_ERROR_CANNOT_SHARE_PAGE (-15)
1930+#define VMCI_ERROR_CANNOT_UNSHARE_PAGE (-16)
1931+#define VMCI_ERROR_NO_PROCESS (-17)
1932+#define VMCI_ERROR_NO_DATAGRAM (-18)
1933+#define VMCI_ERROR_NO_RESOURCES (-19)
1934+#define VMCI_ERROR_UNAVAILABLE (-20)
1935+#define VMCI_ERROR_NOT_FOUND (-21)
1936+#define VMCI_ERROR_ALREADY_EXISTS (-22)
1937+#define VMCI_ERROR_NOT_PAGE_ALIGNED (-23)
1938+#define VMCI_ERROR_INVALID_SIZE (-24)
1939+#define VMCI_ERROR_REGION_ALREADY_SHARED (-25)
1940+#define VMCI_ERROR_TIMEOUT (-26)
1941+#define VMCI_ERROR_DATAGRAM_INCOMPLETE (-27)
1942+#define VMCI_ERROR_INCORRECT_IRQL (-28)
1943+#define VMCI_ERROR_EVENT_UNKNOWN (-29)
1944+#define VMCI_ERROR_OBSOLETE (-30)
1945+#define VMCI_ERROR_QUEUEPAIR_MISMATCH (-31)
1946+#define VMCI_ERROR_QUEUEPAIR_NOTSET (-32)
1947+#define VMCI_ERROR_QUEUEPAIR_NOTOWNER (-33)
1948+#define VMCI_ERROR_QUEUEPAIR_NOTATTACHED (-34)
1949+#define VMCI_ERROR_QUEUEPAIR_NOSPACE (-35)
1950+#define VMCI_ERROR_QUEUEPAIR_NODATA (-36)
1951+#define VMCI_ERROR_BUSMEM_INVALIDATION (-37)
1952+#define VMCI_ERROR_MODULE_NOT_LOADED (-38)
1953+#define VMCI_ERROR_DEVICE_NOT_FOUND (-39)
1954+#define VMCI_ERROR_QUEUEPAIR_NOT_READY (-40)
1955+#define VMCI_ERROR_WOULD_BLOCK (-41)
1956+
1957+/* VMCI clients should return error code withing this range */
1958+#define VMCI_ERROR_CLIENT_MIN (-500)
1959+#define VMCI_ERROR_CLIENT_MAX (-550)
1960+
1961+/* Internal error codes. */
1962+#define VMCI_SHAREDMEM_ERROR_BAD_CONTEXT (-1000)
1963+
1964+#define VMCI_PATH_MAX 256
1965+
1966+/* VMCI reserved events. */
1967+typedef uint32 VMCI_Event;
1968+
1969+#define VMCI_EVENT_CTX_ID_UPDATE 0 // Only applicable to guest endpoints
1970+#define VMCI_EVENT_CTX_REMOVED 1 // Applicable to guest and host
1971+#define VMCI_EVENT_QP_RESUMED 2 // Only applicable to guest endpoints
1972+#define VMCI_EVENT_QP_PEER_ATTACH 3 // Applicable to guest and host
1973+#define VMCI_EVENT_QP_PEER_DETACH 4 // Applicable to guest and host
1974+#define VMCI_EVENT_MEM_ACCESS_ON 5 // Applicable to VMX and vmk. On vmk,
1975+ // this event has the Context payload type.
1976+#define VMCI_EVENT_MEM_ACCESS_OFF 6 // Applicable to VMX and vmk. Same as
1977+ // above for the payload type.
1978+#define VMCI_EVENT_MAX 7
1979+
1980+/*
1981+ * Of the above events, a few are reserved for use in the VMX, and
1982+ * other endpoints (guest and host kernel) should not use them. For
1983+ * the rest of the events, we allow both host and guest endpoints to
1984+ * subscribe to them, to maintain the same API for host and guest
1985+ * endpoints.
1986+ */
1987+
1988+#define VMCI_EVENT_VALID_VMX(_event) (_event == VMCI_EVENT_MEM_ACCESS_ON || \
1989+ _event == VMCI_EVENT_MEM_ACCESS_OFF)
1990+
1991+#if defined(VMX86_SERVER)
1992+#define VMCI_EVENT_VALID(_event) (_event < VMCI_EVENT_MAX)
1993+#else // VMX86_SERVER
1994+#define VMCI_EVENT_VALID(_event) (_event < VMCI_EVENT_MAX && \
1995+ !VMCI_EVENT_VALID_VMX(_event))
1996+#endif // VMX86_SERVER
1997+
1998+/* Reserved guest datagram resource ids. */
1999+#define VMCI_EVENT_HANDLER 0
2000+
2001+/* VMCI privileges. */
2002+typedef enum VMCIResourcePrivilegeType {
2003+ VMCI_PRIV_CH_PRIV,
2004+ VMCI_PRIV_DESTROY_RESOURCE,
2005+ VMCI_PRIV_ASSIGN_CLIENT,
2006+ VMCI_PRIV_DG_CREATE,
2007+ VMCI_PRIV_DG_SEND,
2008+ VMCI_PRIV_NOTIFY,
2009+ VMCI_NUM_PRIVILEGES,
2010+} VMCIResourcePrivilegeType;
2011+
2012+/*
2013+ * VMCI coarse-grained privileges (per context or host
2014+ * process/endpoint. An entity with the restricted flag is only
2015+ * allowed to interact with the hypervisor and trusted entities.
2016+ */
2017+typedef uint32 VMCIPrivilegeFlags;
2018+
2019+#define VMCI_PRIVILEGE_FLAG_RESTRICTED 0x01
2020+#define VMCI_PRIVILEGE_FLAG_TRUSTED 0x02
2021+#define VMCI_PRIVILEGE_ALL_FLAGS (VMCI_PRIVILEGE_FLAG_RESTRICTED | \
2022+ VMCI_PRIVILEGE_FLAG_TRUSTED)
2023+#define VMCI_NO_PRIVILEGE_FLAGS 0x00
2024+#define VMCI_DEFAULT_PROC_PRIVILEGE_FLAGS VMCI_NO_PRIVILEGE_FLAGS
2025+#define VMCI_LEAST_PRIVILEGE_FLAGS VMCI_PRIVILEGE_FLAG_RESTRICTED
2026+#define VMCI_MAX_PRIVILEGE_FLAGS VMCI_PRIVILEGE_FLAG_TRUSTED
2027+
2028+#define VMCI_PUBLIC_GROUP_NAME "vmci public group"
2029+/* 0 through VMCI_RESERVED_RESOURCE_ID_MAX are reserved. */
2030+#define VMCI_RESERVED_RESOURCE_ID_MAX 1023
2031+
2032+#define VMCI_DOMAIN_NAME_MAXLEN 32
2033+
2034+#define VMCI_LGPFX "VMCI: "
2035+
2036+
2037+/*
2038+ * VMCIQueueHeader
2039+ *
2040+ * A Queue cannot stand by itself as designed. Each Queue's header
2041+ * contains a pointer into itself (the producerTail) and into its peer
2042+ * (consumerHead). The reason for the separation is one of
2043+ * accessibility: Each end-point can modify two things: where the next
2044+ * location to enqueue is within its produceQ (producerTail); and
2045+ * where the next dequeue location is in its consumeQ (consumerHead).
2046+ *
2047+ * An end-point cannot modify the pointers of its peer (guest to
2048+ * guest; NOTE that in the host both queue headers are mapped r/w).
2049+ * But, each end-point needs read access to both Queue header
2050+ * structures in order to determine how much space is used (or left)
2051+ * in the Queue. This is because for an end-point to know how full
2052+ * its produceQ is, it needs to use the consumerHead that points into
2053+ * the produceQ but -that- consumerHead is in the Queue header for
2054+ * that end-points consumeQ.
2055+ *
2056+ * Thoroughly confused? Sorry.
2057+ *
2058+ * producerTail: the point to enqueue new entrants. When you approach
2059+ * a line in a store, for example, you walk up to the tail.
2060+ *
2061+ * consumerHead: the point in the queue from which the next element is
2062+ * dequeued. In other words, who is next in line is he who is at the
2063+ * head of the line.
2064+ *
2065+ * Also, producerTail points to an empty byte in the Queue, whereas
2066+ * consumerHead points to a valid byte of data (unless producerTail ==
2067+ * consumerHead in which case consumerHead does not point to a valid
2068+ * byte of data).
2069+ *
2070+ * For a queue of buffer 'size' bytes, the tail and head pointers will be in
2071+ * the range [0, size-1].
2072+ *
2073+ * If produceQHeader->producerTail == consumeQHeader->consumerHead
2074+ * then the produceQ is empty.
2075+ */
2076+
2077+typedef struct VMCIQueueHeader {
2078+ /* All fields are 64bit and aligned. */
2079+ VMCIHandle handle; /* Identifier. */
2080+ Atomic_uint64 producerTail; /* Offset in this queue. */
2081+ Atomic_uint64 consumerHead; /* Offset in peer queue. */
2082+} VMCIQueueHeader;
2083+
2084+
2085+/*
2086+ * If one client of a QueuePair is a 32bit entity, we restrict the QueuePair
2087+ * size to be less than 4GB, and use 32bit atomic operations on the head and
2088+ * tail pointers. 64bit atomic read on a 32bit entity involves cmpxchg8b which
2089+ * is an atomic read-modify-write. This will cause traces to fire when a 32bit
2090+ * consumer tries to read the producer's tail pointer, for example, because the
2091+ * consumer has read-only access to the producer's tail pointer.
2092+ *
2093+ * We provide the following macros to invoke 32bit or 64bit atomic operations
2094+ * based on the architecture the code is being compiled on.
2095+ */
2096+
2097+/* Architecture independent maximum queue size. */
2098+#define QP_MAX_QUEUE_SIZE_ARCH_ANY CONST64U(0xffffffff)
2099+
2100+#ifdef __x86_64__
2101+# define QP_MAX_QUEUE_SIZE_ARCH CONST64U(0xffffffffffffffff)
2102+# define QPAtomic_ReadOffset(x) Atomic_Read64(x)
2103+# define QPAtomic_WriteOffset(x, y) Atomic_Write64(x, y)
2104+#else
2105+ /*
2106+ * Wrappers below are being used to call Atomic_Read32 because of the
2107+ * 'type punned' compilation warning received when Atomic_Read32 is
2108+ * called with a Atomic_uint64 pointer typecasted to Atomic_uint32
2109+ * pointer from QPAtomic_ReadOffset. Ditto with QPAtomic_WriteOffset.
2110+ */
2111+
2112+ static INLINE uint32
2113+ TypeSafe_Atomic_Read32(void *var) // IN:
2114+ {
2115+ return Atomic_Read32((Atomic_uint32 *)(var));
2116+ }
2117+
2118+ static INLINE void
2119+ TypeSafe_Atomic_Write32(void *var, uint32 val) // IN:
2120+ {
2121+ Atomic_Write32((Atomic_uint32 *)(var), (uint32)(val));
2122+ }
2123+
2124+# define QP_MAX_QUEUE_SIZE_ARCH CONST64U(0xffffffff)
2125+# define QPAtomic_ReadOffset(x) TypeSafe_Atomic_Read32((void *)(x))
2126+# define QPAtomic_WriteOffset(x, y) \
2127+ TypeSafe_Atomic_Write32((void *)(x), (uint32)(y))
2128+#endif /* __x86_64__ */
2129+
2130+
2131+/*
2132+ *-----------------------------------------------------------------------------
2133+ *
2134+ * QPAddPointer --
2135+ *
2136+ * Helper to add a given offset to a head or tail pointer. Wraps the value
2137+ * of the pointer around the max size of the queue.
2138+ *
2139+ * Results:
2140+ * None.
2141+ *
2142+ * Side effects:
2143+ * None.
2144+ *
2145+ *-----------------------------------------------------------------------------
2146+ */
2147+
2148+static INLINE void
2149+QPAddPointer(Atomic_uint64 *var, // IN:
2150+ size_t add, // IN:
2151+ uint64 size) // IN:
2152+{
2153+ uint64 newVal = QPAtomic_ReadOffset(var);
2154+
2155+ if (newVal >= size - add) {
2156+ newVal -= size;
2157+ }
2158+ newVal += add;
2159+
2160+ QPAtomic_WriteOffset(var, newVal);
2161+}
2162+
2163+
2164+/*
2165+ *-----------------------------------------------------------------------------
2166+ *
2167+ * VMCIQueueHeader_ProducerTail() --
2168+ *
2169+ * Helper routine to get the Producer Tail from the supplied queue.
2170+ *
2171+ * Results:
2172+ * The contents of the queue's producer tail.
2173+ *
2174+ * Side effects:
2175+ * None.
2176+ *
2177+ *-----------------------------------------------------------------------------
2178+ */
2179+
2180+static INLINE uint64
2181+VMCIQueueHeader_ProducerTail(const VMCIQueueHeader *qHeader) // IN:
2182+{
2183+ VMCIQueueHeader *qh = (VMCIQueueHeader *)qHeader;
2184+ return QPAtomic_ReadOffset(&qh->producerTail);
2185+}
2186+
2187+
2188+/*
2189+ *-----------------------------------------------------------------------------
2190+ *
2191+ * VMCIQueueHeader_ConsumerHead() --
2192+ *
2193+ * Helper routine to get the Consumer Head from the supplied queue.
2194+ *
2195+ * Results:
2196+ * The contents of the queue's consumer tail.
2197+ *
2198+ * Side effects:
2199+ * None.
2200+ *
2201+ *-----------------------------------------------------------------------------
2202+ */
2203+
2204+static INLINE uint64
2205+VMCIQueueHeader_ConsumerHead(const VMCIQueueHeader *qHeader) // IN:
2206+{
2207+ VMCIQueueHeader *qh = (VMCIQueueHeader *)qHeader;
2208+ return QPAtomic_ReadOffset(&qh->consumerHead);
2209+}
2210+
2211+
2212+/*
2213+ *-----------------------------------------------------------------------------
2214+ *
2215+ * VMCIQueueHeader_AddProducerTail() --
2216+ *
2217+ * Helper routine to increment the Producer Tail. Fundamentally,
2218+ * QPAddPointer() is used to manipulate the tail itself.
2219+ *
2220+ * Results:
2221+ * None.
2222+ *
2223+ * Side effects:
2224+ * None.
2225+ *
2226+ *-----------------------------------------------------------------------------
2227+ */
2228+
2229+static INLINE void
2230+VMCIQueueHeader_AddProducerTail(VMCIQueueHeader *qHeader, // IN/OUT:
2231+ size_t add, // IN:
2232+ uint64 queueSize) // IN:
2233+{
2234+ QPAddPointer(&qHeader->producerTail, add, queueSize);
2235+}
2236+
2237+
2238+/*
2239+ *-----------------------------------------------------------------------------
2240+ *
2241+ * VMCIQueueHeader_AddConsumerHead() --
2242+ *
2243+ * Helper routine to increment the Consumer Head. Fundamentally,
2244+ * QPAddPointer() is used to manipulate the head itself.
2245+ *
2246+ * Results:
2247+ * None.
2248+ *
2249+ * Side effects:
2250+ * None.
2251+ *
2252+ *-----------------------------------------------------------------------------
2253+ */
2254+
2255+static INLINE void
2256+VMCIQueueHeader_AddConsumerHead(VMCIQueueHeader *qHeader, // IN/OUT:
2257+ size_t add, // IN:
2258+ uint64 queueSize) // IN:
2259+{
2260+ QPAddPointer(&qHeader->consumerHead, add, queueSize);
2261+}
2262+
2263+
2264+/*
2265+ *-----------------------------------------------------------------------------
2266+ *
2267+ * VMCIQueueHeader_CheckAlignment --
2268+ *
2269+ * Checks if the given queue is aligned to page boundary. Returns TRUE if
2270+ * the alignment is good.
2271+ *
2272+ * Results:
2273+ * TRUE or FALSE.
2274+ *
2275+ * Side effects:
2276+ * None.
2277+ *
2278+ *-----------------------------------------------------------------------------
2279+ */
2280+
2281+static INLINE Bool
2282+VMCIQueueHeader_CheckAlignment(const VMCIQueueHeader *qHeader) // IN:
2283+{
2284+ uintptr_t hdr, offset;
2285+
2286+ hdr = (uintptr_t) qHeader;
2287+ offset = hdr & (PAGE_SIZE -1);
2288+
2289+ return offset == 0;
2290+}
2291+
2292+
2293+/*
2294+ *-----------------------------------------------------------------------------
2295+ *
2296+ * VMCIQueueHeader_GetPointers --
2297+ *
2298+ * Helper routine for getting the head and the tail pointer for a queue.
2299+ * Both the VMCIQueues are needed to get both the pointers for one queue.
2300+ *
2301+ * Results:
2302+ * None.
2303+ *
2304+ * Side effects:
2305+ * None.
2306+ *
2307+ *-----------------------------------------------------------------------------
2308+ */
2309+
2310+static INLINE void
2311+VMCIQueueHeader_GetPointers(const VMCIQueueHeader *produceQHeader, // IN:
2312+ const VMCIQueueHeader *consumeQHeader, // IN:
2313+ uint64 *producerTail, // OUT:
2314+ uint64 *consumerHead) // OUT:
2315+{
2316+ if (producerTail) {
2317+ *producerTail = VMCIQueueHeader_ProducerTail(produceQHeader);
2318+ }
2319+
2320+ if (consumerHead) {
2321+ *consumerHead = VMCIQueueHeader_ConsumerHead(consumeQHeader);
2322+ }
2323+}
2324+
2325+
2326+/*
2327+ *-----------------------------------------------------------------------------
2328+ *
2329+ * VMCIQueueHeader_ResetPointers --
2330+ *
2331+ * Reset the tail pointer (of "this" queue) and the head pointer (of
2332+ * "peer" queue).
2333+ *
2334+ * Results:
2335+ * None.
2336+ *
2337+ * Side effects:
2338+ * None.
2339+ *
2340+ *-----------------------------------------------------------------------------
2341+ */
2342+
2343+static INLINE void
2344+VMCIQueueHeader_ResetPointers(VMCIQueueHeader *qHeader) // IN/OUT:
2345+{
2346+ QPAtomic_WriteOffset(&qHeader->producerTail, CONST64U(0));
2347+ QPAtomic_WriteOffset(&qHeader->consumerHead, CONST64U(0));
2348+}
2349+
2350+
2351+/*
2352+ *-----------------------------------------------------------------------------
2353+ *
2354+ * VMCIQueueHeader_Init --
2355+ *
2356+ * Initializes a queue's state (head & tail pointers).
2357+ *
2358+ * Results:
2359+ * None.
2360+ *
2361+ * Side effects:
2362+ * None.
2363+ *
2364+ *-----------------------------------------------------------------------------
2365+ */
2366+
2367+static INLINE void
2368+VMCIQueueHeader_Init(VMCIQueueHeader *qHeader, // IN/OUT:
2369+ const VMCIHandle handle) // IN:
2370+{
2371+ qHeader->handle = handle;
2372+ VMCIQueueHeader_ResetPointers(qHeader);
2373+}
2374+
2375+
2376+/*
2377+ *-----------------------------------------------------------------------------
2378+ *
2379+ * VMCIQueueHeader_FreeSpace --
2380+ *
2381+ * Finds available free space in a produce queue to enqueue more
2382+ * data or reports an error if queue pair corruption is detected.
2383+ *
2384+ * Results:
2385+ * Free space size in bytes or an error code.
2386+ *
2387+ * Side effects:
2388+ * None.
2389+ *
2390+ *-----------------------------------------------------------------------------
2391+ */
2392+
2393+static INLINE int64
2394+VMCIQueueHeader_FreeSpace(const VMCIQueueHeader *produceQHeader, // IN:
2395+ const VMCIQueueHeader *consumeQHeader, // IN:
2396+ const uint64 produceQSize) // IN:
2397+{
2398+ uint64 tail;
2399+ uint64 head;
2400+ uint64 freeSpace;
2401+
2402+ tail = VMCIQueueHeader_ProducerTail(produceQHeader);
2403+ head = VMCIQueueHeader_ConsumerHead(consumeQHeader);
2404+
2405+ if (tail >= produceQSize || head >= produceQSize) {
2406+ return VMCI_ERROR_INVALID_SIZE;
2407+ }
2408+
2409+ /*
2410+ * Deduct 1 to avoid tail becoming equal to head which causes ambiguity. If
2411+ * head and tail are equal it means that the queue is empty.
2412+ */
2413+
2414+ if (tail >= head) {
2415+ freeSpace = produceQSize - (tail - head) - 1;
2416+ } else {
2417+ freeSpace = head - tail - 1;
2418+ }
2419+
2420+ return freeSpace;
2421+}
2422+
2423+
2424+/*
2425+ *-----------------------------------------------------------------------------
2426+ *
2427+ * VMCIQueueHeader_BufReady --
2428+ *
2429+ * VMCIQueueHeader_FreeSpace() does all the heavy lifting of
2430+ * determing the number of free bytes in a Queue. This routine,
2431+ * then subtracts that size from the full size of the Queue so
2432+ * the caller knows how many bytes are ready to be dequeued.
2433+ *
2434+ * Results:
2435+ * On success, available data size in bytes (up to MAX_INT64).
2436+ * On failure, appropriate error code.
2437+ *
2438+ * Side effects:
2439+ * None.
2440+ *
2441+ *-----------------------------------------------------------------------------
2442+ */
2443+
2444+static INLINE int64
2445+VMCIQueueHeader_BufReady(const VMCIQueueHeader *consumeQHeader, // IN:
2446+ const VMCIQueueHeader *produceQHeader, // IN:
2447+ const uint64 consumeQSize) // IN:
2448+{
2449+ int64 freeSpace;
2450+
2451+ freeSpace = VMCIQueueHeader_FreeSpace(consumeQHeader,
2452+ produceQHeader,
2453+ consumeQSize);
2454+ if (freeSpace < VMCI_SUCCESS) {
2455+ return freeSpace;
2456+ } else {
2457+ return consumeQSize - freeSpace - 1;
2458+ }
2459+}
2460+
2461+
2462+#endif
2463+
2464
2465=== added file '.pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_iocontrols.h'
2466--- .pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_iocontrols.h 1970-01-01 00:00:00 +0000
2467+++ .pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_iocontrols.h 2013-06-28 21:11:42 +0000
2468@@ -0,0 +1,752 @@
2469+/*********************************************************
2470+ * Copyright (C) 2007 VMware, Inc. All rights reserved.
2471+ *
2472+ * This program is free software; you can redistribute it and/or modify it
2473+ * under the terms of the GNU General Public License as published by the
2474+ * Free Software Foundation version 2 and no later version.
2475+ *
2476+ * This program is distributed in the hope that it will be useful, but
2477+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2478+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2479+ * for more details.
2480+ *
2481+ * You should have received a copy of the GNU General Public License along
2482+ * with this program; if not, write to the Free Software Foundation, Inc.,
2483+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2484+ *
2485+ *********************************************************/
2486+
2487+
2488+/*
2489+ * vmci_iocontrols.h
2490+ *
2491+ * The VMCI driver io controls.
2492+ */
2493+
2494+#ifndef _VMCI_IOCONTROLS_H_
2495+#define _VMCI_IOCONTROLS_H_
2496+
2497+#define INCLUDE_ALLOW_USERLEVEL
2498+#define INCLUDE_ALLOW_VMCORE
2499+#define INCLUDE_ALLOW_MODULE
2500+#define INCLUDE_ALLOW_VMKERNEL
2501+#include "includeCheck.h"
2502+
2503+#include "vm_assert.h"
2504+#include "vmci_defs.h"
2505+
2506+#if defined(_WIN32) && defined(WINNT_DDK)
2507+/* We need to expose the API through an IOCTL on Windows. Use latest API. */
2508+#include "vmciKernelAPI.h"
2509+#endif // _WIN32 && WINNT_DDK
2510+
2511+
2512+/*
2513+ *-----------------------------------------------------------------------------
2514+ *
2515+ * VMCIVA64ToPtr --
2516+ *
2517+ * Convert a VA64 to a pointer.
2518+ *
2519+ * Results:
2520+ * Virtual address.
2521+ *
2522+ * Side effects:
2523+ * None
2524+ *
2525+ *-----------------------------------------------------------------------------
2526+ */
2527+
2528+static INLINE void *
2529+VMCIVA64ToPtr(VA64 va64) // IN
2530+{
2531+#ifdef VM_X86_64
2532+ ASSERT_ON_COMPILE(sizeof (void *) == 8);
2533+#else
2534+ ASSERT_ON_COMPILE(sizeof (void *) == 4);
2535+ // Check that nothing of value will be lost.
2536+ ASSERT(!(va64 >> 32));
2537+#endif
2538+ return (void *)(uintptr_t)va64;
2539+}
2540+
2541+
2542+/*
2543+ *-----------------------------------------------------------------------------
2544+ *
2545+ * VMCIPtrToVA64 --
2546+ *
2547+ * Convert a pointer to a VA64.
2548+ *
2549+ * Results:
2550+ * Virtual address.
2551+ *
2552+ * Side effects:
2553+ * None
2554+ *
2555+ *-----------------------------------------------------------------------------
2556+ */
2557+
2558+static INLINE VA64
2559+VMCIPtrToVA64(void const *ptr) // IN
2560+{
2561+ ASSERT_ON_COMPILE(sizeof ptr <= sizeof (VA64));
2562+ return (VA64)(uintptr_t)ptr;
2563+}
2564+
2565+
2566+/*
2567+ * Driver version.
2568+ *
2569+ * Increment major version when you make an incompatible change.
2570+ * Compatibility goes both ways (old driver with new executable
2571+ * as well as new driver with old executable).
2572+ */
2573+
2574+#define VMCI_VERSION_SHIFT_WIDTH 16 /* Never change this. */
2575+#define VMCI_MAKE_VERSION(_major, _minor) ((_major) << \
2576+ VMCI_VERSION_SHIFT_WIDTH | \
2577+ (uint16) (_minor))
2578+#define VMCI_VERSION_MAJOR(v) ((uint32) (v) >> VMCI_VERSION_SHIFT_WIDTH)
2579+#define VMCI_VERSION_MINOR(v) ((uint16) (v))
2580+
2581+/*
2582+ * VMCI_VERSION is always the current version. Subsequently listed
2583+ * versions are ways of detecting previous versions of the connecting
2584+ * application (i.e., VMX).
2585+ *
2586+ * VMCI_VERSION_NOVMVM: This version removed support for VM to VM
2587+ * communication.
2588+ *
2589+ * VMCI_VERSION_NOTIFY: This version introduced doorbell notification
2590+ * support.
2591+ *
2592+ * VMCI_VERSION_HOSTQP: This version introduced host end point support
2593+ * for hosted products.
2594+ *
2595+ * VMCI_VERSION_PREHOSTQP: This is the version prior to the adoption of
2596+ * support for host end-points.
2597+ *
2598+ * VMCI_VERSION_PREVERS2: This fictional version number is intended to
2599+ * represent the version of a VMX which doesn't call into the driver
2600+ * with ioctl VERSION2 and thus doesn't establish its version with the
2601+ * driver.
2602+ */
2603+
2604+#define VMCI_VERSION VMCI_VERSION_NOVMVM
2605+#define VMCI_VERSION_NOVMVM VMCI_MAKE_VERSION(11, 0)
2606+#define VMCI_VERSION_NOTIFY VMCI_MAKE_VERSION(10, 0)
2607+#define VMCI_VERSION_HOSTQP VMCI_MAKE_VERSION(9, 0)
2608+#define VMCI_VERSION_PREHOSTQP VMCI_MAKE_VERSION(8, 0)
2609+#define VMCI_VERSION_PREVERS2 VMCI_MAKE_VERSION(1, 0)
2610+
2611+/*
2612+ * VMCISockets driver version. The version is platform-dependent and is
2613+ * embedded in vsock_version.h for each platform. It can be obtained via
2614+ * VMCISock_Version() (which uses IOCTL_VMCI_SOCKETS_VERSION). The
2615+ * following is simply for constructing an unsigned integer value from the
2616+ * comma-separated version in the header. This must match the macros defined
2617+ * in vmci_sockets.h. An example of using this is:
2618+ * uint16 parts[4] = { VSOCK_DRIVER_VERSION_COMMAS };
2619+ * uint32 version = VMCI_SOCKETS_MAKE_VERSION(parts);
2620+ */
2621+
2622+#define VMCI_SOCKETS_MAKE_VERSION(_p) \
2623+ ((((_p)[0] & 0xFF) << 24) | (((_p)[1] & 0xFF) << 16) | ((_p)[2]))
2624+
2625+#if defined(__linux__) || defined(SOLARIS) || defined(VMKERNEL)
2626+/*
2627+ * Linux defines _IO* macros, but the core kernel code ignore the encoded
2628+ * ioctl value. It is up to individual drivers to decode the value (for
2629+ * example to look at the size of a structure to determine which version
2630+ * of a specific command should be used) or not (which is what we
2631+ * currently do, so right now the ioctl value for a given command is the
2632+ * command itself).
2633+ *
2634+ * Hence, we just define the IOCTL_VMCI_foo values directly, with no
2635+ * intermediate IOCTLCMD_ representation.
2636+ */
2637+# define IOCTLCMD(_cmd) IOCTL_VMCI_ ## _cmd
2638+#elif defined (__APPLE__)
2639+#include <sys/ioccom.h>
2640+#define IOCTLCMD(_cmd) IOCTL_VMCI_ ## _cmd
2641+#define IOCTLCMD_I(_cmd, _type) \
2642+ IOCTL_VMCI_MACOS_ ## _cmd = _IOW('V', IOCTL_VMCI_ ## _cmd, _type)
2643+#define IOCTLCMD_O(_cmd, _type) \
2644+ IOCTL_VMCI_MACOS_ ## _cmd = _IOR('V', IOCTL_VMCI_ ## _cmd, _type)
2645+#define IOCTLCMD_IO(_cmd, _type) \
2646+ IOCTL_VMCI_MACOS_ ## _cmd = _IOWR('V', IOCTL_VMCI_ ## _cmd, _type)
2647+#else // if defined(__linux__)
2648+/*
2649+ * On platforms other than Linux, IOCTLCMD_foo values are just numbers, and
2650+ * we build the IOCTL_VMCI_foo values around these using platform-specific
2651+ * format for encoding arguments and sizes.
2652+ */
2653+# define IOCTLCMD(_cmd) IOCTLCMD_VMCI_ ## _cmd
2654+#endif
2655+
2656+
2657+enum IOCTLCmd_VMCI {
2658+ /*
2659+ * We need to bracket the range of values used for ioctls, because x86_64
2660+ * Linux forces us to explicitly register ioctl handlers by value for
2661+ * handling 32 bit ioctl syscalls. Hence FIRST and LAST. Pick something
2662+ * for FIRST that doesn't collide with vmmon (2001+).
2663+ */
2664+#if defined(__linux__)
2665+ IOCTLCMD(FIRST) = 1951,
2666+#else
2667+ /* Start at 0. */
2668+ IOCTLCMD(FIRST),
2669+#endif
2670+ IOCTLCMD(VERSION) = IOCTLCMD(FIRST),
2671+
2672+ /* BEGIN VMCI */
2673+ IOCTLCMD(INIT_CONTEXT),
2674+
2675+ /*
2676+ * The following two were used for process and datagram process creation.
2677+ * They are not used anymore and reserved for future use.
2678+ * They will fail if issued.
2679+ */
2680+ IOCTLCMD(RESERVED1),
2681+ IOCTLCMD(RESERVED2),
2682+
2683+ /*
2684+ * The following used to be for shared memory. It is now unused and and is
2685+ * reserved for future use. It will fail if issued.
2686+ */
2687+ IOCTLCMD(RESERVED3),
2688+
2689+ /*
2690+ * The follwoing three were also used to be for shared memory. An
2691+ * old WS6 user-mode client might try to use them with the new
2692+ * driver, but since we ensure that only contexts created by VMX'en
2693+ * of the appropriate version (VMCI_VERSION_NOTIFY or
2694+ * VMCI_VERSION_NEWQP) or higher use these ioctl, everything is
2695+ * fine.
2696+ */
2697+ IOCTLCMD(QUEUEPAIR_SETVA),
2698+ IOCTLCMD(NOTIFY_RESOURCE),
2699+ IOCTLCMD(NOTIFICATIONS_RECEIVE),
2700+ IOCTLCMD(VERSION2),
2701+ IOCTLCMD(QUEUEPAIR_ALLOC),
2702+ IOCTLCMD(QUEUEPAIR_SETPAGEFILE),
2703+ IOCTLCMD(QUEUEPAIR_DETACH),
2704+ IOCTLCMD(DATAGRAM_SEND),
2705+ IOCTLCMD(DATAGRAM_RECEIVE),
2706+ IOCTLCMD(DATAGRAM_REQUEST_MAP),
2707+ IOCTLCMD(DATAGRAM_REMOVE_MAP),
2708+ IOCTLCMD(CTX_ADD_NOTIFICATION),
2709+ IOCTLCMD(CTX_REMOVE_NOTIFICATION),
2710+ IOCTLCMD(CTX_GET_CPT_STATE),
2711+ IOCTLCMD(CTX_SET_CPT_STATE),
2712+ IOCTLCMD(GET_CONTEXT_ID),
2713+ /* END VMCI */
2714+
2715+ /*
2716+ * BEGIN VMCI SOCKETS
2717+ *
2718+ * We mark the end of the vmci commands and the start of the vmci sockets
2719+ * commands since they are used in separate modules on Linux.
2720+ * */
2721+ IOCTLCMD(LAST),
2722+ IOCTLCMD(SOCKETS_FIRST) = IOCTLCMD(LAST),
2723+
2724+ /*
2725+ * This used to be for accept() on Windows and Mac OS, which is now
2726+ * redundant (since we now use real handles). It is used instead for
2727+ * getting the version. This value is now public, so it cannot change.
2728+ */
2729+ IOCTLCMD(SOCKETS_VERSION) = IOCTLCMD(SOCKETS_FIRST),
2730+ IOCTLCMD(SOCKETS_BIND),
2731+
2732+ /*
2733+ * This used to be for close() on Windows and Mac OS, but is no longer
2734+ * used for the same reason as accept() above. It is used instead for
2735+ * sending private symbols to the Mac OS driver.
2736+ */
2737+ IOCTLCMD(SOCKETS_SET_SYMBOLS),
2738+ IOCTLCMD(SOCKETS_CONNECT),
2739+
2740+ /*
2741+ * The next two values are public (vmci_sockets.h) and cannot be changed.
2742+ * That means the number of values above these cannot be changed either
2743+ * unless the base index (specified below) is updated accordingly.
2744+ */
2745+ IOCTLCMD(SOCKETS_GET_AF_VALUE),
2746+ IOCTLCMD(SOCKETS_GET_LOCAL_CID),
2747+ IOCTLCMD(SOCKETS_GET_SOCK_NAME),
2748+ IOCTLCMD(SOCKETS_GET_SOCK_OPT),
2749+ IOCTLCMD(SOCKETS_GET_VM_BY_NAME),
2750+ IOCTLCMD(SOCKETS_IOCTL),
2751+ IOCTLCMD(SOCKETS_LISTEN),
2752+ IOCTLCMD(SOCKETS_RECV),
2753+ IOCTLCMD(SOCKETS_RECV_FROM),
2754+ IOCTLCMD(SOCKETS_SELECT),
2755+ IOCTLCMD(SOCKETS_SEND),
2756+ IOCTLCMD(SOCKETS_SEND_TO),
2757+ IOCTLCMD(SOCKETS_SET_SOCK_OPT),
2758+ IOCTLCMD(SOCKETS_SHUTDOWN),
2759+ IOCTLCMD(SOCKETS_SOCKET), /* 1990 on Linux. */
2760+ /* END VMCI SOCKETS */
2761+
2762+ /*
2763+ * We reserve a range of 4 ioctls for VMCI Sockets to grow. We cannot
2764+ * reserve many ioctls here since we are close to overlapping with vmmon
2765+ * ioctls. Define a meta-ioctl if running out of this binary space.
2766+ */
2767+ // Must be last.
2768+ IOCTLCMD(SOCKETS_LAST) = IOCTLCMD(SOCKETS_SOCKET) + 4, /* 1994 on Linux. */
2769+ /*
2770+ * The VSockets ioctls occupy the block above. We define a new range of
2771+ * VMCI ioctls to maintain binary compatibility between the user land and
2772+ * the kernel driver. Careful, vmmon ioctls start from 2001, so this means
2773+ * we can add only 4 new VMCI ioctls. Define a meta-ioctl if running out of
2774+ * this binary space.
2775+ */
2776+
2777+ IOCTLCMD(FIRST2),
2778+ IOCTLCMD(SET_NOTIFY) = IOCTLCMD(FIRST2), /* 1995 on Linux. */
2779+ IOCTLCMD(LAST2),
2780+};
2781+
2782+#if defined (__APPLE__)
2783+/*
2784+ * The size of this must match the size of VSockIoctlPrivSyms in
2785+ * modules/vsock/common/vsockIoctl.h.
2786+ */
2787+#include "vmware_pack_begin.h"
2788+struct IOCTLCmd_VMCIMacOS_PrivSyms {
2789+ char data[328];
2790+}
2791+#include "vmware_pack_end.h"
2792+;
2793+enum IOCTLCmd_VMCIMacOS {
2794+ IOCTLCMD_I(SOCKETS_SET_SYMBOLS, struct IOCTLCmd_VMCIMacOS_PrivSyms),
2795+ IOCTLCMD_O(SOCKETS_VERSION, unsigned int),
2796+ IOCTLCMD_O(SOCKETS_GET_AF_VALUE, int),
2797+ IOCTLCMD_O(SOCKETS_GET_LOCAL_CID, unsigned int),
2798+};
2799+#endif // __APPLE__
2800+
2801+
2802+#if defined _WIN32
2803+/*
2804+ * Windows VMCI ioctl definitions.
2805+ */
2806+
2807+/* PUBLIC: For VMCISockets user-mode clients that use CreateFile(). */
2808+#define VMCI_INTERFACE_VSOCK_PUBLIC_NAME TEXT("\\\\.\\VMCI")
2809+
2810+/* PUBLIC: For VMCISockets user-mode clients that use NtCreateFile(). */
2811+#define VMCI_INTERFACE_VSOCK_PUBLIC_NAME_NT L"\\??\\VMCI"
2812+
2813+/* PUBLIC: For the VMX, which uses CreateFile(). */
2814+#define VMCI_INTERFACE_VMX_PUBLIC_NAME TEXT("\\\\.\\VMCIDev\\VMX")
2815+
2816+/* PRIVATE NAMES */
2817+#define VMCI_DEVICE_VMCI_LINK_PATH L"\\DosDevices\\VMCIDev"
2818+#define VMCI_DEVICE_VSOCK_LINK_PATH L"\\DosDevices\\vmci"
2819+#define VMCI_DEVICE_HOST_NAME_PATH L"\\Device\\VMCIHostDev"
2820+#define VMCI_DEVICE_GUEST_NAME_PATH L"\\Device\\VMCIGuestDev"
2821+/* PRIVATE NAMES */
2822+
2823+/* These values cannot be changed since some of the ioctl values are public. */
2824+#define FILE_DEVICE_VMCI 0x8103
2825+#define VMCI_IOCTL_BASE_INDEX 0x801
2826+#define VMCIIOCTL_BUFFERED(name) \
2827+ CTL_CODE(FILE_DEVICE_VMCI, \
2828+ VMCI_IOCTL_BASE_INDEX + IOCTLCMD_VMCI_ ## name, \
2829+ METHOD_BUFFERED, \
2830+ FILE_ANY_ACCESS)
2831+#define VMCIIOCTL_NEITHER(name) \
2832+ CTL_CODE(FILE_DEVICE_VMCI, \
2833+ VMCI_IOCTL_BASE_INDEX + IOCTLCMD_VMCI_ ## name, \
2834+ METHOD_NEITHER, \
2835+ FILE_ANY_ACCESS)
2836+
2837+enum IOCTLCmd_VMCIWin32 {
2838+ IOCTLCMD(DEVICE_GET) = IOCTLCMD(LAST2) + 1,
2839+ IOCTLCMD(SOCKETS_SERVICE_GET),
2840+ IOCTLCMD(SOCKETS_STOP),
2841+};
2842+
2843+#define IOCTL_VMCI_VERSION VMCIIOCTL_BUFFERED(VERSION)
2844+
2845+/* BEGIN VMCI */
2846+#define IOCTL_VMCI_INIT_CONTEXT \
2847+ VMCIIOCTL_BUFFERED(INIT_CONTEXT)
2848+#define IOCTL_VMCI_HYPERCALL \
2849+ VMCIIOCTL_BUFFERED(HYPERCALL)
2850+#define IOCTL_VMCI_CREATE_DATAGRAM_HANDLE \
2851+ VMCIIOCTL_BUFFERED(CREATE_DATAGRAM_HANDLE)
2852+#define IOCTL_VMCI_DESTROY_DATAGRAM_HANDLE \
2853+ VMCIIOCTL_BUFFERED(DESTROY_DATAGRAM_HANDLE)
2854+#define IOCTL_VMCI_NOTIFY_RESOURCE \
2855+ VMCIIOCTL_BUFFERED(NOTIFY_RESOURCE)
2856+#define IOCTL_VMCI_NOTIFICATIONS_RECEIVE \
2857+ VMCIIOCTL_BUFFERED(NOTIFICATIONS_RECEIVE)
2858+#define IOCTL_VMCI_VERSION2 \
2859+ VMCIIOCTL_BUFFERED(VERSION2)
2860+#define IOCTL_VMCI_QUEUEPAIR_ALLOC \
2861+ VMCIIOCTL_BUFFERED(QUEUEPAIR_ALLOC)
2862+#define IOCTL_VMCI_QUEUEPAIR_SETVA \
2863+ VMCIIOCTL_BUFFERED(QUEUEPAIR_SETVA)
2864+#define IOCTL_VMCI_QUEUEPAIR_SETPAGEFILE \
2865+ VMCIIOCTL_BUFFERED(QUEUEPAIR_SETPAGEFILE)
2866+#define IOCTL_VMCI_QUEUEPAIR_DETACH \
2867+ VMCIIOCTL_BUFFERED(QUEUEPAIR_DETACH)
2868+#define IOCTL_VMCI_DATAGRAM_SEND \
2869+ VMCIIOCTL_BUFFERED(DATAGRAM_SEND)
2870+#define IOCTL_VMCI_DATAGRAM_RECEIVE \
2871+ VMCIIOCTL_NEITHER(DATAGRAM_RECEIVE)
2872+#define IOCTL_VMCI_DATAGRAM_REQUEST_MAP \
2873+ VMCIIOCTL_BUFFERED(DATAGRAM_REQUEST_MAP)
2874+#define IOCTL_VMCI_DATAGRAM_REMOVE_MAP \
2875+ VMCIIOCTL_BUFFERED(DATAGRAM_REMOVE_MAP)
2876+#define IOCTL_VMCI_CTX_ADD_NOTIFICATION \
2877+ VMCIIOCTL_BUFFERED(CTX_ADD_NOTIFICATION)
2878+#define IOCTL_VMCI_CTX_REMOVE_NOTIFICATION \
2879+ VMCIIOCTL_BUFFERED(CTX_REMOVE_NOTIFICATION)
2880+#define IOCTL_VMCI_CTX_GET_CPT_STATE \
2881+ VMCIIOCTL_BUFFERED(CTX_GET_CPT_STATE)
2882+#define IOCTL_VMCI_CTX_SET_CPT_STATE \
2883+ VMCIIOCTL_BUFFERED(CTX_SET_CPT_STATE)
2884+#define IOCTL_VMCI_GET_CONTEXT_ID \
2885+ VMCIIOCTL_BUFFERED(GET_CONTEXT_ID)
2886+#define IOCTL_VMCI_DEVICE_GET \
2887+ VMCIIOCTL_BUFFERED(DEVICE_GET)
2888+/* END VMCI */
2889+
2890+/* BEGIN VMCI SOCKETS */
2891+#define IOCTL_VMCI_SOCKETS_VERSION \
2892+ VMCIIOCTL_BUFFERED(SOCKETS_VERSION)
2893+#define IOCTL_VMCI_SOCKETS_BIND \
2894+ VMCIIOCTL_BUFFERED(SOCKETS_BIND)
2895+#define IOCTL_VMCI_SOCKETS_CONNECT \
2896+ VMCIIOCTL_BUFFERED(SOCKETS_CONNECT)
2897+#define IOCTL_VMCI_SOCKETS_GET_AF_VALUE \
2898+ VMCIIOCTL_BUFFERED(SOCKETS_GET_AF_VALUE)
2899+#define IOCTL_VMCI_SOCKETS_GET_LOCAL_CID \
2900+ VMCIIOCTL_BUFFERED(SOCKETS_GET_LOCAL_CID)
2901+#define IOCTL_VMCI_SOCKETS_GET_SOCK_NAME \
2902+ VMCIIOCTL_BUFFERED(SOCKETS_GET_SOCK_NAME)
2903+#define IOCTL_VMCI_SOCKETS_GET_SOCK_OPT \
2904+ VMCIIOCTL_BUFFERED(SOCKETS_GET_SOCK_OPT)
2905+#define IOCTL_VMCI_SOCKETS_GET_VM_BY_NAME \
2906+ VMCIIOCTL_BUFFERED(SOCKETS_GET_VM_BY_NAME)
2907+#define IOCTL_VMCI_SOCKETS_IOCTL \
2908+ VMCIIOCTL_BUFFERED(SOCKETS_IOCTL)
2909+#define IOCTL_VMCI_SOCKETS_LISTEN \
2910+ VMCIIOCTL_BUFFERED(SOCKETS_LISTEN)
2911+#define IOCTL_VMCI_SOCKETS_RECV_FROM \
2912+ VMCIIOCTL_BUFFERED(SOCKETS_RECV_FROM)
2913+#define IOCTL_VMCI_SOCKETS_SELECT \
2914+ VMCIIOCTL_BUFFERED(SOCKETS_SELECT)
2915+#define IOCTL_VMCI_SOCKETS_SEND_TO \
2916+ VMCIIOCTL_BUFFERED(SOCKETS_SEND_TO)
2917+#define IOCTL_VMCI_SOCKETS_SET_SOCK_OPT \
2918+ VMCIIOCTL_BUFFERED(SOCKETS_SET_SOCK_OPT)
2919+#define IOCTL_VMCI_SOCKETS_SHUTDOWN \
2920+ VMCIIOCTL_BUFFERED(SOCKETS_SHUTDOWN)
2921+#define IOCTL_VMCI_SOCKETS_SERVICE_GET \
2922+ VMCIIOCTL_BUFFERED(SOCKETS_SERVICE_GET)
2923+#define IOCTL_VMCI_SOCKETS_STOP \
2924+ VMCIIOCTL_NEITHER(SOCKETS_STOP)
2925+/* END VMCI SOCKETS */
2926+
2927+#endif // _WIN32
2928+
2929+
2930+/*
2931+ * VMCI driver initialization. This block can also be used to
2932+ * pass initial group membership etc.
2933+ */
2934+typedef struct VMCIInitBlock {
2935+ VMCIId cid;
2936+ VMCIPrivilegeFlags flags;
2937+#ifdef _WIN32
2938+ uint64 event; /* Handle for signalling vmci calls on windows. */
2939+#endif // _WIN32
2940+} VMCIInitBlock;
2941+
2942+typedef struct VMCISharedMemInfo {
2943+ VMCIHandle handle;
2944+ uint32 size;
2945+ uint32 result;
2946+ VA64 va; /* Currently only used in the guest. */
2947+ char pageFileName[VMCI_PATH_MAX];
2948+} VMCISharedMemInfo;
2949+
2950+typedef struct VMCIQueuePairAllocInfo_VMToVM {
2951+ VMCIHandle handle;
2952+ VMCIId peer;
2953+ uint32 flags;
2954+ uint64 produceSize;
2955+ uint64 consumeSize;
2956+#if !defined(VMX86_SERVER) && !defined(VMKERNEL)
2957+ VA64 producePageFile; /* User VA. */
2958+ VA64 consumePageFile; /* User VA. */
2959+ uint64 producePageFileSize; /* Size of the file name array. */
2960+ uint64 consumePageFileSize; /* Size of the file name array. */
2961+#else
2962+ PPN * PPNs;
2963+ uint64 numPPNs;
2964+#endif
2965+ int32 result;
2966+ uint32 _pad;
2967+} VMCIQueuePairAllocInfo_VMToVM;
2968+
2969+typedef struct VMCIQueuePairAllocInfo {
2970+ VMCIHandle handle;
2971+ VMCIId peer;
2972+ uint32 flags;
2973+ uint64 produceSize;
2974+ uint64 consumeSize;
2975+#if !defined(VMX86_SERVER) && !defined(VMKERNEL)
2976+ VA64 ppnVA; /* Start VA of queue pair PPNs. */
2977+#else
2978+ PPN * PPNs;
2979+#endif
2980+ uint64 numPPNs;
2981+ int32 result;
2982+ uint32 version;
2983+} VMCIQueuePairAllocInfo;
2984+
2985+typedef struct VMCIQueuePairSetVAInfo {
2986+ VMCIHandle handle;
2987+ VA64 va; /* Start VA of queue pair PPNs. */
2988+ uint64 numPPNs;
2989+ uint32 version;
2990+ int32 result;
2991+} VMCIQueuePairSetVAInfo;
2992+
2993+/*
2994+ * For backwards compatibility, here is a version of the
2995+ * VMCIQueuePairPageFileInfo before host support end-points was added.
2996+ * Note that the current version of that structure requires VMX to
2997+ * pass down the VA of the mapped file. Before host support was added
2998+ * there was nothing of the sort. So, when the driver sees the ioctl
2999+ * with a parameter that is the sizeof
3000+ * VMCIQueuePairPageFileInfo_NoHostQP then it can infer that the version
3001+ * of VMX running can't attach to host end points because it doesn't
3002+ * provide the VA of the mapped files.
3003+ *
3004+ * The Linux driver doesn't get an indication of the size of the
3005+ * structure passed down from user space. So, to fix a long standing
3006+ * but unfiled bug, the _pad field has been renamed to version.
3007+ * Existing versions of VMX always initialize the PageFileInfo
3008+ * structure so that _pad, er, version is set to 0.
3009+ *
3010+ * A version value of 1 indicates that the size of the structure has
3011+ * been increased to include two UVA's: produceUVA and consumeUVA.
3012+ * These UVA's are of the mmap()'d queue contents backing files.
3013+ *
3014+ * In addition, if when VMX is sending down the
3015+ * VMCIQueuePairPageFileInfo structure it gets an error then it will
3016+ * try again with the _NoHostQP version of the file to see if an older
3017+ * VMCI kernel module is running.
3018+ */
3019+typedef struct VMCIQueuePairPageFileInfo_NoHostQP {
3020+ VMCIHandle handle;
3021+ VA64 producePageFile; /* User VA. */
3022+ VA64 consumePageFile; /* User VA. */
3023+ uint64 producePageFileSize; /* Size of the file name array. */
3024+ uint64 consumePageFileSize; /* Size of the file name array. */
3025+ int32 result;
3026+ uint32 version; /* Was _pad. Must be 0. */
3027+} VMCIQueuePairPageFileInfo_NoHostQP;
3028+
3029+typedef struct VMCIQueuePairPageFileInfo {
3030+ VMCIHandle handle;
3031+#if !defined(VMX86_SERVER) && !defined(VMKERNEL)
3032+ VA64 producePageFile; /* User VA. */
3033+ VA64 consumePageFile; /* User VA. */
3034+ uint64 producePageFileSize; /* Size of the file name array. */
3035+ uint64 consumePageFileSize; /* Size of the file name array. */
3036+#endif
3037+ int32 result;
3038+ uint32 version; /* Was _pad. */
3039+ VA64 produceVA; /* User VA of the mapped file. */
3040+ VA64 consumeVA; /* User VA of the mapped file. */
3041+} VMCIQueuePairPageFileInfo;
3042+
3043+typedef struct VMCIQueuePairDetachInfo {
3044+ VMCIHandle handle;
3045+ int32 result;
3046+ uint32 _pad;
3047+} VMCIQueuePairDetachInfo;
3048+
3049+typedef struct VMCIDatagramSendRecvInfo {
3050+ VA64 addr;
3051+ uint32 len;
3052+ int32 result;
3053+} VMCIDatagramSendRecvInfo;
3054+
3055+/* Used to add/remove well-known datagram mappings. */
3056+typedef struct VMCIDatagramMapInfo {
3057+ VMCIId wellKnownID;
3058+ int result;
3059+} VMCIDatagramMapInfo;
3060+
3061+/* Used to add/remove remote context notifications. */
3062+typedef struct VMCINotifyAddRemoveInfo {
3063+ VMCIId remoteCID;
3064+ int result;
3065+} VMCINotifyAddRemoveInfo;
3066+
3067+/* Used to set/get current context's checkpoint state. */
3068+typedef struct VMCICptBufInfo {
3069+ VA64 cptBuf;
3070+ uint32 cptType;
3071+ uint32 bufSize;
3072+ int32 result;
3073+ uint32 _pad;
3074+} VMCICptBufInfo;
3075+
3076+/* Used to pass notify flag's address to the host driver. */
3077+typedef struct VMCISetNotifyInfo {
3078+ VA64 notifyUVA;
3079+ int32 result;
3080+ uint32 _pad;
3081+} VMCISetNotifyInfo;
3082+
3083+#define VMCI_NOTIFY_RESOURCE_QUEUE_PAIR 0
3084+#define VMCI_NOTIFY_RESOURCE_DOOR_BELL 1
3085+
3086+#define VMCI_NOTIFY_RESOURCE_ACTION_NOTIFY 0
3087+#define VMCI_NOTIFY_RESOURCE_ACTION_CREATE 1
3088+#define VMCI_NOTIFY_RESOURCE_ACTION_DESTROY 2
3089+
3090+/*
3091+ * Used to create and destroy doorbells, and generate a notification
3092+ * for a doorbell or queue pair.
3093+ */
3094+
3095+typedef struct VMCINotifyResourceInfo {
3096+ VMCIHandle handle;
3097+ uint16 resource;
3098+ uint16 action;
3099+ int32 result;
3100+} VMCINotifyResourceInfo;
3101+
3102+/*
3103+ * Used to recieve pending notifications for doorbells and queue
3104+ * pairs.
3105+ */
3106+
3107+typedef struct VMCINotificationReceiveInfo {
3108+ VA64 dbHandleBufUVA;
3109+ uint64 dbHandleBufSize;
3110+ VA64 qpHandleBufUVA;
3111+ uint64 qpHandleBufSize;
3112+ int32 result;
3113+ uint32 _pad;
3114+} VMCINotificationReceiveInfo;
3115+
3116+#if defined(_WIN32) && defined(WINNT_DDK)
3117+/*
3118+ * Used on Windows to expose the API calls that are no longer exported. This
3119+ * is kernel-mode only, and both sides will have the same bitness, so we can
3120+ * use pointers directly.
3121+ */
3122+
3123+/* Version 1. */
3124+typedef struct VMCIDeviceGetInfoVer1 {
3125+ VMCI_DeviceReleaseFct *deviceRelease;
3126+ VMCIDatagram_CreateHndFct *dgramCreateHnd;
3127+ VMCIDatagram_CreateHndPrivFct *dgramCreateHndPriv;
3128+ VMCIDatagram_DestroyHndFct *dgramDestroyHnd;
3129+ VMCIDatagram_SendFct *dgramSend;
3130+ VMCI_GetContextIDFct *getContextId;
3131+ VMCI_VersionFct *version;
3132+ VMCIEvent_SubscribeFct *eventSubscribe;
3133+ VMCIEvent_UnsubscribeFct *eventUnsubscribe;
3134+ VMCIQPair_AllocFct *qpairAlloc;
3135+ VMCIQPair_DetachFct *qpairDetach;
3136+ VMCIQPair_GetProduceIndexesFct *qpairGetProduceIndexes;
3137+ VMCIQPair_GetConsumeIndexesFct *qpairGetConsumeIndexes;
3138+ VMCIQPair_ProduceFreeSpaceFct *qpairProduceFreeSpace;
3139+ VMCIQPair_ProduceBufReadyFct *qpairProduceBufReady;
3140+ VMCIQPair_ConsumeFreeSpaceFct *qpairConsumeFreeSpace;
3141+ VMCIQPair_ConsumeBufReadyFct *qpairConsumeBufReady;
3142+ VMCIQPair_EnqueueFct *qpairEnqueue;
3143+ VMCIQPair_DequeueFct *qpairDequeue;
3144+ VMCIQPair_PeekFct *qpairPeek;
3145+ VMCIQPair_EnqueueVFct *qpairEnqueueV;
3146+ VMCIQPair_DequeueVFct *qpairDequeueV;
3147+ VMCIQPair_PeekVFct *qpairPeekV;
3148+ VMCI_ContextID2HostVmIDFct *contextID2HostVmID;
3149+ VMCI_IsContextOwnerFct *isContextOwner;
3150+ VMCIContext_GetPrivFlagsFct *contextGetPrivFlags;
3151+} VMCIDeviceGetInfoVer1;
3152+
3153+/* Version 2. */
3154+typedef struct VMCIDeviceGetInfoVer2 {
3155+ VMCIDoorbell_CreateFct *doorbellCreate;
3156+ VMCIDoorbell_DestroyFct *doorbellDestroy;
3157+ VMCIDoorbell_NotifyFct *doorbellNotify;
3158+} VMCIDeviceGetInfoVer2;
3159+
3160+typedef struct VMCIDeviceGetInfoHdr {
3161+ /* Requested API version on input, supported version on output. */
3162+ uint32 apiVersion;
3163+ VMCI_DeviceShutdownFn *deviceShutdownCB;
3164+ void *userData;
3165+ void *deviceRegistration;
3166+} VMCIDeviceGetInfoHdr;
3167+
3168+/* Combination of all versions. */
3169+typedef struct VMCIDeviceGetInfo {
3170+ VMCIDeviceGetInfoHdr hdr;
3171+ VMCIDeviceGetInfoVer1 ver1;
3172+ VMCIDeviceGetInfoVer2 ver2;
3173+} VMCIDeviceGetInfo;
3174+#endif // _WIN32 && WINNT_DDK
3175+
3176+
3177+#ifdef __APPLE__
3178+/*
3179+ * Mac OS ioctl definitions.
3180+ *
3181+ * Mac OS defines _IO* macros, and the core kernel code uses the size encoded
3182+ * in the ioctl value to copy the memory back and forth (depending on the
3183+ * direction encoded in the ioctl value) between the user and kernel address
3184+ * spaces.
3185+ * See iocontrolsMacOS.h for details on how this is done. We use sockets only
3186+ * for vmci.
3187+ */
3188+
3189+#include <sys/ioccom.h>
3190+
3191+enum VMCrossTalkSockOpt {
3192+ VMCI_SO_VERSION = 0,
3193+ VMCI_SO_CONTEXT = IOCTL_VMCI_INIT_CONTEXT,
3194+ VMCI_SO_NOTIFY_RESOURCE = IOCTL_VMCI_NOTIFY_RESOURCE,
3195+ VMCI_SO_NOTIFICATIONS_RECEIVE = IOCTL_VMCI_NOTIFICATIONS_RECEIVE,
3196+ VMCI_SO_VERSION2 = IOCTL_VMCI_VERSION2,
3197+ VMCI_SO_QUEUEPAIR_ALLOC = IOCTL_VMCI_QUEUEPAIR_ALLOC,
3198+ VMCI_SO_QUEUEPAIR_SETVA = IOCTL_VMCI_QUEUEPAIR_SETVA,
3199+ VMCI_SO_QUEUEPAIR_SETPAGEFILE = IOCTL_VMCI_QUEUEPAIR_SETPAGEFILE,
3200+ VMCI_SO_QUEUEPAIR_DETACH = IOCTL_VMCI_QUEUEPAIR_DETACH,
3201+ VMCI_SO_DATAGRAM_SEND = IOCTL_VMCI_DATAGRAM_SEND,
3202+ VMCI_SO_DATAGRAM_RECEIVE = IOCTL_VMCI_DATAGRAM_RECEIVE,
3203+ VMCI_SO_DATAGRAM_REQUEST_MAP = IOCTL_VMCI_DATAGRAM_REQUEST_MAP,
3204+ VMCI_SO_DATAGRAM_REMOVE_MAP = IOCTL_VMCI_DATAGRAM_REMOVE_MAP,
3205+ VMCI_SO_CTX_ADD_NOTIFICATION = IOCTL_VMCI_CTX_ADD_NOTIFICATION,
3206+ VMCI_SO_CTX_REMOVE_NOTIFICATION = IOCTL_VMCI_CTX_REMOVE_NOTIFICATION,
3207+ VMCI_SO_CTX_GET_CPT_STATE = IOCTL_VMCI_CTX_GET_CPT_STATE,
3208+ VMCI_SO_CTX_SET_CPT_STATE = IOCTL_VMCI_CTX_SET_CPT_STATE,
3209+ VMCI_SO_GET_CONTEXT_ID = IOCTL_VMCI_GET_CONTEXT_ID,
3210+ VMCI_SO_USERFD,
3211+};
3212+
3213+#define VMCI_MACOS_HOST_DEVICE "com.vmware.kext.vmci"
3214+
3215+#endif
3216+
3217+/* Clean up helper macros */
3218+#undef IOCTLCMD
3219+
3220+#endif // ifndef _VMCI_IOCONTROLS_H_
3221
3222=== added file '.pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_kernel_if.h'
3223--- .pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_kernel_if.h 1970-01-01 00:00:00 +0000
3224+++ .pc/04-quantal-module-backport.patch/modules/linux/shared/vmci_kernel_if.h 2013-06-28 21:11:42 +0000
3225@@ -0,0 +1,462 @@
3226+/*********************************************************
3227+ * Copyright (C) 2006-2011 VMware, Inc. All rights reserved.
3228+ *
3229+ * This program is free software; you can redistribute it and/or modify it
3230+ * under the terms of the GNU General Public License as published by the
3231+ * Free Software Foundation version 2 and no later version.
3232+ *
3233+ * This program is distributed in the hope that it will be useful, but
3234+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
3235+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3236+ * for more details.
3237+ *
3238+ * You should have received a copy of the GNU General Public License along
3239+ * with this program; if not, write to the Free Software Foundation, Inc.,
3240+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3241+ *
3242+ *********************************************************/
3243+
3244+/*
3245+ * vmci_kernel_if.h --
3246+ *
3247+ * This file defines helper functions for VMCI host _and_ guest
3248+ * kernel code. It must work for Windows, Mac OS, vmkernel, Linux and
3249+ * Solaris kernels, i.e. using defines where necessary.
3250+ */
3251+
3252+#ifndef _VMCI_KERNEL_IF_H_
3253+#define _VMCI_KERNEL_IF_H_
3254+
3255+#if !defined(linux) && !defined(_WIN32) && !defined(__APPLE__) && \
3256+ !defined(VMKERNEL) && !defined(SOLARIS)
3257+# error "Platform not supported."
3258+#endif
3259+
3260+#if defined(_WIN32)
3261+# include <ntddk.h>
3262+#endif
3263+
3264+#if defined(linux) && !defined(VMKERNEL)
3265+# include "driver-config.h"
3266+# include "compat_cred.h"
3267+# include "compat_module.h"
3268+# include "compat_semaphore.h"
3269+# include "compat_spinlock.h"
3270+# include "compat_version.h"
3271+# include <linux/wait.h>
3272+#endif // linux
3273+
3274+#ifdef __APPLE__
3275+# include <IOKit/IOLib.h>
3276+# include <mach/task.h>
3277+# include <mach/semaphore.h>
3278+# include <sys/kauth.h>
3279+#endif
3280+
3281+#ifdef VMKERNEL
3282+# include "splock.h"
3283+# include "semaphore_ext.h"
3284+# include "vmkapi.h"
3285+# include "world_dist.h"
3286+#endif
3287+
3288+#ifdef SOLARIS
3289+# include <sys/ddi.h>
3290+# include <sys/kmem.h>
3291+# include <sys/mutex.h>
3292+# include <sys/poll.h>
3293+# include <sys/semaphore.h>
3294+# include <sys/sunddi.h>
3295+# include <sys/types.h>
3296+#endif
3297+
3298+#include "vm_basic_types.h"
3299+#include "vmci_defs.h"
3300+
3301+#if defined(VMKERNEL)
3302+# include "list.h"
3303+#else
3304+# include "dbllnklst.h"
3305+#endif
3306+
3307+/* Flags for specifying memory type. */
3308+#define VMCI_MEMORY_NORMAL 0x0
3309+#define VMCI_MEMORY_ATOMIC 0x1
3310+#define VMCI_MEMORY_NONPAGED 0x2
3311+
3312+/* Platform specific type definitions. */
3313+
3314+#if defined(VMKERNEL)
3315+# define VMCI_EXPORT_SYMBOL(_SYMBOL) VMK_MODULE_EXPORT_SYMBOL(_SYMBOL);
3316+#elif defined(linux)
3317+# define VMCI_EXPORT_SYMBOL(_symbol) EXPORT_SYMBOL(_symbol);
3318+#elif defined(__APPLE__)
3319+# define VMCI_EXPORT_SYMBOL(_symbol) __attribute__((visibility("default")))
3320+#else
3321+# define VMCI_EXPORT_SYMBOL(_symbol)
3322+#endif
3323+
3324+#if defined(VMKERNEL)
3325+ typedef SP_SpinLock VMCILock;
3326+ typedef SP_IRQL VMCILockFlags;
3327+ typedef Semaphore VMCIEvent;
3328+ typedef Semaphore VMCIMutex;
3329+ typedef World_ID VMCIHostVmID;
3330+ typedef uint32 VMCIHostUser;
3331+ typedef PPN *VMCIQPGuestMem;
3332+#elif defined(linux)
3333+ typedef spinlock_t VMCILock;
3334+ typedef unsigned long VMCILockFlags;
3335+ typedef wait_queue_head_t VMCIEvent;
3336+ typedef struct semaphore VMCIMutex;
3337+ typedef PPN *VMCIPpnList; /* List of PPNs in produce/consume queue. */
3338+ typedef uid_t VMCIHostUser;
3339+ typedef VA64 VMCIQPGuestMem;
3340+#elif defined(__APPLE__)
3341+ typedef IOLock *VMCILock;
3342+ typedef unsigned long VMCILockFlags;
3343+ typedef struct {
3344+ IOLock *lock;
3345+ DblLnkLst_Links waiters;
3346+ int buffered;
3347+ } VMCIEvent;
3348+ typedef IOLock *VMCIMutex;
3349+ typedef void *VMCIPpnList; /* Actually a pointer to the C++ Object IOMemoryDescriptor */
3350+ typedef uid_t VMCIHostUser;
3351+ typedef VA64 *VMCIQPGuestMem;
3352+#elif defined(_WIN32)
3353+ typedef KSPIN_LOCK VMCILock;
3354+ typedef KIRQL VMCILockFlags;
3355+ typedef KEVENT VMCIEvent;
3356+ typedef FAST_MUTEX VMCIMutex;
3357+ typedef PMDL VMCIPpnList; /* MDL to map the produce/consume queue. */
3358+ typedef PSID VMCIHostUser;
3359+ typedef VA64 *VMCIQPGuestMem;
3360+#elif defined(SOLARIS)
3361+ typedef kmutex_t VMCILock;
3362+ typedef unsigned long VMCILockFlags;
3363+ typedef ksema_t VMCIEvent;
3364+ typedef kmutex_t VMCIMutex;
3365+ typedef PPN *VMCIPpnList; /* List of PPNs in produce/consume queue. */
3366+ typedef uid_t VMCIHostUser;
3367+ typedef VA64 VMCIQPGuestMem;
3368+#endif // VMKERNEL
3369+
3370+/* Callback needed for correctly waiting on events. */
3371+typedef int (*VMCIEventReleaseCB)(void *clientData);
3372+
3373+/*
3374+ * Internal locking dependencies within VMCI:
3375+ * * CONTEXTFIRE < CONTEXT, CONTEXTLIST, EVENT, HASHTABLE
3376+ * * DOORBELL < HASHTABLE
3377+ * * QPHIBERNATE < EVENT
3378+ */
3379+
3380+#ifdef VMKERNEL
3381+ typedef Lock_Rank VMCILockRank;
3382+ typedef SemaRank VMCISemaRank;
3383+
3384+ #define VMCI_SEMA_RANK_QPHEADER (SEMA_RANK_FS - 1)
3385+
3386+ #define VMCI_LOCK_RANK_MAX (MIN(SP_RANK_WAIT, \
3387+ SP_RANK_HEAPLOCK_DYNAMIC) - 1)
3388+#else
3389+ typedef unsigned long VMCILockRank;
3390+ typedef unsigned long VMCISemaRank;
3391+
3392+ #define VMCI_LOCK_RANK_MAX 0x0fff
3393+
3394+ #define VMCI_SEMA_RANK_QPHEADER 0x0fff
3395+#endif // VMKERNEL
3396+#define VMCI_LOCK_RANK_CONTEXT VMCI_LOCK_RANK_MAX
3397+#define VMCI_LOCK_RANK_CONTEXTLIST VMCI_LOCK_RANK_MAX
3398+#define VMCI_LOCK_RANK_DATAGRAMVMK VMCI_LOCK_RANK_MAX
3399+#define VMCI_LOCK_RANK_EVENT VMCI_LOCK_RANK_MAX
3400+#define VMCI_LOCK_RANK_HASHTABLE VMCI_LOCK_RANK_MAX
3401+#define VMCI_LOCK_RANK_RESOURCE VMCI_LOCK_RANK_MAX
3402+#define VMCI_LOCK_RANK_QPHEADER VMCI_LOCK_RANK_MAX
3403+#define VMCI_LOCK_RANK_DOORBELL (VMCI_LOCK_RANK_HASHTABLE - 1)
3404+#define VMCI_LOCK_RANK_CONTEXTFIRE (MIN(VMCI_LOCK_RANK_CONTEXT, \
3405+ MIN(VMCI_LOCK_RANK_CONTEXTLIST, \
3406+ MIN(VMCI_LOCK_RANK_EVENT, \
3407+ VMCI_LOCK_RANK_HASHTABLE))) - 1)
3408+#define VMCI_LOCK_RANK_QPHIBERNATE (VMCI_LOCK_RANK_EVENT - 1)
3409+#define VMCI_LOCK_RANK_PACKET_QP (VMCI_LOCK_RANK_QPHEADER - 1)
3410+//#define VMCI_LOCK_RANK_PACKET_QP 0xffd /* For vVol */
3411+
3412+#define VMCI_SEMA_RANK_QUEUEPAIRLIST (VMCI_SEMA_RANK_QPHEADER - 1)
3413+#define VMCI_SEMA_RANK_GUESTMEM (VMCI_SEMA_RANK_QUEUEPAIRLIST - 1)
3414+#define VMCI_SEMA_RANK_PACKET_QP (VMCI_SEMA_RANK_QPHEADER - 1)
3415+//#define VMCI_SEMA_RANK_PACKET_QP 0xffd /* For vVol */
3416+
3417+/*
3418+ * Host specific struct used for signalling.
3419+ */
3420+
3421+typedef struct VMCIHost {
3422+#if defined(VMKERNEL)
3423+ World_ID vmmWorldID[2]; /*
3424+ * First one is the active one and the second
3425+ * one is shadow world during FSR.
3426+ */
3427+#elif defined(linux)
3428+ wait_queue_head_t waitQueue;
3429+#elif defined(__APPLE__)
3430+ struct Socket *socket; /* vmci Socket object on Mac OS. */
3431+#elif defined(_WIN32)
3432+ KEVENT *callEvent; /* Ptr to userlevel event used when signalling
3433+ * new pending guestcalls in kernel.
3434+ */
3435+#elif defined(SOLARIS)
3436+ struct pollhead pollhead; /* Per datagram handle pollhead structure to
3437+ * be treated as a black-box. None of its
3438+ * fields should be referenced.
3439+ */
3440+#endif
3441+} VMCIHost;
3442+
3443+/*
3444+ * Guest device port I/O.
3445+ */
3446+
3447+#if defined(linux)
3448+ typedef unsigned short int VMCIIoPort;
3449+ typedef int VMCIIoHandle;
3450+#elif defined(_WIN32)
3451+ typedef PUCHAR VMCIIoPort;
3452+ typedef int VMCIIoHandle;
3453+#elif defined(SOLARIS)
3454+ typedef uint8_t * VMCIIoPort;
3455+ typedef ddi_acc_handle_t VMCIIoHandle;
3456+#elif defined(__APPLE__)
3457+ typedef unsigned short int VMCIIoPort;
3458+ typedef void *VMCIIoHandle;
3459+#endif // __APPLE__
3460+
3461+void VMCI_ReadPortBytes(VMCIIoHandle handle, VMCIIoPort port, uint8 *buffer,
3462+ size_t bufferLength);
3463+
3464+
3465+int VMCI_InitLock(VMCILock *lock, char *name, VMCILockRank rank);
3466+void VMCI_CleanupLock(VMCILock *lock);
3467+void VMCI_GrabLock(VMCILock *lock, VMCILockFlags *flags);
3468+void VMCI_ReleaseLock(VMCILock *lock, VMCILockFlags flags);
3469+void VMCI_GrabLock_BH(VMCILock *lock, VMCILockFlags *flags);
3470+void VMCI_ReleaseLock_BH(VMCILock *lock, VMCILockFlags flags);
3471+
3472+void VMCIHost_InitContext(VMCIHost *hostContext, uintptr_t eventHnd);
3473+void VMCIHost_ReleaseContext(VMCIHost *hostContext);
3474+void VMCIHost_SignalCall(VMCIHost *hostContext);
3475+void VMCIHost_ClearCall(VMCIHost *hostContext);
3476+Bool VMCIHost_WaitForCallLocked(VMCIHost *hostContext,
3477+ VMCILock *lock,
3478+ VMCILockFlags *flags,
3479+ Bool useBH);
3480+#ifdef VMKERNEL
3481+int VMCIHost_ContextToHostVmID(VMCIHost *hostContext, VMCIHostVmID *hostVmID);
3482+void VMCIHost_SetActiveHnd(VMCIHost *hostContext, uintptr_t eventHnd);
3483+Bool VMCIHost_RemoveHnd(VMCIHost *hostContext, uintptr_t eventHnd);
3484+Bool VMCIHost_IsActiveHnd(VMCIHost *hostContext, uintptr_t eventHnd);
3485+void VMCIHost_SetInactiveHnd(VMCIHost *hostContext, uintptr_t eventHnd);
3486+uint32 VMCIHost_NumHnds(VMCIHost *hostContext);
3487+uintptr_t VMCIHost_GetActiveHnd(VMCIHost *hostContext);
3488+void VMCIHost_SignalBitmap(VMCIHost *hostContext);
3489+#endif
3490+
3491+#if defined(_WIN32)
3492+ /*
3493+ * On Windows, Driver Verifier will panic() if we leak memory when we are
3494+ * unloaded. It dumps the leaked blocks for us along with callsites, which
3495+ * it handily tracks, but if we embed ExAllocate() inside a function, then
3496+ * the callsite is useless. So make this a macro on this platform only.
3497+ */
3498+# define VMCI_AllocKernelMem(_sz, _f) \
3499+ ExAllocatePoolWithTag((((_f) & VMCI_MEMORY_NONPAGED) ? \
3500+ NonPagedPool : PagedPool), \
3501+ (_sz), 'MMTC')
3502+#else // _WIN32
3503+void *VMCI_AllocKernelMem(size_t size, int flags);
3504+#endif // _WIN32
3505+void VMCI_FreeKernelMem(void *ptr, size_t size);
3506+
3507+int VMCI_CopyToUser(VA64 dst, const void *src, size_t len);
3508+Bool VMCIWellKnownID_AllowMap(VMCIId wellKnownID,
3509+ VMCIPrivilegeFlags privFlags);
3510+
3511+int VMCIHost_CompareUser(VMCIHostUser *user1, VMCIHostUser *user2);
3512+
3513+void VMCI_CreateEvent(VMCIEvent *event);
3514+void VMCI_DestroyEvent(VMCIEvent *event);
3515+void VMCI_SignalEvent(VMCIEvent *event);
3516+void VMCI_WaitOnEvent(VMCIEvent *event, VMCIEventReleaseCB releaseCB,
3517+ void *clientData);
3518+#if (defined(__APPLE__) || defined(__linux__) || defined(_WIN32)) && !defined(VMKERNEL)
3519+Bool VMCI_WaitOnEventInterruptible(VMCIEvent *event,
3520+ VMCIEventReleaseCB releaseCB,
3521+ void *clientData);
3522+#endif
3523+
3524+#if !defined(VMKERNEL) && (defined(__linux__) || defined(_WIN32) || \
3525+ defined(__APPLE__) || defined(SOLARIS))
3526+int VMCI_CopyFromUser(void *dst, VA64 src, size_t len);
3527+#endif
3528+
3529+typedef void (VMCIWorkFn)(void *data);
3530+Bool VMCI_CanScheduleDelayedWork(void);
3531+int VMCI_ScheduleDelayedWork(VMCIWorkFn *workFn, void *data);
3532+
3533+int VMCIMutex_Init(VMCIMutex *mutex, char *name, VMCILockRank rank);
3534+void VMCIMutex_Destroy(VMCIMutex *mutex);
3535+void VMCIMutex_Acquire(VMCIMutex *mutex);
3536+void VMCIMutex_Release(VMCIMutex *mutex);
3537+
3538+#if defined(SOLARIS) || defined(_WIN32) || defined(__APPLE__)
3539+int VMCIKernelIf_Init(void);
3540+void VMCIKernelIf_Exit(void);
3541+#if defined(_WIN32)
3542+void VMCIKernelIf_DrainDelayedWork(void);
3543+#endif // _WIN32
3544+#endif // SOLARIS || _WIN32 || __APPLE__
3545+
3546+#if !defined(VMKERNEL) && (defined(__linux__) || defined(_WIN32) || \
3547+ defined(SOLARIS) || defined(__APPLE__))
3548+void *VMCI_AllocQueue(uint64 size, uint32 flags);
3549+void VMCI_FreeQueue(void *q, uint64 size);
3550+typedef struct PPNSet {
3551+ uint64 numProducePages;
3552+ uint64 numConsumePages;
3553+ VMCIPpnList producePPNs;
3554+ VMCIPpnList consumePPNs;
3555+ Bool initialized;
3556+} PPNSet;
3557+int VMCI_AllocPPNSet(void *produceQ, uint64 numProducePages, void *consumeQ,
3558+ uint64 numConsumePages, PPNSet *ppnSet);
3559+void VMCI_FreePPNSet(PPNSet *ppnSet);
3560+int VMCI_PopulatePPNList(uint8 *callBuf, const PPNSet *ppnSet);
3561+#endif
3562+
3563+struct VMCIQueue;
3564+
3565+struct PageStoreAttachInfo;
3566+struct VMCIQueue *VMCIHost_AllocQueue(uint64 queueSize);
3567+void VMCIHost_FreeQueue(struct VMCIQueue *queue, uint64 queueSize);
3568+
3569+#if defined(VMKERNEL)
3570+typedef World_Handle *VMCIGuestMemID;
3571+#define INVALID_VMCI_GUEST_MEM_ID NULL
3572+#else
3573+typedef uint32 VMCIGuestMemID;
3574+#define INVALID_VMCI_GUEST_MEM_ID 0
3575+#endif
3576+
3577+#if defined(VMKERNEL) || defined(__linux__) || defined(_WIN32) || \
3578+ defined(__APPLE__)
3579+ struct QueuePairPageStore;
3580+ int VMCIHost_RegisterUserMemory(struct QueuePairPageStore *pageStore,
3581+ struct VMCIQueue *produceQ,
3582+ struct VMCIQueue *consumeQ);
3583+ void VMCIHost_UnregisterUserMemory(struct VMCIQueue *produceQ,
3584+ struct VMCIQueue *consumeQ);
3585+ int VMCIHost_MapQueues(struct VMCIQueue *produceQ,
3586+ struct VMCIQueue *consumeQ,
3587+ uint32 flags);
3588+ int VMCIHost_UnmapQueues(VMCIGuestMemID gid,
3589+ struct VMCIQueue *produceQ,
3590+ struct VMCIQueue *consumeQ);
3591+ void VMCI_InitQueueMutex(struct VMCIQueue *produceQ,
3592+ struct VMCIQueue *consumeQ);
3593+ void VMCI_CleanupQueueMutex(struct VMCIQueue *produceQ,
3594+ struct VMCIQueue *consumeQ);
3595+ int VMCI_AcquireQueueMutex(struct VMCIQueue *queue, Bool canBlock);
3596+ void VMCI_ReleaseQueueMutex(struct VMCIQueue *queue);
3597+#else // Below are the guest OS'es without host side support.
3598+# define VMCI_InitQueueMutex(_pq, _cq)
3599+# define VMCI_CleanupQueueMutex(_pq, _cq)
3600+# define VMCI_AcquireQueueMutex(_q, _cb) VMCI_SUCCESS
3601+# define VMCI_ReleaseQueueMutex(_q)
3602+# define VMCIHost_RegisterUserMemory(_ps, _pq, _cq) VMCI_ERROR_UNAVAILABLE
3603+# define VMCIHost_UnregisterUserMemory(_pq, _cq)
3604+# define VMCIHost_MapQueues(_pq, _cq, _f) VMCI_SUCCESS
3605+# define VMCIHost_UnmapQueues(_gid, _pq, _cq) VMCI_SUCCESS
3606+#endif
3607+
3608+#if defined(VMKERNEL)
3609+ void VMCIHost_MarkQueuesAvailable(struct VMCIQueue *produceQ,
3610+ struct VMCIQueue *consumeQ);
3611+ void VMCIHost_MarkQueuesUnavailable(struct VMCIQueue *produceQ,
3612+ struct VMCIQueue *consumeQ);
3613+#else
3614+# define VMCIHost_MarkQueuesAvailable(_q, _p) while(0) { }
3615+# define VMCIHost_MarkQueuesUnavailable(_q, _p) while(0) { }
3616+#endif
3617+
3618+#if defined(VMKERNEL) || defined(__linux__)
3619+ void VMCI_LockQueueHeader(struct VMCIQueue *queue);
3620+ void VMCI_UnlockQueueHeader(struct VMCIQueue *queue);
3621+#else
3622+# define VMCI_LockQueueHeader(_q) ASSERT_NOT_IMPLEMENTED(FALSE)
3623+# define VMCI_UnlockQueueHeader(_q) ASSERT_NOT_IMPLEMENTED(FALSE)
3624+#endif
3625+
3626+#if (!defined(VMKERNEL) && defined(__linux__)) || defined(_WIN32) || \
3627+ defined(__APPLE__) || defined(SOLARIS)
3628+ int VMCIHost_GetUserMemory(VA64 produceUVA, VA64 consumeUVA,
3629+ struct VMCIQueue *produceQ,
3630+ struct VMCIQueue *consumeQ);
3631+ void VMCIHost_ReleaseUserMemory(struct VMCIQueue *produceQ,
3632+ struct VMCIQueue *consumeQ);
3633+#else
3634+# define VMCIHost_GetUserMemory(_puva, _cuva, _pq, _cq) VMCI_ERROR_UNAVAILABLE
3635+# define VMCIHost_ReleaseUserMemory(_pq, _cq) ASSERT_NOT_IMPLEMENTED(FALSE)
3636+#endif
3637+
3638+#if defined(_WIN32)
3639+ Bool VMCI_EnqueueToDevNull(struct VMCIQueue *queue);
3640+ int VMCI_ConvertToLocalQueue(struct VMCIQueue *queueInfo,
3641+ struct VMCIQueue *otherQueueInfo,
3642+ uint64 size, Bool keepContent,
3643+ void **oldQueue);
3644+ void VMCI_RevertToNonLocalQueue(struct VMCIQueue *queueInfo,
3645+ void *nonLocalQueue, uint64 size);
3646+ void VMCI_FreeQueueBuffer(void *queue, uint64 size);
3647+ Bool VMCI_CanCreate(void);
3648+#else // _WIN32
3649+# define VMCI_EnqueueToDevNull(_q) FALSE
3650+# define VMCI_ConvertToLocalQueue(_pq, _cq, _s, _oq, _kc) VMCI_ERROR_UNAVAILABLE
3651+# define VMCI_RevertToNonLocalQueue(_q, _nlq, _s)
3652+# define VMCI_FreeQueueBuffer(_q, _s)
3653+# define VMCI_CanCreate() TRUE
3654+#endif // !_WIN32
3655+Bool VMCI_GuestPersonalityActive(void);
3656+Bool VMCI_HostPersonalityActive(void);
3657+
3658+
3659+#if defined(VMKERNEL)
3660+ typedef List_Links VMCIListItem;
3661+ typedef List_Links VMCIList;
3662+
3663+# define VMCIList_Init(_l) List_Init(_l)
3664+# define VMCIList_InitEntry(_e) List_InitElement(_e)
3665+# define VMCIList_Empty(_l) List_IsEmpty(_l)
3666+# define VMCIList_Insert(_e, _l) List_Insert(_e, LIST_ATREAR(_l))
3667+# define VMCIList_Remove(_e) List_Remove(_e)
3668+# define VMCIList_Scan(_cur, _l) LIST_FORALL(_l, _cur)
3669+# define VMCIList_ScanSafe(_cur, _next, _l) LIST_FORALL_SAFE(_l, _cur, _next)
3670+# define VMCIList_Entry(_elem, _type, _field) List_Entry(_elem, _type, _field)
3671+# define VMCIList_First(_l) (VMCIList_Empty(_l)?NULL:List_First(_l))
3672+#else
3673+ typedef DblLnkLst_Links VMCIListItem;
3674+ typedef DblLnkLst_Links VMCIList;
3675+
3676+# define VMCIList_Init(_l) DblLnkLst_Init(_l)
3677+# define VMCIList_InitEntry(_e) DblLnkLst_Init(_e)
3678+# define VMCIList_Empty(_l) (!DblLnkLst_IsLinked(_l))
3679+# define VMCIList_Insert(_e, _l) DblLnkLst_LinkLast(_l, _e)
3680+# define VMCIList_Remove(_e) DblLnkLst_Unlink1(_e)
3681+# define VMCIList_Scan(_cur, _l) DblLnkLst_ForEach(_cur, _l)
3682+# define VMCIList_ScanSafe(_cur, _next, _l) DblLnkLst_ForEachSafe(_cur, _next, _l)
3683+# define VMCIList_Entry(_elem, _type, _field) DblLnkLst_Container(_elem, _type, _field)
3684+# define VMCIList_First(_l) (VMCIList_Empty(_l)?NULL:(_l)->next)
3685+#endif
3686+
3687+#endif // _VMCI_KERNEL_IF_H_
3688
3689=== added directory '.pc/04-quantal-module-backport.patch/modules/linux/vmblock'
3690=== added directory '.pc/04-quantal-module-backport.patch/modules/linux/vmblock/linux'
3691=== added file '.pc/04-quantal-module-backport.patch/modules/linux/vmblock/linux/filesystem.c'
3692--- .pc/04-quantal-module-backport.patch/modules/linux/vmblock/linux/filesystem.c 1970-01-01 00:00:00 +0000
3693+++ .pc/04-quantal-module-backport.patch/modules/linux/vmblock/linux/filesystem.c 2013-06-28 21:11:42 +0000
3694@@ -0,0 +1,626 @@
3695+/*********************************************************
3696+ * Copyright (C) 2006 VMware, Inc. All rights reserved.
3697+ *
3698+ * This program is free software; you can redistribute it and/or modify it
3699+ * under the terms of the GNU General Public License as published by the
3700+ * Free Software Foundation version 2 and no later version.
3701+ *
3702+ * This program is distributed in the hope that it will be useful, but
3703+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
3704+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3705+ * for more details.
3706+ *
3707+ * You should have received a copy of the GNU General Public License along
3708+ * with this program; if not, write to the Free Software Foundation, Inc.,
3709+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3710+ *
3711+ *********************************************************/
3712+
3713+/*
3714+ * filesystem.c --
3715+ *
3716+ * File system for the vmblock driver.
3717+ *
3718+ */
3719+
3720+#include "driver-config.h"
3721+#include <linux/kernel.h>
3722+#include <linux/module.h>
3723+#include <linux/proc_fs.h>
3724+#include <linux/mount.h>
3725+#include <linux/fs.h>
3726+
3727+#include "compat_namei.h"
3728+
3729+#include "os.h"
3730+#include "vmblockInt.h"
3731+#include "filesystem.h"
3732+
3733+#define VMBLOCK_ROOT_INO 1
3734+#define GetRootInode(sb) Iget(sb, NULL, NULL, VMBLOCK_ROOT_INO)
3735+
3736+static struct inode *GetInode(struct super_block *sb, ino_t ino);
3737+
3738+/* File system operations */
3739+
3740+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
3741+static struct dentry *FsOpMount(struct file_system_type *fsType, int flags,
3742+ const char *devName, void *rawData);
3743+#elif defined(VMW_GETSB_2618)
3744+static int FsOpGetSb(struct file_system_type *fsType, int flags,
3745+ const char *devName, void *rawData, struct vfsmount *mnt);
3746+#else
3747+static struct super_block *FsOpGetSb(struct file_system_type *fsType, int flags,
3748+ const char *devName, void *rawData);
3749+#endif
3750+static int FsOpReadSuper(struct super_block *sb, void *rawData, int flags);
3751+
3752+
3753+/* Utility */
3754+static compat_kmem_cache_ctor InodeCacheCtor;
3755+
3756+
3757+/* Variables */
3758+compat_kmem_cache *VMBlockInodeCache;
3759+
3760+/* Local variables */
3761+static char const *fsRoot;
3762+static size_t fsRootLen;
3763+static struct file_system_type fsType = {
3764+ .owner = THIS_MODULE,
3765+ .name = VMBLOCK_FS_NAME,
3766+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
3767+ .mount = FsOpMount,
3768+#else
3769+ .get_sb = FsOpGetSb,
3770+#endif
3771+ .kill_sb = kill_anon_super,
3772+};
3773+
3774+
3775+/*
3776+ * Public functions (with respect to the module)
3777+ */
3778+
3779+/*
3780+ *----------------------------------------------------------------------------
3781+ *
3782+ * VMBlockInitFileSystem --
3783+ *
3784+ * Initializes the file system and registers it with the kernel.
3785+ *
3786+ * Results:
3787+ * Zero on success, negative error code on failure.
3788+ *
3789+ * Side effects:
3790+ * None.
3791+ *
3792+ *----------------------------------------------------------------------------
3793+ */
3794+
3795+int
3796+VMBlockInitFileSystem(char const *root) // IN: directory redirecting to
3797+{
3798+ int ret;
3799+
3800+ if (!root) {
3801+ Warning("VMBlockInitFileSystem: root not provided "
3802+ "(missing module parameter?)\n");
3803+ return -EINVAL;
3804+ }
3805+
3806+ /*
3807+ * Here we assume that the provided root is valid so the module will load.
3808+ * The mount operation will fail if that is not the case.
3809+ */
3810+ fsRoot = root;
3811+ fsRootLen = strlen(fsRoot);
3812+
3813+ if (fsRootLen >= PATH_MAX) {
3814+ return -ENAMETOOLONG;
3815+ }
3816+
3817+ /* Initialize our inode slab allocator */
3818+ VMBlockInodeCache = os_kmem_cache_create("VMBlockInodeCache",
3819+ sizeof (VMBlockInodeInfo),
3820+ 0,
3821+ InodeCacheCtor);
3822+ if (!VMBlockInodeCache) {
3823+ Warning("VMBlockInitFileSystem: could not initialize inode cache\n");
3824+ return -ENOMEM;
3825+ }
3826+
3827+ /* Tell the kernel about our file system */
3828+ ret = register_filesystem(&fsType);
3829+ if (ret < 0) {
3830+ Warning("VMBlockInitFileSystem: could not initialize file system\n");
3831+ kmem_cache_destroy(VMBlockInodeCache);
3832+ return ret;
3833+ }
3834+
3835+ LOG(4, "file system registered with root of [%s]\n", fsRoot);
3836+
3837+ return 0;
3838+}
3839+
3840+
3841+/*
3842+ *----------------------------------------------------------------------------
3843+ *
3844+ * VMBlockCleanupFileSystem --
3845+ *
3846+ * Cleans up file system and unregisters it with the kernel.
3847+ *
3848+ * Results:
3849+ * Zero on success, negative error code on failure.
3850+ *
3851+ * Side effects:
3852+ * None.
3853+ *
3854+ *----------------------------------------------------------------------------
3855+ */
3856+
3857+int
3858+VMBlockCleanupFileSystem(void)
3859+{
3860+ int ret;
3861+
3862+ ret = unregister_filesystem(&fsType);
3863+ if (ret < 0) {
3864+ Warning("VMBlockCleanupFileSystem: could not unregister file system\n");
3865+ return ret;
3866+ }
3867+
3868+ kmem_cache_destroy(VMBlockInodeCache);
3869+
3870+ return 0;
3871+}
3872+
3873+
3874+/*
3875+ *----------------------------------------------------------------------------
3876+ *
3877+ * VMBlockReadInode --
3878+ *
3879+ * A filesystem wide function that is called to initialize a new inode.
3880+ * This is called from two different places depending on the kernel version.
3881+ * In older kernels that provide the iget() interface, this function is
3882+ * called by the kernel as part of inode initialization (from
3883+ * SuperOpReadInode). In newer kernels that call iget_locked(), this
3884+ * function is called by filesystem code to initialize the new inode.
3885+ *
3886+ * Results:
3887+ * None.
3888+ *
3889+ * Side effects:
3890+ * None.
3891+ *
3892+ *----------------------------------------------------------------------------
3893+ */
3894+
3895+void
3896+VMBlockReadInode(struct inode *inode) // IN: Inode to initialize
3897+{
3898+ VMBlockInodeInfo *iinfo = INODE_TO_IINFO(inode);
3899+
3900+ iinfo->name[0] = '\0';
3901+ iinfo->nameLen = 0;
3902+ iinfo->actualDentry = NULL;
3903+}
3904+
3905+
3906+/*
3907+ *----------------------------------------------------------------------------
3908+ *
3909+ * GetNextIno --
3910+ *
3911+ * Gets the next available inode number.
3912+ *
3913+ * Results:
3914+ * The next available inode number.
3915+ *
3916+ * Side effects:
3917+ * None.
3918+ *
3919+ *----------------------------------------------------------------------------
3920+ */
3921+
3922+ino_t
3923+GetNextIno(void)
3924+{
3925+ static atomic_t nextIno = ATOMIC_INIT(VMBLOCK_ROOT_INO + 1);
3926+
3927+ return (ino_t) atomic_inc_return(&nextIno);
3928+}
3929+
3930+
3931+/*
3932+ *----------------------------------------------------------------------------
3933+ *
3934+ * GetInode --
3935+ *
3936+ * This function replaces iget() and should be called instead of it. In newer
3937+ * kernels that have removed the iget() interface, GetInode() obtains an inode
3938+ * and if it is a new one, then initializes the inode by calling
3939+ * VMBlockReadInode(). In older kernels that support the iget() interface,
3940+ * VMBlockReadInode() is called by iget() internally by the superblock function
3941+ * SuperOpReadInode.
3942+ *
3943+ * Results:
3944+ * A new inode object on success, NULL on error.
3945+ *
3946+ * Side effects:
3947+ * None.
3948+ *
3949+ *----------------------------------------------------------------------------
3950+ */
3951+
3952+static struct inode *
3953+GetInode(struct super_block *sb, // IN: file system superblock object
3954+ ino_t ino) // IN: inode number to assign to new inode
3955+{
3956+ struct inode *inode;
3957+
3958+ inode = iget_locked(sb, ino);
3959+ if (!inode) {
3960+ return NULL;
3961+ } else if (inode->i_state & I_NEW) {
3962+ VMBlockReadInode(inode);
3963+ unlock_new_inode(inode);
3964+ }
3965+ return inode;
3966+}
3967+
3968+
3969+/*
3970+ *----------------------------------------------------------------------------
3971+ *
3972+ * Iget --
3973+ *
3974+ * Lookup or create a new inode.
3975+ *
3976+ * Inode creation in detail:
3977+ * Throughout the file system, we call the VFS iget() function to get a new
3978+ * inode. This in turn invokes our file system's SuperOpAllocInode()
3979+ * function, which allocates an inode info structure (VMBlockInodeInfo)
3980+ * using the kernel's slab allocator. When a new slab is created, each
3981+ * object is initialized with the constructor (InodeCacheCtor()), but that
3982+ * occurs only once per struct (e.g., when a struct from a slab is freed and
3983+ * reused, the constructor is not invoked again). SuperOpAllocInode() then
3984+ * returns the address of the inode struct that is embedded within the inode
3985+ * info we have allocated. iget() also invokes our SuperOpReadInode()
3986+ * function to do any further file system wide initialization to the inode,
3987+ * then returns the inode to us (this function).
3988+ *
3989+ * Note that in older kernels that don't have the alloc_inode operation
3990+ * (where VMW_EMBED_INODE is undefined), the allocation is delayed until
3991+ * this function and is contained within the INODE_TO_IINFO macro. That
3992+ * allocation is freed in the SuperOpClearInode() function.
3993+ *
3994+ * This function then constructs the full path of the actual file name and
3995+ * does a path_lookup() to see if it exists. If it does, we save a pointer
3996+ * to the actual dentry within our inode info for future use. If it
3997+ * doesn't, we still provide an inode but indicate that it doesn't exist by
3998+ * setting the actual dentry to NULL. Callers that need to handle this case
3999+ * differently check for the existence of the actual dentry (and actual
4000+ * inode) to ensure the actual file exists.
4001+ *
4002+ * Results:
4003+ * A new inode object on success, NULL on error.
4004+ *
4005+ * Side effects:
4006+ * A path lookup is done for the actual file.
4007+ *
4008+ *----------------------------------------------------------------------------
4009+ */
4010+
4011+struct inode *
4012+Iget(struct super_block *sb, // IN: file system superblock object
4013+ struct inode *dir, // IN: containing directory
4014+ struct dentry *dentry, // IN: dentry within directory
4015+ ino_t ino) // IN: inode number to assign to new inode
4016+{
4017+ VMBlockInodeInfo *iinfo;
4018+ struct inode *inode;
4019+ struct nameidata actualNd;
4020+
4021+ ASSERT(sb);
4022+
4023+ inode = GetInode(sb, ino);
4024+ if (!inode) {
4025+ return NULL;
4026+ }
4027+
4028+ iinfo = INODE_TO_IINFO(inode);
4029+ if (!iinfo) {
4030+ Warning("Iget: invalid inode provided, or unable to allocate inode info\n");
4031+ goto error_inode;
4032+ }
4033+
4034+ /* Populate iinfo->name with the full path of the target file */
4035+ if (MakeFullName(dir, dentry, iinfo->name, sizeof iinfo->name) < 0) {
4036+ Warning("Iget: could not make full name\n");
4037+ goto error_inode;
4038+ }
4039+
4040+ if (compat_path_lookup(iinfo->name, 0, &actualNd)) {
4041+ /*
4042+ * This file does not exist, so we create an inode that doesn't know
4043+ * about its underlying file. Operations that create files and
4044+ * directories need an inode to operate on even if there is no actual
4045+ * file yet.
4046+ */
4047+ iinfo->actualDentry = NULL;
4048+ return inode;
4049+ }
4050+
4051+ iinfo->actualDentry = compat_vmw_nd_to_dentry(actualNd);
4052+ compat_path_release(&actualNd);
4053+
4054+ return inode;
4055+
4056+error_inode:
4057+ iput(inode);
4058+ return NULL;
4059+}
4060+
4061+
4062+/*
4063+ *----------------------------------------------------------------------------
4064+ *
4065+ * InodeCacheCtor --
4066+ *
4067+ * The constructor for inode info structs that occurs once at slab
4068+ * allocation. That is, this is called once for each piece of memory that
4069+ * is used to satisfy inode info allocations; it should only be used to
4070+ * initialized items that will naturally return to their initialized state
4071+ * before deallocation (such as locks, list_heads).
4072+ *
4073+ * We only invoke the inode's initialization routine since all of the inode
4074+ * info members need to be initialized on each allocation (in
4075+ * SuperOpReadInode()).
4076+ *
4077+ * Results:
4078+ * None.
4079+ *
4080+ * Side effects:
4081+ * None.
4082+ *
4083+ *----------------------------------------------------------------------------
4084+ */
4085+
4086+static void
4087+InodeCacheCtor(COMPAT_KMEM_CACHE_CTOR_ARGS(slabElem)) // IN: allocated slab item to initialize
4088+{
4089+ VMBlockInodeInfo *iinfo = slabElem;
4090+
4091+ inode_init_once(&iinfo->inode);
4092+}
4093+
4094+
4095+/*
4096+ *----------------------------------------------------------------------------
4097+ *
4098+ * MakeFullName --
4099+ *
4100+ * Constructs the full filename from the provided directory and a dentry
4101+ * contained within it.
4102+ *
4103+ * Results:
4104+ * Zero on success, negative error code on failure.
4105+ *
4106+ * Side effects:
4107+ * None.
4108+ *
4109+ *----------------------------------------------------------------------------
4110+ */
4111+
4112+int
4113+MakeFullName(struct inode *dir, // IN : directory
4114+ struct dentry *dentry, // IN : dentry in that directory
4115+ char *bufOut, // OUT: output buffer
4116+ size_t bufOutSize) // IN : size of output buffer
4117+{
4118+ ASSERT(bufOut);
4119+
4120+ /*
4121+ * If dir is supplied, contruct the full path of the actual file, otherwise
4122+ * it's the root directory.
4123+ */
4124+ if (dir == NULL) {
4125+ if (fsRootLen >= bufOutSize) {
4126+ Warning("MakeFullName: root path was too long.\n");
4127+ return -ENAMETOOLONG;
4128+ }
4129+ memcpy(bufOut, fsRoot, fsRootLen);
4130+ bufOut[fsRootLen] = '\0';
4131+ } else {
4132+ VMBlockInodeInfo *dirIinfo;
4133+ int ret;
4134+
4135+ ASSERT(dir);
4136+ ASSERT(dentry);
4137+
4138+ if (!dentry->d_name.name) {
4139+ Warning("MakeFullName: dentry name is empty\n");
4140+ return -EINVAL;
4141+ }
4142+
4143+ dirIinfo = INODE_TO_IINFO(dir);
4144+
4145+ /*
4146+ * If dirIinfo->name[1] is '\0', then it is "/" and we don't need
4147+ * another '/' between it and the additional name.
4148+ */
4149+ ret = snprintf(bufOut, bufOutSize,
4150+ dirIinfo->name[1] == '\0' ? "%s%s" : "%s/%s",
4151+ dirIinfo->name, dentry->d_name.name);
4152+ if (ret >= bufOutSize) {
4153+ Warning("MakeFullName: path was too long.\n");
4154+ return -ENAMETOOLONG;
4155+ }
4156+ }
4157+
4158+ return 0;
4159+}
4160+
4161+
4162+/* File system operations */
4163+
4164+/*
4165+ *-----------------------------------------------------------------------------
4166+ *
4167+ * FsOpReadSuper --
4168+ *
4169+ * The main entry point of the filesystem side of the driver. Called when
4170+ * a userland process does a mount(2) of an hgfs filesystem. This makes the
4171+ * whole driver transition from its initial state to state 1. Fill the
4172+ * content of the uninitialized superblock provided by the kernel.
4173+ *
4174+ * 'rawData' is a pointer (that can be NULL) to a kernel buffer (whose
4175+ * size is <= PAGE_SIZE) that corresponds to the filesystem-specific 'data'
4176+ * argument passed to mount(2).
4177+ *
4178+ * Results:
4179+ * zero and initialized superblock on success
4180+ * negative value on failure
4181+ *
4182+ * Side effects:
4183+ * None
4184+ *
4185+ *-----------------------------------------------------------------------------
4186+ */
4187+
4188+static int
4189+FsOpReadSuper(struct super_block *sb, // OUT: Superblock object
4190+ void *rawData, // IN: Fs-specific mount data
4191+ int flags) // IN: Mount flags
4192+{
4193+ struct inode *rootInode;
4194+ struct dentry *rootDentry;
4195+
4196+ if (!sb) {
4197+ Warning("FsOpReadSuper: invalid arg from kernel\n");
4198+ return -EINVAL;
4199+ }
4200+
4201+ sb->s_magic = VMBLOCK_SUPER_MAGIC;
4202+ sb->s_blocksize = 1024;
4203+ sb->s_op = &VMBlockSuperOps;
4204+
4205+ /*
4206+ * Make root inode and dentry. Ensure that the directory we are redirecting
4207+ * to has an actual dentry and inode, and that it is in fact a directory.
4208+ */
4209+ rootInode = GetRootInode(sb);
4210+ if (!rootInode) {
4211+ return -EINVAL;
4212+ }
4213+
4214+ if (!INODE_TO_IINFO(rootInode) ||
4215+ !INODE_TO_ACTUALDENTRY(rootInode) ||
4216+ !INODE_TO_ACTUALINODE(rootInode) ||
4217+ !S_ISDIR(INODE_TO_ACTUALINODE(rootInode)->i_mode)) {
4218+ iput(rootInode);
4219+ return -EINVAL;
4220+ }
4221+
4222+ rootDentry = d_alloc_root(rootInode);
4223+ if (!rootDentry) {
4224+ iput(rootInode);
4225+ return -ENOMEM;
4226+ }
4227+ sb->s_root = rootDentry;
4228+
4229+ rootInode->i_op = &RootInodeOps;
4230+ rootInode->i_fop = &RootFileOps;
4231+ rootInode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
4232+
4233+ LOG(4, "%s file system mounted\n", VMBLOCK_FS_NAME);
4234+ return 0;
4235+}
4236+
4237+
4238+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
4239+/*
4240+ *-----------------------------------------------------------------------------
4241+ *
4242+ * FsOpMount --
4243+ *
4244+ * Invokes generic kernel code to mount a deviceless filesystem.
4245+ *
4246+ * Results:
4247+ * Mount's root dentry tructure on success
4248+ * ERR_PTR()-encoded negative error code on failure
4249+ *
4250+ * Side effects:
4251+ * None
4252+ *
4253+ *-----------------------------------------------------------------------------
4254+ */
4255+
4256+struct dentry *
4257+FsOpMount(struct file_system_type *fs_type, // IN: file system type of mount
4258+ int flags, // IN: mount flags
4259+ const char *dev_name, // IN: device mounting on
4260+ void *rawData) // IN: mount arguments
4261+{
4262+ return mount_nodev(fs_type, flags, rawData, FsOpReadSuper);
4263+}
4264+#elif defined(VMW_GETSB_2618)
4265+/*
4266+ *-----------------------------------------------------------------------------
4267+ *
4268+ * FsOpGetSb --
4269+ *
4270+ * Invokes generic kernel code to prepare superblock for
4271+ * deviceless filesystem.
4272+ *
4273+ * Results:
4274+ * 0 on success
4275+ * negative error code on failure
4276+ *
4277+ * Side effects:
4278+ * None
4279+ *
4280+ *-----------------------------------------------------------------------------
4281+ */
4282+
4283+static int
4284+FsOpGetSb(struct file_system_type *fs_type, // IN: file system type of mount
4285+ int flags, // IN: mount flags
4286+ const char *dev_name, // IN: device mounting on
4287+ void *rawData, // IN: mount arguments
4288+ struct vfsmount *mnt) // IN: vfs mount
4289+{
4290+ return get_sb_nodev(fs_type, flags, rawData, FsOpReadSuper, mnt);
4291+}
4292+#else
4293+/*
4294+ *-----------------------------------------------------------------------------
4295+ *
4296+ * FsOpGetSb --
4297+ *
4298+ * Invokes generic kernel code to prepare superblock for
4299+ * deviceless filesystem.
4300+ *
4301+ * Results:
4302+ * The initialized superblock on success
4303+ * NULL on failure
4304+ *
4305+ * Side effects:
4306+ * None
4307+ *
4308+ *-----------------------------------------------------------------------------
4309+ */
4310+
4311+static struct super_block *
4312+FsOpGetSb(struct file_system_type *fs_type, // IN: file system type of mount
4313+ int flags, // IN: mount flags
4314+ const char *dev_name, // IN: device mounting on
4315+ void *rawData) // IN: mount arguments
4316+{
4317+ return get_sb_nodev(fs_type, flags, rawData, FsOpReadSuper);
4318+}
4319+#endif
4320+
4321
4322=== added directory '.pc/04-quantal-module-backport.patch/modules/linux/vmci'
4323=== added directory '.pc/04-quantal-module-backport.patch/modules/linux/vmci/common'
4324=== added file '.pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciCommonInt.h'
4325--- .pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciCommonInt.h 1970-01-01 00:00:00 +0000
4326+++ .pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciCommonInt.h 2013-06-28 21:11:42 +0000
4327@@ -0,0 +1,133 @@
4328+/*********************************************************
4329+ * Copyright (C) 2006-2011 VMware, Inc. All rights reserved.
4330+ *
4331+ * This program is free software; you can redistribute it and/or modify it
4332+ * under the terms of the GNU General Public License as published by the
4333+ * Free Software Foundation version 2 and no later version.
4334+ *
4335+ * This program is distributed in the hope that it will be useful, but
4336+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
4337+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4338+ * for more details.
4339+ *
4340+ * You should have received a copy of the GNU General Public License along
4341+ * with this program; if not, write to the Free Software Foundation, Inc.,
4342+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
4343+ *
4344+ *********************************************************/
4345+
4346+/*
4347+ * vmciCommonInt.h --
4348+ *
4349+ * Struct definitions for VMCI internal common code.
4350+ */
4351+
4352+#ifndef _VMCI_COMMONINT_H_
4353+#define _VMCI_COMMONINT_H_
4354+
4355+#define INCLUDE_ALLOW_MODULE
4356+#define INCLUDE_ALLOW_VMMON
4357+#define INCLUDE_ALLOW_VMCORE
4358+#define INCLUDE_ALLOW_VMKERNEL
4359+#include "includeCheck.h"
4360+
4361+#include "vm_atomic.h"
4362+#include "vmci_defs.h"
4363+#include "vmci_call_defs.h"
4364+#include "vmci_infrastructure.h"
4365+#include "vmci_handle_array.h"
4366+#include "vmci_kernel_if.h"
4367+
4368+
4369+/*
4370+ * The DatagramQueueEntry is a queue header for the in-kernel VMCI
4371+ * datagram queues. It is allocated in non-paged memory, as the
4372+ * content is accessed while holding a spinlock. The pending datagram
4373+ * itself may be allocated from paged memory. We shadow the size of
4374+ * the datagram in the non-paged queue entry as this size is used
4375+ * while holding the same spinlock as above.
4376+ */
4377+
4378+typedef struct DatagramQueueEntry {
4379+ VMCIListItem listItem; /* For queuing. */
4380+ size_t dgSize; /* Size of datagram. */
4381+ VMCIDatagram *dg; /* Pending datagram. */
4382+} DatagramQueueEntry;
4383+
4384+
4385+struct VMCIContext {
4386+ VMCIListItem listItem; /* For global VMCI list. */
4387+ VMCIId cid;
4388+ Atomic_uint32 refCount;
4389+ VMCIList datagramQueue; /* Head of per VM queue. */
4390+ uint32 pendingDatagrams;
4391+ size_t datagramQueueSize;/* Size of datagram queue in bytes. */
4392+ int userVersion; /*
4393+ * Version of the code that created
4394+ * this context; e.g., VMX.
4395+ */
4396+ VMCILock lock; /* Locks callQueue and handleArrays. */
4397+ VMCIHandleArray *queuePairArray; /*
4398+ * QueuePairs attached to. The array of
4399+ * handles for queue pairs is accessed
4400+ * from the code for QP API, and there
4401+ * it is protected by the QP lock. It
4402+ * is also accessed from the context
4403+ * clean up path, which does not
4404+ * require a lock. VMCILock is not
4405+ * used to protect the QP array field.
4406+ */
4407+ VMCIHandleArray *doorbellArray; /* Doorbells created by context. */
4408+ VMCIHandleArray *pendingDoorbellArray; /* Doorbells pending for context. */
4409+ VMCIHandleArray *notifierArray; /* Contexts current context is subscribing to. */
4410+ VMCIHost hostContext;
4411+ VMCIPrivilegeFlags privFlags;
4412+ VMCIHostUser user;
4413+ Bool validUser;
4414+#ifdef VMKERNEL
4415+ Bool isQuiesced; /* Whether current VM is quiesced */
4416+ VMCIId migrateCid; /* The migrate cid if it is migrating */
4417+ VMCIMutex guestMemMutex; /*
4418+ * Coordinates guest memory
4419+ * registration/release during FSR.
4420+ */
4421+ VMCIGuestMemID curGuestMemID; /* ID of current registered guest mem */
4422+#endif
4423+#ifndef VMX86_SERVER
4424+ Bool *notify; /* Notify flag pointer - hosted only. */
4425+# ifdef __linux__
4426+ struct page *notifyPage; /* Page backing the notify UVA. */
4427+# endif
4428+#endif
4429+};
4430+
4431+
4432+/*
4433+ *------------------------------------------------------------------------------
4434+ *
4435+ * VMCIDenyInteraction --
4436+ *
4437+ * Utilility function that checks whether two entities are allowed
4438+ * to interact. If one of them is restricted, the other one must
4439+ * be trusted.
4440+ *
4441+ * Result:
4442+ * TRUE if the two entities are not allowed to interact. FALSE otherwise.
4443+ *
4444+ * Side effects:
4445+ * None.
4446+ *
4447+ *------------------------------------------------------------------------------
4448+ */
4449+
4450+static INLINE Bool
4451+VMCIDenyInteraction(VMCIPrivilegeFlags partOne, // IN
4452+ VMCIPrivilegeFlags partTwo) // IN
4453+{
4454+ return (((partOne & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
4455+ !(partTwo & VMCI_PRIVILEGE_FLAG_TRUSTED)) ||
4456+ ((partTwo & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
4457+ !(partOne & VMCI_PRIVILEGE_FLAG_TRUSTED)));
4458+}
4459+
4460+#endif /* _VMCI_COMMONINT_H_ */
4461
4462=== added file '.pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciContext.c'
4463--- .pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciContext.c 1970-01-01 00:00:00 +0000
4464+++ .pc/04-quantal-module-backport.patch/modules/linux/vmci/common/vmciContext.c 2013-06-28 21:11:42 +0000
4465@@ -0,0 +1,2542 @@
4466+/*********************************************************
4467+ * Copyright (C) 2006-2011 VMware, Inc. All rights reserved.
4468+ *
4469+ * This program is free software; you can redistribute it and/or modify it
4470+ * under the terms of the GNU General Public License as published by the
4471+ * Free Software Foundation version 2 and no later version.
4472+ *
4473+ * This program is distributed in the hope that it will be useful, but
4474+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
4475+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4476+ * for more details.
4477+ *
4478+ * You should have received a copy of the GNU General Public License along
4479+ * with this program; if not, write to the Free Software Foundation, Inc.,
4480+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
4481+ *
4482+ *********************************************************/
4483+
4484+/*
4485+ * vmciContext.c --
4486+ *
4487+ * Platform independent routines for VMCI calls.
4488+ */
4489+
4490+#include "vmci_kernel_if.h"
4491+#include "vm_assert.h"
4492+#include "vmci_defs.h"
4493+#include "vmci_infrastructure.h"
4494+#include "vmciCommonInt.h"
4495+#include "vmciContext.h"
4496+#include "vmciDatagram.h"
4497+#include "vmciDoorbell.h"
4498+#include "vmciDriver.h"
4499+#include "vmciEvent.h"
4500+#include "vmciKernelAPI.h"
4501+#include "vmciQueuePair.h"
4502+#if defined(VMKERNEL)
4503+# include "vmciVmkInt.h"
4504+# include "vm_libc.h"
4505+# include "helper_ext.h"
4506+#endif
4507+
4508+#define LGPFX "VMCIContext: "
4509+
4510+static void VMCIContextFreeContext(VMCIContext *context);
4511+static Bool VMCIContextExists(VMCIId cid);
4512+static int VMCIContextFireNotification(VMCIId contextID,
4513+ VMCIPrivilegeFlags privFlags);
4514+#if defined(VMKERNEL)
4515+static void VMCIContextReleaseGuestMemLocked(VMCIContext *context,
4516+ VMCIGuestMemID gid);
4517+#endif
4518+
4519+/*
4520+ * List of current VMCI contexts.
4521+ */
4522+
4523+static struct {
4524+ VMCIList head;
4525+ VMCILock lock;
4526+ VMCILock firingLock;
4527+} contextList;
4528+
4529+
4530+/*
4531+ *----------------------------------------------------------------------
4532+ *
4533+ * VMCIContextSignalNotify --
4534+ *
4535+ * Sets the notify flag to TRUE. Assumes that the context lock is
4536+ * held.
4537+ *
4538+ * Results:
4539+ * None.
4540+ *
4541+ * Side effects:
4542+ * None.
4543+ *
4544+ *----------------------------------------------------------------------
4545+ */
4546+
4547+static INLINE void
4548+VMCIContextSignalNotify(VMCIContext *context) // IN:
4549+{
4550+#ifndef VMX86_SERVER
4551+ if (context->notify) {
4552+ *context->notify = TRUE;
4553+ }
4554+#endif
4555+}
4556+
4557+
4558+/*
4559+ *----------------------------------------------------------------------
4560+ *
4561+ * VMCIContextClearNotify --
4562+ *
4563+ * Sets the notify flag to FALSE. Assumes that the context lock is
4564+ * held.
4565+ *
4566+ * Results:
4567+ * None.
4568+ *
4569+ * Side effects:
4570+ * None.
4571+ *
4572+ *----------------------------------------------------------------------
4573+ */
4574+
4575+static INLINE void
4576+VMCIContextClearNotify(VMCIContext *context) // IN:
4577+{
4578+#ifndef VMX86_SERVER
4579+ if (context->notify) {
4580+ *context->notify = FALSE;
4581+ }
4582+#endif
4583+}
4584+
4585+
4586+/*
4587+ *----------------------------------------------------------------------
4588+ *
4589+ * VMCIContextClearNotifyAndCall --
4590+ *
4591+ * If nothing requires the attention of the guest, clears both
4592+ * notify flag and call.
4593+ *
4594+ * Results:
4595+ * None.
4596+ *
4597+ * Side effects:
4598+ * None.
4599+ *
4600+ *----------------------------------------------------------------------
4601+ */
4602+
4603+static INLINE void
4604+VMCIContextClearNotifyAndCall(VMCIContext *context) // IN:
4605+{
4606+ if (context->pendingDatagrams == 0 &&
4607+ VMCIHandleArray_GetSize(context->pendingDoorbellArray) == 0) {
4608+ VMCIHost_ClearCall(&context->hostContext);
4609+ VMCIContextClearNotify(context);
4610+ }
4611+}
4612+
4613+
4614+#ifndef VMX86_SERVER
4615+/*
4616+ *----------------------------------------------------------------------
4617+ *
4618+ * VMCIContext_CheckAndSignalNotify --
4619+ *
4620+ * Sets the context's notify flag iff datagrams are pending for this
4621+ * context. Called from VMCISetupNotify().
4622+ *
4623+ * Results:
4624+ * None.
4625+ *
4626+ * Side effects:
4627+ * None.
4628+ *
4629+ *----------------------------------------------------------------------
4630+ */
4631+
4632+void
4633+VMCIContext_CheckAndSignalNotify(VMCIContext *context) // IN:
4634+{
4635+ VMCILockFlags flags;
4636+
4637+ ASSERT(context);
4638+ VMCI_GrabLock(&contextList.lock, &flags);
4639+ if (context->pendingDatagrams) {
4640+ VMCIContextSignalNotify(context);
4641+ }
4642+ VMCI_ReleaseLock(&contextList.lock, flags);
4643+}
4644+#endif
4645+
4646+
4647+/*
4648+ *----------------------------------------------------------------------
4649+ *
4650+ * VMCIContext_Init --
4651+ *
4652+ * Initializes the VMCI context module.
4653+ *
4654+ * Results:
4655+ * None.
4656+ *
4657+ * Side effects:
4658+ * None.
4659+ *
4660+ *----------------------------------------------------------------------
4661+ */
4662+
4663+int
4664+VMCIContext_Init(void)
4665+{
4666+ int err;
4667+
4668+ VMCIList_Init(&contextList.head);
4669+
4670+ err = VMCI_InitLock(&contextList.lock, "VMCIContextListLock",
4671+ VMCI_LOCK_RANK_CONTEXTLIST);
4672+ if (err < VMCI_SUCCESS) {
4673+ return err;
4674+ }
4675+
4676+ err = VMCI_InitLock(&contextList.firingLock, "VMCIContextFiringLock",
4677+ VMCI_LOCK_RANK_CONTEXTFIRE);
4678+ if (err < VMCI_SUCCESS) {
4679+ VMCI_CleanupLock(&contextList.lock);
4680+ }
4681+
4682+ return err;
4683+}
4684+
4685+
4686+/*
4687+ *----------------------------------------------------------------------
4688+ *
4689+ * VMCIContext_Exit --
4690+ *
4691+ * Cleans up the contexts module.
4692+ *
4693+ * Results:
4694+ * None.
4695+ *
4696+ * Side effects:
4697+ * None.
4698+ *
4699+ *----------------------------------------------------------------------
4700+ */
4701+
4702+void
4703+VMCIContext_Exit(void)
4704+{
4705+ VMCI_CleanupLock(&contextList.firingLock);
4706+ VMCI_CleanupLock(&contextList.lock);
4707+}
4708+
4709+
4710+/*
4711+ *----------------------------------------------------------------------
4712+ *
4713+ * VMCIContext_InitContext --
4714+ *
4715+ * Allocates and initializes a VMCI context.
4716+ *
4717+ * Results:
4718+ * Returns 0 on success, appropriate error code otherwise.
4719+ *
4720+ * Side effects:
4721+ * None.
4722+ *
4723+ *----------------------------------------------------------------------
4724+ */
4725+
4726+int
4727+VMCIContext_InitContext(VMCIId cid, // IN
4728+ VMCIPrivilegeFlags privFlags, // IN
4729+ uintptr_t eventHnd, // IN
4730+ int userVersion, // IN: User's vers no.
4731+ VMCIHostUser *user, // IN
4732+ VMCIContext **outContext) // OUT
4733+{
4734+ VMCILockFlags flags;
4735+ VMCIContext *context;
4736+ int result;
4737+
4738+ if (privFlags & ~VMCI_PRIVILEGE_ALL_FLAGS) {
4739+ VMCI_DEBUG_LOG(4, (LGPFX"Invalid flag (flags=0x%x) for VMCI context.\n",
4740+ privFlags));
4741+ return VMCI_ERROR_INVALID_ARGS;
4742+ }
4743+
4744+ if (userVersion == 0) {
4745+ return VMCI_ERROR_INVALID_ARGS;
4746+ }
4747+
4748+ context = VMCI_AllocKernelMem(sizeof *context, VMCI_MEMORY_NONPAGED);
4749+ if (context == NULL) {
4750+ VMCI_WARNING((LGPFX"Failed to allocate memory for VMCI context.\n"));
4751+ return VMCI_ERROR_NO_MEM;
4752+ }
4753+ memset(context, 0, sizeof *context);
4754+
4755+ VMCIList_InitEntry(&context->listItem);
4756+ VMCIList_Init(&context->datagramQueue);
4757+
4758+ context->userVersion = userVersion;
4759+
4760+ context->queuePairArray = VMCIHandleArray_Create(0);
4761+ if (!context->queuePairArray) {
4762+ result = VMCI_ERROR_NO_MEM;
4763+ goto error;
4764+ }
4765+
4766+ context->doorbellArray = VMCIHandleArray_Create(0);
4767+ if (!context->doorbellArray) {
4768+ result = VMCI_ERROR_NO_MEM;
4769+ goto error;
4770+ }
4771+
4772+ context->pendingDoorbellArray = VMCIHandleArray_Create(0);
4773+ if (!context->pendingDoorbellArray) {
4774+ result = VMCI_ERROR_NO_MEM;
4775+ goto error;
4776+ }
4777+
4778+ context->notifierArray = VMCIHandleArray_Create(0);
4779+ if (context->notifierArray == NULL) {
4780+ result = VMCI_ERROR_NO_MEM;
4781+ goto error;
4782+ }
4783+
4784+ result = VMCI_InitLock(&context->lock, "VMCIContextLock",
4785+ VMCI_LOCK_RANK_CONTEXT);
4786+ if (result < VMCI_SUCCESS) {
4787+ goto error;
4788+ }
4789+ Atomic_Write(&context->refCount, 1);
4790+
4791+#if defined(VMKERNEL)
4792+ result = VMCIMutex_Init(&context->guestMemMutex, "VMCIGuestMem",
4793+ VMCI_SEMA_RANK_GUESTMEM);
4794+ if (result < VMCI_SUCCESS) {
4795+ VMCI_CleanupLock(&context->lock);
4796+ goto error;
4797+ }
4798+ context->curGuestMemID = INVALID_VMCI_GUEST_MEM_ID;
4799+#endif
4800+
4801+ /* Inititialize host-specific VMCI context. */
4802+ VMCIHost_InitContext(&context->hostContext, eventHnd);
4803+
4804+ context->privFlags = privFlags;
4805+
4806+ /*
4807+ * If we collide with an existing context we generate a new and use it
4808+ * instead. The VMX will determine if regeneration is okay. Since there
4809+ * isn't 4B - 16 VMs running on a given host, the below loop will terminate.
4810+ */
4811+ VMCI_GrabLock(&contextList.lock, &flags);
4812+ ASSERT(cid != VMCI_INVALID_ID);
4813+ while (VMCIContextExists(cid)) {
4814+
4815+ /*
4816+ * If the cid is below our limit and we collide we are creating duplicate
4817+ * contexts internally so we want to assert fail in that case.
4818+ */
4819+ ASSERT(cid >= VMCI_RESERVED_CID_LIMIT);
4820+
4821+ /* We reserve the lowest 16 ids for fixed contexts. */
4822+ cid = MAX(cid, VMCI_RESERVED_CID_LIMIT-1) + 1;
4823+ if (cid == VMCI_INVALID_ID) {
4824+ cid = VMCI_RESERVED_CID_LIMIT;
4825+ }
4826+ }
4827+ ASSERT(!VMCIContextExists(cid));
4828+ context->cid = cid;
4829+ context->validUser = user != NULL;
4830+ if (context->validUser) {
4831+ context->user = *user;
4832+ }
4833+ VMCIList_Insert(&context->listItem, &contextList.head);
4834+ VMCI_ReleaseLock(&contextList.lock, flags);
4835+
4836+#ifdef VMKERNEL
4837+ VMCIContext_SetFSRState(context, FALSE, VMCI_INVALID_ID, eventHnd, FALSE);
4838+#endif
4839+
4840+#ifndef VMX86_SERVER
4841+ context->notify = NULL;
4842+# ifdef __linux__
4843+ context->notifyPage = NULL;
4844+# endif
4845+#endif
4846+
4847+ *outContext = context;
4848+ return VMCI_SUCCESS;
4849+
4850+error:
4851+ if (context->notifierArray) {
4852+ VMCIHandleArray_Destroy(context->notifierArray);
4853+ }
4854+ if (context->queuePairArray) {
4855+ VMCIHandleArray_Destroy(context->queuePairArray);
4856+ }
4857+ if (context->doorbellArray) {
4858+ VMCIHandleArray_Destroy(context->doorbellArray);
4859+ }
4860+ if (context->pendingDoorbellArray) {
4861+ VMCIHandleArray_Destroy(context->pendingDoorbellArray);
4862+ }
4863+ VMCI_FreeKernelMem(context, sizeof *context);
4864+ return result;
4865+}
4866+
4867+
4868+/*
4869+ *----------------------------------------------------------------------
4870+ *
4871+ * VMCIContext_ReleaseContext --
4872+ *
4873+ * Cleans up a VMCI context.
4874+ *
4875+ * Results:
4876+ * None.
4877+ *
4878+ * Side effects:
4879+ * None.
4880+ *
4881+ *----------------------------------------------------------------------
4882+ */
4883+
4884+void
4885+VMCIContext_ReleaseContext(VMCIContext *context) // IN
4886+{
4887+ VMCILockFlags flags;
4888+
4889+ /* Dequeue VMCI context. */
4890+
4891+ VMCI_GrabLock(&contextList.lock, &flags);
4892+ VMCIList_Remove(&context->listItem);
4893+ VMCI_ReleaseLock(&contextList.lock, flags);
4894+
4895+ VMCIContext_Release(context);
4896+}
4897+
4898+
4899+/*
4900+ *-----------------------------------------------------------------------------
4901+ *
4902+ * VMCIContextFreeContext --
4903+ *
4904+ * Deallocates all parts of a context datastructure. This
4905+ * functions doesn't lock the context, because it assumes that
4906+ * the caller is holding the last reference to context. As paged
4907+ * memory may be freed as part of the call, the function must be
4908+ * called without holding any spinlocks as this is not allowed on
4909+ * Windows.
4910+ *
4911+ * Results:
4912+ * None.
4913+ *
4914+ * Side effects:
4915+ * Paged memory is freed.
4916+ *
4917+ *-----------------------------------------------------------------------------
4918+ */
4919+
4920+static void
4921+VMCIContextFreeContext(VMCIContext *context) // IN
4922+{
4923+ VMCIListItem *curr;
4924+ VMCIListItem *next;
4925+ DatagramQueueEntry *dqEntry;
4926+ VMCIHandle tempHandle;
4927+
4928+ /* Fire event to all contexts interested in knowing this context is dying. */
4929+ VMCIContextFireNotification(context->cid, context->privFlags);
4930+
4931+ /*
4932+ * Cleanup all queue pair resources attached to context. If the VM dies
4933+ * without cleaning up, this code will make sure that no resources are
4934+ * leaked.
4935+ */
4936+
4937+ tempHandle = VMCIHandleArray_GetEntry(context->queuePairArray, 0);
4938+ while (!VMCI_HANDLE_EQUAL(tempHandle, VMCI_INVALID_HANDLE)) {
4939+ if (VMCIQPBroker_Detach(tempHandle, context) < VMCI_SUCCESS) {
4940+ /*
4941+ * When VMCIQPBroker_Detach() succeeds it removes the handle from the
4942+ * array. If detach fails, we must remove the handle ourselves.
4943+ */
4944+ VMCIHandleArray_RemoveEntry(context->queuePairArray, tempHandle);
4945+ }
4946+ tempHandle = VMCIHandleArray_GetEntry(context->queuePairArray, 0);
4947+ }
4948+
4949+ /*
4950+ * It is fine to destroy this without locking the callQueue, as
4951+ * this is the only thread having a reference to the context.
4952+ */
4953+
4954+ VMCIList_ScanSafe(curr, next, &context->datagramQueue) {
4955+ dqEntry = VMCIList_Entry(curr, DatagramQueueEntry, listItem);
4956+ VMCIList_Remove(curr);
4957+ ASSERT(dqEntry && dqEntry->dg);
4958+ ASSERT(dqEntry->dgSize == VMCI_DG_SIZE(dqEntry->dg));
4959+ VMCI_FreeKernelMem(dqEntry->dg, dqEntry->dgSize);
4960+ VMCI_FreeKernelMem(dqEntry, sizeof *dqEntry);
4961+ }
4962+
4963+ VMCIHandleArray_Destroy(context->notifierArray);
4964+ VMCIHandleArray_Destroy(context->queuePairArray);
4965+ VMCIHandleArray_Destroy(context->doorbellArray);
4966+ VMCIHandleArray_Destroy(context->pendingDoorbellArray);
4967+ VMCI_CleanupLock(&context->lock);
4968+#if defined(VMKERNEL)
4969+ VMCIMutex_Destroy(&context->guestMemMutex);
4970+#endif
4971+ VMCIHost_ReleaseContext(&context->hostContext);
4972+#ifndef VMX86_SERVER
4973+# ifdef __linux__
4974+ /* TODO Windows and Mac OS. */
4975+ VMCIUnsetNotify(context);
4976+# endif
4977+#endif
4978+ VMCI_FreeKernelMem(context, sizeof *context);
4979+}
4980+
4981+
4982+/*
4983+ *----------------------------------------------------------------------
4984+ *
4985+ * VMCIContext_PendingDatagrams --
4986+ *
4987+ * Returns the current number of pending datagrams. The call may
4988+ * also serve as a synchronization point for the datagram queue,
4989+ * as no enqueue operations can occur concurrently.
4990+ *
4991+ * Results:
4992+ * Length of datagram queue for the given context.
4993+ *
4994+ * Side effects:
4995+ * Locks datagram queue.
4996+ *
4997+ *----------------------------------------------------------------------
4998+ */
4999+
5000+int
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches