Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 375461
Collapse All | Expand All

(-)old/vmblock-only/linux/dentry.c (+4 lines)
Lines 118-124 Link Here
118
#endif
118
#endif
119
   }
119
   }
120
120
121
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
121
   if (compat_path_lookup(iinfo->name, 0, &actualNd)) {
122
   if (compat_path_lookup(iinfo->name, 0, &actualNd)) {
123
#else
124
   if (kern_path(iinfo->name, 0, &(actualNd.path))) {
125
#endif
122
      LOG(4, "DentryOpRevalidate: [%s] no longer exists\n", iinfo->name);
126
      LOG(4, "DentryOpRevalidate: [%s] no longer exists\n", iinfo->name);
123
      return 0;
127
      return 0;
124
   }
128
   }
(-)old/vmblock-only/linux/filesystem.c (-8 / +32 lines)
Lines 51-58 Link Here
51
/* File system operations */
51
/* File system operations */
52
#if KERNEL_25_FS /* { */
52
#if KERNEL_25_FS /* { */
53
#   if defined(VMW_GETSB_2618)
53
#   if defined(VMW_GETSB_2618)
54
static int FsOpGetSb(struct file_system_type *fsType, int flags,
54
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
55
                     const char *devName, void *rawData, struct vfsmount *mnt);
55
 static int FsOpGetSb(struct file_system_type *fsType, int flags,
56
                      const char *devName, void *rawData, struct vfsmount *mnt);
57
#else
58
static struct dentry *FsOpMount(struct file_system_type *fsType, int flags,
59
                     const char *devName, void *rawData);
60
#endif
56
#   elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 70)
61
#   elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 70)
57
static struct super_block *FsOpGetSb(struct file_system_type *fsType, int flags,
62
static struct super_block *FsOpGetSb(struct file_system_type *fsType, int flags,
58
                                     const char *devName, void *rawData);
63
                                     const char *devName, void *rawData);
Lines 80-87 Link Here
80
static struct file_system_type fsType = {
85
static struct file_system_type fsType = {
81
   .owner = THIS_MODULE,
86
   .owner = THIS_MODULE,
82
   .name = VMBLOCK_FS_NAME,
87
   .name = VMBLOCK_FS_NAME,
88
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
89
    .get_sb = FsOpGetSb,
90
#else
91
   .mount = FsOpMount,
92
#endif
83
#if KERNEL_25_FS
93
#if KERNEL_25_FS
84
   .get_sb = FsOpGetSb,
85
   .kill_sb = kill_anon_super,
94
   .kill_sb = kill_anon_super,
86
#else
95
#else
87
   .read_super = FsOpReadSuper24,
96
   .read_super = FsOpReadSuper24,
Lines 239-245 Link Here
239
ino_t
248
ino_t
240
GetNextIno(void)
249
GetNextIno(void)
241
{
250
{
242
   static spinlock_t inoLock = SPIN_LOCK_UNLOCKED;
251
   static DEFINE_SPINLOCK(inoLock);
243
   static ino_t nextIno = VMBLOCK_ROOT_INO + 1;
252
   static ino_t nextIno = VMBLOCK_ROOT_INO + 1;
244
   ino_t ret;
253
   ino_t ret;
245
254
Lines 365-372 Link Here
365
      goto error_inode;
374
      goto error_inode;
366
   }
375
   }
367
376
368
   if (compat_path_lookup(iinfo->name, 0, &actualNd)) {
377
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
369
      /*
378
    if (compat_path_lookup(iinfo->name, 0, &actualNd)) {
379
#else
380
   if (kern_path(iinfo->name, 0, &(actualNd.path))) {
381
#endif
382
     /*
370
       * This file does not exist, so we create an inode that doesn't know
383
       * This file does not exist, so we create an inode that doesn't know
371
       * about its underlying file.  Operations that create files and
384
       * about its underlying file.  Operations that create files and
372
       * directories need an inode to operate on even if there is no actual
385
       * directories need an inode to operate on even if there is no actual
Lines 598-610 Link Here
598
/*
611
/*
599
 *-----------------------------------------------------------------------------
612
 *-----------------------------------------------------------------------------
600
 *
613
 *
601
 * FsOpGetSb --
614
 * FsOpGetSb/FsOpMount --
602
 *
615
 *
603
 *    Invokes generic kernel code to prepare superblock for
616
 *    Invokes generic kernel code to prepare superblock for
604
 *    deviceless filesystem.
617
 *    deviceless filesystem.
605
 *
618
 *
606
 * Results:
619
 * Results:
607
 *    0 on success
620
 *    0/dentry on success
608
 *    negative error code on failure
621
 *    negative error code on failure
609
 *
622
 *
610
 * Side effects:
623
 * Side effects:
Lines 613-618 Link Here
613
 *-----------------------------------------------------------------------------
626
 *-----------------------------------------------------------------------------
614
 */
627
 */
615
628
629
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
616
static int
630
static int
617
FsOpGetSb(struct file_system_type *fs_type, // IN: file system type of mount
631
FsOpGetSb(struct file_system_type *fs_type, // IN: file system type of mount
618
          int flags,                        // IN: mount flags
632
          int flags,                        // IN: mount flags
Lines 623-628 Link Here
623
   return get_sb_nodev(fs_type, flags, rawData, FsOpReadSuper, mnt);
637
   return get_sb_nodev(fs_type, flags, rawData, FsOpReadSuper, mnt);
624
}
638
}
625
#else
639
#else
640
struct dentry *
641
FsOpMount(struct file_system_type *fs_type, // IN: file system type of mount
642
          int flags,                        // IN: mount flags
643
          const char *dev_name,             // IN: device mounting on
644
          void *rawData)                    // IN: mount arguments
645
{
646
   return mount_nodev(fs_type, flags, rawData, FsOpReadSuper);
647
}
648
#endif
649
#else
626
/*
650
/*
627
 *-----------------------------------------------------------------------------
651
 *-----------------------------------------------------------------------------
628
 *
652
 *
(-)old/vmci-only/linux/driver.c (-2 / +2 lines)
Lines 20-25 Link Here
20
#include "driver-config.h"
20
#include "driver-config.h"
21
21
22
#define EXPORT_SYMTAB
22
#define EXPORT_SYMTAB
23
#define HAVE_UNLOCKED_IOCTL
23
24
24
#include "compat_version.h"
25
#include "compat_version.h"
25
#include "compat_kernel.h"
26
#include "compat_kernel.h"
Lines 34-40 Link Here
34
#include "compat_semaphore.h"
35
#include "compat_semaphore.h"
35
#endif
36
#endif
36
#include <linux/smp.h>
37
#include <linux/smp.h>
37
#include <linux/smp_lock.h>
38
38
39
#include <linux/poll.h>
39
#include <linux/poll.h>
40
40
Lines 360-366 Link Here
360
   memset(vmciLinux, 0, sizeof *vmciLinux);
360
   memset(vmciLinux, 0, sizeof *vmciLinux);
361
   vmciLinux->ctType = VMCIOBJ_NOT_SET;
361
   vmciLinux->ctType = VMCIOBJ_NOT_SET;
362
#if defined(HAVE_COMPAT_IOCTL) || defined(HAVE_UNLOCKED_IOCTL)
362
#if defined(HAVE_COMPAT_IOCTL) || defined(HAVE_UNLOCKED_IOCTL)
363
   init_MUTEX(&vmciLinux->lock);
363
   sema_init(&vmciLinux->lock, 1);
364
#endif
364
#endif
365
365
366
   filp->private_data = vmciLinux;
366
   filp->private_data = vmciLinux;
(-)old/vmmon-only/linux/driver.c (-9 / +11 lines)
Lines 20-25 Link Here
20
#include "driver-config.h"
20
#include "driver-config.h"
21
21
22
#define EXPORT_SYMTAB
22
#define EXPORT_SYMTAB
23
#define VMW_HAVE_UNLOCKED_IOCTL
23
24
24
#include "compat_version.h"
25
#include "compat_version.h"
25
#include "compat_kernel.h"
26
#include "compat_kernel.h"
Lines 37-43 Link Here
37
#include "compat_cred.h"
38
#include "compat_cred.h"
38
39
39
#include <linux/smp.h>
40
#include <linux/smp.h>
40
#include <linux/smp_lock.h>
41
#include <linux/mutex.h>
41
42
42
#include <linux/poll.h>
43
#include <linux/poll.h>
43
44
Lines 127-132 Link Here
127
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 20)
128
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 20)
128
int errno;       // required for compat_exit()
129
int errno;       // required for compat_exit()
129
#endif
130
#endif
131
static DEFINE_MUTEX(driver_mutex);
130
static void LinuxDriverQueue(VMLinux *vmLinux);
132
static void LinuxDriverQueue(VMLinux *vmLinux);
131
static void LinuxDriverDequeue(VMLinux *vmLinux);
133
static void LinuxDriverDequeue(VMLinux *vmLinux);
132
static Bool LinuxDriverCheckPadding(void);
134
static Bool LinuxDriverCheckPadding(void);
Lines 246-252 Link Here
246
   int ret;
248
   int ret;
247
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 26) || \
249
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 26) || \
248
   (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3))
250
   (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3))
249
   lock_kernel();
251
   mutex_lock(&driver_mutex);
250
#endif
252
#endif
251
   ret = -ENOTTY;
253
   ret = -ENOTTY;
252
   if (filp && filp->f_op && filp->f_op->ioctl == LinuxDriver_Ioctl) {
254
   if (filp && filp->f_op && filp->f_op->ioctl == LinuxDriver_Ioctl) {
Lines 254-260 Link Here
254
   }
256
   }
255
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 26) || \
257
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 26) || \
256
   (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3))
258
   (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3))
257
   unlock_kernel();
259
   mutex_unlock(&driver_mutex);
258
#endif
260
#endif
259
   return ret;
261
   return ret;
260
}
262
}
Lines 769-775 Link Here
769
771
770
772
771
#define POLLQUEUE_MAX_TASK 1000
773
#define POLLQUEUE_MAX_TASK 1000
772
static spinlock_t pollQueueLock __attribute__((unused)) = SPIN_LOCK_UNLOCKED;
774
static DEFINE_SPINLOCK(pollQueueLock);
773
static void *pollQueue[POLLQUEUE_MAX_TASK];
775
static void *pollQueue[POLLQUEUE_MAX_TASK];
774
static unsigned int pollQueueCount = 0;
776
static unsigned int pollQueueCount = 0;
775
777
Lines 1030-1036 Link Here
1030
		* but unfortunately there is no way how to detect that
1032
		* but unfortunately there is no way how to detect that
1031
		* we are building for RedHat's kernel...
1033
		* we are building for RedHat's kernel...
1032
		*/
1034
		*/
1033
	       static spinlock_t timerLock = SPIN_LOCK_UNLOCKED;
1035
               static DEFINE_SPINLOCK(timerLock);
1034
1036
1035
	       spin_lock(&timerLock);
1037
	       spin_lock(&timerLock);
1036
	       mod_timer(&linuxState.pollTimer, jiffies + 1);
1038
	       mod_timer(&linuxState.pollTimer, jiffies + 1);
Lines 1742-1755 Link Here
1742
         retval = -EINVAL;
1744
         retval = -EINVAL;
1743
         break;
1745
         break;
1744
      }
1746
      }
1745
      unlock_kernel();
1747
      mutex_unlock(&driver_mutex);
1746
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
1748
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
1747
#  if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
1749
#  if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
1748
      ASSERT(!kernel_locked());
1750
      ASSERT(!kernel_locked());
1749
#  endif
1751
#  endif
1750
#endif
1752
#endif
1751
      retval = Vmx86_RunVM(vmLinux->vm, vcpuid);
1753
      retval = Vmx86_RunVM(vmLinux->vm, vcpuid);
1752
      lock_kernel();
1754
      mutex_lock(&driver_mutex);
1753
      break;
1755
      break;
1754
1756
1755
   case IOCTL_VMX86_SET_UID:
1757
   case IOCTL_VMX86_SET_UID:
Lines 2440-2448 Link Here
2440
{
2442
{
2441
   long err;
2443
   long err;
2442
2444
2443
   lock_kernel();
2445
   mutex_lock(&driver_mutex);
2444
   err = LinuxDriver_Ioctl(NULL, filp, iocmd, ioarg);
2446
   err = LinuxDriver_Ioctl(NULL, filp, iocmd, ioarg);
2445
   unlock_kernel();
2447
   mutex_unlock(&driver_mutex);
2446
   return err;
2448
   return err;
2447
}
2449
}
2448
#endif
2450
#endif
(-)old/vmmon-only/linux/hostif.c (-3 / +3 lines)
Lines 46-52 Link Here
46
#include <linux/mman.h>
46
#include <linux/mman.h>
47
47
48
#include <linux/smp.h>
48
#include <linux/smp.h>
49
#include <linux/smp_lock.h>
50
49
51
#include <asm/io.h>
50
#include <asm/io.h>
52
#include <linux/mc146818rtc.h>
51
#include <linux/mc146818rtc.h>
Lines 82-87 Link Here
82
81
83
#define UPTIME_FREQ CONST64(1000000)
82
#define UPTIME_FREQ CONST64(1000000)
84
83
84
static DEFINE_MUTEX(hostif_mutex);
85
static struct {
85
static struct {
86
   Atomic_uint64     uptimeBase;
86
   Atomic_uint64     uptimeBase;
87
   VersionedAtomic   version;
87
   VersionedAtomic   version;
Lines 3417-3425 Link Here
3417
   if (filp->f_op->ioctl) {
3417
   if (filp->f_op->ioctl) {
3418
      long err;
3418
      long err;
3419
3419
3420
      lock_kernel();
3420
      mutex_lock(&hostif_mutex);
3421
      err = filp->f_op->ioctl(filp->f_dentry->d_inode, filp, iocmd, ioarg);
3421
      err = filp->f_op->ioctl(filp->f_dentry->d_inode, filp, iocmd, ioarg);
3422
      unlock_kernel();
3422
      mutex_unlock(&hostif_mutex);
3423
      return err;
3423
      return err;
3424
   }
3424
   }
3425
#endif
3425
#endif
(-)old/vmnet-only/bridge.c (-2 / +3 lines)
Lines 54-59 Link Here
54
#include "compat_netdevice.h"
54
#include "compat_netdevice.h"
55
#include "vnetInt.h"
55
#include "vnetInt.h"
56
#include "smac.h"
56
#include "smac.h"
57
#include "compat_mutex.h"
57
58
58
#define VNET_BRIDGE_HISTORY    48
59
#define VNET_BRIDGE_HISTORY    48
59
60
Lines 1035-1045 Link Here
1035
    * Put in promiscuous mode if need be.
1036
    * Put in promiscuous mode if need be.
1036
    */
1037
    */
1037
1038
1038
   down(&vnetStructureSemaphore);
1039
   compat_mutex_lock(&vnetStructureMutex);
1039
   if (VNetGetAttachedPorts(&bridge->port.jack)) {
1040
   if (VNetGetAttachedPorts(&bridge->port.jack)) {
1040
      VNetBridgeStartPromisc(bridge, rtnlLock);
1041
      VNetBridgeStartPromisc(bridge, rtnlLock);
1041
   }
1042
   }
1042
   up(&vnetStructureSemaphore);
1043
   compat_mutex_unlock(&vnetStructureMutex);
1043
1044
1044
   /* send link state up event */
1045
   /* send link state up event */
1045
   retval = VNetBridgeSendLinkStateEvent(bridge, bridge->dev->ifindex, TRUE);
1046
   retval = VNetBridgeSendLinkStateEvent(bridge, bridge->dev->ifindex, TRUE);
(-)old/vmnet-only/compat_mutex.h (+48 lines)
Line 0 Link Here
1
/*********************************************************
2
 * Copyright (C) 2009 VMware, Inc. All rights reserved.
3
 *
4
 * This program is free software; you can redistribute it and/or modify it
5
 * under the terms of the GNU General Public License as published by the
6
 * Free Software Foundation version 2 and no later version.
7
 *
8
 * This program is distributed in the hope that it will be useful, but
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11
 * for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License along
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
15
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
16
 *
17
 *********************************************************/
18
19
#ifndef __COMPAT_MUTEX_H__
20
#   define __COMPAT_MUTEX_H__
21
22
23
/* Blocking mutexes were introduced in 2.6.16. */
24
25
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
26
27
#include "compat_semaphore.h"
28
29
typedef struct semaphore compat_mutex_t;
30
31
# define compat_mutex_init(_mx)         init_MUTEX(_mx)
32
# define compat_mutex_lock(_mx)         down(_mx)
33
# define compat_mutex_unlock(_mx)       up(_mx)
34
35
#else
36
37
#include <linux/mutex.h>
38
39
typedef struct mutex compat_mutex_t;
40
41
# define compat_define_mutex(_mx)       DEFINE_MUTEX(_mx)
42
# define compat_mutex_init(_mx)         mutex_init(_mx)
43
# define compat_mutex_lock(_mx)         mutex_lock(_mx)
44
# define compat_mutex_unlock(_mx)       mutex_unlock(_mx)
45
46
#endif
47
48
#endif /* __COMPAT_MUTEX_H__ */
(-)old/vmnet-only/driver.c (-28 / +28 lines)
Lines 32-38 Link Here
32
#include <linux/poll.h>
32
#include <linux/poll.h>
33
33
34
#include <linux/smp.h>
34
#include <linux/smp.h>
35
#include <linux/smp_lock.h>
36
35
37
#include <linux/netdevice.h>
36
#include <linux/netdevice.h>
38
#include <linux/etherdevice.h>
37
#include <linux/etherdevice.h>
Lines 57-63 Link Here
57
#include "compat_uaccess.h"
56
#include "compat_uaccess.h"
58
#include "compat_kdev_t.h"
57
#include "compat_kdev_t.h"
59
#include "compat_sched.h"
58
#include "compat_sched.h"
60
#include "compat_semaphore.h"
59
#include "compat_mutex.h"
61
#include "vmnetInt.h"
60
#include "vmnetInt.h"
62
61
63
/*
62
/*
Lines 105-123 Link Here
105
 * use write_lock_irqsave() to gain write access.
104
 * use write_lock_irqsave() to gain write access.
106
 *
105
 *
107
 * If you are acquiring this lock for write, and you do
106
 * If you are acquiring this lock for write, and you do
108
 * not have vnetStructureSemaphore already acquired,
107
 * not have vnetStructureMutex already acquired,
109
 * it is most certainly a bug.
108
 * it is most certainly a bug.
110
 */
109
 */
111
static rwlock_t vnetPeerLock = RW_LOCK_UNLOCKED;
110
static DEFINE_RWLOCK(vnetPeerLock);
112
111
113
/*
112
/*
114
 * All concurrent changes to the network structure are
113
 * All concurrent changes to the network structure are
115
 * guarded by this semaphore.
114
 * guarded by this semaphore.
116
 *
115
 *
117
 * For change to peer field you must own both
116
 * For change to peer field you must own both
118
 * vnetStructureSemaphore and vnetPeerLock for write.
117
 * vnetStructureMutex and vnetPeerLock for write.
119
 */
118
 */
120
DECLARE_MUTEX(vnetStructureSemaphore);
119
compat_define_mutex(vnetStructureMutex);
120
compat_define_mutex(driver_mutex);
121
121
122
#if defined(VM_X86_64) && !defined(HAVE_COMPAT_IOCTL)
122
#if defined(VM_X86_64) && !defined(HAVE_COMPAT_IOCTL)
123
/*
123
/*
Lines 134-140 Link Here
134
#endif
134
#endif
135
135
136
/*
136
/*
137
 * List of known ports. Use vnetStructureSemaphore for locking.
137
 * List of known ports. Use vnetStructureMutex for locking.
138
 */
138
 */
139
139
140
static VNetPort *vnetAllPorts     = NULL;
140
static VNetPort *vnetAllPorts     = NULL;
Lines 267-277 Link Here
267
			    struct file * filp)  // IN:
267
			    struct file * filp)  // IN:
268
{
268
{
269
   int ret = -ENOTTY;
269
   int ret = -ENOTTY;
270
   lock_kernel();
270
   compat_mutex_lock(&driver_mutex);
271
   if (filp && filp->f_op && filp->f_op->ioctl == VNetFileOpIoctl) {
271
   if (filp && filp->f_op && filp->f_op->ioctl == VNetFileOpIoctl) {
272
      ret = VNetFileOpIoctl(filp->f_dentry->d_inode, filp, iocmd, ioarg);
272
      ret = VNetFileOpIoctl(filp->f_dentry->d_inode, filp, iocmd, ioarg);
273
   }
273
   }
274
   unlock_kernel();
274
   compat_mutex_unlock(&driver_mutex);
275
   return ret;
275
   return ret;
276
}
276
}
277
277
Lines 386-392 Link Here
386
 * VNetAddPortToList --
386
 * VNetAddPortToList --
387
 *
387
 *
388
 *      Add port to list of known ports.
388
 *      Add port to list of known ports.
389
 *	Caller must own vnetStructureSemaphore.
389
 *	Caller must own vnetStructureMutex.
390
 *
390
 *
391
 * Results:
391
 * Results:
392
 *
392
 *
Lines 412-418 Link Here
412
 * VNetRemovePortFromList --
412
 * VNetRemovePortFromList --
413
 *
413
 *
414
 *      Remove port from list of known ports.
414
 *      Remove port from list of known ports.
415
 *	Caller must own vnetStructureSemaphore.
415
 *	Caller must own vnetStructureMutex.
416
 *
416
 *
417
 * Results:
417
 * Results:
418
 *
418
 *
Lines 643-659 Link Here
643
      return -EBUSY;
643
      return -EBUSY;
644
   }
644
   }
