Gentoo Archives: gentoo-commits

From: "Vadim Kuznetsov (vadimk)" <vadimk@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-emulation/vmware-modules/files/patches/vmmon: 050_all_kernel-2.6.29.patch
Date: Fri, 28 Aug 2009 09:18:50
Message-Id: E1Mh2Qn-0005hu-4D@stork.gentoo.org
1 vadimk 09/08/28 14:27:57
2
3 Added: 050_all_kernel-2.6.29.patch
4 Log:
5 1.0.0.15 patches suggested in bug 273173
6 (Portage version: 2.2_rc33/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 app-emulation/vmware-modules/files/patches/vmmon/050_all_kernel-2.6.29.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-emulation/vmware-modules/files/patches/vmmon/050_all_kernel-2.6.29.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-emulation/vmware-modules/files/patches/vmmon/050_all_kernel-2.6.29.patch?rev=1.1&content-type=text/plain
13
14 Index: 050_all_kernel-2.6.29.patch
15 ===================================================================
16 diff -ruN vmmon-only-patched/autoconf/smpcall.c vmmon-only-rerefixed/autoconf/smpcall.c
17 --- vmmon-only-patched/autoconf/smpcall.c 1970-01-01 02:00:00.000000000 +0200
18 +++ vmmon-only-rerefixed/autoconf/smpcall.c 2008-10-20 15:52:46.000000000 +0300
19 @@ -0,0 +1,23 @@
20 +/* **********************************************************
21 + * Copyright (C) 2008 VMware, Inc. All Rights Reserved. -- VMware Confidential
22 + * **********************************************************/
23 +
24 +/*
25 + * Detect whether smp_call_function has 4 or 3 arguments.
26 + * Change happened between 2.6.26 and 2.6.27-rc1.
27 + */
28 +
29 +#include <linux/autoconf.h>
30 +#include <linux/version.h>
31 +
32 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
33 +# error This compile test intentionally fails.
34 +#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
35 +# include <linux/smp.h>
36 +
37 +int
38 +vmware_smp_call_function(void (*func)(void *info), void *info, int wait)
39 +{
40 + return smp_call_function(func, info, wait);
41 +}
42 +#endif
43 diff -ruN vmmon-only-patched/common/cpuid.c vmmon-only-rerefixed/common/cpuid.c
44 --- vmmon-only-patched/common/cpuid.c 2009-07-08 16:21:02.000000000 +0300
45 +++ vmmon-only-rerefixed/common/cpuid.c 2008-10-20 16:23:37.000000000 +0300
46 @@ -8,7 +8,6 @@
47
48 # include <linux/string.h>
49 #endif
50 -
51 #include "vmware.h"
52 #include "vm_assert.h"
53 #include "x86.h"
54 diff -ruN vmmon-only-patched/common/task.c vmmon-only-rerefixed/common/task.c
55 --- vmmon-only-patched/common/task.c 2009-07-08 16:21:02.000000000 +0300
56 +++ vmmon-only-rerefixed/common/task.c 2008-10-20 16:09:29.000000000 +0300
57 @@ -25,16 +25,13 @@
58 * we do not need asm/page.h anymore in this file - not surprising, this
59 * is common file, yes? And Windows do not have page.h, do they?
60 */
61 -#include <linux/version.h>
62 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
63 -#define _I386_PAGE_H
64 -#else
65 -#define _ASM_X86_PAGE_H
66 -#endif
67 +#define _ASM_X86_PAGE_H
68 /* On Linux, must come before any inclusion of asm/page.h --hpreg */
69 -#include "hostKernel.h"
70 #ifdef linux
71 +#include "hostKernel.h"
72 +#include "driver-config.h"
73 # include <linux/string.h>
74 +//# include <linux/kernel.h>
75
76 # ifdef USE_PERFCTRS_HOSTED
77 # include "perfctr.h"
78 diff -ruN vmmon-only-patched/common/task_compat.h vmmon-only-rerefixed/common/task_compat.h
79 --- vmmon-only-patched/common/task_compat.h 2009-07-08 16:21:02.000000000 +0300
80 +++ vmmon-only-rerefixed/common/task_compat.h 2008-10-20 16:15:25.000000000 +0300
81 @@ -1,7 +1,8 @@
82 +#include <linux/init.h>
83 #include "modulecall_compat.h"
84 #include "x86msr.h"
85
86 -typedef struct SysenterStateV45 {
87 +struct SysenterStateV45 {
88 uint64 rsp;
89 uint64 rip;
90 Selector cs;
91 @@ -3646,5 +3647,6 @@
92 return TRUE;
93 }
94
95 +// printk("/dev/vmmon: Cannot load module. Use standard gcc compiler\n");
96 return FALSE;
97 }
98 diff -ruN vmmon-only-patched/include/compat_semaphore.h vmmon-only-rerefixed/include/compat_semaphore.h
99 --- vmmon-only-patched/include/compat_semaphore.h 2009-07-08 16:21:02.000000000 +0300
100 +++ vmmon-only-rerefixed/include/compat_semaphore.h 2008-10-20 14:15:58.000000000 +0300
101 @@ -2,11 +2,7 @@
102 # define __COMPAT_SEMAPHORE_H__
103
104
105 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
106 #include <linux/semaphore.h>
107 -#else
108 -#include <asm/semaphore.h>
109 -#endif
110
111
112 /*
113 diff -ruN vmmon-only-patched/include/compat_wait.h vmmon-only-rerefixed/include/compat_wait.h
114 --- vmmon-only-patched/include/compat_wait.h 2009-07-08 16:21:02.000000000 +0300
115 +++ vmmon-only-rerefixed/include/compat_wait.h 2009-04-03 19:58:51.000000000 +0300
116 @@ -34,13 +34,13 @@
117 * 2.4.20-wolk4.0s.
118 */
119
120 -#ifdef VMW_HAVE_EPOLL // {
121 +#if VMW_HAVE_EPOLL // {
122 #define compat_poll_wqueues struct poll_wqueues
123 #else // } {
124 #define compat_poll_wqueues poll_table
125 #endif // }
126
127 -#ifdef VMW_HAVE_EPOLL // {
128 +#if VMW_HAVE_EPOLL // {
129
130 /* If prototype does not match, build will abort here */
131 extern void poll_initwait(compat_poll_wqueues *);
132 @@ -57,7 +57,8 @@
133 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0) // {
134
135 /* If prototype does not match, build will abort here */
136 -extern void poll_initwait(compat_poll_wqueues *);
137 +//extern void poll_initwait(compat_poll_wqueues *);
138 +extern void poll_initwait(struct poll_wqueues *pwq);
139
140 #define compat_poll_initwait(wait, table) ( \
141 (wait) = (table), \
142 diff -ruN vmmon-only-patched/include/vcpuset.h vmmon-only-rerefixed/include/vcpuset.h
143 --- vmmon-only-patched/include/vcpuset.h 2009-07-08 16:21:02.000000000 +0300
144 +++ vmmon-only-rerefixed/include/vcpuset.h 2009-04-21 13:46:14.000000000 +0300
145 @@ -71,9 +71,7 @@
146 #define ffs(x) ffs_x86_64(x)
147
148 #elif defined MODULE
149 -#ifndef __cplusplus
150 - #include "linux/bitops.h"
151 -#else
152 + //#include <linux/bitops.h>
153 static inline int ffs_x86_hack(int x)
154 {
155 int r;
156 @@ -91,7 +89,7 @@
157 }
158
159 #define ffs(x) ffs_x86_hack(x)
160 -#endif
161 +
162 #elif defined __APPLE__ && defined KERNEL
163 /*
164 * XXXMACOS An ugly hack to resolve redefinition of PAGE_ defines
165 diff -ruN vmmon-only-patched/include/x86apic.h vmmon-only-rerefixed/include/x86apic.h
166 --- vmmon-only-patched/include/x86apic.h 2009-07-08 16:21:02.000000000 +0300
167 +++ vmmon-only-rerefixed/include/x86apic.h 2009-04-20 19:50:19.000000000 +0300
168 @@ -77,7 +77,7 @@
169 #define APIC_LVT_DELVMODE(_lvt) (_lvt & 0x700)
170 #define APIC_LVT_RESET_VALUE 0x00010000
171
172 -#define APIC_BASE_MSR 0x1b
173 +//#define APIC_BASE_MSR 0x1b
174
175 #define APIC_MSR_BASEMASK QWORD(0x0000000f,0xfffff000)
176 #define APIC_MSR_ENABLED 0x00000800
177 diff -ruN vmmon-only-patched/include/x86paging.h vmmon-only-rerefixed/include/x86paging.h
178 --- vmmon-only-patched/include/x86paging.h 2009-07-08 16:21:02.000000000 +0300
179 +++ vmmon-only-rerefixed/include/x86paging.h 2008-10-20 14:15:49.000000000 +0300
180 @@ -58,9 +58,7 @@
181
182 #define PTE_AVAIL_MASK 0xe00
183 #define PTE_AVAIL_SHIFT 9
184 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
185 -#define PTE_PFN_MASK 0xfffff000
186 -#endif
187 +//#define PTE_PFN_MASK 0xfffff000
188 #define PAE_PTE_PFN_MASK CONST64U(0xffffff000)
189 #define LM_PTE_PFN_MASK CONST64U(0xffffffffff000)
190 #define PTE_PFN_SHIFT 12
191 diff -ruN vmmon-only-patched/linux/driver.c vmmon-only-rerefixed/linux/driver.c
192 --- vmmon-only-patched/linux/driver.c 2009-07-08 16:21:02.000000000 +0300
193 +++ vmmon-only-rerefixed/linux/driver.c 2009-05-19 16:02:02.000000000 +0300
194 @@ -113,15 +113,6 @@
195 #define VMWare_SetVTracer(VTrace_Set)
196 #endif
197
198 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
199 -#define VMW_NOPAGE_2624
200 -
201 -#define VMMON_MAP_OFFSET_SHIFT 0
202 -#define VMMON_MAP_OFFSET_MASK 0x00000FFF
203 -#define VMMON_MAP_OFFSET(base) \
204 - (((base) >> VMMON_MAP_OFFSET_SHIFT) & VMMON_MAP_OFFSET_MASK)
205 -#endif
206 -
207 struct VMXLinuxState linuxState;
208
209 static int vmversion = VME_DEFAULT;
210 @@ -157,10 +148,8 @@
211
212 static int LinuxDriver_Close(struct inode *inode, struct file *filp);
213 static unsigned int LinuxDriverPoll(struct file *file, poll_table *wait);
214 -#if defined(VMW_NOPAGE_2624)
215 -static int LinuxDriverFault(struct vm_area_struct *vma, struct vm_fault *fault);
216 -static int LinuxDriverLockedFault(struct vm_area_struct *vma, struct vm_fault *fault);
217 -#elif defined(VMW_NOPAGE_261)
218 +#if 0
219 +#if defined(VMW_NOPAGE_261)
220 static struct page *LinuxDriverNoPage(struct vm_area_struct *vma,
221 unsigned long address, int *type);
222 static struct page *LinuxDriverLockedNoPage(struct vm_area_struct *vma,
223 @@ -171,29 +160,36 @@
224 static struct page *LinuxDriverLockedNoPage(struct vm_area_struct *vma,
225 unsigned long address, int unused);
226 #else
227 -static unsigned long LinuxDriverNoPage(struct vm_area_struct *vma,
228 - unsigned long address, int write_access);
229 -static unsigned long LinuxDriverLockedNoPage(struct vm_area_struct *vma,
230 - unsigned long address, int unused);
231 #endif
232 -static int LinuxDriverMmap(struct file *filp, struct vm_area_struct *vma);
233 +static int LinuxDriverNoPage(struct vm_area_struct *vma,
234 + struct vm_fault *fdata);
235 +static int LinuxDriverLockedNoPage(struct vm_area_struct *vma,
236 + struct vm_fault *fdata);
237 +
238
239 -static void LinuxDriverPollTimeout(unsigned long clientData);
240
241 static struct vm_operations_struct vmuser_mops = {
242 -#ifdef VMW_NOPAGE_2624
243 - .fault = LinuxDriverFault
244 -#else
245 - .nopage = LinuxDriverNoPage
246 -#endif
247 + .fault = LinuxDriverNoPage
248 };
249
250 struct vm_operations_struct vmuser_locked_mops = {
251 -#ifdef VMW_NOPAGE_2624
252 - .fault = LinuxDriverLockedFault
253 -#else
254 - .nopage = LinuxDriverLockedNoPage
255 + .fault = LinuxDriverLockedNoPage
256 +};
257 #endif
258 +static void LinuxDriverPollTimeout(unsigned long clientData);
259 +static int LinuxDriverMmap(struct file *filp, struct vm_area_struct *vma);
260 +
261 +static int LinuxDriverNoPage(struct vm_area_struct *vma,
262 + struct vm_fault *fdata);
263 +static int LinuxDriverLockedNoPage(struct vm_area_struct *vma,
264 + struct vm_fault *fdata);
265 +
266 +static struct vm_operations_struct vmuser_mops = {
267 + .fault = LinuxDriverNoPage
268 +};
269 +
270 +struct vm_operations_struct vmuser_locked_mops = {
271 + .fault = LinuxDriverLockedNoPage
272 };
273
274 static struct file_operations vmuser_fops;
275 @@ -576,7 +572,7 @@
276 memset(vmLinux, 0, sizeof *vmLinux);
277 vmLinux->version = LinuxDriverEmulatedVersion();
278 /* If caller's euid was not 0, we are running devel build */
279 - vmLinux->maySetUid = current->euid != 0;
280 + vmLinux->maySetUid = current->cred->euid != 0;
281 vmLinux->ctType = VMCIOBJ_NOT_SET;
282
283 sema_init(&vmLinux->lock4Gb, 1);
284 @@ -1164,53 +1160,22 @@
285 *-----------------------------------------------------------------------------
286 */
287
288 -#if defined(VMW_NOPAGE_2624)
289 -static int LinuxDriverFault(struct vm_area_struct *vma, //IN
290 - struct vm_fault *fault) //IN/OUT
291 -#elif defined(VMW_NOPAGE_261)
292 -static struct page *LinuxDriverNoPage(struct vm_area_struct *vma, //IN
293 - unsigned long address, //IN
294 - int *type) //OUT: Fault type
295 -#elif defined(KERNEL_2_4_0)
296 -static struct page *LinuxDriverNoPage(struct vm_area_struct *vma, //IN
297 - unsigned long address, //IN
298 - int unused) //nothing
299 -#else
300 -static unsigned long LinuxDriverNoPage(struct vm_area_struct *vma,//IN
301 - unsigned long address, //IN
302 - int write_access) //IN
303 -#endif
304 +static int LinuxDriverNoPage(struct vm_area_struct *vma,//IN
305 + struct vm_fault *fdata)
306 {
307 VMLinux *vmLinux = (VMLinux *) vma->vm_file->private_data;
308 unsigned long pg;
309 struct page* page;
310
311 -#ifdef VMW_NOPAGE_2624
312 - pg = fault->pgoff;
313 -#else
314 - pg = ((address - vma->vm_start) >> PAGE_SHIFT) + compat_vm_pgoff(vma);
315 -#endif
316 + pg = fdata->pgoff;
317 pg = VMMON_MAP_OFFSET(pg);
318 if (pg >= vmLinux->size4Gb) {
319 -#ifdef VMW_NOPAGE_2624
320 - return VM_FAULT_SIGBUS;
321 -#else
322 return 0;
323 -#endif
324 }
325 page = vmLinux->pages4Gb[pg];
326 get_page(page);
327 -#ifdef VMW_NOPAGE_2624
328 - fault->page = page;
329 - return 0;
330 -#elif defined(KERNEL_2_4_0)
331 -#ifdef VMW_NOPAGE_261
332 - *type = VM_FAULT_MINOR;
333 -#endif
334 - return page;
335 -#else
336 - return page_address(page);
337 -#endif
338 + fdata->page = page;
339 + return VM_FAULT_MINOR;
340 }
341
342
343 @@ -1393,6 +1358,7 @@
344 VMLinux *vmLinux = (VMLinux *) filp->private_data;
345 int retval = 0;
346 Vcpuid vcpuid;
347 + struct cred *new;
348
349 switch (iocmd) {
350 case IOCTL_VMX86_VERSION:
351 @@ -1527,8 +1493,14 @@
352 devel_suid();
353 #else
354 if (vmLinux->maySetUid) {
355 - current->suid = 0;
356 - cap_set_full(current->cap_permitted);
357 + new = prepare_creds();
358 + if (!new) {
359 + retval = -ENOMEM;
360 + break;
361 + }
362 + new->suid = 0;
363 + cap_set_full(new->cap_permitted);
364 + commit_creds(new);
365 retval = 0;
366 } else {
367 retval = -EPERM;
368 @@ -1793,10 +1765,10 @@
369 }
370
371 case IOCTL_VMX86_ALLOW_CORE_DUMP:
372 - if (current->euid == current->uid &&
373 - current->fsuid == current->uid &&
374 - current->egid == current->gid &&
375 - current->fsgid == current->gid) {
376 + if (new->euid == current_uid() &&
377 + new->fsuid == current_uid() &&
378 + new->egid == new->gid &&
379 + new->fsgid == new->gid) {
380 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23) || defined(MMF_DUMPABLE)
381 /* Dump core, readable by user. */
382 set_bit(MMF_DUMPABLE, &current->mm->flags);
383 @@ -1813,7 +1785,7 @@
384 break;
385
386 case IOCTL_VMX86_BROADCAST_IPI:
387 - retval = compat_smp_call_function(LinuxDriverIPIHandler, NULL, 1, 1);
388 + retval = compat_smp_call_function(LinuxDriverIPIHandler, NULL, 1);
389 break;
390
391 #ifdef USE_PERFCTRS_HOSTED
392 diff -ruN vmmon-only-patched/linux/driver_compat.h vmmon-only-rerefixed/linux/driver_compat.h
393 --- vmmon-only-patched/linux/driver_compat.h 2009-07-08 16:21:02.000000000 +0300
394 +++ vmmon-only-rerefixed/linux/driver_compat.h 2008-07-24 18:55:05.000000000 +0300
395 @@ -268,22 +268,8 @@
396 *-----------------------------------------------------------------------------
397 */
398
399 -#if defined(VMW_NOPAGE_2624)
400 -static int LinuxDriverLockedFault(struct vm_area_struct *vma, //IN
401 - struct vm_fault *fault) //IN/OUT
402 -#elif defined(VMW_NOPAGE_261)
403 -static struct page *LinuxDriverLockedNoPage(struct vm_area_struct *vma, //IN
404 - unsigned long address, //IN
405 - int *type) //OUT: Fault type
406 -#elif defined(KERNEL_2_4_0)
407 -static struct page *LinuxDriverLockedNoPage(struct vm_area_struct *vma, //IN
408 - unsigned long address, //IN
409 - int unused) //nothing
410 -#else
411 -static unsigned long LinuxDriverLockedNoPage(struct vm_area_struct *vma, //IN
412 - unsigned long address, //IN
413 - int unused) //nothing
414 -#endif
415 +static int LinuxDriverLockedNoPage(struct vm_area_struct *vma, //IN
416 + struct vm_fault *fdata)
417 {
418 VMLinux *vmLinux = (VMLinux *) vma->vm_file->private_data;
419 unsigned long pg;
420 @@ -291,67 +277,34 @@
421 struct VMHostEntry* vmhe;
422 struct page* result;
423
424 -#ifdef VMW_NOPAGE_2624
425 - pg = fault->pgoff;
426 -#else
427 - pg = ((address - vma->vm_start) >> PAGE_SHIFT) + compat_vm_pgoff(vma);
428 -#endif
429 + pg = fdata->pgoff;
430 if (pg >= vmLinux->sizeLocked) {
431 printk(KERN_DEBUG "vmmon: Something went wrong: entry %08lX out of range (>=%08X) for mapping on filp %p\n", pg, vmLinux->sizeLocked, vmLinux);
432 -#ifdef VMW_NOPAGE_2624
433 - return VM_FAULT_SIGBUS;
434 -#else
435 return NOPAGE_SIGBUS;
436 -#endif
437 }
438 if (!vmLinux->vm || !vmLinux->vm->vmhost) {
439 printk(KERN_DEBUG "vmmon: Something went wrong: no vm or vmhost for mapping on filp %p\n", vmLinux);
440 -#ifdef VMW_NOPAGE_2624
441 - return VM_FAULT_SIGBUS;
442 -#else
443 return NOPAGE_SIGBUS;
444 -#endif
445 }
446 pgt = vmLinux->pagesLocked->ent[pg / VMHOST_MAPPING_PT];
447 if (!pgt) {
448 printk(KERN_DEBUG "vmmon: Something went wrong: missing entry %08lX from mapping on filp %p\n", pg, vmLinux);
449 -#ifdef VMW_NOPAGE_2624
450 - return VM_FAULT_SIGBUS;
451 -#else
452 return NOPAGE_SIGBUS;
453 -#endif
454 }
455 vmhe = kmap(pgt);
456 result = vmhe->ent[pg % VMHOST_MAPPING_PT];
457 kunmap(pgt);
458 if (!result) {
459 printk(KERN_DEBUG "vmmon: Something went wrong: attempt to access non-existing entry %08lX in mapping on filp %p\n", pg, vmLinux);
460 -#ifdef VMW_NOPAGE_2624
461 - return VM_FAULT_SIGBUS;
462 -#else
463 return NOPAGE_SIGBUS;
464 -#endif
465 }
466 if (!PhysTrack_Test(vmLinux->vm->vmhost->AWEPages, page_to_pfn(result))) {
467 printk(KERN_DEBUG "vmmon: MPN %08lX not tracked! Someone released it before removing it from VA first!\n", pg);
468 -#ifdef VMW_NOPAGE_2624
469 - return VM_FAULT_SIGBUS;
470 -#else
471 return NOPAGE_SIGBUS;
472 -#endif
473 }
474 get_page(result);
475 -#if defined(VMW_NOPAGE_2624)
476 - fault->page = result;
477 - return 0;
478 -#elif defined(KERNEL_2_4_0)
479 -#ifdef VMW_NOPAGE_261
480 - *type = VM_FAULT_MINOR;
481 -#endif
482 - return result;
483 -#else
484 - return page_address(result);
485 -#endif
486 + fdata->page = result;
487 + return VM_FAULT_MINOR;
488 }
489
490
491 diff -ruN vmmon-only-patched/linux/driver.h vmmon-only-rerefixed/linux/driver.h
492 --- vmmon-only-patched/linux/driver.h 2009-07-08 16:21:02.000000000 +0300
493 +++ vmmon-only-rerefixed/linux/driver.h 2008-10-20 14:21:26.000000000 +0300
494 @@ -90,7 +90,7 @@
495 struct VMLinux **pollBack;
496 } VMLinux;
497
498 -extern struct vm_operations_struct vmuser_locked_mops;
499 +//extern struct vm_operations_struct vmuser_locked_mops;
500 #define VMHOST_MAPPING_PD (PAGE_SIZE / sizeof(void*))
501 #define VMHOST_MAPPING_PT (PAGE_SIZE / sizeof(void*))
502 struct VMHostEntry {
503 @@ -131,6 +131,7 @@
504 spinlock_t pollListLock;
505 #endif
506
507 +// volatile int fastClockThread;
508 volatile struct task_struct *fastClockThread;
509 unsigned fastClockRate;
510
511 diff -ruN vmmon-only-patched/linux/hostif.c vmmon-only-rerefixed/linux/hostif.c
512 --- vmmon-only-patched/linux/hostif.c 2009-07-08 16:21:02.000000000 +0300
513 +++ vmmon-only-rerefixed/linux/hostif.c 2009-04-21 17:47:54.000000000 +0300
514 @@ -18,6 +18,7 @@
515 #include "compat_page.h"
516 #include <linux/binfmts.h>
517 #include <linux/fs.h>
518 +#include <linux/kthread.h>
519 #include "compat_sched.h"
520 #include <linux/file.h>
521 #ifdef KERNEL_2_2
522 @@ -70,10 +71,6 @@
523 #include "compat_timer.h"
524 #include "x86.h"
525
526 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
527 -#include <linux/kthread.h>
528 -#include <linux/mutex.h>
529 -#endif
530 static COMPAT_DECLARE_COMPLETION(fastClockExited);
531
532 /*
533 @@ -140,95 +137,6 @@
534 #define HOST_ISTRACKED_PFN(_vm, _pfn) (PhysTrack_Test(_vm->physTracker, _pfn))
535
536
537 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24))
538 -/*
539 - *-----------------------------------------------------------------------------
540 - *
541 - * MutexInit --
542 - *
543 - * Initialize a Mutex. --hpreg
544 - *
545 - * Results:
546 - * None
547 - *
548 - * Side effects:
549 - * None
550 - *
551 - *-----------------------------------------------------------------------------
552 - */
553 -
554 -#define MutexInit(_mutex, _name) mutex_init(_mutex)
555 -/*
556 - *-----------------------------------------------------------------------------
557 - *
558 - * MutexIsLocked --
559 - *
560 - * Determine if a Mutex is locked by the current thread. --hpreg
561 - *
562 - * Results:
563 - * TRUE if yes
564 - * FALSE if no
565 - *
566 - * Side effects:
567 - * None
568 - *
569 - *-----------------------------------------------------------------------------
570 - */
571 -
572 -#define MutexIsLocked(_mutex) mutex_is_locked(_mutex)
573 -
574 -/*
575 - *-----------------------------------------------------------------------------
576 - *
577 - * MutexLock --
578 - *
579 - * Acquire a Mutex. --hpreg
580 - *
581 - * Results:
582 - * None
583 - *
584 - * Side effects:
585 - * None
586 - *
587 - *-----------------------------------------------------------------------------
588 - */
589 -
590 -#define MutexLock(_mutex, _callerID) mutex_lock(_mutex)
591 -
592 -/*
593 - *-----------------------------------------------------------------------------
594 - *
595 - * MutexUnlock --
596 - *
597 - * Release a Mutex. --hpreg
598 - *
599 - * Results:
600 - * None
601 - *
602 - * Side effects:
603 - * None
604 - *
605 - *-----------------------------------------------------------------------------
606 - */
607 -
608 -#define MutexUnlock(_mutex, _callerID) mutex_unlock(_mutex)
609 -
610 -/* This mutex protects the driver-wide state. --hpreg */
611 -static DEFINE_MUTEX(globalMutex);
612 -
613 -/*
614 - * This mutex protects the fast clock rate and is held while
615 - * creating/destroying the fastClockThread. It ranks below
616 - * globalMutex. We can't use globalMutex for this purpose because the
617 - * fastClockThread itself acquires the globalMutex, so trying to hold
618 - * the mutex while destroying the thread can cause a deadlock.
619 - */
620 -static DEFINE_MUTEX(fastClockMutex);
621 -
622 -/* This mutex protects linuxState.pollList. */
623 -static DEFINE_MUTEX(pollListMutex);
624 -
625 -#else
626 /*
627 *-----------------------------------------------------------------------------
628 *
629 @@ -371,7 +279,6 @@
630 /* This mutex protects linuxState.pollList. */
631 static Mutex pollListMutex;
632
633 -#endif /* USE_KTHREAD */
634
635 /*
636 *-----------------------------------------------------------------------------
637 @@ -444,7 +351,7 @@
638 MutexUnlock(&globalMutex, callerID);
639 }
640
641 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
642 +
643 #ifdef VMX86_DEBUG
644 /*
645 *-----------------------------------------------------------------------------
646 @@ -469,7 +376,6 @@
647 return MutexIsLocked(&globalMutex);
648 }
649 #endif
650 -#endif
651
652
653 /*
654 @@ -564,7 +470,6 @@
655 MutexUnlock(&pollListMutex, callerID);
656 }
657
658 -
659 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 3)
660 static INLINE void
661 down_write_mmap(void)
662 @@ -620,7 +525,6 @@
663 up_write_mmap();
664 }
665 #endif
666 -
667 /*
668 *----------------------------------------------------------------------
669 *
670 @@ -678,7 +582,7 @@
671 #else
672 pte_val(*pte) &= ~_PAGE_NX;
673 #endif
674 - compat_smp_call_function (TLBInvalidatePage, (void *)vaddr, 1, 1);
675 + smp_call_function (TLBInvalidatePage, (void *)vaddr, 1);
676 TLBInvalidatePage((void *)vaddr);
677 }
678 if (ptemap) {
679 @@ -2911,7 +2815,7 @@
680 if (targetHostCpu != INVALID_HOST_CPU) {
681 ASSERT(targetHostCpu < MAX_PROCESSORS);
682 (void) compat_smp_call_function(LinuxDriverIPIHandler,
683 - NULL, 1, 1);
684 + NULL, 1);
685 return TRUE;
686 }
687 }
688 @@ -3099,7 +3003,7 @@
689 {
690 compat_preempt_disable();
691 HostIFFillCPUID((void*)info);
692 - (void)compat_smp_call_function(HostIFFillCPUID, (void*)info, 1, 1);
693 + (void)compat_smp_call_function(HostIFFillCPUID, (void*)info, 1);
694 compat_preempt_enable();
695 }
696
697 @@ -3136,7 +3040,7 @@
698 compat_preempt_disable();
699 HostIFBrokenCPUHelper((void*)&badcpumask); // run on this machine CPU
700 (void)compat_smp_call_function(HostIFBrokenCPUHelper, (void*)&badcpumask,
701 - 1, 1); // run on all other machine CPUs
702 + 1); // run on all other machine CPUs
703 compat_preempt_enable();
704
705 return badcpumask;
706 @@ -3335,46 +3239,6 @@
707 /*
708 *----------------------------------------------------------------------
709 *
710 - * HostIFDoIoctl --
711 - *
712 - * Issue ioctl. Assume kernel is not locked. It is not true now,
713 - * but it makes things easier to understand, and won't surprise us
714 - * later when we get rid of kernel lock from our code.
715 - *
716 - * Results:
717 - * Same as ioctl method.
718 - *
719 - * Side effects:
720 - * none.
721 - *
722 - *----------------------------------------------------------------------
723 - */
724 -
725 -static long
726 -HostIFDoIoctl(struct file *filp,
727 - u_int iocmd,
728 - unsigned long ioarg)
729 -{
730 -#ifdef HAVE_UNLOCKED_IOCTL
731 - if (filp->f_op->unlocked_ioctl) {
732 - return filp->f_op->unlocked_ioctl(filp, iocmd, ioarg);
733 - }
734 -#endif
735 - if (filp->f_op->ioctl) {
736 - long err;
737 -
738 - lock_kernel();
739 - err = filp->f_op->ioctl(filp->f_dentry->d_inode, filp, iocmd, ioarg);
740 - unlock_kernel();
741 - return err;
742 - }
743 - return -ENOIOCTLCMD;
744 -}
745 -
746 -
747 -/*
748 - *----------------------------------------------------------------------
749 - *
750 * HostIFFastClockThread --
751 *
752 * Kernel thread that provides finer-grained wakeups than the
753 @@ -3399,15 +3263,19 @@
754 int res;
755 mm_segment_t oldFS;
756 unsigned rate = 0;
757 + struct cred *cred;
758
759 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
760 compat_daemonize("vmware-rtc");
761 -#endif
762 oldFS = get_fs();
763 set_fs(KERNEL_DS);
764 compat_allow_signal(SIGKILL);
765 - cap_raise(current->cap_effective, CAP_SYS_RESOURCE);
766 - compat_set_user_nice(current, -20);
767 + cred = prepare_creds();
768 + if(!cred)
769 + return -ENOMEM;
770 + cap_raise(cred->cap_effective, CAP_SYS_RESOURCE);
771 + commit_creds(cred);
772 +
773 + //compat_set_user_nice(current, -20);
774
775 while (linuxState.fastClockRate > HZ + HZ/16) {
776 unsigned long buf;
777 @@ -3423,7 +3291,8 @@
778 p2rate <<= 1;
779 }
780
781 - res = HostIFDoIoctl(filp, RTC_IRQP_SET, p2rate);
782 + res = filp->f_op->ioctl(filp->f_dentry->d_inode,
783 + filp, RTC_IRQP_SET, p2rate);
784 if (res < 0) {
785 Warning("/dev/rtc set rate %d failed: %d\n", p2rate, res);
786 goto out;
787 @@ -3526,31 +3395,54 @@
788 if (rate > HZ + HZ/16) {
789 if (!linuxState.fastClockThread) {
790 struct file *filp;
791 + struct cred *cred;
792 int fsuid, res;
793 Bool cap;
794 - struct task_struct *t;
795 + struct task_struct *t;
796
797 - fsuid = current->fsuid;
798 + /*fsuid = current->fsuid;
799 current->fsuid = 0;
800 + */
801 + cred = prepare_creds();
802 + fsuid = cred->fsuid;
803 + cred->fsuid = 0;
804 + commit_creds(cred);
805 filp = filp_open("/dev/rtc", O_RDONLY, 0);
806 - current->fsuid = fsuid;
807 + cred = prepare_creds();
808 + cred->fsuid = fsuid;
809 + commit_creds(cred);
810 + //current->fsuid = fsuid;
811 if (IS_ERR(filp) || !filp) {
812 Warning("/dev/rtc open failed: %d\n", (int)(VA)filp);
813 return -(int)(VA)filp;
814 }
815 - cap = cap_raised(current->cap_effective, CAP_SYS_RESOURCE);
816 + /* cap = cap_raised(current->cap_effective, CAP_SYS_RESOURCE);
817 cap_raise(current->cap_effective, CAP_SYS_RESOURCE);
818 - res = HostIFDoIoctl(filp, RTC_PIE_ON, 0);
819 +*/
820 + cred = prepare_creds();
821 + cap = cap_raised(cred->cap_effective, CAP_SYS_RESOURCE);
822 + cap_raise(cred->cap_effective, CAP_SYS_RESOURCE);
823 + commit_creds(cred);
824 + if (filp->f_op->ioctl) {
825 + lock_kernel();
826 + res = filp->f_op->ioctl(filp->f_path.dentry->d_inode, filp, RTC_PIE_ON, 0);
827 + unlock_kernel();
828 + }
829 + else
830 + res = -1;
831 if (!cap) {
832 - cap_lower(current->cap_effective, CAP_SYS_RESOURCE);
833 + cred = prepare_creds();
834 + // cap_lower(current->cap_effective, CAP_SYS_RESOURCE);
835 + cap_lower(cred->cap_effective, CAP_SYS_RESOURCE);
836 + commit_creds(cred);
837 }
838 if (res < 0) {
839 Warning("/dev/rtc enable interrupt failed: %d\n", res);
840 compat_filp_close(filp, current->files);
841 return -res;
842 }
843 - t = kthread_create(HostIFFastClockThread, filp, "vmware-rtc");
844 - if (IS_ERR(t)) {
845 + t = kthread_create(HostIFFastClockThread, filp, "vmware-rtc");
846 + if (IS_ERR(t)) {
847 /*
848 * Ignore ERESTARTNOINTR silently, it occurs when signal is
849 * pending, and syscall layer automatically reissues operation
850 @@ -3563,11 +3455,11 @@
851 return -PTR_ERR(t);
852 }
853 linuxState.fastClockThread = t;
854 - wake_up_process(t);
855 + wake_up_process(t);
856 }
857 } else {
858 if (linuxState.fastClockThread) {
859 - send_sig(SIGKILL, linuxState.fastClockThread, 1);
860 + send_sig(SIGKILL, linuxState.fastClockThread, 1);
861 compat_wait_for_completion(&fastClockExited);
862 linuxState.fastClockThread = NULL;
863 }
864 diff -ruN vmmon-only-patched/linux/hostif_compat.h vmmon-only-rerefixed/linux/hostif_compat.h
865 --- vmmon-only-patched/linux/hostif_compat.h 2009-07-08 16:21:02.000000000 +0300
866 +++ vmmon-only-rerefixed/linux/hostif_compat.h 2009-04-21 13:45:08.000000000 +0300
867 @@ -93,11 +93,13 @@
868 }
869 return -EFAULT;
870 }
871 + /*
872 if (vma->vm_ops != &vmuser_locked_mops) {
873 printk(KERN_DEBUG "Found non-vmmon VMA (%#lX-%#lX) for VA %p\n",
874 vma->vm_start, vma->vm_end, (void*)va);
875 return -EINVAL;
876 }
877 + */
878 vmLinux = (VMLinux*)vma->vm_file->private_data;
879 if (!vmLinux) {
880 printk(KERN_DEBUG "Found vmmon VMA (%#lX-%#lX) for VA %p"
881 @@ -367,7 +369,7 @@
882 {
883 compat_preempt_disable();
884 HostIFSystemCallResetMSR(regs);
885 - (void)compat_smp_call_function(HostIFSystemCallResetMSR, (void *)regs, 1, 1);
886 + (void)compat_smp_call_function(HostIFSystemCallResetMSR, (void *)regs, 1);
887 compat_preempt_enable();
888 }
889
890 @@ -775,7 +777,8 @@
891 }
892 }
893
894 - mpn = PgtblVa2MPN(__fix_to_virt(VMWARE__FIX_IO_APIC_BASE));
895 + //mpn = PgtblVa2MPN(__fix_to_virt(VMWARE__FIX_IO_APIC_BASE));
896 + mpn = PgtblVa2MPN(__fix_to_virt(FIX_IO_APIC_BASE_0));
897 if (mpn == INVALID_MPN) {
898 return 0;
899 }
900 diff -ruN vmmon-only-patched/linux/vmhost.h vmmon-only-rerefixed/linux/vmhost.h
901 --- vmmon-only-patched/linux/vmhost.h 2009-07-08 16:21:02.000000000 +0300
902 +++ vmmon-only-rerefixed/linux/vmhost.h 2005-06-19 04:23:03.000000000 +0300
903 @@ -13,7 +13,7 @@
904 #include "compat_semaphore.h"
905 #include "compat_wait.h"
906
907 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
908 +
909 #ifdef VMX86_DEBUG
910 /*
911 * A MutexHolder object. In debug builds, we record information about the
912 @@ -54,7 +54,7 @@
913 MutexHolder cur;
914 #endif
915 } Mutex;
916 -#endif
917 +
918
919 /*
920 * Per-vm host-specific state.
921 @@ -65,11 +65,7 @@
922 * Used for shared modifications to VM's VMDriver data, mostly page locking.
923 * It has higher rank than the global mutex.
924 */
925 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
926 - struct mutex vmMutex;
927 -#else
928 Mutex vmMutex;
929 -#endif
930
931 atomic_t pendingUserCalls;
932 wait_queue_head_t callQueue;
933 diff -ruN vmmon-only-patched/linux/vmmonInt.h vmmon-only-rerefixed/linux/vmmonInt.h
934 --- vmmon-only-patched/linux/vmmonInt.h 2009-07-08 16:21:02.000000000 +0300
935 +++ vmmon-only-rerefixed/linux/vmmonInt.h 2009-04-20 19:14:30.000000000 +0300
936 @@ -31,16 +31,7 @@
937 } while (0)
938 #endif
939
940 -#if defined(CONFIG_SMP) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 2, 8)
941 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
942 -#define compat_smp_call_function(_a0,_a1,_a2,_a3) smp_call_function(_a0,_a1,_a3)
943 -#else
944 -#define compat_smp_call_function smp_call_function
945 -#endif
946 -#else
947 -#define compat_smp_call_function(_a0,_a1,_a2,_a3) 0
948 -#endif
949 -
950 +#define compat_smp_call_function(fn, info, wait) smp_call_function(fn, info, wait)
951
952 /*
953 * Although this is not really related to kernel-compatibility, I put this
954 diff -ruN vmmon-only-patched/Makefile vmmon-only-rerefixed/Makefile
955 --- vmmon-only-patched/Makefile 2009-07-08 16:21:02.000000000 +0300
956 +++ vmmon-only-rerefixed/Makefile 2007-11-28 12:39:37.000000000 +0200
957 @@ -15,7 +15,7 @@
958 VM_UNAME = $(shell uname -r)
959
960 # Header directory for the running kernel
961 -HEADER_DIR = ${KERNEL_DIR}/include
962 +HEADER_DIR = /lib/modules/$(VM_UNAME)/build/include
963
964 BUILD_DIR = $(HEADER_DIR)/..
965
966 diff -ruN vmmon-only-patched/Makefile.kernel vmmon-only-rerefixed/Makefile.kernel
967 --- vmmon-only-patched/Makefile.kernel 2009-07-08 16:21:02.000000000 +0300
968 +++ vmmon-only-rerefixed/Makefile.kernel 2009-04-21 18:01:30.000000000 +0300
969 @@ -16,18 +16,20 @@
970 EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/nopage1.c, -DVMW_NOPAGE_261, )
971 EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/skas1.c, -DVMW_SKAS_MMAP, )
972 EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/ioapic.c, \
973 - -DVMWARE__FIX_IO_APIC_BASE=FIX_IO_APIC_BASE_0, \
974 - -DVMWARE__FIX_IO_APIC_BASE=FIX_IO_APIC_BASE )
975 -EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/epoll.c, -DVMW_HAVE_EPOLL, )
976 + -DVMWARE__FIX_IO_APIC_BASE=FIX_IO_APIC_BASE_0)
977 +# -DVMWARE__FIX_IO_APIC_BASE=FIX_IO_APIC_BASE ) #only for UP ?
978 +#EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/epoll.c, -DVMW_HAVE_EPOLL, )
979 +EXTRA_CFLAGS += "-DVMW_HAVE_EPOLL"
980 EXTRA_CFLAGS += $(shell if [ -f $(HEADER_DIR)/linux/compile.h ]; then echo "-DVMW_HAVE_COMPILE_H"; fi)
981 EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/setnice.c, -DVMW_HAVE_SET_USER_NICE, )
982 +EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/smpcall.c, -DVMW_HAVE_SMP_CALL_3ARG, )
983
984 CXX_KFLAGS := $(call vm_check_gxx,-fno-exceptions,)
985
986 # 2.6.x build system
987 CFLAGS_task.o := -x c++ $(CXX_KFLAGS)
988 # 2.4.x build system
989 -CFLAGS_common/task.o := $(CFLAGS_task.o)
990 +#CFLAGS_common/task.o := $(CFLAGS_task.o)
991
992 obj-m += $(DRIVER).o
993
994 diff -ruN vmmon-only-patched/Makefile.normal vmmon-only-rerefixed/Makefile.normal
995 --- vmmon-only-patched/Makefile.normal 2009-07-08 16:21:02.000000000 +0300
996 +++ vmmon-only-rerefixed/Makefile.normal 2009-04-21 13:42:29.000000000 +0300
997 @@ -67,8 +67,8 @@
998 CC_OPTS += $(call vm_check_build, $(SRCROOT)/autoconf/nopage1.c, -DVMW_NOPAGE_261, )
999 CC_OPTS += $(call vm_check_build, $(SRCROOT)/autoconf/skas1.c, -DVMW_SKAS_MMAP, )
1000 CC_OPTS += $(call vm_check_build, $(SRCROOT)/autoconf/ioapic.c, \
1001 - -DVMWARE__FIX_IO_APIC_BASE=FIX_IO_APIC_BASE_0, \
1002 - -DVMWARE__FIX_IO_APIC_BASE=FIX_IO_APIC_BASE )
1003 + -DVMWARE__FIX_IO_APIC_BASE=FIX_IO_APIC_BASE_0)
1004 +# -DVMWARE__FIX_IO_APIC_BASE=FIX_IO_APIC_BASE ) #up?
1005 CC_OPTS += $(call vm_check_build, $(SRCROOT)/autoconf/epoll.c, -DVMW_HAVE_EPOLL, )
1006 CC_OPTS += $(shell if [ -f $(HEADER_DIR)/linux/compile.h ]; then echo "-DVMW_HAVE_COMPILE_H"; fi)
1007 CC_OPTS += $(call vm_check_build, $(SRCROOT)/autoconf/setnice.c, -DVMW_HAVE_SET_USER_NICE, )
1008 diff -ruN vmmon-only-patched/Module.markers vmmon-only-rerefixed/Module.markers
1009 --- vmmon-only-patched/Module.markers 1970-01-01 02:00:00.000000000 +0200
1010 +++ vmmon-only-rerefixed/Module.markers 2008-10-20 16:18:10.000000000 +0300
1011 @@ -0,0 +1,4 @@
1012 +core_marker_format vmlinux name %s format %s
1013 +kernel_sched_schedule vmlinux prev_pid %d next_pid %d prev_state %ld ## rq %p prev %p next %p
1014 +kernel_sched_wakeup vmlinux pid %d state %ld ## rq %p task %p rq->curr %p
1015 +kernel_sched_wakeup_new vmlinux pid %d state %ld ## rq %p task %p rq->curr %p
1016 diff -ruN vmmon-only-patched/modules.order vmmon-only-rerefixed/modules.order
1017 --- vmmon-only-patched/modules.order 1970-01-01 02:00:00.000000000 +0200
1018 +++ vmmon-only-rerefixed/modules.order 2009-04-21 18:01:42.000000000 +0300
1019 @@ -0,0 +1 @@
1020 +kernel//home/kang/tmp/vmware-update-2.6.27-5.5.7-2/vmmon-only/vmmon.ko