1 |
ikelos 09/01/10 12:10:55 |
2 |
|
3 |
Added: 040_all_kernel-2.6.27.patch |
4 |
Log: |
5 |
Add in vmware-modules-1.0.0.15-r2. Should compile on kernels up to and including 2.6.28, big thanks go to Tim Yamin for help with the patches. |
6 |
(Portage version: 2.2_rc20/cvs/Linux 2.6.28 i686) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 app-emulation/vmware-modules/files/patches/vmmon/040_all_kernel-2.6.27.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-emulation/vmware-modules/files/patches/vmmon/040_all_kernel-2.6.27.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-emulation/vmware-modules/files/patches/vmmon/040_all_kernel-2.6.27.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: 040_all_kernel-2.6.27.patch |
15 |
=================================================================== |
16 |
diff --git a/common/task.c b/common/task.c |
17 |
index 264948d..62f4487 100644 |
18 |
--- a/common/task.c |
19 |
+++ b/common/task.c |
20 |
@@ -35,7 +35,6 @@ extern "C" { |
21 |
#include "hostKernel.h" |
22 |
#ifdef linux |
23 |
# include <linux/string.h> |
24 |
-# include <linux/kernel.h> |
25 |
|
26 |
# ifdef USE_PERFCTRS_HOSTED |
27 |
# include "perfctr.h" |
28 |
diff --git a/common/task_compat.h b/common/task_compat.h |
29 |
index b9f4f61..7e9c3de 100644 |
30 |
--- a/common/task_compat.h |
31 |
+++ b/common/task_compat.h |
32 |
@@ -3646,6 +3646,5 @@ Task_CheckPadding(void) |
33 |
return TRUE; |
34 |
} |
35 |
|
36 |
- printk("/dev/vmmon: Cannot load module. Use standard gcc compiler\n"); |
37 |
return FALSE; |
38 |
} |
39 |
diff --git a/include/compat_semaphore.h b/include/compat_semaphore.h |
40 |
index 6514067..b2e399d 100644 |
41 |
--- a/include/compat_semaphore.h |
42 |
+++ b/include/compat_semaphore.h |
43 |
@@ -2,7 +2,7 @@ |
44 |
# define __COMPAT_SEMAPHORE_H__ |
45 |
|
46 |
|
47 |
-#include <asm/semaphore.h> |
48 |
+#include <linux/semaphore.h> |
49 |
|
50 |
|
51 |
/* |
52 |
diff --git a/include/vcpuset.h b/include/vcpuset.h |
53 |
index 977f3ce..03346df 100644 |
54 |
--- a/include/vcpuset.h |
55 |
+++ b/include/vcpuset.h |
56 |
@@ -71,7 +71,27 @@ ffs_x86_64(int x) |
57 |
#define ffs(x) ffs_x86_64(x) |
58 |
|
59 |
#elif defined MODULE |
60 |
+#ifndef __cplusplus |
61 |
#include "linux/bitops.h" |
62 |
+#else |
63 |
+static inline int ffs_x86_hack(int x) |
64 |
+{ |
65 |
+ int r; |
66 |
+#ifdef CONFIG_X86_CMOV |
67 |
+ asm("bsfl %1,%0\n\t" |
68 |
+ "cmovzl %2,%0" |
69 |
+ : "=r" (r) : "rm" (x), "r" (-1)); |
70 |
+#else |
71 |
+ asm("bsfl %1,%0\n\t" |
72 |
+ "jnz 1f\n\t" |
73 |
+ "movl $-1,%0\n" |
74 |
+ "1:" : "=r" (r) : "rm" (x)); |
75 |
+#endif |
76 |
+ return r + 1; |
77 |
+} |
78 |
+ |
79 |
+#define ffs(x) ffs_x86_hack(x) |
80 |
+#endif |
81 |
#elif defined __APPLE__ && defined KERNEL |
82 |
/* |
83 |
* XXXMACOS An ugly hack to resolve redefinition of PAGE_ defines |
84 |
diff --git a/include/x86paging.h b/include/x86paging.h |
85 |
index 688207f..abf26d2 100644 |
86 |
--- a/include/x86paging.h |
87 |
+++ b/include/x86paging.h |
88 |
@@ -58,7 +58,9 @@ |
89 |
|
90 |
#define PTE_AVAIL_MASK 0xe00 |
91 |
#define PTE_AVAIL_SHIFT 9 |
92 |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) |
93 |
#define PTE_PFN_MASK 0xfffff000 |
94 |
+#endif |
95 |
#define PAE_PTE_PFN_MASK CONST64U(0xffffff000) |
96 |
#define LM_PTE_PFN_MASK CONST64U(0xffffffffff000) |
97 |
#define PTE_PFN_SHIFT 12 |
98 |
diff --git a/linux/driver.c b/linux/driver.c |
99 |
index bd33762..802b91a 100644 |
100 |
--- a/linux/driver.c |
101 |
+++ b/linux/driver.c |
102 |
@@ -113,6 +113,15 @@ static int LinuxDriverAPMstate = APM_STATE_READY; |
103 |
#define VMWare_SetVTracer(VTrace_Set) |
104 |
#endif |
105 |
|
106 |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) |
107 |
+#define VMW_NOPAGE_2624 |
108 |
+ |
109 |
+#define VMMON_MAP_OFFSET_SHIFT 0 |
110 |
+#define VMMON_MAP_OFFSET_MASK 0x00000FFF |
111 |
+#define VMMON_MAP_OFFSET(base) \ |
112 |
+ (((base) >> VMMON_MAP_OFFSET_SHIFT) & VMMON_MAP_OFFSET_MASK) |
113 |
+#endif |
114 |
+ |
115 |
struct VMXLinuxState linuxState; |
116 |
|
117 |
static int vmversion = VME_DEFAULT; |
118 |
@@ -125,6 +134,7 @@ MODULE_PARM_DESC(vmversion, "VMware version you use: 1=VMware 2, 2=GSX 1, 3=VMwa |
119 |
"5=GSX 2, 6=GSX 2.5, 7=VMware 4, 8=VMware 3.2.1, 9=GSX 2.5.1, " |
120 |
"10=VMware 4.5, 11=VMware 4.5.2, 12=GSX 3.2, 13=VMware 5.0, 14=VMware 5.5, " |
121 |
"15=Server 1.0, 16=VMware 6.0, 17=TOT"); |
122 |
+MODULE_LICENSE("Proprietary"); |
123 |
|
124 |
/* |
125 |
*---------------------------------------------------------------------- |
126 |
@@ -147,7 +157,10 @@ static long LinuxDriver_CompatIoctl(struct file *filp, |
127 |
|
128 |
static int LinuxDriver_Close(struct inode *inode, struct file *filp); |
129 |
static unsigned int LinuxDriverPoll(struct file *file, poll_table *wait); |
130 |
-#if defined(VMW_NOPAGE_261) |
131 |
+#if defined(VMW_NOPAGE_2624) |
132 |
+static int LinuxDriverFault(struct vm_area_struct *vma, struct vm_fault *fault); |
133 |
+static int LinuxDriverLockedFault(struct vm_area_struct *vma, struct vm_fault *fault); |
134 |
+#elif defined(VMW_NOPAGE_261) |
135 |
static struct page *LinuxDriverNoPage(struct vm_area_struct *vma, |
136 |
unsigned long address, int *type); |
137 |
static struct page *LinuxDriverLockedNoPage(struct vm_area_struct *vma, |
138 |
@@ -168,11 +181,19 @@ static int LinuxDriverMmap(struct file *filp, struct vm_area_struct *vma); |
139 |
static void LinuxDriverPollTimeout(unsigned long clientData); |
140 |
|
141 |
static struct vm_operations_struct vmuser_mops = { |
142 |
+#ifdef VMW_NOPAGE_2624 |
143 |
+ .fault = LinuxDriverFault |
144 |
+#else |
145 |
.nopage = LinuxDriverNoPage |
146 |
+#endif |
147 |
}; |
148 |
|
149 |
struct vm_operations_struct vmuser_locked_mops = { |
150 |
+#ifdef VMW_NOPAGE_2624 |
151 |
+ .fault = LinuxDriverLockedFault |
152 |
+#else |
153 |
.nopage = LinuxDriverLockedNoPage |
154 |
+#endif |
155 |
}; |
156 |
|
157 |
static struct file_operations vmuser_fops; |
158 |
@@ -1143,7 +1164,10 @@ LinuxDriverIPIHandler(void *info) |
159 |
*----------------------------------------------------------------------------- |
160 |
*/ |
161 |
|
162 |
-#ifdef VMW_NOPAGE_261 |
163 |
+#if defined(VMW_NOPAGE_2624) |
164 |
+static int LinuxDriverFault(struct vm_area_struct *vma, //IN |
165 |
+ struct vm_fault *fault) //IN/OUT |
166 |
+#elif defined(VMW_NOPAGE_261) |
167 |
static struct page *LinuxDriverNoPage(struct vm_area_struct *vma, //IN |
168 |
unsigned long address, //IN |
169 |
int *type) //OUT: Fault type |
170 |
@@ -1161,14 +1185,25 @@ static unsigned long LinuxDriverNoPage(struct vm_area_struct *vma,//IN |
171 |
unsigned long pg; |
172 |
struct page* page; |
173 |
|
174 |
+#ifdef VMW_NOPAGE_2624 |
175 |
+ pg = fault->pgoff; |
176 |
+#else |
177 |
pg = ((address - vma->vm_start) >> PAGE_SHIFT) + compat_vm_pgoff(vma); |
178 |
+#endif |
179 |
pg = VMMON_MAP_OFFSET(pg); |
180 |
if (pg >= vmLinux->size4Gb) { |
181 |
+#ifdef VMW_NOPAGE_2624 |
182 |
+ return VM_FAULT_SIGBUS; |
183 |
+#else |
184 |
return 0; |
185 |
+#endif |
186 |
} |
187 |
page = vmLinux->pages4Gb[pg]; |
188 |
get_page(page); |
189 |
-#ifdef KERNEL_2_4_0 |
190 |
+#ifdef VMW_NOPAGE_2624 |
191 |
+ fault->page = page; |
192 |
+ return 0; |
193 |
+#elif defined(KERNEL_2_4_0) |
194 |
#ifdef VMW_NOPAGE_261 |
195 |
*type = VM_FAULT_MINOR; |
196 |
#endif |
197 |
diff --git a/linux/driver.h b/linux/driver.h |
198 |
index 89c1620..dec6877 100644 |
199 |
--- a/linux/driver.h |
200 |
+++ b/linux/driver.h |
201 |
@@ -131,7 +131,7 @@ typedef struct VMXLinuxState { |
202 |
spinlock_t pollListLock; |
203 |
#endif |
204 |
|
205 |
- volatile int fastClockThread; |
206 |
+ volatile struct task_struct *fastClockThread; |
207 |
unsigned fastClockRate; |
208 |
|
209 |
/* |
210 |
diff --git a/linux/driver_compat.h b/linux/driver_compat.h |
211 |
index 2b1f520..13afc74 100644 |
212 |
--- a/linux/driver_compat.h |
213 |
+++ b/linux/driver_compat.h |
214 |
@@ -268,7 +268,10 @@ LinuxDriverDestructorLocked(VMLinux *vmLinux) // IN |
215 |
*----------------------------------------------------------------------------- |
216 |
*/ |
217 |
|
218 |
-#ifdef VMW_NOPAGE_261 |
219 |
+#if defined(VMW_NOPAGE_2624) |
220 |
+static int LinuxDriverLockedFault(struct vm_area_struct *vma, //IN |
221 |
+ struct vm_fault *fault) //IN/OUT |
222 |
+#elif defined(VMW_NOPAGE_261) |
223 |
static struct page *LinuxDriverLockedNoPage(struct vm_area_struct *vma, //IN |
224 |
unsigned long address, //IN |
225 |
int *type) //OUT: Fault type |
226 |
@@ -288,33 +291,60 @@ static unsigned long LinuxDriverLockedNoPage(struct vm_area_struct *vma, //IN |
227 |
struct VMHostEntry* vmhe; |
228 |
struct page* result; |
229 |
|
230 |
+#ifdef VMW_NOPAGE_2624 |
231 |
+ pg = fault->pgoff; |
232 |
+#else |
233 |
pg = ((address - vma->vm_start) >> PAGE_SHIFT) + compat_vm_pgoff(vma); |
234 |
+#endif |
235 |
if (pg >= vmLinux->sizeLocked) { |
236 |
printk(KERN_DEBUG "vmmon: Something went wrong: entry %08lX out of range (>=%08X) for mapping on filp %p\n", pg, vmLinux->sizeLocked, vmLinux); |
237 |
+#ifdef VMW_NOPAGE_2624 |
238 |
+ return VM_FAULT_SIGBUS; |
239 |
+#else |
240 |
return NOPAGE_SIGBUS; |
241 |
+#endif |
242 |
} |
243 |
if (!vmLinux->vm || !vmLinux->vm->vmhost) { |
244 |
printk(KERN_DEBUG "vmmon: Something went wrong: no vm or vmhost for mapping on filp %p\n", vmLinux); |
245 |
+#ifdef VMW_NOPAGE_2624 |
246 |
+ return VM_FAULT_SIGBUS; |
247 |
+#else |
248 |
return NOPAGE_SIGBUS; |
249 |
+#endif |
250 |
} |
251 |
pgt = vmLinux->pagesLocked->ent[pg / VMHOST_MAPPING_PT]; |
252 |
if (!pgt) { |
253 |
printk(KERN_DEBUG "vmmon: Something went wrong: missing entry %08lX from mapping on filp %p\n", pg, vmLinux); |
254 |
+#ifdef VMW_NOPAGE_2624 |
255 |
+ return VM_FAULT_SIGBUS; |
256 |
+#else |
257 |
return NOPAGE_SIGBUS; |
258 |
+#endif |
259 |
} |
260 |
vmhe = kmap(pgt); |
261 |
result = vmhe->ent[pg % VMHOST_MAPPING_PT]; |
262 |
kunmap(pgt); |
263 |
if (!result) { |
264 |
printk(KERN_DEBUG "vmmon: Something went wrong: attempt to access non-existing entry %08lX in mapping on filp %p\n", pg, vmLinux); |
265 |
+#ifdef VMW_NOPAGE_2624 |
266 |
+ return VM_FAULT_SIGBUS; |
267 |
+#else |
268 |
return NOPAGE_SIGBUS; |
269 |
+#endif |
270 |
} |
271 |
if (!PhysTrack_Test(vmLinux->vm->vmhost->AWEPages, page_to_pfn(result))) { |
272 |
printk(KERN_DEBUG "vmmon: MPN %08lX not tracked! Someone released it before removing it from VA first!\n", pg); |
273 |
+#ifdef VMW_NOPAGE_2624 |
274 |
+ return VM_FAULT_SIGBUS; |
275 |
+#else |
276 |
return NOPAGE_SIGBUS; |
277 |
+#endif |
278 |
} |
279 |
get_page(result); |
280 |
-#ifdef KERNEL_2_4_0 |
281 |
+#if defined(VMW_NOPAGE_2624) |
282 |
+ fault->page = result; |
283 |
+ return 0; |
284 |
+#elif defined(KERNEL_2_4_0) |
285 |
#ifdef VMW_NOPAGE_261 |
286 |
*type = VM_FAULT_MINOR; |
287 |
#endif |
288 |
diff --git a/linux/hostif.c b/linux/hostif.c |
289 |
index 2ec1ab1..bd6ef1e 100644 |
290 |
--- a/linux/hostif.c |
291 |
+++ b/linux/hostif.c |
292 |
@@ -70,6 +70,10 @@ |
293 |
#include "compat_timer.h" |
294 |
#include "x86.h" |
295 |
|
296 |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) |
297 |
+#include <linux/kthread.h> |
298 |
+#include <linux/mutex.h> |
299 |
+#endif |
300 |
static COMPAT_DECLARE_COMPLETION(fastClockExited); |
301 |
|
302 |
/* |
303 |
@@ -136,6 +140,95 @@ static COMPAT_DECLARE_COMPLETION(fastClockExited); |
304 |
#define HOST_ISTRACKED_PFN(_vm, _pfn) (PhysTrack_Test(_vm->physTracker, _pfn)) |
305 |
|
306 |
|
307 |
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)) |
308 |
+/* |
309 |
+ *----------------------------------------------------------------------------- |
310 |
+ * |
311 |
+ * MutexInit -- |
312 |
+ * |
313 |
+ * Initialize a Mutex. --hpreg |
314 |
+ * |
315 |
+ * Results: |
316 |
+ * None |
317 |
+ * |
318 |
+ * Side effects: |
319 |
+ * None |
320 |
+ * |
321 |
+ *----------------------------------------------------------------------------- |
322 |
+ */ |
323 |
+ |
324 |
+#define MutexInit(_mutex, _name) mutex_init(_mutex) |
325 |
+/* |
326 |
+ *----------------------------------------------------------------------------- |
327 |
+ * |
328 |
+ * MutexIsLocked -- |
329 |
+ * |
330 |
+ * Determine if a Mutex is locked by the current thread. --hpreg |
331 |
+ * |
332 |
+ * Results: |
333 |
+ * TRUE if yes |
334 |
+ * FALSE if no |
335 |
+ * |
336 |
+ * Side effects: |
337 |
+ * None |
338 |
+ * |
339 |
+ *----------------------------------------------------------------------------- |
340 |
+ */ |
341 |
+ |
342 |
+#define MutexIsLocked(_mutex) mutex_is_locked(_mutex) |
343 |
+ |
344 |
+/* |
345 |
+ *----------------------------------------------------------------------------- |
346 |
+ * |
347 |
+ * MutexLock -- |
348 |
+ * |
349 |
+ * Acquire a Mutex. --hpreg |
350 |
+ * |
351 |
+ * Results: |
352 |
+ * None |
353 |
+ * |
354 |
+ * Side effects: |
355 |
+ * None |
356 |
+ * |
357 |
+ *----------------------------------------------------------------------------- |
358 |
+ */ |
359 |
+ |
360 |
+#define MutexLock(_mutex, _callerID) mutex_lock(_mutex) |
361 |
+ |
362 |
+/* |
363 |
+ *----------------------------------------------------------------------------- |
364 |
+ * |
365 |
+ * MutexUnlock -- |
366 |
+ * |
367 |
+ * Release a Mutex. --hpreg |
368 |
+ * |
369 |
+ * Results: |
370 |
+ * None |
371 |
+ * |
372 |
+ * Side effects: |
373 |
+ * None |
374 |
+ * |
375 |
+ *----------------------------------------------------------------------------- |
376 |
+ */ |
377 |
+ |
378 |
+#define MutexUnlock(_mutex, _callerID) mutex_unlock(_mutex) |
379 |
+ |
380 |
+/* This mutex protects the driver-wide state. --hpreg */ |
381 |
+static DEFINE_MUTEX(globalMutex); |
382 |
+ |
383 |
+/* |
384 |
+ * This mutex protects the fast clock rate and is held while |
385 |
+ * creating/destroying the fastClockThread. It ranks below |
386 |
+ * globalMutex. We can't use globalMutex for this purpose because the |
387 |
+ * fastClockThread itself acquires the globalMutex, so trying to hold |
388 |
+ * the mutex while destroying the thread can cause a deadlock. |
389 |
+ */ |
390 |
+static DEFINE_MUTEX(fastClockMutex); |
391 |
+ |
392 |
+/* This mutex protects linuxState.pollList. */ |
393 |
+static DEFINE_MUTEX(pollListMutex); |
394 |
+ |
395 |
+#else |
396 |
/* |
397 |
*----------------------------------------------------------------------------- |
398 |
* |
399 |
@@ -278,6 +371,7 @@ static Mutex fastClockMutex; |
400 |
/* This mutex protects linuxState.pollList. */ |
401 |
static Mutex pollListMutex; |
402 |
|
403 |
+#endif /* USE_KTHREAD */ |
404 |
|
405 |
/* |
406 |
*----------------------------------------------------------------------------- |
407 |
@@ -350,7 +444,7 @@ HostIF_GlobalUnlock(int callerID) // IN |
408 |
MutexUnlock(&globalMutex, callerID); |
409 |
} |
410 |
|
411 |
- |
412 |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) |
413 |
#ifdef VMX86_DEBUG |
414 |
/* |
415 |
*----------------------------------------------------------------------------- |
416 |
@@ -375,6 +469,7 @@ HostIF_GlobalLockIsHeld(void) |
417 |
return MutexIsLocked(&globalMutex); |
418 |
} |
419 |
#endif |
420 |
+#endif |
421 |
|
422 |
|
423 |
/* |
424 |
@@ -583,7 +678,7 @@ DoClearNXBit(VA vaddr) |
425 |
#else |
426 |
pte_val(*pte) &= ~_PAGE_NX; |
427 |
#endif |
428 |
- smp_call_function (TLBInvalidatePage, (void *)vaddr, 1, 1); |
429 |
+ compat_smp_call_function (TLBInvalidatePage, (void *)vaddr, 1, 1); |
430 |
TLBInvalidatePage((void *)vaddr); |
431 |
} |
432 |
if (ptemap) { |
433 |
@@ -3240,6 +3335,46 @@ HostIF_NumOnlineLogicalCPUs(void) |
434 |
/* |
435 |
*---------------------------------------------------------------------- |
436 |
* |
437 |
+ * HostIFDoIoctl -- |
438 |
+ * |
439 |
+ * Issue ioctl. Assume kernel is not locked. It is not true now, |
440 |
+ * but it makes things easier to understand, and won't surprise us |
441 |
+ * later when we get rid of kernel lock from our code. |
442 |
+ * |
443 |
+ * Results: |
444 |
+ * Same as ioctl method. |
445 |
+ * |
446 |
+ * Side effects: |
447 |
+ * none. |
448 |
+ * |
449 |
+ *---------------------------------------------------------------------- |
450 |
+ */ |
451 |
+ |
452 |
+static long |
453 |
+HostIFDoIoctl(struct file *filp, |
454 |
+ u_int iocmd, |
455 |
+ unsigned long ioarg) |
456 |
+{ |
457 |
+#ifdef HAVE_UNLOCKED_IOCTL |
458 |
+ if (filp->f_op->unlocked_ioctl) { |
459 |
+ return filp->f_op->unlocked_ioctl(filp, iocmd, ioarg); |
460 |
+ } |
461 |
+#endif |
462 |
+ if (filp->f_op->ioctl) { |
463 |
+ long err; |
464 |
+ |
465 |
+ lock_kernel(); |
466 |
+ err = filp->f_op->ioctl(filp->f_dentry->d_inode, filp, iocmd, ioarg); |
467 |
+ unlock_kernel(); |
468 |
+ return err; |
469 |
+ } |
470 |
+ return -ENOIOCTLCMD; |
471 |
+} |
472 |
+ |
473 |
+ |
474 |
+/* |
475 |
+ *---------------------------------------------------------------------- |
476 |
+ * |
477 |
* HostIFFastClockThread -- |
478 |
* |
479 |
* Kernel thread that provides finer-grained wakeups than the |
480 |
@@ -3265,7 +3400,9 @@ HostIFFastClockThread(void *data) |
481 |
mm_segment_t oldFS; |
482 |
unsigned rate = 0; |
483 |
|
484 |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) |
485 |
compat_daemonize("vmware-rtc"); |
486 |
+#endif |
487 |
oldFS = get_fs(); |
488 |
set_fs(KERNEL_DS); |
489 |
compat_allow_signal(SIGKILL); |
490 |
@@ -3286,8 +3423,7 @@ HostIFFastClockThread(void *data) |
491 |
p2rate <<= 1; |
492 |
} |
493 |
|
494 |
- res = filp->f_op->ioctl(filp->f_dentry->d_inode, |
495 |
- filp, RTC_IRQP_SET, p2rate); |
496 |
+ res = HostIFDoIoctl(filp, RTC_IRQP_SET, p2rate); |
497 |
if (res < 0) { |
498 |
Warning("/dev/rtc set rate %d failed: %d\n", p2rate, res); |
499 |
goto out; |
500 |
@@ -3392,19 +3528,19 @@ HostIF_SetFastClockRate(unsigned int rate) // IN: Frequency in Hz. |
501 |
struct file *filp; |
502 |
int fsuid, res; |
503 |
Bool cap; |
504 |
- long pid; |
505 |
+ struct task_struct *t; |
506 |
|
507 |
fsuid = current->fsuid; |
508 |
current->fsuid = 0; |
509 |
filp = filp_open("/dev/rtc", O_RDONLY, 0); |
510 |
current->fsuid = fsuid; |
511 |
- if (IS_ERR(filp)) { |
512 |
+ if (IS_ERR(filp) || !filp) { |
513 |
Warning("/dev/rtc open failed: %d\n", (int)(VA)filp); |
514 |
return -(int)(VA)filp; |
515 |
} |
516 |
cap = cap_raised(current->cap_effective, CAP_SYS_RESOURCE); |
517 |
cap_raise(current->cap_effective, CAP_SYS_RESOURCE); |
518 |
- res = filp->f_op->ioctl(filp->f_dentry->d_inode, filp, RTC_PIE_ON, 0); |
519 |
+ res = HostIFDoIoctl(filp, RTC_PIE_ON, 0); |
520 |
if (!cap) { |
521 |
cap_lower(current->cap_effective, CAP_SYS_RESOURCE); |
522 |
} |
523 |
@@ -3413,26 +3549,27 @@ HostIF_SetFastClockRate(unsigned int rate) // IN: Frequency in Hz. |
524 |
compat_filp_close(filp, current->files); |
525 |
return -res; |
526 |
} |
527 |
- pid = kernel_thread(HostIFFastClockThread, filp, 0); |
528 |
- if (pid < 0) { |
529 |
+ t = kthread_create(HostIFFastClockThread, filp, "vmware-rtc"); |
530 |
+ if (IS_ERR(t)) { |
531 |
/* |
532 |
* Ignore ERESTARTNOINTR silently, it occurs when signal is |
533 |
* pending, and syscall layer automatically reissues operation |
534 |
* after signal is handled. |
535 |
*/ |
536 |
- if (pid != -ERESTARTNOINTR) { |
537 |
- Warning("/dev/rtc cannot start watch thread: %ld\n", pid); |
538 |
+ if (PTR_ERR(t) != -ERESTARTNOINTR) { |
539 |
+ Warning("/dev/rtc cannot start watch thread: %ld\n", PTR_ERR(t)); |
540 |
} |
541 |
compat_filp_close(filp, current->files); |
542 |
- return -pid; |
543 |
+ return -PTR_ERR(t); |
544 |
} |
545 |
- linuxState.fastClockThread = pid; |
546 |
+ linuxState.fastClockThread = t; |
547 |
+ wake_up_process(t); |
548 |
} |
549 |
} else { |
550 |
if (linuxState.fastClockThread) { |
551 |
- kill_proc(linuxState.fastClockThread, SIGKILL, 1); |
552 |
- linuxState.fastClockThread = 0; |
553 |
+ send_sig(SIGKILL, linuxState.fastClockThread, 1); |
554 |
compat_wait_for_completion(&fastClockExited); |
555 |
+ linuxState.fastClockThread = NULL; |
556 |
} |
557 |
} |
558 |
return 0; |
559 |
diff --git a/linux/vmhost.h b/linux/vmhost.h |
560 |
index 7bb43f1..d5f2f64 100644 |
561 |
--- a/linux/vmhost.h |
562 |
+++ b/linux/vmhost.h |
563 |
@@ -13,7 +13,7 @@ |
564 |
#include "compat_semaphore.h" |
565 |
#include "compat_wait.h" |
566 |
|
567 |
- |
568 |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) |
569 |
#ifdef VMX86_DEBUG |
570 |
/* |
571 |
* A MutexHolder object. In debug builds, we record information about the |
572 |
@@ -54,7 +54,7 @@ typedef struct Mutex { |
573 |
MutexHolder cur; |
574 |
#endif |
575 |
} Mutex; |
576 |
- |
577 |
+#endif |
578 |
|
579 |
/* |
580 |
* Per-vm host-specific state. |
581 |
@@ -65,7 +65,11 @@ typedef struct VMHost { |
582 |
* Used for shared modifications to VM's VMDriver data, mostly page locking. |
583 |
* It has higher rank than the global mutex. |
584 |
*/ |
585 |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) |
586 |
+ struct mutex vmMutex; |
587 |
+#else |
588 |
Mutex vmMutex; |
589 |
+#endif |
590 |
|
591 |
atomic_t pendingUserCalls; |
592 |
wait_queue_head_t callQueue; |
593 |
diff --git a/linux/vmmonInt.h b/linux/vmmonInt.h |
594 |
index 12a121d..08b7f59 100644 |
595 |
--- a/linux/vmmonInt.h |
596 |
+++ b/linux/vmmonInt.h |
597 |
@@ -32,7 +32,11 @@ |
598 |
#endif |
599 |
|
600 |
#if defined(CONFIG_SMP) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 2, 8) |
601 |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) |
602 |
+#define compat_smp_call_function(_a0,_a1,_a2,_a3) smp_call_function(_a0,_a1,_a3) |
603 |
+#else |
604 |
#define compat_smp_call_function smp_call_function |
605 |
+#endif |
606 |
#else |
607 |
#define compat_smp_call_function(_a0,_a1,_a2,_a3) 0 |
608 |
#endif |