645
645
646
   down(&vnetStructureSemaphore);
646
   compat_mutex_lock(&vnetStructureMutex);
647
   retval = VNetConnect(&port->jack, hubJack);
647
   retval = VNetConnect(&port->jack, hubJack);
648
   if (retval) {
648
   if (retval) {
649
      up(&vnetStructureSemaphore);
649
      compat_mutex_unlock(&vnetStructureMutex);
650
      VNetFree(&port->jack);
650
      VNetFree(&port->jack);
651
      VNetFree(hubJack);
651
      VNetFree(hubJack);
652
      return retval;
652
      return retval;
653
   }
653
   }
654
654
655
   VNetAddPortToList(port);
655
   VNetAddPortToList(port);
656
   up(&vnetStructureSemaphore);
656
   compat_mutex_unlock(&vnetStructureMutex);
657
657
658
   /*
658
   /*
659
    * Store away jack in file pointer private field for later use.
659
    * Store away jack in file pointer private field for later use.
Lines 698-707 Link Here
698
      return -EBADF;
698
      return -EBADF;
699
   }
699
   }
700
700
701
   down(&vnetStructureSemaphore);
701
   compat_mutex_lock(&vnetStructureMutex);
702
   peer = VNetDisconnect(&port->jack);
702
   peer = VNetDisconnect(&port->jack);
703
   VNetRemovePortFromList(port);
703
   VNetRemovePortFromList(port);
704
   up(&vnetStructureSemaphore);
704
   compat_mutex_unlock(&vnetStructureMutex);
705
705
706
   VNetFree(&port->jack);
706
   VNetFree(&port->jack);
707
   VNetFree(peer);
707
   VNetFree(peer);
Lines 1186-1194 Link Here
1186
   if (filp && filp->f_dentry) {
1186
   if (filp && filp->f_dentry) {
1187
      inode = filp->f_dentry->d_inode;
1187
      inode = filp->f_dentry->d_inode;
1188
   }
1188
   }
1189
   lock_kernel();
1189
   compat_mutex_lock(&driver_mutex);
1190
   err = VNetFileOpIoctl(inode, filp, iocmd, ioarg);
1190
   err = VNetFileOpIoctl(inode, filp, iocmd, ioarg);
1191
   unlock_kernel();
1191
   compat_mutex_unlock(&driver_mutex);
1192
   return err;
1192
   return err;
1193
}
1193
}
1194
#endif
1194
#endif
Lines 1248-1254 Link Here
1248
    * old peer if a cycle is detected.
1248
    * old peer if a cycle is detected.
1249
    */
