diff -cbr a/include/compat_semaphore.h b/include/compat_semaphore.h *** a/include/compat_semaphore.h 2008-05-16 03:19:56.000000000 -0400 --- b/include/compat_semaphore.h 2008-09-04 16:37:32.000000000 -0400 *************** *** 2,8 **** --- 2,12 ---- # define __COMPAT_SEMAPHORE_H__ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) #include + #else + #include + #endif /* diff -cbr a/include/x86paging.h b/include/x86paging.h *** a/include/x86paging.h 2008-05-16 03:19:55.000000000 -0400 --- b/include/x86paging.h 2008-09-04 16:34:05.000000000 -0400 *************** *** 58,64 **** --- 58,66 ---- #define PTE_AVAIL_MASK 0xe00 #define PTE_AVAIL_SHIFT 9 + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) #define PTE_PFN_MASK 0xfffff000 + #endif #define PAE_PTE_PFN_MASK CONST64U(0xffffff000) #define LM_PTE_PFN_MASK CONST64U(0xffffffffff000) #define PTE_PFN_SHIFT 12 diff -cbr a/linux/driver.c b/linux/driver.c *** a/linux/driver.c 2008-06-23 22:11:57.000000000 -0400 --- b/linux/driver.c 2008-09-03 14:16:49.000000000 -0400 *************** *** 422,428 **** --- 422,432 ---- linuxState.pollTimer.data = 0; linuxState.pollTimer.function = LinuxDriverPollTimeout; + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) + linuxState.fastClockTask = NULL; + #else linuxState.fastClockThread = 0; + #endif linuxState.fastClockRate = 0; #ifdef POLLSPINLOCK *************** *** 1082,1088 **** --- 1086,1097 ---- mask = POLLIN; } } else { + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) + if ((linuxState.fastClockTask!=NULL) && + vmLinux->pollTimeoutPtr != NULL) { + #else if (linuxState.fastClockThread && vmLinux->pollTimeoutPtr != NULL) { + #endif struct timeval tv; do_gettimeofday(&tv); poll_wait(filp, &vmLinux->pollQueue, wait); diff -cbr a/linux/driver.h b/linux/driver.h *** a/linux/driver.h 2008-05-16 03:19:55.000000000 -0400 --- b/linux/driver.h 2008-09-04 16:37:00.000000000 -0400 *************** *** 96,102 **** --- 96,106 ---- spinlock_t pollListLock; #endif + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) + struct task_struct *fastClockTask; + #else volatile int fastClockThread; + #endif unsigned fastClockRate; } VMXLinuxState; diff -cbr a/linux/hostif.c b/linux/hostif.c *** a/linux/hostif.c 2008-05-16 03:19:55.000000000 -0400 --- b/linux/hostif.c 2008-09-03 14:48:40.000000000 -0400 *************** *** 70,75 **** --- 70,79 ---- #include "compat_timer.h" #include "x86.h" + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) + #include + #include + #endif static COMPAT_DECLARE_COMPLETION(fastClockExited); /* *************** *** 136,141 **** --- 140,234 ---- #define HOST_ISTRACKED_PFN(_vm, _pfn) (PhysTrack_Test(_vm->physTracker, _pfn)) + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)) + /* + *----------------------------------------------------------------------------- + * + * MutexInit -- + * + * Initialize a Mutex. --hpreg + * + * Results: + * None + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + + #define MutexInit(_mutex, _name) mutex_init(_mutex) + /* + *----------------------------------------------------------------------------- + * + * MutexIsLocked -- + * + * Determine if a Mutex is locked by the current thread. --hpreg + * + * Results: + * TRUE if yes + * FALSE if no + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + + #define MutexIsLocked(_mutex) mutex_is_locked(_mutex) + + /* + *----------------------------------------------------------------------------- + * + * MutexLock -- + * + * Acquire a Mutex. --hpreg + * + * Results: + * None + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + + #define MutexLock(_mutex, _callerID) mutex_lock(_mutex) + + /* + *----------------------------------------------------------------------------- + * + * MutexUnlock -- + * + * Release a Mutex. --hpreg + * + * Results: + * None + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + + #define MutexUnlock(_mutex, _callerID) mutex_unlock(_mutex) + + /* This mutex protects the driver-wide state. --hpreg */ + static DEFINE_MUTEX(globalMutex); + + /* + * This mutex protects the fast clock rate and is held while + * creating/destroying the fastClockThread. It ranks below + * globalMutex. We can't use globalMutex for this purpose because the + * fastClockThread itself acquires the globalMutex, so trying to hold + * the mutex while destroying the thread can cause a deadlock. + */ + static DEFINE_MUTEX(fastClockMutex); + + /* This mutex protects linuxState.pollList. */ + static DEFINE_MUTEX(pollListMutex); + + #else /* *----------------------------------------------------------------------------- * *************** *** 278,283 **** --- 371,377 ---- /* This mutex protects linuxState.pollList. */ static Mutex pollListMutex; + #endif /* USE_KTHREAD */ /* *----------------------------------------------------------------------------- *************** *** 350,356 **** MutexUnlock(&globalMutex, callerID); } ! #ifdef VMX86_DEBUG /* *----------------------------------------------------------------------------- --- 444,450 ---- MutexUnlock(&globalMutex, callerID); } ! #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) #ifdef VMX86_DEBUG /* *----------------------------------------------------------------------------- *************** *** 375,380 **** --- 469,475 ---- return MutexIsLocked(&globalMutex); } #endif + #endif /* *************** *** 583,589 **** #else pte_val(*pte) &= ~_PAGE_NX; #endif ! smp_call_function (TLBInvalidatePage, (void *)vaddr, 1, 1); TLBInvalidatePage((void *)vaddr); } if (ptemap) { --- 678,684 ---- #else pte_val(*pte) &= ~_PAGE_NX; #endif ! compat_smp_call_function (TLBInvalidatePage, (void *)vaddr, 1, 1); TLBInvalidatePage((void *)vaddr); } if (ptemap) { *************** *** 2030,2036 **** MutexUnlock(&vm->vmhost->vmMutex, callerID); } - #ifdef VMX86_DEBUG /* *----------------------------------------------------------------------------- --- 2125,2130 ---- *************** *** 3279,3292 **** mm_segment_t oldFS; unsigned rate = 0; compat_daemonize("vmware-rtc"); oldFS = get_fs(); set_fs(KERNEL_DS); compat_allow_signal(SIGKILL); cap_raise(current->cap_effective, CAP_SYS_RESOURCE); compat_set_user_nice(current, -20); ! ! while (linuxState.fastClockRate > HZ + HZ/16) { unsigned long buf; loff_t pos = 0; unsigned p2rate; --- 3373,3389 ---- mm_segment_t oldFS; unsigned rate = 0; + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) compat_daemonize("vmware-rtc"); + #endif oldFS = get_fs(); set_fs(KERNEL_DS); + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) compat_allow_signal(SIGKILL); + #endif cap_raise(current->cap_effective, CAP_SYS_RESOURCE); compat_set_user_nice(current, -20); ! while (linuxState.fastClockRate > HZ + HZ/16){ unsigned long buf; loff_t pos = 0; unsigned p2rate; *************** *** 3402,3412 **** */ if (rate > HZ + HZ/16) { if (!linuxState.fastClockThread) { struct file *filp; int fsuid, res; Bool cap; - long pid; fsuid = current->fsuid; current->fsuid = 0; --- 3499,3515 ---- */ if (rate > HZ + HZ/16) { + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) + if (linuxState.fastClockTask==NULL) { + struct task_struct *t; + #else if (!linuxState.fastClockThread) { + long pid; + #endif struct file *filp; int fsuid, res; Bool cap; fsuid = current->fsuid; current->fsuid = 0; *************** *** 3427,3432 **** --- 3530,3544 ---- compat_filp_close(filp, current->files); return -res; } + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) + t = kthread_create(HostIFFastClockThread, filp, "vmware-rtc"); + if (IS_ERR(t)) { + compat_filp_close(filp, current->files); + return -PTR_ERR(t); + } + linuxState.fastClockTask=t; + wake_up_process(t); + #else pid = kernel_thread(HostIFFastClockThread, filp, 0); if (pid < 0) { /* *************** *** 3441,3453 **** --- 3553,3574 ---- return -pid; } linuxState.fastClockThread = pid; + #endif } } else { + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) + if (linuxState.fastClockTask!=NULL) { + kthread_stop(linuxState.fastClockTask); + linuxState.fastClockTask = NULL; + compat_wait_for_completion(&fastClockExited); + } + #else if (linuxState.fastClockThread) { kill_proc(linuxState.fastClockThread, SIGKILL, 1); linuxState.fastClockThread = 0; compat_wait_for_completion(&fastClockExited); } + #endif } return 0; } *************** *** 3544,3550 **** * *----------------------------------------------------------------------------- */ - void HostIF_UnmapUserMem(struct page **page) // IN/OUT { --- 3665,3670 ---- *************** *** 3557,3559 **** --- 3677,3680 ---- kunmap(p); put_page(p); } + diff -cbr a/linux/vmhost.h b/linux/vmhost.h *** a/linux/vmhost.h 2008-05-16 03:19:55.000000000 -0400 --- b/linux/vmhost.h 2008-09-03 14:27:43.000000000 -0400 *************** *** 13,19 **** #include "compat_semaphore.h" #include "compat_wait.h" ! #ifdef VMX86_DEBUG /* * A MutexHolder object. In debug builds, we record information about the --- 13,19 ---- #include "compat_semaphore.h" #include "compat_wait.h" ! #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) #ifdef VMX86_DEBUG /* * A MutexHolder object. In debug builds, we record information about the *************** *** 54,60 **** MutexHolder cur; #endif } Mutex; ! /* * Per-vm host-specific state. --- 54,60 ---- MutexHolder cur; #endif } Mutex; ! #endif /* * Per-vm host-specific state. *************** *** 65,71 **** --- 65,75 ---- * Used for shared modifications to VM's VMDriver data, mostly page locking. * It has higher rank than the global mutex. */ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) + struct mutex vmMutex; + #else Mutex vmMutex; + #endif atomic_t pendingUserCalls; wait_queue_head_t callQueue; diff -cbr a/linux/vmmonInt.h b/linux/vmmonInt.h *** a/linux/vmmonInt.h 2008-05-16 03:19:55.000000000 -0400 --- b/linux/vmmonInt.h 2008-08-30 12:04:49.000000000 -0400 *************** *** 32,38 **** --- 32,42 ---- #endif #if defined(CONFIG_SMP) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 2, 8) + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) + #define compat_smp_call_function(_a0,_a1,_a2,_a3) smp_call_function(_a0,_a1,_a3) + #else #define compat_smp_call_function smp_call_function + #endif #else #define compat_smp_call_function(_a0,_a1,_a2,_a3) 0 #endif