diff -Nur old/vmblock-only/linux/dentry.c new/vmblock-only/linux/dentry.c --- old/vmblock-only/linux/dentry.c 2009-08-15 04:55:22.000000000 +0200 +++ new/vmblock-only/linux/dentry.c 2011-07-18 15:35:24.806553595 +0200 @@ -118,7 +118,11 @@ #endif } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) if (compat_path_lookup(iinfo->name, 0, &actualNd)) { +#else + if (kern_path(iinfo->name, 0, &(actualNd.path))) { +#endif LOG(4, "DentryOpRevalidate: [%s] no longer exists\n", iinfo->name); return 0; } diff -Nur old/vmblock-only/linux/filesystem.c new/vmblock-only/linux/filesystem.c --- old/vmblock-only/linux/filesystem.c 2009-08-15 04:55:22.000000000 +0200 +++ new/vmblock-only/linux/filesystem.c 2011-07-18 15:35:24.806553595 +0200 @@ -51,8 +51,13 @@ /* File system operations */ #if KERNEL_25_FS /* { */ # if defined(VMW_GETSB_2618) -static int FsOpGetSb(struct file_system_type *fsType, int flags, - const char *devName, void *rawData, struct vfsmount *mnt); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) + static int FsOpGetSb(struct file_system_type *fsType, int flags, + const char *devName, void *rawData, struct vfsmount *mnt); +#else +static struct dentry *FsOpMount(struct file_system_type *fsType, int flags, + const char *devName, void *rawData); +#endif # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 70) static struct super_block *FsOpGetSb(struct file_system_type *fsType, int flags, const char *devName, void *rawData); @@ -80,8 +85,12 @@ static struct file_system_type fsType = { .owner = THIS_MODULE, .name = VMBLOCK_FS_NAME, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) + .get_sb = FsOpGetSb, +#else + .mount = FsOpMount, +#endif #if KERNEL_25_FS - .get_sb = FsOpGetSb, .kill_sb = kill_anon_super, #else .read_super = FsOpReadSuper24, @@ -239,7 +248,7 @@ ino_t GetNextIno(void) { - static spinlock_t inoLock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(inoLock); static ino_t nextIno = VMBLOCK_ROOT_INO + 1; ino_t ret; @@ -365,8 +374,12 @@ goto error_inode; } - if (compat_path_lookup(iinfo->name, 0, &actualNd)) { - /* +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) + if (compat_path_lookup(iinfo->name, 0, &actualNd)) { +#else + if (kern_path(iinfo->name, 0, &(actualNd.path))) { +#endif + /* * This file does not exist, so we create an inode that doesn't know * about its underlying file. Operations that create files and * directories need an inode to operate on even if there is no actual @@ -598,13 +611,13 @@ /* *----------------------------------------------------------------------------- * - * FsOpGetSb -- + * FsOpGetSb/FsOpMount -- * * Invokes generic kernel code to prepare superblock for * deviceless filesystem. * * Results: - * 0 on success + * 0/dentry on success * negative error code on failure * * Side effects: @@ -613,6 +626,7 @@ *----------------------------------------------------------------------------- */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) static int FsOpGetSb(struct file_system_type *fs_type, // IN: file system type of mount int flags, // IN: mount flags @@ -623,6 +637,16 @@ return get_sb_nodev(fs_type, flags, rawData, FsOpReadSuper, mnt); } #else +struct dentry * +FsOpMount(struct file_system_type *fs_type, // IN: file system type of mount + int flags, // IN: mount flags + const char *dev_name, // IN: device mounting on + void *rawData) // IN: mount arguments +{ + return mount_nodev(fs_type, flags, rawData, FsOpReadSuper); +} +#endif +#else /* *----------------------------------------------------------------------------- * diff -Nur old/vmci-only/linux/driver.c new/vmci-only/linux/driver.c --- old/vmci-only/linux/driver.c 2009-08-15 04:55:23.000000000 +0200 +++ new/vmci-only/linux/driver.c 2011-07-18 15:35:24.806553595 +0200 @@ -20,6 +20,7 @@ #include "driver-config.h" #define EXPORT_SYMTAB +#define HAVE_UNLOCKED_IOCTL #include "compat_version.h" #include "compat_kernel.h" @@ -34,7 +35,6 @@ #include "compat_semaphore.h" #endif #include -#include #include @@ -360,7 +360,7 @@ memset(vmciLinux, 0, sizeof *vmciLinux); vmciLinux->ctType = VMCIOBJ_NOT_SET; #if defined(HAVE_COMPAT_IOCTL) || defined(HAVE_UNLOCKED_IOCTL) - init_MUTEX(&vmciLinux->lock); + sema_init(&vmciLinux->lock, 1); #endif filp->private_data = vmciLinux; diff -Nur old/vmmon-only/linux/driver.c new/vmmon-only/linux/driver.c --- old/vmmon-only/linux/driver.c 2011-07-18 15:34:54.732715126 +0200 +++ new/vmmon-only/linux/driver.c 2011-07-18 15:35:24.807553590 +0200 @@ -20,6 +20,7 @@ #include "driver-config.h" #define EXPORT_SYMTAB +#define VMW_HAVE_UNLOCKED_IOCTL #include "compat_version.h" #include "compat_kernel.h" @@ -37,7 +38,7 @@ #include "compat_cred.h" #include -#include +#include #include @@ -127,6 +128,7 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 20) int errno; // required for compat_exit() #endif +static DEFINE_MUTEX(driver_mutex); static void LinuxDriverQueue(VMLinux *vmLinux); static void LinuxDriverDequeue(VMLinux *vmLinux); static Bool LinuxDriverCheckPadding(void); @@ -246,7 +248,7 @@ int ret; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 26) || \ (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3)) - lock_kernel(); + mutex_lock(&driver_mutex); #endif ret = -ENOTTY; if (filp && filp->f_op && filp->f_op->ioctl == LinuxDriver_Ioctl) { @@ -254,7 +256,7 @@ } #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 26) || \ (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3)) - unlock_kernel(); + mutex_unlock(&driver_mutex); #endif return ret; } @@ -769,7 +771,7 @@ #define POLLQUEUE_MAX_TASK 1000 -static spinlock_t pollQueueLock __attribute__((unused)) = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(pollQueueLock); static void *pollQueue[POLLQUEUE_MAX_TASK]; static unsigned int pollQueueCount = 0; @@ -1030,7 +1032,7 @@ * but unfortunately there is no way how to detect that * we are building for RedHat's kernel... */ - static spinlock_t timerLock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(timerLock); spin_lock(&timerLock); mod_timer(&linuxState.pollTimer, jiffies + 1); @@ -1742,14 +1744,14 @@ retval = -EINVAL; break; } - unlock_kernel(); + mutex_unlock(&driver_mutex); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) # if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) ASSERT(!kernel_locked()); # endif #endif retval = Vmx86_RunVM(vmLinux->vm, vcpuid); - lock_kernel(); + mutex_lock(&driver_mutex); break; case IOCTL_VMX86_SET_UID: @@ -2440,9 +2442,9 @@ { long err; - lock_kernel(); + mutex_lock(&driver_mutex); err = LinuxDriver_Ioctl(NULL, filp, iocmd, ioarg); - unlock_kernel(); + mutex_unlock(&driver_mutex); return err; } #endif diff -Nur old/vmmon-only/linux/hostif.c new/vmmon-only/linux/hostif.c --- old/vmmon-only/linux/hostif.c 2011-07-18 15:34:54.733715121 +0200 +++ new/vmmon-only/linux/hostif.c 2011-07-18 15:41:07.830697394 +0200 @@ -46,7 +46,6 @@ #include #include -#include #include #include @@ -82,6 +81,7 @@ #define UPTIME_FREQ CONST64(1000000) +static DEFINE_MUTEX(hostif_mutex); static struct { Atomic_uint64 uptimeBase; VersionedAtomic version; @@ -3417,9 +3417,9 @@ if (filp->f_op->ioctl) { long err; - lock_kernel(); + mutex_lock(&hostif_mutex); err = filp->f_op->ioctl(filp->f_dentry->d_inode, filp, iocmd, ioarg); - unlock_kernel(); + mutex_unlock(&hostif_mutex); return err; } #endif diff -Nur old/vmnet-only/bridge.c new/vmnet-only/bridge.c --- old/vmnet-only/bridge.c 2009-08-15 04:55:21.000000000 +0200 +++ new/vmnet-only/bridge.c 2011-07-18 15:35:24.808553585 +0200 @@ -54,6 +54,7 @@ #include "compat_netdevice.h" #include "vnetInt.h" #include "smac.h" +#include "compat_mutex.h" #define VNET_BRIDGE_HISTORY 48 @@ -1035,11 +1036,11 @@ * Put in promiscuous mode if need be. */ - down(&vnetStructureSemaphore); + compat_mutex_lock(&vnetStructureMutex); if (VNetGetAttachedPorts(&bridge->port.jack)) { VNetBridgeStartPromisc(bridge, rtnlLock); } - up(&vnetStructureSemaphore); + compat_mutex_unlock(&vnetStructureMutex); /* send link state up event */ retval = VNetBridgeSendLinkStateEvent(bridge, bridge->dev->ifindex, TRUE); diff -Nur old/vmnet-only/compat_mutex.h new/vmnet-only/compat_mutex.h --- old/vmnet-only/compat_mutex.h 1970-01-01 01:00:00.000000000 +0100 +++ new/vmnet-only/compat_mutex.h 2011-07-18 15:42:54.749113908 +0200 @@ -0,0 +1,48 @@ +/********************************************************* + * Copyright (C) 2009 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation version 2 and no later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *********************************************************/ + +#ifndef __COMPAT_MUTEX_H__ +# define __COMPAT_MUTEX_H__ + + +/* Blocking mutexes were introduced in 2.6.16. */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) + +#include "compat_semaphore.h" + +typedef struct semaphore compat_mutex_t; + +# define compat_mutex_init(_mx) init_MUTEX(_mx) +# define compat_mutex_lock(_mx) down(_mx) +# define compat_mutex_unlock(_mx) up(_mx) + +#else + +#include + +typedef struct mutex compat_mutex_t; + +# define compat_define_mutex(_mx) DEFINE_MUTEX(_mx) +# define compat_mutex_init(_mx) mutex_init(_mx) +# define compat_mutex_lock(_mx) mutex_lock(_mx) +# define compat_mutex_unlock(_mx) mutex_unlock(_mx) + +#endif + +#endif /* __COMPAT_MUTEX_H__ */ diff -Nur old/vmnet-only/driver.c new/vmnet-only/driver.c --- old/vmnet-only/driver.c 2009-08-15 04:55:22.000000000 +0200 +++ new/vmnet-only/driver.c 2011-07-18 15:35:24.808553585 +0200 @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -57,7 +56,7 @@ #include "compat_uaccess.h" #include "compat_kdev_t.h" #include "compat_sched.h" -#include "compat_semaphore.h" +#include "compat_mutex.h" #include "vmnetInt.h" /* @@ -105,19 +104,20 @@ * use write_lock_irqsave() to gain write access. * * If you are acquiring this lock for write, and you do - * not have vnetStructureSemaphore already acquired, + * not have vnetStructureMutex already acquired, * it is most certainly a bug. */ -static rwlock_t vnetPeerLock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(vnetPeerLock); /* * All concurrent changes to the network structure are * guarded by this semaphore. * * For change to peer field you must own both - * vnetStructureSemaphore and vnetPeerLock for write. + * vnetStructureMutex and vnetPeerLock for write. */ -DECLARE_MUTEX(vnetStructureSemaphore); +compat_define_mutex(vnetStructureMutex); +compat_define_mutex(driver_mutex); #if defined(VM_X86_64) && !defined(HAVE_COMPAT_IOCTL) /* @@ -134,7 +134,7 @@ #endif /* - * List of known ports. Use vnetStructureSemaphore for locking. + * List of known ports. Use vnetStructureMutex for locking. */ static VNetPort *vnetAllPorts = NULL; @@ -267,11 +267,11 @@ struct file * filp) // IN: { int ret = -ENOTTY; - lock_kernel(); + compat_mutex_lock(&driver_mutex); if (filp && filp->f_op && filp->f_op->ioctl == VNetFileOpIoctl) { ret = VNetFileOpIoctl(filp->f_dentry->d_inode, filp, iocmd, ioarg); } - unlock_kernel(); + compat_mutex_unlock(&driver_mutex); return ret; } @@ -386,7 +386,7 @@ * VNetAddPortToList -- * * Add port to list of known ports. - * Caller must own vnetStructureSemaphore. + * Caller must own vnetStructureMutex. * * Results: * @@ -412,7 +412,7 @@ * VNetRemovePortFromList -- * * Remove port from list of known ports. - * Caller must own vnetStructureSemaphore. + * Caller must own vnetStructureMutex. * * Results: * @@ -643,17 +643,17 @@ return -EBUSY; } - down(&vnetStructureSemaphore); + compat_mutex_lock(&vnetStructureMutex); retval = VNetConnect(&port->jack, hubJack); if (retval) { - up(&vnetStructureSemaphore); + compat_mutex_unlock(&vnetStructureMutex); VNetFree(&port->jack); VNetFree(hubJack); return retval; } VNetAddPortToList(port); - up(&vnetStructureSemaphore); + compat_mutex_unlock(&vnetStructureMutex); /* * Store away jack in file pointer private field for later use. @@ -698,10 +698,10 @@ return -EBADF; } - down(&vnetStructureSemaphore); + compat_mutex_lock(&vnetStructureMutex); peer = VNetDisconnect(&port->jack); VNetRemovePortFromList(port); - up(&vnetStructureSemaphore); + compat_mutex_unlock(&vnetStructureMutex); VNetFree(&port->jack); VNetFree(peer); @@ -1186,9 +1186,9 @@ if (filp && filp->f_dentry) { inode = filp->f_dentry->d_inode; } - lock_kernel(); + compat_mutex_lock(&driver_mutex); err = VNetFileOpIoctl(inode, filp, iocmd, ioarg); - unlock_kernel(); + compat_mutex_unlock(&driver_mutex); return err; } #endif @@ -1248,7 +1248,7 @@ * old peer if a cycle is detected. */ - down(&vnetStructureSemaphore); + compat_mutex_lock(&vnetStructureMutex); /* Disconnect from the old peer */ oldPeer = VNetDisconnect(jack); @@ -1263,7 +1263,7 @@ /* Connect failed, so reconnect back to old peer */ int retval2 = VNetConnect(jack, oldPeer); - up(&vnetStructureSemaphore); + compat_mutex_unlock(&vnetStructureMutex); /* Free the new peer */ VNetFree(newPeer); @@ -1285,7 +1285,7 @@ VNetRemovePortFromList(jackPort); } - up(&vnetStructureSemaphore); + compat_mutex_unlock(&vnetStructureMutex); /* Connected to new peer, so dealloc the old peer */ if (connectNewToPeerOfJack) { @@ -1447,7 +1447,7 @@ * VNetConnect -- * * Connect 2 jacks. - * vnetStructureSemaphore must be held. + * vnetStructureMutex must be held. * * Results: * errno. @@ -1508,7 +1508,7 @@ * VNetDisconnect -- * * Disconnect 2 jacks. - * vnetStructureSemaphore must be held. + * vnetStructureMutex must be held. * * Results: * Return the peer jack (returns NULL on error, or if no peer) @@ -1555,7 +1555,7 @@ * Perform the cycle detect alogorithm for this generation on a * specific interface. This could be a bridged interface, host * interface or both. - * vnetStructureSemaphore must be held. + * vnetStructureMutex must be held. * * Results: * TRUE if a cycle was detected, FALSE otherwise. @@ -1606,7 +1606,7 @@ * * Free's the linked list that may have been constructed * during a recent run on the cycle detect alogorithm. - * vnetStructureSemaphore must be held. + * vnetStructureMutex must be held. * * Results: * None. @@ -1685,15 +1685,15 @@ { VNetPort *p; - down(&vnetStructureSemaphore); + compat_mutex_lock(&vnetStructureMutex); for (p = vnetAllPorts; p != NULL; p = p->next) { if (p != port && MAC_EQ(p->paddr, mac)) { - up(&vnetStructureSemaphore); + compat_mutex_unlock(&vnetStructureMutex); return -EBUSY; } } memcpy(port->paddr, mac, ETH_ALEN); - up(&vnetStructureSemaphore); + compat_mutex_unlock(&vnetStructureMutex); return 0; } diff -Nur old/vmnet-only/filter.c new/vmnet-only/filter.c --- old/vmnet-only/filter.c 2009-08-15 04:55:21.000000000 +0200 +++ new/vmnet-only/filter.c 2011-07-18 15:35:24.809553580 +0200 @@ -76,14 +76,14 @@ RuleSet *activeRule = NULL; /* actual rule set for filter callback to use */ /* locks to protect against concurrent accesses. */ -static DECLARE_MUTEX(filterIoctlSem); /* serialize ioctl()s from user space. */ +static DEFINE_SEMAPHORE(filterIoctlSem); /* serialize ioctl()s from user space. */ /* * user/netfilter hook concurrency lock. * This spinlock doesn't scale well if/when in the future the netfilter * callbacks can be concurrently executing on multiple threads on multiple * CPUs, so we should revisit locking for allowing for that in the future. */ -spinlock_t activeRuleLock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(activeRuleLock); /* * Logging. diff -Nur old/vmnet-only/hub.c new/vmnet-only/hub.c --- old/vmnet-only/hub.c 2009-08-15 04:55:21.000000000 +0200 +++ new/vmnet-only/hub.c 2011-07-18 15:35:24.809553580 +0200 @@ -85,7 +85,7 @@ * so we use __attribute__((unused)) to quiet the compiler. */ -static spinlock_t vnetHubLock __attribute__((unused)) = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(vnetHubLock); /* diff -Nur old/vmnet-only/vnetInt.h new/vmnet-only/vnetInt.h --- old/vmnet-only/vnetInt.h 2009-08-15 04:55:21.000000000 +0200 +++ new/vmnet-only/vnetInt.h 2011-07-18 15:35:24.809553580 +0200 @@ -113,7 +113,7 @@ * that send packet between them. */ -extern struct semaphore vnetStructureSemaphore; +extern struct mutex vnetStructureMutex; struct VNetJack { VNetJack *peer; @@ -247,7 +247,7 @@ * VNetPortsChanged -- * * Notify a jack that the number of connected ports has changed. - * vnetStructureSemaphore must be held. + * vnetStructureMutex must be held. * * Results: * None. diff -Nur old/vmnet-only/vnetUserListener.c new/vmnet-only/vnetUserListener.c --- old/vmnet-only/vnetUserListener.c 2011-07-18 15:34:54.633715656 +0200 +++ new/vmnet-only/vnetUserListener.c 2011-07-18 15:35:24.809553580 +0200 @@ -35,6 +35,7 @@ #include "compat_sched.h" #include "compat_wait.h" #include "vnetInt.h" +#include "compat_sched.h" typedef struct VNetUserListener_EventNode VNetUserListener_EventNode; diff -Nur old/vsock-only/linux/af_vsock.c new/vsock-only/linux/af_vsock.c --- old/vsock-only/linux/af_vsock.c 2011-07-18 15:34:54.709715249 +0200 +++ new/vsock-only/linux/af_vsock.c 2011-07-18 15:35:24.812553564 +0200 @@ -101,7 +101,6 @@ #include #include #include -#include #include #if defined(__x86_64__) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12) # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) @@ -421,7 +420,7 @@ VSockPacket pkt; } VSockRecvPktInfo; -static DECLARE_MUTEX(registrationMutex); +static DEFINE_SEMAPHORE(registrationMutex); static int devOpenCount = 0; static int vsockVmciSocketCount = 0; #ifdef VMX86_TOOLS @@ -3283,7 +3282,7 @@ * upon connection establishment. */ timeout = sock_sndtimeo(listener, flags & O_NONBLOCK); - compat_init_prepare_to_wait(listener->compat_sk_sleep, &wait, TASK_INTERRUPTIBLE); + compat_init_prepare_to_wait(compat_sk_sleep(listener), &wait, TASK_INTERRUPTIBLE); while ((connected = VSockVmciDequeueAccept(listener)) == NULL && listener->compat_sk_err == 0) { @@ -3299,7 +3298,7 @@ goto outWait; } - compat_cont_prepare_to_wait(listener->compat_sk_sleep, &wait, TASK_INTERRUPTIBLE); + compat_cont_prepare_to_wait(compat_sk_sleep(listener), &wait, TASK_INTERRUPTIBLE); } if (listener->compat_sk_err) { @@ -3333,7 +3332,7 @@ } outWait: - compat_finish_wait(listener->compat_sk_sleep, &wait, TASK_RUNNING); + compat_finish_wait(compat_sk_sleep(listener), &wait, TASK_RUNNING); out: release_sock(listener); return err; diff -Nur old/vsock-only/linux/util.c new/vsock-only/linux/util.c --- old/vsock-only/linux/util.c 2011-07-18 15:34:54.617715742 +0200 +++ new/vsock-only/linux/util.c 2011-07-18 15:35:24.812553564 +0200 @@ -34,7 +34,7 @@ struct list_head vsockBindTable[VSOCK_HASH_SIZE + 1]; struct list_head vsockConnectedTable[VSOCK_HASH_SIZE]; -spinlock_t vsockTableLock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(vsockTableLock); /* * snprintf() wasn't exported until 2.4.10: fall back on sprintf in those