1249
    */
1250
1250
1251
   down(&vnetStructureSemaphore);
1251
   compat_mutex_lock(&vnetStructureMutex);
1252
1252
1253
   /* Disconnect from the old peer */
1253
   /* Disconnect from the old peer */
1254
   oldPeer = VNetDisconnect(jack);
1254
   oldPeer = VNetDisconnect(jack);
Lines 1263-1269 Link Here
1263
1263
1264
      /* Connect failed, so reconnect back to old peer */
1264
      /* Connect failed, so reconnect back to old peer */
1265
      int retval2 = VNetConnect(jack, oldPeer);
1265
      int retval2 = VNetConnect(jack, oldPeer);
1266
      up(&vnetStructureSemaphore);
1266
      compat_mutex_unlock(&vnetStructureMutex);
1267
1267
1268
      /* Free the new peer */
1268
      /* Free the new peer */
1269
      VNetFree(newPeer);
1269
      VNetFree(newPeer);
Lines 1285-1291 Link Here
1285
      VNetRemovePortFromList(jackPort);
1285
      VNetRemovePortFromList(jackPort);
1286
   }
1286
   }
1287
1287
1288
   up(&vnetStructureSemaphore);
1288
   compat_mutex_unlock(&vnetStructureMutex);
1289
1289
1290
   /* Connected to new peer, so dealloc the old peer */
1290
   /* Connected to new peer, so dealloc the old peer */
1291
   if (connectNewToPeerOfJack) {
1291
   if (connectNewToPeerOfJack) {
Lines 1447-1453 Link Here
1447
 * VNetConnect --
1447
 * VNetConnect --
1448
 *
1448
 *
1449
 *      Connect 2 jacks.
1449
 *      Connect 2 jacks.
1450
 *	vnetStructureSemaphore must be held.
1450
 *	vnetStructureMutex must be held.
1451
 *
1451
 *
1452
 * Results:
1452
 * Results:
1453
 *      errno.
1453
 *      errno.
Lines 1508-1514 Link Here
1508
 * VNetDisconnect --
1508
 * VNetDisconnect --
1509
 *
1509
 *
1510
 *	Disconnect 2 jacks.
1510
 *	Disconnect 2 jacks.
1511
 *	vnetStructureSemaphore must be held.
1511
 *	vnetStructureMutex must be held.
1512
 *
1512
 *
1513
 * Results:
1513
 * Results:
1514
 *      Return the peer jack (returns NULL on error, or if no peer)
1514
 *      Return the peer jack (returns NULL on error, or if no peer)
Lines 1555-1561 Link Here
1555
 *      Perform the cycle detect alogorithm for this generation on a
1555
 *      Perform the cycle detect alogorithm for this generation on a
1556
 *      specific interface. This could be a bridged interface, host
1556
 *      specific interface. This could be a bridged interface, host
1557
 *      interface or both.
1557
 *      interface or both.
1558
 *      vnetStructureSemaphore must be held.
1558
 *      vnetStructureMutex must be held.
1559
 *
1559
 *
1560
 * Results:
1560
 * Results:
1561
 *      TRUE if a cycle was detected, FALSE otherwise.
1561
 *      TRUE if a cycle was detected, FALSE otherwise.
Lines 1606-1612 Link Here
1606
 *
1606
 *
1607
 *      Free's the linked list that may have been constructed
1607
 *      Free's the linked list that may have been constructed
1608
 *      during a recent run on the cycle detect alogorithm.
1608
 *      during a recent run on the cycle detect alogorithm.
1609
 *      vnetStructureSemaphore must be held.
1609
 *      vnetStructureMutex must be held.
1610
 *
1610
 *
1611
 * Results:
1611
 * Results:
1612
 *      None.
1612
 *      None.
Lines 1685-1699 Link Here
1685
{
1685
{
1686
   VNetPort *p;
1686
   VNetPort *p;
1687
1687
1688
   down(&vnetStructureSemaphore);
1688
   compat_mutex_lock(&vnetStructureMutex);
1689
   for (p = vnetAllPorts; p != NULL; p = p->next) {
1689
   for (p = vnetAllPorts; p != NULL; p = p->next) {
1690
      if (p != port && MAC_EQ(p->paddr, mac)) {
1690
      if (p != port && MAC_EQ(p->paddr, mac)) {
1691
         up(&vnetStructureSemaphore);
1691
         compat_mutex_unlock(&vnetStructureMutex);
1692
         return -EBUSY;
1692
         return -EBUSY;
1693
      }
1693
      }
1694
   }
1694
   }
1695
   memcpy(port->paddr, mac, ETH_ALEN);
1695
   memcpy(port->paddr, mac, ETH_ALEN);
1696
   up(&vnetStructureSemaphore);
1696
   compat_mutex_unlock(&vnetStructureMutex);
1697
   return 0;
1697
   return 0;
1698
}
1698
}
1699
1699
(-)old/vmnet-only/filter.c (-2 / +2 lines)
Lines 76-89 Link Here
76
RuleSet *activeRule = NULL;   /* actual rule set for filter callback to use */
76
RuleSet *activeRule = NULL;   /* actual rule set for filter callback to use */
77
77
78
/* locks to protect against concurrent accesses. */
78
/* locks to protect against concurrent accesses. */
79
static DECLARE_MUTEX(filterIoctlSem);   /* serialize ioctl()s from user space. */
79
static DEFINE_SEMAPHORE(filterIoctlSem);   /* serialize ioctl()s from user space. */
80
/*
80
/*
81
 * user/netfilter hook concurrency lock.
81
 * user/netfilter hook concurrency lock.
82
 * This spinlock doesn't scale well if/when in the future the netfilter
82
 * This spinlock doesn't scale well if/when in the future the netfilter
83
 * callbacks can be concurrently executing on multiple threads on multiple
83
 * callbacks can be concurrently executing on multiple threads on multiple
84
 * CPUs, so we should revisit locking for allowing for that in the future.
84
 * CPUs, so we should revisit locking for allowing for that in the future.
85
 */
85
 */
86
spinlock_t activeRuleLock = SPIN_LOCK_UNLOCKED;
86
DEFINE_SPINLOCK(activeRuleLock);
87
87
88
/*
88
/*
89
 * Logging.
89
 * Logging.
(-)old/vmnet-only/hub.c (-1 / +1 lines)
Lines 85-91 Link Here
85
 * so we use __attribute__((unused)) to quiet the compiler.
85
 * so we use __attribute__((unused)) to quiet the compiler.
86
 */
86
 */
87
87
88
static spinlock_t vnetHubLock __attribute__((unused)) = SPIN_LOCK_UNLOCKED;
88
static DEFINE_SPINLOCK(vnetHubLock);
89
89
90
90
91
/*
91
/*
(-)old/vmnet-only/vnetInt.h (-2 / +2 lines)
Lines 113-119 Link Here
113
 *  that send packet between them.
113
 *  that send packet between them.
114
 */
114
 */
115
115
116
extern struct semaphore vnetStructureSemaphore;
116
extern struct mutex vnetStructureMutex;
117
117
118
struct VNetJack {
118
struct VNetJack {
119
   VNetJack      *peer;
119
   VNetJack      *peer;
Lines 247-253 Link Here
247
 * VNetPortsChanged --
247
 * VNetPortsChanged --
248
 *
248
 *
249
 *      Notify a jack that the number of connected ports has changed.
249
 *      Notify a jack that the number of connected ports has changed.
250
 *	vnetStructureSemaphore must be held.
250
 *	vnetStructureMutex must be held.
251
 *
251
 *
252
 * Results: 
252
 * Results: 
253
 *      None.
253
 *      None.
(-)old/vmnet-only/vnetUserListener.c (+1 lines)
Lines 35-40 Link Here
35
#include "compat_sched.h"
35
#include "compat_sched.h"
36
#include "compat_wait.h"
36
#include "compat_wait.h"
37
#include "vnetInt.h"
37
#include "vnetInt.h"
38
#include "compat_sched.h"
38
39
39
typedef struct VNetUserListener_EventNode VNetUserListener_EventNode;
40
typedef struct VNetUserListener_EventNode VNetUserListener_EventNode;
40
41
(-)old/vsock-only/linux/af_vsock.c (-5 / +4 lines)
Lines 101-107 Link Here
101
#include <linux/miscdevice.h>
101
#include <linux/miscdevice.h>
102
#include <linux/poll.h>
102
#include <linux/poll.h>
103
#include <linux/smp.h>
103
#include <linux/smp.h>
104
#include <linux/smp_lock.h>
105
#include <asm/io.h>
104
#include <asm/io.h>
106
#if defined(__x86_64__) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12)
105
#if defined(__x86_64__) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12)
107
#   if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
106
#   if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
Lines 421-427 Link Here
421
   VSockPacket pkt;
420
   VSockPacket pkt;
422
} VSockRecvPktInfo;
421
} VSockRecvPktInfo;
423
422
424
static DECLARE_MUTEX(registrationMutex);
423
static DEFINE_SEMAPHORE(registrationMutex);
425
static int devOpenCount = 0;
424
static int devOpenCount = 0;
426
static int vsockVmciSocketCount = 0;
425
static int vsockVmciSocketCount = 0;
427
#ifdef VMX86_TOOLS
426
#ifdef VMX86_TOOLS
Lines 3283-3289 Link Here
3283
    * upon connection establishment.
3282
    * upon connection establishment.
3284
    */
3283
    */
3285
   timeout = sock_sndtimeo(listener, flags & O_NONBLOCK);
3284
   timeout = sock_sndtimeo(listener, flags & O_NONBLOCK);
3286
   compat_init_prepare_to_wait(listener->compat_sk_sleep, &wait, TASK_INTERRUPTIBLE);
3285
   compat_init_prepare_to_wait(compat_sk_sleep(listener), &wait, TASK_INTERRUPTIBLE);
3287
3286
3288
   while ((connected = VSockVmciDequeueAccept(listener)) == NULL &&
3287
   while ((connected = VSockVmciDequeueAccept(listener)) == NULL &&
3289
          listener->compat_sk_err == 0) {
3288
          listener->compat_sk_err == 0) {
Lines 3299-3305 Link Here
3299
         goto outWait;
3298
         goto outWait;
3300
      }
3299
      }
3301
3300
3302
      compat_cont_prepare_to_wait(listener->compat_sk_sleep, &wait, TASK_INTERRUPTIBLE);
3301
      compat_cont_prepare_to_wait(compat_sk_sleep(listener), &wait, TASK_INTERRUPTIBLE);
3303
   }
3302
   }
3304
3303
3305
   if (listener->compat_sk_err) {
3304
   if (listener->compat_sk_err) {
Lines 3333-3339 Link Here
3333
   }
3332
   }
3334
3333
3335
outWait:
3334
outWait:
3336
   compat_finish_wait(listener->compat_sk_sleep, &wait, TASK_RUNNING);
3335
   compat_finish_wait(compat_sk_sleep(listener), &wait, TASK_RUNNING);
3337
out:
3336
out:
3338
   release_sock(listener);
3337
   release_sock(listener);
3339
   return err;
3338
   return err;
(-)old/vsock-only/linux/util.c (-1 / +1 lines)
Lines 34-40 Link Here
34
struct list_head vsockBindTable[VSOCK_HASH_SIZE + 1];
34
struct list_head vsockBindTable[VSOCK_HASH_SIZE + 1];
35
struct list_head vsockConnectedTable[VSOCK_HASH_SIZE];
35
struct list_head vsockConnectedTable[VSOCK_HASH_SIZE];
36
36
37
spinlock_t vsockTableLock = SPIN_LOCK_UNLOCKED;
37
DEFINE_SPINLOCK(vsockTableLock);
38
38
39
/*
39
/*
40
 * snprintf() wasn't exported until 2.4.10: fall back on sprintf in those
40
 * snprintf() wasn't exported until 2.4.10: fall back on sprintf in those

Return to bug 375461