/[linux-patches]/genpatches-2.6/tags/2.6.32-15/1003_linux-2.6.32.4.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.32-15/1003_linux-2.6.32.4.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1735 - (show annotations) (download)
Wed Aug 4 11:25:09 2010 UTC (4 years, 4 months ago) by mpagano
File size: 141110 byte(s)
2.6.32-15 release
1 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
2 index 9a3334a..62619f2 100644
3 --- a/arch/alpha/kernel/osf_sys.c
4 +++ b/arch/alpha/kernel/osf_sys.c
5 @@ -178,25 +178,18 @@ SYSCALL_DEFINE6(osf_mmap, unsigned long, addr, unsigned long, len,
6 unsigned long, prot, unsigned long, flags, unsigned long, fd,
7 unsigned long, off)
8 {
9 - struct file *file = NULL;
10 - unsigned long ret = -EBADF;
11 + unsigned long ret = -EINVAL;
12
13 #if 0
14 if (flags & (_MAP_HASSEMAPHORE | _MAP_INHERIT | _MAP_UNALIGNED))
15 printk("%s: unimplemented OSF mmap flags %04lx\n",
16 current->comm, flags);
17 #endif
18 - if (!(flags & MAP_ANONYMOUS)) {
19 - file = fget(fd);
20 - if (!file)
21 - goto out;
22 - }
23 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
24 - down_write(&current->mm->mmap_sem);
25 - ret = do_mmap(file, addr, len, prot, flags, off);
26 - up_write(&current->mm->mmap_sem);
27 - if (file)
28 - fput(file);
29 + if ((off + PAGE_ALIGN(len)) < off)
30 + goto out;
31 + if (off & ~PAGE_MASK)
32 + goto out;
33 + ret = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
34 out:
35 return ret;
36 }
37 diff --git a/arch/arm/include/asm/mman.h b/arch/arm/include/asm/mman.h
38 index 8eebf89..41f99c5 100644
39 --- a/arch/arm/include/asm/mman.h
40 +++ b/arch/arm/include/asm/mman.h
41 @@ -1 +1,4 @@
42 #include <asm-generic/mman.h>
43 +
44 +#define arch_mmap_check(addr, len, flags) \
45 + (((flags) & MAP_FIXED && (addr) < FIRST_USER_ADDRESS) ? -EINVAL : 0)
46 diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
47 index fafce1b..4f07168 100644
48 --- a/arch/arm/kernel/calls.S
49 +++ b/arch/arm/kernel/calls.S
50 @@ -172,7 +172,7 @@
51 /* 160 */ CALL(sys_sched_get_priority_min)
52 CALL(sys_sched_rr_get_interval)
53 CALL(sys_nanosleep)
54 - CALL(sys_arm_mremap)
55 + CALL(sys_mremap)
56 CALL(sys_setresuid16)
57 /* 165 */ CALL(sys_getresuid16)
58 CALL(sys_ni_syscall) /* vm86 */
59 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
60 index f0fe95b..2c1db77 100644
61 --- a/arch/arm/kernel/entry-common.S
62 +++ b/arch/arm/kernel/entry-common.S
63 @@ -416,12 +416,12 @@ sys_mmap2:
64 tst r5, #PGOFF_MASK
65 moveq r5, r5, lsr #PAGE_SHIFT - 12
66 streq r5, [sp, #4]
67 - beq do_mmap2
68 + beq sys_mmap_pgoff
69 mov r0, #-EINVAL
70 mov pc, lr
71 #else
72 str r5, [sp, #4]
73 - b do_mmap2
74 + b sys_mmap_pgoff
75 #endif
76 ENDPROC(sys_mmap2)
77
78 diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
79 index 78ecaac..ae4027b 100644
80 --- a/arch/arm/kernel/sys_arm.c
81 +++ b/arch/arm/kernel/sys_arm.c
82 @@ -28,41 +28,6 @@
83 #include <linux/ipc.h>
84 #include <linux/uaccess.h>
85
86 -extern unsigned long do_mremap(unsigned long addr, unsigned long old_len,
87 - unsigned long new_len, unsigned long flags,
88 - unsigned long new_addr);
89 -
90 -/* common code for old and new mmaps */
91 -inline long do_mmap2(
92 - unsigned long addr, unsigned long len,
93 - unsigned long prot, unsigned long flags,
94 - unsigned long fd, unsigned long pgoff)
95 -{
96 - int error = -EINVAL;
97 - struct file * file = NULL;
98 -
99 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
100 -
101 - if (flags & MAP_FIXED && addr < FIRST_USER_ADDRESS)
102 - goto out;
103 -
104 - error = -EBADF;
105 - if (!(flags & MAP_ANONYMOUS)) {
106 - file = fget(fd);
107 - if (!file)
108 - goto out;
109 - }
110 -
111 - down_write(&current->mm->mmap_sem);
112 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
113 - up_write(&current->mm->mmap_sem);
114 -
115 - if (file)
116 - fput(file);
117 -out:
118 - return error;
119 -}
120 -
121 struct mmap_arg_struct {
122 unsigned long addr;
123 unsigned long len;
124 @@ -84,29 +49,11 @@ asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
125 if (a.offset & ~PAGE_MASK)
126 goto out;
127
128 - error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
129 + error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
130 out:
131 return error;
132 }
133
134 -asmlinkage unsigned long
135 -sys_arm_mremap(unsigned long addr, unsigned long old_len,
136 - unsigned long new_len, unsigned long flags,
137 - unsigned long new_addr)
138 -{
139 - unsigned long ret = -EINVAL;
140 -
141 - if (flags & MREMAP_FIXED && new_addr < FIRST_USER_ADDRESS)
142 - goto out;
143 -
144 - down_write(&current->mm->mmap_sem);
145 - ret = do_mremap(addr, old_len, new_len, flags, new_addr);
146 - up_write(&current->mm->mmap_sem);
147 -
148 -out:
149 - return ret;
150 -}
151 -
152 /*
153 * Perform the select(nd, in, out, ex, tv) and mmap() system
154 * calls.
155 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
156 index 2b79964..f5abc51 100644
157 --- a/arch/arm/mm/mmap.c
158 +++ b/arch/arm/mm/mmap.c
159 @@ -54,7 +54,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
160 * We enforce the MAP_FIXED case.
161 */
162 if (flags & MAP_FIXED) {
163 - if (aliasing && flags & MAP_SHARED && addr & (SHMLBA - 1))
164 + if (aliasing && flags & MAP_SHARED &&
165 + (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1))
166 return -EINVAL;
167 return addr;
168 }
169 diff --git a/arch/avr32/include/asm/syscalls.h b/arch/avr32/include/asm/syscalls.h
170 index 483d666..66a1972 100644
171 --- a/arch/avr32/include/asm/syscalls.h
172 +++ b/arch/avr32/include/asm/syscalls.h
173 @@ -29,10 +29,6 @@ asmlinkage int sys_sigaltstack(const stack_t __user *, stack_t __user *,
174 struct pt_regs *);
175 asmlinkage int sys_rt_sigreturn(struct pt_regs *);
176
177 -/* kernel/sys_avr32.c */
178 -asmlinkage long sys_mmap2(unsigned long, unsigned long, unsigned long,
179 - unsigned long, unsigned long, off_t);
180 -
181 /* mm/cache.c */
182 asmlinkage int sys_cacheflush(int, void __user *, size_t);
183
184 diff --git a/arch/avr32/kernel/sys_avr32.c b/arch/avr32/kernel/sys_avr32.c
185 index 5d2daea..459349b 100644
186 --- a/arch/avr32/kernel/sys_avr32.c
187 +++ b/arch/avr32/kernel/sys_avr32.c
188 @@ -5,39 +5,8 @@
189 * it under the terms of the GNU General Public License version 2 as
190 * published by the Free Software Foundation.
191 */
192 -#include <linux/errno.h>
193 -#include <linux/fs.h>
194 -#include <linux/file.h>
195 -#include <linux/mm.h>
196 #include <linux/unistd.h>
197
198 -#include <asm/mman.h>
199 -#include <asm/uaccess.h>
200 -#include <asm/syscalls.h>
201 -
202 -asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
203 - unsigned long prot, unsigned long flags,
204 - unsigned long fd, off_t offset)
205 -{
206 - int error = -EBADF;
207 - struct file *file = NULL;
208 -
209 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
210 - if (!(flags & MAP_ANONYMOUS)) {
211 - file = fget(fd);
212 - if (!file)
213 - return error;
214 - }
215 -
216 - down_write(&current->mm->mmap_sem);
217 - error = do_mmap_pgoff(file, addr, len, prot, flags, offset);
218 - up_write(&current->mm->mmap_sem);
219 -
220 - if (file)
221 - fput(file);
222 - return error;
223 -}
224 -
225 int kernel_execve(const char *file, char **argv, char **envp)
226 {
227 register long scno asm("r8") = __NR_execve;
228 diff --git a/arch/avr32/kernel/syscall-stubs.S b/arch/avr32/kernel/syscall-stubs.S
229 index f7244cd..0447a3e 100644
230 --- a/arch/avr32/kernel/syscall-stubs.S
231 +++ b/arch/avr32/kernel/syscall-stubs.S
232 @@ -61,7 +61,7 @@ __sys_execve:
233 __sys_mmap2:
234 pushm lr
235 st.w --sp, ARG6
236 - call sys_mmap2
237 + call sys_mmap_pgoff
238 sub sp, -4
239 popm pc
240
241 diff --git a/arch/blackfin/kernel/sys_bfin.c b/arch/blackfin/kernel/sys_bfin.c
242 index afcef12..2e7f8e1 100644
243 --- a/arch/blackfin/kernel/sys_bfin.c
244 +++ b/arch/blackfin/kernel/sys_bfin.c
245 @@ -22,39 +22,6 @@
246 #include <asm/cacheflush.h>
247 #include <asm/dma.h>
248
249 -/* common code for old and new mmaps */
250 -static inline long
251 -do_mmap2(unsigned long addr, unsigned long len,
252 - unsigned long prot, unsigned long flags,
253 - unsigned long fd, unsigned long pgoff)
254 -{
255 - int error = -EBADF;
256 - struct file *file = NULL;
257 -
258 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
259 - if (!(flags & MAP_ANONYMOUS)) {
260 - file = fget(fd);
261 - if (!file)
262 - goto out;
263 - }
264 -
265 - down_write(&current->mm->mmap_sem);
266 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
267 - up_write(&current->mm->mmap_sem);
268 -
269 - if (file)
270 - fput(file);
271 - out:
272 - return error;
273 -}
274 -
275 -asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
276 - unsigned long prot, unsigned long flags,
277 - unsigned long fd, unsigned long pgoff)
278 -{
279 - return do_mmap2(addr, len, prot, flags, fd, pgoff);
280 -}
281 -
282 asmlinkage void *sys_sram_alloc(size_t size, unsigned long flags)
283 {
284 return sram_alloc_with_lsl(size, flags);
285 diff --git a/arch/blackfin/mach-common/entry.S b/arch/blackfin/mach-common/entry.S
286 index 94a0375..1d8f00a 100644
287 --- a/arch/blackfin/mach-common/entry.S
288 +++ b/arch/blackfin/mach-common/entry.S
289 @@ -1422,7 +1422,7 @@ ENTRY(_sys_call_table)
290 .long _sys_ni_syscall /* streams2 */
291 .long _sys_vfork /* 190 */
292 .long _sys_getrlimit
293 - .long _sys_mmap2
294 + .long _sys_mmap_pgoff
295 .long _sys_truncate64
296 .long _sys_ftruncate64
297 .long _sys_stat64 /* 195 */
298 diff --git a/arch/cris/kernel/sys_cris.c b/arch/cris/kernel/sys_cris.c
299 index 2ad962c..c2bbb1a 100644
300 --- a/arch/cris/kernel/sys_cris.c
301 +++ b/arch/cris/kernel/sys_cris.c
302 @@ -26,31 +26,6 @@
303 #include <asm/uaccess.h>
304 #include <asm/segment.h>
305
306 -/* common code for old and new mmaps */
307 -static inline long
308 -do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
309 - unsigned long flags, unsigned long fd, unsigned long pgoff)
310 -{
311 - int error = -EBADF;
312 - struct file * file = NULL;
313 -
314 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
315 - if (!(flags & MAP_ANONYMOUS)) {
316 - file = fget(fd);
317 - if (!file)
318 - goto out;
319 - }
320 -
321 - down_write(&current->mm->mmap_sem);
322 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
323 - up_write(&current->mm->mmap_sem);
324 -
325 - if (file)
326 - fput(file);
327 -out:
328 - return error;
329 -}
330 -
331 asmlinkage unsigned long old_mmap(unsigned long __user *args)
332 {
333 unsigned long buffer[6];
334 @@ -63,7 +38,7 @@ asmlinkage unsigned long old_mmap(unsigned long __user *args)
335 if (buffer[5] & ~PAGE_MASK) /* verify that offset is on page boundary */
336 goto out;
337
338 - err = do_mmap2(buffer[0], buffer[1], buffer[2], buffer[3],
339 + err = sys_mmap_pgoff(buffer[0], buffer[1], buffer[2], buffer[3],
340 buffer[4], buffer[5] >> PAGE_SHIFT);
341 out:
342 return err;
343 @@ -73,7 +48,8 @@ asmlinkage long
344 sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
345 unsigned long flags, unsigned long fd, unsigned long pgoff)
346 {
347 - return do_mmap2(addr, len, prot, flags, fd, pgoff);
348 + /* bug(?): 8Kb pages here */
349 + return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
350 }
351
352 /*
353 diff --git a/arch/frv/kernel/sys_frv.c b/arch/frv/kernel/sys_frv.c
354 index 2b6b528..1d3d4c9 100644
355 --- a/arch/frv/kernel/sys_frv.c
356 +++ b/arch/frv/kernel/sys_frv.c
357 @@ -31,9 +31,6 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
358 unsigned long prot, unsigned long flags,
359 unsigned long fd, unsigned long pgoff)
360 {
361 - int error = -EBADF;
362 - struct file * file = NULL;
363 -
364 /* As with sparc32, make sure the shift for mmap2 is constant
365 (12), no matter what PAGE_SIZE we have.... */
366
367 @@ -41,69 +38,10 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
368 trying to map something we can't */
369 if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
370 return -EINVAL;
371 - pgoff >>= PAGE_SHIFT - 12;
372 -
373 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
374 - if (!(flags & MAP_ANONYMOUS)) {
375 - file = fget(fd);
376 - if (!file)
377 - goto out;
378 - }
379 -
380 - down_write(&current->mm->mmap_sem);
381 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
382 - up_write(&current->mm->mmap_sem);
383 -
384 - if (file)
385 - fput(file);
386 -out:
387 - return error;
388 -}
389 -
390 -#if 0 /* DAVIDM - do we want this */
391 -struct mmap_arg_struct64 {
392 - __u32 addr;
393 - __u32 len;
394 - __u32 prot;
395 - __u32 flags;
396 - __u64 offset; /* 64 bits */
397 - __u32 fd;
398 -};
399 -
400 -asmlinkage long sys_mmap64(struct mmap_arg_struct64 *arg)
401 -{
402 - int error = -EFAULT;
403 - struct file * file = NULL;
404 - struct mmap_arg_struct64 a;
405 - unsigned long pgoff;
406 -
407 - if (copy_from_user(&a, arg, sizeof(a)))
408 - return -EFAULT;
409 -
410 - if ((long)a.offset & ~PAGE_MASK)
411 - return -EINVAL;
412 -
413 - pgoff = a.offset >> PAGE_SHIFT;
414 - if ((a.offset >> PAGE_SHIFT) != pgoff)
415 - return -EINVAL;
416 -
417 - if (!(a.flags & MAP_ANONYMOUS)) {
418 - error = -EBADF;
419 - file = fget(a.fd);
420 - if (!file)
421 - goto out;
422 - }
423 - a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
424
425 - down_write(&current->mm->mmap_sem);
426 - error = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, pgoff);
427 - up_write(&current->mm->mmap_sem);
428 - if (file)
429 - fput(file);
430 -out:
431 - return error;
432 + return sys_mmap_pgoff(addr, len, prot, flags, fd,
433 + pgoff >> (PAGE_SHIFT - 12));
434 }
435 -#endif
436
437 /*
438 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
439 diff --git a/arch/h8300/kernel/sys_h8300.c b/arch/h8300/kernel/sys_h8300.c
440 index 8cb5d73..b5969db 100644
441 --- a/arch/h8300/kernel/sys_h8300.c
442 +++ b/arch/h8300/kernel/sys_h8300.c
443 @@ -26,39 +26,6 @@
444 #include <asm/traps.h>
445 #include <asm/unistd.h>
446
447 -/* common code for old and new mmaps */
448 -static inline long do_mmap2(
449 - unsigned long addr, unsigned long len,
450 - unsigned long prot, unsigned long flags,
451 - unsigned long fd, unsigned long pgoff)
452 -{
453 - int error = -EBADF;
454 - struct file * file = NULL;
455 -
456 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
457 - if (!(flags & MAP_ANONYMOUS)) {
458 - file = fget(fd);
459 - if (!file)
460 - goto out;
461 - }
462 -
463 - down_write(&current->mm->mmap_sem);
464 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
465 - up_write(&current->mm->mmap_sem);
466 -
467 - if (file)
468 - fput(file);
469 -out:
470 - return error;
471 -}
472 -
473 -asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
474 - unsigned long prot, unsigned long flags,
475 - unsigned long fd, unsigned long pgoff)
476 -{
477 - return do_mmap2(addr, len, prot, flags, fd, pgoff);
478 -}
479 -
480 /*
481 * Perform the select(nd, in, out, ex, tv) and mmap() system
482 * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
483 @@ -87,57 +54,11 @@ asmlinkage int old_mmap(struct mmap_arg_struct *arg)
484 if (a.offset & ~PAGE_MASK)
485 goto out;
486
487 - a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
488 -
489 - error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
490 -out:
491 - return error;
492 -}
493 -
494 -#if 0 /* DAVIDM - do we want this */
495 -struct mmap_arg_struct64 {
496 - __u32 addr;
497 - __u32 len;
498 - __u32 prot;
499 - __u32 flags;
500 - __u64 offset; /* 64 bits */
501 - __u32 fd;
502 -};
503 -
504 -asmlinkage long sys_mmap64(struct mmap_arg_struct64 *arg)
505 -{
506 - int error = -EFAULT;
507 - struct file * file = NULL;
508 - struct mmap_arg_struct64 a;
509 - unsigned long pgoff;
510 -
511 - if (copy_from_user(&a, arg, sizeof(a)))
512 - return -EFAULT;
513 -
514 - if ((long)a.offset & ~PAGE_MASK)
515 - return -EINVAL;
516 -
517 - pgoff = a.offset >> PAGE_SHIFT;
518 - if ((a.offset >> PAGE_SHIFT) != pgoff)
519 - return -EINVAL;
520 -
521 - if (!(a.flags & MAP_ANONYMOUS)) {
522 - error = -EBADF;
523 - file = fget(a.fd);
524 - if (!file)
525 - goto out;
526 - }
527 - a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
528 -
529 - down_write(&current->mm->mmap_sem);
530 - error = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, pgoff);
531 - up_write(&current->mm->mmap_sem);
532 - if (file)
533 - fput(file);
534 + error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
535 + a.offset >> PAGE_SHIFT);
536 out:
537 return error;
538 }
539 -#endif
540
541 struct sel_arg_struct {
542 unsigned long n;
543 diff --git a/arch/h8300/kernel/syscalls.S b/arch/h8300/kernel/syscalls.S
544 index 4eb67fa..2d69881 100644
545 --- a/arch/h8300/kernel/syscalls.S
546 +++ b/arch/h8300/kernel/syscalls.S
547 @@ -206,7 +206,7 @@ SYMBOL_NAME_LABEL(sys_call_table)
548 .long SYMBOL_NAME(sys_ni_syscall) /* streams2 */
549 .long SYMBOL_NAME(sys_vfork) /* 190 */
550 .long SYMBOL_NAME(sys_getrlimit)
551 - .long SYMBOL_NAME(sys_mmap2)
552 + .long SYMBOL_NAME(sys_mmap_pgoff)
553 .long SYMBOL_NAME(sys_truncate64)
554 .long SYMBOL_NAME(sys_ftruncate64)
555 .long SYMBOL_NAME(sys_stat64) /* 195 */
556 diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
557 index 625ed8f..e031ee8 100644
558 --- a/arch/ia64/ia32/sys_ia32.c
559 +++ b/arch/ia64/ia32/sys_ia32.c
560 @@ -858,6 +858,9 @@ ia32_do_mmap (struct file *file, unsigned long addr, unsigned long len, int prot
561
562 prot = get_prot32(prot);
563
564 + if (flags & MAP_HUGETLB)
565 + return -ENOMEM;
566 +
567 #if PAGE_SHIFT > IA32_PAGE_SHIFT
568 mutex_lock(&ia32_mmap_mutex);
569 {
570 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
571 index 92ed83f..609d500 100644
572 --- a/arch/ia64/kernel/sys_ia64.c
573 +++ b/arch/ia64/kernel/sys_ia64.c
574 @@ -100,51 +100,7 @@ sys_getpagesize (void)
575 asmlinkage unsigned long
576 ia64_brk (unsigned long brk)
577 {
578 - unsigned long rlim, retval, newbrk, oldbrk;
579 - struct mm_struct *mm = current->mm;
580 -
581 - /*
582 - * Most of this replicates the code in sys_brk() except for an additional safety
583 - * check and the clearing of r8. However, we can't call sys_brk() because we need
584 - * to acquire the mmap_sem before we can do the test...
585 - */
586 - down_write(&mm->mmap_sem);
587 -
588 - if (brk < mm->end_code)
589 - goto out;
590 - newbrk = PAGE_ALIGN(brk);
591 - oldbrk = PAGE_ALIGN(mm->brk);
592 - if (oldbrk == newbrk)
593 - goto set_brk;
594 -
595 - /* Always allow shrinking brk. */
596 - if (brk <= mm->brk) {
597 - if (!do_munmap(mm, newbrk, oldbrk-newbrk))
598 - goto set_brk;
599 - goto out;
600 - }
601 -
602 - /* Check against unimplemented/unmapped addresses: */
603 - if ((newbrk - oldbrk) > RGN_MAP_LIMIT || REGION_OFFSET(newbrk) > RGN_MAP_LIMIT)
604 - goto out;
605 -
606 - /* Check against rlimit.. */
607 - rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
608 - if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
609 - goto out;
610 -
611 - /* Check against existing mmap mappings. */
612 - if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE))
613 - goto out;
614 -
615 - /* Ok, looks good - let it rip. */
616 - if (do_brk(oldbrk, newbrk-oldbrk) != oldbrk)
617 - goto out;
618 -set_brk:
619 - mm->brk = brk;
620 -out:
621 - retval = mm->brk;
622 - up_write(&mm->mmap_sem);
623 + unsigned long retval = sys_brk(brk);
624 force_successful_syscall_return();
625 return retval;
626 }
627 @@ -185,39 +141,6 @@ int ia64_mmap_check(unsigned long addr, unsigned long len,
628 return 0;
629 }
630
631 -static inline unsigned long
632 -do_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, unsigned long pgoff)
633 -{
634 - struct file *file = NULL;
635 -
636 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
637 - if (!(flags & MAP_ANONYMOUS)) {
638 - file = fget(fd);
639 - if (!file)
640 - return -EBADF;
641 -
642 - if (!file->f_op || !file->f_op->mmap) {
643 - addr = -ENODEV;
644 - goto out;
645 - }
646 - }
647 -
648 - /* Careful about overflows.. */
649 - len = PAGE_ALIGN(len);
650 - if (!len || len > TASK_SIZE) {
651 - addr = -EINVAL;
652 - goto out;
653 - }
654 -
655 - down_write(&current->mm->mmap_sem);
656 - addr = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
657 - up_write(&current->mm->mmap_sem);
658 -
659 -out: if (file)
660 - fput(file);
661 - return addr;
662 -}
663 -
664 /*
665 * mmap2() is like mmap() except that the offset is expressed in units
666 * of PAGE_SIZE (instead of bytes). This allows to mmap2() (pieces
667 @@ -226,7 +149,7 @@ out: if (file)
668 asmlinkage unsigned long
669 sys_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, long pgoff)
670 {
671 - addr = do_mmap2(addr, len, prot, flags, fd, pgoff);
672 + addr = sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
673 if (!IS_ERR((void *) addr))
674 force_successful_syscall_return();
675 return addr;
676 @@ -238,7 +161,7 @@ sys_mmap (unsigned long addr, unsigned long len, int prot, int flags, int fd, lo
677 if (offset_in_page(off) != 0)
678 return -EINVAL;
679
680 - addr = do_mmap2(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
681 + addr = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
682 if (!IS_ERR((void *) addr))
683 force_successful_syscall_return();
684 return addr;
685 diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c
686 index 305ac85..d3c865c 100644
687 --- a/arch/m32r/kernel/sys_m32r.c
688 +++ b/arch/m32r/kernel/sys_m32r.c
689 @@ -76,30 +76,6 @@ asmlinkage int sys_tas(int __user *addr)
690 return oldval;
691 }
692
693 -asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
694 - unsigned long prot, unsigned long flags,
695 - unsigned long fd, unsigned long pgoff)
696 -{
697 - int error = -EBADF;
698 - struct file *file = NULL;
699 -
700 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
701 - if (!(flags & MAP_ANONYMOUS)) {
702 - file = fget(fd);
703 - if (!file)
704 - goto out;
705 - }
706 -
707 - down_write(&current->mm->mmap_sem);
708 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
709 - up_write(&current->mm->mmap_sem);
710 -
711 - if (file)
712 - fput(file);
713 -out:
714 - return error;
715 -}
716 -
717 /*
718 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
719 *
720 diff --git a/arch/m32r/kernel/syscall_table.S b/arch/m32r/kernel/syscall_table.S
721 index aa3bf4c..60536e2 100644
722 --- a/arch/m32r/kernel/syscall_table.S
723 +++ b/arch/m32r/kernel/syscall_table.S
724 @@ -191,7 +191,7 @@ ENTRY(sys_call_table)
725 .long sys_ni_syscall /* streams2 */
726 .long sys_vfork /* 190 */
727 .long sys_getrlimit
728 - .long sys_mmap2
729 + .long sys_mmap_pgoff
730 .long sys_truncate64
731 .long sys_ftruncate64
732 .long sys_stat64 /* 195 */
733 diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
734 index 7deb402..218f441 100644
735 --- a/arch/m68k/kernel/sys_m68k.c
736 +++ b/arch/m68k/kernel/sys_m68k.c
737 @@ -29,37 +29,16 @@
738 #include <asm/page.h>
739 #include <asm/unistd.h>
740
741 -/* common code for old and new mmaps */
742 -static inline long do_mmap2(
743 - unsigned long addr, unsigned long len,
744 - unsigned long prot, unsigned long flags,
745 - unsigned long fd, unsigned long pgoff)
746 -{
747 - int error = -EBADF;
748 - struct file * file = NULL;
749 -
750 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
751 - if (!(flags & MAP_ANONYMOUS)) {
752 - file = fget(fd);
753 - if (!file)
754 - goto out;
755 - }
756 -
757 - down_write(&current->mm->mmap_sem);
758 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
759 - up_write(&current->mm->mmap_sem);
760 -
761 - if (file)
762 - fput(file);
763 -out:
764 - return error;
765 -}
766 -
767 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
768 unsigned long prot, unsigned long flags,
769 unsigned long fd, unsigned long pgoff)
770 {
771 - return do_mmap2(addr, len, prot, flags, fd, pgoff);
772 + /*
773 + * This is wrong for sun3 - there PAGE_SIZE is 8Kb,
774 + * so we need to shift the argument down by 1; m68k mmap64(3)
775 + * (in libc) expects the last argument of mmap2 in 4Kb units.
776 + */
777 + return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
778 }
779
780 /*
781 @@ -90,57 +69,11 @@ asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
782 if (a.offset & ~PAGE_MASK)
783 goto out;
784
785 - a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
786 -
787 - error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
788 -out:
789 - return error;
790 -}
791 -
792 -#if 0
793 -struct mmap_arg_struct64 {
794 - __u32 addr;
795 - __u32 len;
796 - __u32 prot;
797 - __u32 flags;
798 - __u64 offset; /* 64 bits */
799 - __u32 fd;
800 -};
801 -
802 -asmlinkage long sys_mmap64(struct mmap_arg_struct64 *arg)
803 -{
804 - int error = -EFAULT;
805 - struct file * file = NULL;
806 - struct mmap_arg_struct64 a;
807 - unsigned long pgoff;
808 -
809 - if (copy_from_user(&a, arg, sizeof(a)))
810 - return -EFAULT;
811 -
812 - if ((long)a.offset & ~PAGE_MASK)
813 - return -EINVAL;
814 -
815 - pgoff = a.offset >> PAGE_SHIFT;
816 - if ((a.offset >> PAGE_SHIFT) != pgoff)
817 - return -EINVAL;
818 -
819 - if (!(a.flags & MAP_ANONYMOUS)) {
820 - error = -EBADF;
821 - file = fget(a.fd);
822 - if (!file)
823 - goto out;
824 - }
825 - a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
826 -
827 - down_write(&current->mm->mmap_sem);
828 - error = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, pgoff);
829 - up_write(&current->mm->mmap_sem);
830 - if (file)
831 - fput(file);
832 + error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
833 + a.offset >> PAGE_SHIFT);
834 out:
835 return error;
836 }
837 -#endif
838
839 struct sel_arg_struct {
840 unsigned long n;
841 diff --git a/arch/m68knommu/kernel/sys_m68k.c b/arch/m68knommu/kernel/sys_m68k.c
842 index efdd090..b67cbc7 100644
843 --- a/arch/m68knommu/kernel/sys_m68k.c
844 +++ b/arch/m68knommu/kernel/sys_m68k.c
845 @@ -27,39 +27,6 @@
846 #include <asm/cacheflush.h>
847 #include <asm/unistd.h>
848
849 -/* common code for old and new mmaps */
850 -static inline long do_mmap2(
851 - unsigned long addr, unsigned long len,
852 - unsigned long prot, unsigned long flags,
853 - unsigned long fd, unsigned long pgoff)
854 -{
855 - int error = -EBADF;
856 - struct file * file = NULL;
857 -
858 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
859 - if (!(flags & MAP_ANONYMOUS)) {
860 - file = fget(fd);
861 - if (!file)
862 - goto out;
863 - }
864 -
865 - down_write(&current->mm->mmap_sem);
866 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
867 - up_write(&current->mm->mmap_sem);
868 -
869 - if (file)
870 - fput(file);
871 -out:
872 - return error;
873 -}
874 -
875 -asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
876 - unsigned long prot, unsigned long flags,
877 - unsigned long fd, unsigned long pgoff)
878 -{
879 - return do_mmap2(addr, len, prot, flags, fd, pgoff);
880 -}
881 -
882 /*
883 * Perform the select(nd, in, out, ex, tv) and mmap() system
884 * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
885 @@ -88,9 +55,8 @@ asmlinkage int old_mmap(struct mmap_arg_struct *arg)
886 if (a.offset & ~PAGE_MASK)
887 goto out;
888
889 - a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
890 -
891 - error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
892 + error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
893 + a.offset >> PAGE_SHIFT);
894 out:
895 return error;
896 }
897 diff --git a/arch/m68knommu/kernel/syscalltable.S b/arch/m68knommu/kernel/syscalltable.S
898 index 23535cc..486837e 100644
899 --- a/arch/m68knommu/kernel/syscalltable.S
900 +++ b/arch/m68knommu/kernel/syscalltable.S
901 @@ -210,7 +210,7 @@ ENTRY(sys_call_table)
902 .long sys_ni_syscall /* streams2 */
903 .long sys_vfork /* 190 */
904 .long sys_getrlimit
905 - .long sys_mmap2
906 + .long sys_mmap_pgoff
907 .long sys_truncate64
908 .long sys_ftruncate64
909 .long sys_stat64 /* 195 */
910 diff --git a/arch/microblaze/kernel/sys_microblaze.c b/arch/microblaze/kernel/sys_microblaze.c
911 index 07cabed..9f3c205 100644
912 --- a/arch/microblaze/kernel/sys_microblaze.c
913 +++ b/arch/microblaze/kernel/sys_microblaze.c
914 @@ -62,46 +62,14 @@ out:
915 return error;
916 }
917
918 -asmlinkage long
919 -sys_mmap2(unsigned long addr, unsigned long len,
920 - unsigned long prot, unsigned long flags,
921 - unsigned long fd, unsigned long pgoff)
922 -{
923 - struct file *file = NULL;
924 - int ret = -EBADF;
925 -
926 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
927 - if (!(flags & MAP_ANONYMOUS)) {
928 - file = fget(fd);
929 - if (!file) {
930 - printk(KERN_INFO "no fd in mmap\r\n");
931 - goto out;
932 - }
933 - }
934 -
935 - down_write(&current->mm->mmap_sem);
936 - ret = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
937 - up_write(&current->mm->mmap_sem);
938 - if (file)
939 - fput(file);
940 -out:
941 - return ret;
942 -}
943 -
944 asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
945 unsigned long prot, unsigned long flags,
946 unsigned long fd, off_t pgoff)
947 {
948 - int err = -EINVAL;
949 -
950 - if (pgoff & ~PAGE_MASK) {
951 - printk(KERN_INFO "no pagemask in mmap\r\n");
952 - goto out;
953 - }
954 + if (pgoff & ~PAGE_MASK)
955 + return -EINVAL;
956
957 - err = sys_mmap2(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT);
958 -out:
959 - return err;
960 + return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT);
961 }
962
963 /*
964 diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
965 index ecec191..eb50ce5 100644
966 --- a/arch/microblaze/kernel/syscall_table.S
967 +++ b/arch/microblaze/kernel/syscall_table.S
968 @@ -196,7 +196,7 @@ ENTRY(sys_call_table)
969 .long sys_ni_syscall /* reserved for streams2 */
970 .long sys_vfork /* 190 */
971 .long sys_getrlimit
972 - .long sys_mmap2 /* mmap2 */
973 + .long sys_mmap_pgoff /* mmap2 */
974 .long sys_truncate64
975 .long sys_ftruncate64
976 .long sys_stat64 /* 195 */
977 diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
978 index b77fefa..ea4a746 100644
979 --- a/arch/mips/kernel/linux32.c
980 +++ b/arch/mips/kernel/linux32.c
981 @@ -67,28 +67,13 @@ SYSCALL_DEFINE6(32_mmap2, unsigned long, addr, unsigned long, len,
982 unsigned long, prot, unsigned long, flags, unsigned long, fd,
983 unsigned long, pgoff)
984 {
985 - struct file * file = NULL;
986 unsigned long error;
987
988 error = -EINVAL;
989 if (pgoff & (~PAGE_MASK >> 12))
990 goto out;
991 - pgoff >>= PAGE_SHIFT-12;
992 -
993 - if (!(flags & MAP_ANONYMOUS)) {
994 - error = -EBADF;
995 - file = fget(fd);
996 - if (!file)
997 - goto out;
998 - }
999 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1000 -
1001 - down_write(&current->mm->mmap_sem);
1002 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1003 - up_write(&current->mm->mmap_sem);
1004 - if (file)
1005 - fput(file);
1006 -
1007 + error = sys_mmap_pgoff(addr, len, prot, flags, fd,
1008 + pgoff >> (PAGE_SHIFT-12));
1009 out:
1010 return error;
1011 }
1012 diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
1013 index fe0d798..3f7f466 100644
1014 --- a/arch/mips/kernel/syscall.c
1015 +++ b/arch/mips/kernel/syscall.c
1016 @@ -93,7 +93,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
1017 * We do not accept a shared mapping if it would violate
1018 * cache aliasing constraints.
1019 */
1020 - if ((flags & MAP_SHARED) && (addr & shm_align_mask))
1021 + if ((flags & MAP_SHARED) &&
1022 + ((addr - (pgoff << PAGE_SHIFT)) & shm_align_mask))
1023 return -EINVAL;
1024 return addr;
1025 }
1026 @@ -129,31 +130,6 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
1027 }
1028 }
1029
1030 -/* common code for old and new mmaps */
1031 -static inline unsigned long
1032 -do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
1033 - unsigned long flags, unsigned long fd, unsigned long pgoff)
1034 -{
1035 - unsigned long error = -EBADF;
1036 - struct file * file = NULL;
1037 -
1038 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1039 - if (!(flags & MAP_ANONYMOUS)) {
1040 - file = fget(fd);
1041 - if (!file)
1042 - goto out;
1043 - }
1044 -
1045 - down_write(&current->mm->mmap_sem);
1046 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1047 - up_write(&current->mm->mmap_sem);
1048 -
1049 - if (file)
1050 - fput(file);
1051 -out:
1052 - return error;
1053 -}
1054 -
1055 SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len,
1056 unsigned long, prot, unsigned long, flags, unsigned long,
1057 fd, off_t, offset)
1058 @@ -164,7 +140,7 @@ SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len,
1059 if (offset & ~PAGE_MASK)
1060 goto out;
1061
1062 - result = do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
1063 + result = sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
1064
1065 out:
1066 return result;
1067 @@ -177,7 +153,7 @@ SYSCALL_DEFINE6(mips_mmap2, unsigned long, addr, unsigned long, len,
1068 if (pgoff & (~PAGE_MASK >> 12))
1069 return -EINVAL;
1070
1071 - return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT-12));
1072 + return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT-12));
1073 }
1074
1075 save_static_function(sys_fork);
1076 diff --git a/arch/mn10300/include/asm/mman.h b/arch/mn10300/include/asm/mman.h
1077 index 8eebf89..db5c53d 100644
1078 --- a/arch/mn10300/include/asm/mman.h
1079 +++ b/arch/mn10300/include/asm/mman.h
1080 @@ -1 +1,6 @@
1081 #include <asm-generic/mman.h>
1082 +
1083 +#define MIN_MAP_ADDR PAGE_SIZE /* minimum fixed mmap address */
1084 +
1085 +#define arch_mmap_check(addr, len, flags) \
1086 + (((flags) & MAP_FIXED && (addr) < MIN_MAP_ADDR) ? -EINVAL : 0)
1087 diff --git a/arch/mn10300/kernel/entry.S b/arch/mn10300/kernel/entry.S
1088 index a94e7ea..c9ee6c0 100644
1089 --- a/arch/mn10300/kernel/entry.S
1090 +++ b/arch/mn10300/kernel/entry.S
1091 @@ -578,7 +578,7 @@ ENTRY(sys_call_table)
1092 .long sys_ni_syscall /* reserved for streams2 */
1093 .long sys_vfork /* 190 */
1094 .long sys_getrlimit
1095 - .long sys_mmap2
1096 + .long sys_mmap_pgoff
1097 .long sys_truncate64
1098 .long sys_ftruncate64
1099 .long sys_stat64 /* 195 */
1100 diff --git a/arch/mn10300/kernel/sys_mn10300.c b/arch/mn10300/kernel/sys_mn10300.c
1101 index 8ca5af0..17cc6ce 100644
1102 --- a/arch/mn10300/kernel/sys_mn10300.c
1103 +++ b/arch/mn10300/kernel/sys_mn10300.c
1104 @@ -23,47 +23,13 @@
1105
1106 #include <asm/uaccess.h>
1107
1108 -#define MIN_MAP_ADDR PAGE_SIZE /* minimum fixed mmap address */
1109 -
1110 -/*
1111 - * memory mapping syscall
1112 - */
1113 -asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
1114 - unsigned long prot, unsigned long flags,
1115 - unsigned long fd, unsigned long pgoff)
1116 -{
1117 - struct file *file = NULL;
1118 - long error = -EINVAL;
1119 -
1120 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1121 -
1122 - if (flags & MAP_FIXED && addr < MIN_MAP_ADDR)
1123 - goto out;
1124 -
1125 - error = -EBADF;
1126 - if (!(flags & MAP_ANONYMOUS)) {
1127 - file = fget(fd);
1128 - if (!file)
1129 - goto out;
1130 - }
1131 -
1132 - down_write(&current->mm->mmap_sem);
1133 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1134 - up_write(&current->mm->mmap_sem);
1135 -
1136 - if (file)
1137 - fput(file);
1138 -out:
1139 - return error;
1140 -}
1141 -
1142 asmlinkage long old_mmap(unsigned long addr, unsigned long len,
1143 unsigned long prot, unsigned long flags,
1144 unsigned long fd, unsigned long offset)
1145 {
1146 if (offset & ~PAGE_MASK)
1147 return -EINVAL;
1148 - return sys_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
1149 + return sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
1150 }
1151
1152 struct sel_arg_struct {
1153 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
1154 index 71b3195..9147391 100644
1155 --- a/arch/parisc/kernel/sys_parisc.c
1156 +++ b/arch/parisc/kernel/sys_parisc.c
1157 @@ -110,37 +110,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
1158 return addr;
1159 }
1160
1161 -static unsigned long do_mmap2(unsigned long addr, unsigned long len,
1162 - unsigned long prot, unsigned long flags, unsigned long fd,
1163 - unsigned long pgoff)
1164 -{
1165 - struct file * file = NULL;
1166 - unsigned long error = -EBADF;
1167 - if (!(flags & MAP_ANONYMOUS)) {
1168 - file = fget(fd);
1169 - if (!file)
1170 - goto out;
1171 - }
1172 -
1173 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1174 -
1175 - down_write(&current->mm->mmap_sem);
1176 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1177 - up_write(&current->mm->mmap_sem);
1178 -
1179 - if (file != NULL)
1180 - fput(file);
1181 -out:
1182 - return error;
1183 -}
1184 -
1185 asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
1186 unsigned long prot, unsigned long flags, unsigned long fd,
1187 unsigned long pgoff)
1188 {
1189 /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE
1190 we have. */
1191 - return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT - 12));
1192 + return sys_mmap_pgoff(addr, len, prot, flags, fd,
1193 + pgoff >> (PAGE_SHIFT - 12));
1194 }
1195
1196 asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
1197 @@ -148,7 +125,8 @@ asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
1198 unsigned long offset)
1199 {
1200 if (!(offset & ~PAGE_MASK)) {
1201 - return do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
1202 + return sys_mmap_pgoff(addr, len, prot, flags, fd,
1203 + offset >> PAGE_SHIFT);
1204 } else {
1205 return -EINVAL;
1206 }
1207 diff --git a/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h
1208 index 0845488..0192a4e 100644
1209 --- a/arch/powerpc/include/asm/module.h
1210 +++ b/arch/powerpc/include/asm/module.h
1211 @@ -87,5 +87,10 @@ struct exception_table_entry;
1212 void sort_ex_table(struct exception_table_entry *start,
1213 struct exception_table_entry *finish);
1214
1215 +#ifdef CONFIG_MODVERSIONS
1216 +#define ARCH_RELOCATES_KCRCTAB
1217 +
1218 +extern const unsigned long reloc_start[];
1219 +#endif
1220 #endif /* __KERNEL__ */
1221 #endif /* _ASM_POWERPC_MODULE_H */
1222 diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
1223 index c04832c..3370e62 100644
1224 --- a/arch/powerpc/kernel/syscalls.c
1225 +++ b/arch/powerpc/kernel/syscalls.c
1226 @@ -140,7 +140,6 @@ static inline unsigned long do_mmap2(unsigned long addr, size_t len,
1227 unsigned long prot, unsigned long flags,
1228 unsigned long fd, unsigned long off, int shift)
1229 {
1230 - struct file * file = NULL;
1231 unsigned long ret = -EINVAL;
1232
1233 if (!arch_validate_prot(prot))
1234 @@ -151,20 +150,8 @@ static inline unsigned long do_mmap2(unsigned long addr, size_t len,
1235 goto out;
1236 off >>= shift;
1237 }
1238 -
1239 - ret = -EBADF;
1240 - if (!(flags & MAP_ANONYMOUS)) {
1241 - if (!(file = fget(fd)))
1242 - goto out;
1243 - }
1244 -
1245 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1246
1247 - down_write(&current->mm->mmap_sem);
1248 - ret = do_mmap_pgoff(file, addr, len, prot, flags, off);
1249 - up_write(&current->mm->mmap_sem);
1250 - if (file)
1251 - fput(file);
1252 + ret = sys_mmap_pgoff(addr, len, prot, flags, fd, off);
1253 out:
1254 return ret;
1255 }
1256 diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
1257 index 27735a7..dcd01c8 100644
1258 --- a/arch/powerpc/kernel/vmlinux.lds.S
1259 +++ b/arch/powerpc/kernel/vmlinux.lds.S
1260 @@ -38,6 +38,9 @@ jiffies = jiffies_64 + 4;
1261 #endif
1262 SECTIONS
1263 {
1264 + . = 0;
1265 + reloc_start = .;
1266 +
1267 . = KERNELBASE;
1268
1269 /*
1270 diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
1271 index 0debcec..9c746c0 100644
1272 --- a/arch/s390/kernel/compat_linux.c
1273 +++ b/arch/s390/kernel/compat_linux.c
1274 @@ -683,38 +683,6 @@ struct mmap_arg_struct_emu31 {
1275 u32 offset;
1276 };
1277
1278 -/* common code for old and new mmaps */
1279 -static inline long do_mmap2(
1280 - unsigned long addr, unsigned long len,
1281 - unsigned long prot, unsigned long flags,
1282 - unsigned long fd, unsigned long pgoff)
1283 -{
1284 - struct file * file = NULL;
1285 - unsigned long error = -EBADF;
1286 -
1287 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1288 - if (!(flags & MAP_ANONYMOUS)) {
1289 - file = fget(fd);
1290 - if (!file)
1291 - goto out;
1292 - }
1293 -
1294 - down_write(&current->mm->mmap_sem);
1295 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1296 - if (!IS_ERR((void *) error) && error + len >= 0x80000000ULL) {
1297 - /* Result is out of bounds. */
1298 - do_munmap(current->mm, addr, len);
1299 - error = -ENOMEM;
1300 - }
1301 - up_write(&current->mm->mmap_sem);
1302 -
1303 - if (file)
1304 - fput(file);
1305 -out:
1306 - return error;
1307 -}
1308 -
1309 -
1310 asmlinkage unsigned long
1311 old32_mmap(struct mmap_arg_struct_emu31 __user *arg)
1312 {
1313 @@ -728,7 +696,8 @@ old32_mmap(struct mmap_arg_struct_emu31 __user *arg)
1314 if (a.offset & ~PAGE_MASK)
1315 goto out;
1316
1317 - error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
1318 + error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
1319 + a.offset >> PAGE_SHIFT);
1320 out:
1321 return error;
1322 }
1323 @@ -741,7 +710,7 @@ sys32_mmap2(struct mmap_arg_struct_emu31 __user *arg)
1324
1325 if (copy_from_user(&a, arg, sizeof(a)))
1326 goto out;
1327 - error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
1328 + error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
1329 out:
1330 return error;
1331 }
1332 diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c
1333 index e9d94f6..86a74c9 100644
1334 --- a/arch/s390/kernel/sys_s390.c
1335 +++ b/arch/s390/kernel/sys_s390.c
1336 @@ -32,32 +32,6 @@
1337 #include <asm/uaccess.h>
1338 #include "entry.h"
1339
1340 -/* common code for old and new mmaps */
1341 -static inline long do_mmap2(
1342 - unsigned long addr, unsigned long len,
1343 - unsigned long prot, unsigned long flags,
1344 - unsigned long fd, unsigned long pgoff)
1345 -{
1346 - long error = -EBADF;
1347 - struct file * file = NULL;
1348 -
1349 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1350 - if (!(flags & MAP_ANONYMOUS)) {
1351 - file = fget(fd);
1352 - if (!file)
1353 - goto out;
1354 - }
1355 -
1356 - down_write(&current->mm->mmap_sem);
1357 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1358 - up_write(&current->mm->mmap_sem);
1359 -
1360 - if (file)
1361 - fput(file);
1362 -out:
1363 - return error;
1364 -}
1365 -
1366 /*
1367 * Perform the select(nd, in, out, ex, tv) and mmap() system
1368 * calls. Linux for S/390 isn't able to handle more than 5
1369 @@ -81,7 +55,7 @@ SYSCALL_DEFINE1(mmap2, struct mmap_arg_struct __user *, arg)
1370
1371 if (copy_from_user(&a, arg, sizeof(a)))
1372 goto out;
1373 - error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
1374 + error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
1375 out:
1376 return error;
1377 }
1378 @@ -98,7 +72,7 @@ SYSCALL_DEFINE1(s390_old_mmap, struct mmap_arg_struct __user *, arg)
1379 if (a.offset & ~PAGE_MASK)
1380 goto out;
1381
1382 - error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
1383 + error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
1384 out:
1385 return error;
1386 }
1387 diff --git a/arch/score/kernel/sys_score.c b/arch/score/kernel/sys_score.c
1388 index 0012494..856ed68 100644
1389 --- a/arch/score/kernel/sys_score.c
1390 +++ b/arch/score/kernel/sys_score.c
1391 @@ -36,34 +36,16 @@ asmlinkage long
1392 sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
1393 unsigned long flags, unsigned long fd, unsigned long pgoff)
1394 {
1395 - int error = -EBADF;
1396 - struct file *file = NULL;
1397 -
1398 - if (pgoff & (~PAGE_MASK >> 12))
1399 - return -EINVAL;
1400 -
1401 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1402 - if (!(flags & MAP_ANONYMOUS)) {
1403 - file = fget(fd);
1404 - if (!file)
1405 - return error;
1406 - }
1407 -
1408 - down_write(&current->mm->mmap_sem);
1409 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1410 - up_write(&current->mm->mmap_sem);
1411 -
1412 - if (file)
1413 - fput(file);
1414 -
1415 - return error;
1416 + return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
1417 }
1418
1419 asmlinkage long
1420 sys_mmap(unsigned long addr, unsigned long len, unsigned long prot,
1421 - unsigned long flags, unsigned long fd, off_t pgoff)
1422 + unsigned long flags, unsigned long fd, off_t offset)
1423 {
1424 - return sys_mmap2(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT);
1425 + if (unlikely(offset & ~PAGE_MASK))
1426 + return -EINVAL;
1427 + return sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
1428 }
1429
1430 asmlinkage long
1431 diff --git a/arch/sh/kernel/sys_sh.c b/arch/sh/kernel/sys_sh.c
1432 index 8aa5d1c..71399cd 100644
1433 --- a/arch/sh/kernel/sys_sh.c
1434 +++ b/arch/sh/kernel/sys_sh.c
1435 @@ -28,37 +28,13 @@
1436 #include <asm/cacheflush.h>
1437 #include <asm/cachectl.h>
1438
1439 -static inline long
1440 -do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
1441 - unsigned long flags, int fd, unsigned long pgoff)
1442 -{
1443 - int error = -EBADF;
1444 - struct file *file = NULL;
1445 -
1446 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1447 - if (!(flags & MAP_ANONYMOUS)) {
1448 - file = fget(fd);
1449 - if (!file)
1450 - goto out;
1451 - }
1452 -
1453 - down_write(&current->mm->mmap_sem);
1454 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1455 - up_write(&current->mm->mmap_sem);
1456 -
1457 - if (file)
1458 - fput(file);
1459 -out:
1460 - return error;
1461 -}
1462 -
1463 asmlinkage int old_mmap(unsigned long addr, unsigned long len,
1464 unsigned long prot, unsigned long flags,
1465 int fd, unsigned long off)
1466 {
1467 if (off & ~PAGE_MASK)
1468 return -EINVAL;
1469 - return do_mmap2(addr, len, prot, flags, fd, off>>PAGE_SHIFT);
1470 + return sys_mmap_pgoff(addr, len, prot, flags, fd, off>>PAGE_SHIFT);
1471 }
1472
1473 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
1474 @@ -74,7 +50,7 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
1475
1476 pgoff >>= PAGE_SHIFT - 12;
1477
1478 - return do_mmap2(addr, len, prot, flags, fd, pgoff);
1479 + return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
1480 }
1481
1482 /*
1483 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
1484 index d2984fa..afeb710 100644
1485 --- a/arch/sh/mm/mmap.c
1486 +++ b/arch/sh/mm/mmap.c
1487 @@ -54,7 +54,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
1488 /* We do not accept a shared mapping if it would violate
1489 * cache aliasing constraints.
1490 */
1491 - if ((flags & MAP_SHARED) && (addr & shm_align_mask))
1492 + if ((flags & MAP_SHARED) &&
1493 + ((addr - (pgoff << PAGE_SHIFT)) & shm_align_mask))
1494 return -EINVAL;
1495 return addr;
1496 }
1497 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
1498 index 03035c8..3a82e65 100644
1499 --- a/arch/sparc/kernel/sys_sparc_32.c
1500 +++ b/arch/sparc/kernel/sys_sparc_32.c
1501 @@ -45,7 +45,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
1502 /* We do not accept a shared mapping if it would violate
1503 * cache aliasing constraints.
1504 */
1505 - if ((flags & MAP_SHARED) && (addr & (SHMLBA - 1)))
1506 + if ((flags & MAP_SHARED) &&
1507 + ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
1508 return -EINVAL;
1509 return addr;
1510 }
1511 @@ -79,15 +80,6 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
1512 }
1513 }
1514
1515 -asmlinkage unsigned long sparc_brk(unsigned long brk)
1516 -{
1517 - if(ARCH_SUN4C) {
1518 - if ((brk & 0xe0000000) != (current->mm->brk & 0xe0000000))
1519 - return current->mm->brk;
1520 - }
1521 - return sys_brk(brk);
1522 -}
1523 -
1524 /*
1525 * sys_pipe() is the normal C calling standard for creating
1526 * a pipe. It's not the way unix traditionally does this, though.
1527 @@ -234,31 +226,6 @@ int sparc_mmap_check(unsigned long addr, unsigned long len)
1528 }
1529
1530 /* Linux version of mmap */
1531 -static unsigned long do_mmap2(unsigned long addr, unsigned long len,
1532 - unsigned long prot, unsigned long flags, unsigned long fd,
1533 - unsigned long pgoff)
1534 -{
1535 - struct file * file = NULL;
1536 - unsigned long retval = -EBADF;
1537 -
1538 - if (!(flags & MAP_ANONYMOUS)) {
1539 - file = fget(fd);
1540 - if (!file)
1541 - goto out;
1542 - }
1543 -
1544 - len = PAGE_ALIGN(len);
1545 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1546 -
1547 - down_write(&current->mm->mmap_sem);
1548 - retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1549 - up_write(&current->mm->mmap_sem);
1550 -
1551 - if (file)
1552 - fput(file);
1553 -out:
1554 - return retval;
1555 -}
1556
1557 asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
1558 unsigned long prot, unsigned long flags, unsigned long fd,
1559 @@ -266,14 +233,16 @@ asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
1560 {
1561 /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE
1562 we have. */
1563 - return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT - 12));
1564 + return sys_mmap_pgoff(addr, len, prot, flags, fd,
1565 + pgoff >> (PAGE_SHIFT - 12));
1566 }
1567
1568 asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
1569 unsigned long prot, unsigned long flags, unsigned long fd,
1570 unsigned long off)
1571 {
1572 - return do_mmap2(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
1573 + /* no alignment check? */
1574 + return sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
1575 }
1576
1577 long sparc_remap_file_pages(unsigned long start, unsigned long size,
1578 @@ -287,27 +256,6 @@ long sparc_remap_file_pages(unsigned long start, unsigned long size,
1579 (pgoff >> (PAGE_SHIFT - 12)), flags);
1580 }
1581
1582 -extern unsigned long do_mremap(unsigned long addr,
1583 - unsigned long old_len, unsigned long new_len,
1584 - unsigned long flags, unsigned long new_addr);
1585 -
1586 -asmlinkage unsigned long sparc_mremap(unsigned long addr,
1587 - unsigned long old_len, unsigned long new_len,
1588 - unsigned long flags, unsigned long new_addr)
1589 -{
1590 - unsigned long ret = -EINVAL;
1591 -
1592 - if (unlikely(sparc_mmap_check(addr, old_len)))
1593 - goto out;
1594 - if (unlikely(sparc_mmap_check(new_addr, new_len)))
1595 - goto out;
1596 - down_write(&current->mm->mmap_sem);
1597 - ret = do_mremap(addr, old_len, new_len, flags, new_addr);
1598 - up_write(&current->mm->mmap_sem);
1599 -out:
1600 - return ret;
1601 -}
1602 -
1603 /* we come to here via sys_nis_syscall so it can setup the regs argument */
1604 asmlinkage unsigned long
1605 c_sys_nis_syscall (struct pt_regs *regs)
1606 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
1607 index e2d1024..cfa0e19 100644
1608 --- a/arch/sparc/kernel/sys_sparc_64.c
1609 +++ b/arch/sparc/kernel/sys_sparc_64.c
1610 @@ -317,10 +317,14 @@ bottomup:
1611 unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, unsigned long len, unsigned long pgoff, unsigned long flags)
1612 {
1613 unsigned long align_goal, addr = -ENOMEM;
1614 + unsigned long (*get_area)(struct file *, unsigned long,
1615 + unsigned long, unsigned long, unsigned long);
1616 +
1617 + get_area = current->mm->get_unmapped_area;
1618
1619 if (flags & MAP_FIXED) {
1620 /* Ok, don't mess with it. */
1621 - return get_unmapped_area(NULL, orig_addr, len, pgoff, flags);
1622 + return get_area(NULL, orig_addr, len, pgoff, flags);
1623 }
1624 flags &= ~MAP_SHARED;
1625
1626 @@ -333,7 +337,7 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
1627 align_goal = (64UL * 1024);
1628
1629 do {
1630 - addr = get_unmapped_area(NULL, orig_addr, len + (align_goal - PAGE_SIZE), pgoff, flags);
1631 + addr = get_area(NULL, orig_addr, len + (align_goal - PAGE_SIZE), pgoff, flags);
1632 if (!(addr & ~PAGE_MASK)) {
1633 addr = (addr + (align_goal - 1UL)) & ~(align_goal - 1UL);
1634 break;
1635 @@ -351,7 +355,7 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
1636 * be obtained.
1637 */
1638 if (addr & ~PAGE_MASK)
1639 - addr = get_unmapped_area(NULL, orig_addr, len, pgoff, flags);
1640 + addr = get_area(NULL, orig_addr, len, pgoff, flags);
1641
1642 return addr;
1643 }
1644 @@ -399,18 +403,6 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
1645 }
1646 }
1647
1648 -SYSCALL_DEFINE1(sparc_brk, unsigned long, brk)
1649 -{
1650 - /* People could try to be nasty and use ta 0x6d in 32bit programs */
1651 - if (test_thread_flag(TIF_32BIT) && brk >= STACK_TOP32)
1652 - return current->mm->brk;
1653 -
1654 - if (unlikely(straddles_64bit_va_hole(current->mm->brk, brk)))
1655 - return current->mm->brk;
1656 -
1657 - return sys_brk(brk);
1658 -}
1659 -
1660 /*
1661 * sys_pipe() is the normal C calling standard for creating
1662 * a pipe. It's not the way unix traditionally does this, though.
1663 @@ -568,23 +560,13 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
1664 unsigned long, prot, unsigned long, flags, unsigned long, fd,
1665 unsigned long, off)
1666 {
1667 - struct file * file = NULL;
1668 - unsigned long retval = -EBADF;
1669 -
1670 - if (!(flags & MAP_ANONYMOUS)) {
1671 - file = fget(fd);
1672 - if (!file)
1673 - goto out;
1674 - }
1675 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1676 - len = PAGE_ALIGN(len);
1677 + unsigned long retval = -EINVAL;
1678
1679 - down_write(&current->mm->mmap_sem);
1680 - retval = do_mmap(file, addr, len, prot, flags, off);
1681 - up_write(&current->mm->mmap_sem);
1682 -
1683 - if (file)
1684 - fput(file);
1685 + if ((off + PAGE_ALIGN(len)) < off)
1686 + goto out;
1687 + if (off & ~PAGE_MASK)
1688 + goto out;
1689 + retval = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
1690 out:
1691 return retval;
1692 }
1693 @@ -614,12 +596,6 @@ SYSCALL_DEFINE5(64_mremap, unsigned long, addr, unsigned long, old_len,
1694
1695 if (test_thread_flag(TIF_32BIT))
1696 goto out;
1697 - if (unlikely(new_len >= VA_EXCLUDE_START))
1698 - goto out;
1699 - if (unlikely(sparc_mmap_check(addr, old_len)))
1700 - goto out;
1701 - if (unlikely(sparc_mmap_check(new_addr, new_len)))
1702 - goto out;
1703
1704 down_write(&current->mm->mmap_sem);
1705 ret = do_mremap(addr, old_len, new_len, flags, new_addr);
1706 diff --git a/arch/sparc/kernel/systbls.h b/arch/sparc/kernel/systbls.h
1707 index a63c5d2..d2f999a 100644
1708 --- a/arch/sparc/kernel/systbls.h
1709 +++ b/arch/sparc/kernel/systbls.h
1710 @@ -9,7 +9,6 @@
1711 struct new_utsname;
1712
1713 extern asmlinkage unsigned long sys_getpagesize(void);
1714 -extern asmlinkage unsigned long sparc_brk(unsigned long brk);
1715 extern asmlinkage long sparc_pipe(struct pt_regs *regs);
1716 extern asmlinkage long sys_ipc(unsigned int call, int first,
1717 unsigned long second,
1718 diff --git a/arch/sparc/kernel/systbls_32.S b/arch/sparc/kernel/systbls_32.S
1719 index 0f1658d..14f950a 100644
1720 --- a/arch/sparc/kernel/systbls_32.S
1721 +++ b/arch/sparc/kernel/systbls_32.S
1722 @@ -19,7 +19,7 @@ sys_call_table:
1723 /*0*/ .long sys_restart_syscall, sys_exit, sys_fork, sys_read, sys_write
1724 /*5*/ .long sys_open, sys_close, sys_wait4, sys_creat, sys_link
1725 /*10*/ .long sys_unlink, sunos_execv, sys_chdir, sys_chown16, sys_mknod
1726 -/*15*/ .long sys_chmod, sys_lchown16, sparc_brk, sys_nis_syscall, sys_lseek
1727 +/*15*/ .long sys_chmod, sys_lchown16, sys_brk, sys_nis_syscall, sys_lseek
1728 /*20*/ .long sys_getpid, sys_capget, sys_capset, sys_setuid16, sys_getuid16
1729 /*25*/ .long sys_vmsplice, sys_ptrace, sys_alarm, sys_sigaltstack, sys_pause
1730 /*30*/ .long sys_utime, sys_lchown, sys_fchown, sys_access, sys_nice
1731 @@ -67,7 +67,7 @@ sys_call_table:
1732 /*235*/ .long sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys_mlockall
1733 /*240*/ .long sys_munlockall, sys_sched_setparam, sys_sched_getparam, sys_sched_setscheduler, sys_sched_getscheduler
1734 /*245*/ .long sys_sched_yield, sys_sched_get_priority_max, sys_sched_get_priority_min, sys_sched_rr_get_interval, sys_nanosleep
1735 -/*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1736 +/*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1737 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1738 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1739 /*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
1740 diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S
1741 index 009825f..f63c871 100644
1742 --- a/arch/sparc/kernel/systbls_64.S
1743 +++ b/arch/sparc/kernel/systbls_64.S
1744 @@ -21,7 +21,7 @@ sys_call_table32:
1745 /*0*/ .word sys_restart_syscall, sys32_exit, sys_fork, sys_read, sys_write
1746 /*5*/ .word sys32_open, sys_close, sys32_wait4, sys32_creat, sys_link
1747 /*10*/ .word sys_unlink, sunos_execv, sys_chdir, sys_chown16, sys32_mknod
1748 -/*15*/ .word sys_chmod, sys_lchown16, sys_sparc_brk, sys32_perfctr, sys32_lseek
1749 +/*15*/ .word sys_chmod, sys_lchown16, sys_brk, sys32_perfctr, sys32_lseek
1750 /*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid16, sys_getuid16
1751 /*25*/ .word sys32_vmsplice, compat_sys_ptrace, sys_alarm, sys32_sigaltstack, sys_pause
1752 /*30*/ .word compat_sys_utime, sys_lchown, sys_fchown, sys32_access, sys32_nice
1753 @@ -96,7 +96,7 @@ sys_call_table:
1754 /*0*/ .word sys_restart_syscall, sparc_exit, sys_fork, sys_read, sys_write
1755 /*5*/ .word sys_open, sys_close, sys_wait4, sys_creat, sys_link
1756 /*10*/ .word sys_unlink, sys_nis_syscall, sys_chdir, sys_chown, sys_mknod
1757 -/*15*/ .word sys_chmod, sys_lchown, sys_sparc_brk, sys_perfctr, sys_lseek
1758 +/*15*/ .word sys_chmod, sys_lchown, sys_brk, sys_perfctr, sys_lseek
1759 /*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid, sys_getuid
1760 /*25*/ .word sys_vmsplice, sys_ptrace, sys_alarm, sys_sigaltstack, sys_nis_syscall
1761 /*30*/ .word sys_utime, sys_nis_syscall, sys_nis_syscall, sys_access, sys_nice
1762 diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
1763 index a4625c7..cccab85 100644
1764 --- a/arch/um/kernel/syscall.c
1765 +++ b/arch/um/kernel/syscall.c
1766 @@ -8,6 +8,7 @@
1767 #include "linux/mm.h"
1768 #include "linux/sched.h"
1769 #include "linux/utsname.h"
1770 +#include "linux/syscalls.h"
1771 #include "asm/current.h"
1772 #include "asm/mman.h"
1773 #include "asm/uaccess.h"
1774 @@ -37,31 +38,6 @@ long sys_vfork(void)
1775 return ret;
1776 }
1777
1778 -/* common code for old and new mmaps */
1779 -long sys_mmap2(unsigned long addr, unsigned long len,
1780 - unsigned long prot, unsigned long flags,
1781 - unsigned long fd, unsigned long pgoff)
1782 -{
1783 - long error = -EBADF;
1784 - struct file * file = NULL;
1785 -
1786 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1787 - if (!(flags & MAP_ANONYMOUS)) {
1788 - file = fget(fd);
1789 - if (!file)
1790 - goto out;
1791 - }
1792 -
1793 - down_write(&current->mm->mmap_sem);
1794 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1795 - up_write(&current->mm->mmap_sem);
1796 -
1797 - if (file)
1798 - fput(file);
1799 - out:
1800 - return error;
1801 -}
1802 -
1803 long old_mmap(unsigned long addr, unsigned long len,
1804 unsigned long prot, unsigned long flags,
1805 unsigned long fd, unsigned long offset)
1806 @@ -70,7 +46,7 @@ long old_mmap(unsigned long addr, unsigned long len,
1807 if (offset & ~PAGE_MASK)
1808 goto out;
1809
1810 - err = sys_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
1811 + err = sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
1812 out:
1813 return err;
1814 }
1815 diff --git a/arch/um/sys-i386/shared/sysdep/syscalls.h b/arch/um/sys-i386/shared/sysdep/syscalls.h
1816 index 9056981..e778767 100644
1817 --- a/arch/um/sys-i386/shared/sysdep/syscalls.h
1818 +++ b/arch/um/sys-i386/shared/sysdep/syscalls.h
1819 @@ -20,7 +20,3 @@ extern syscall_handler_t *sys_call_table[];
1820 #define EXECUTE_SYSCALL(syscall, regs) \
1821 ((long (*)(struct syscall_args)) \
1822 (*sys_call_table[syscall]))(SYSCALL_ARGS(&regs->regs))
1823 -
1824 -extern long sys_mmap2(unsigned long addr, unsigned long len,
1825 - unsigned long prot, unsigned long flags,
1826 - unsigned long fd, unsigned long pgoff);
1827 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
1828 index 2649840..f2824fb 100644
1829 --- a/arch/x86/Kconfig.cpu
1830 +++ b/arch/x86/Kconfig.cpu
1831 @@ -400,7 +400,7 @@ config X86_TSC
1832
1833 config X86_CMPXCHG64
1834 def_bool y
1835 - depends on !M386 && !M486
1836 + depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM
1837
1838 # this should be set for all -march=.. options where the compiler
1839 # generates cmov.
1840 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
1841 index 581b056..5294d84 100644
1842 --- a/arch/x86/ia32/ia32entry.S
1843 +++ b/arch/x86/ia32/ia32entry.S
1844 @@ -696,7 +696,7 @@ ia32_sys_call_table:
1845 .quad quiet_ni_syscall /* streams2 */
1846 .quad stub32_vfork /* 190 */
1847 .quad compat_sys_getrlimit
1848 - .quad sys32_mmap2
1849 + .quad sys_mmap_pgoff
1850 .quad sys32_truncate64
1851 .quad sys32_ftruncate64
1852 .quad sys32_stat64 /* 195 */
1853 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
1854 index 9f55271..016218c 100644
1855 --- a/arch/x86/ia32/sys_ia32.c
1856 +++ b/arch/x86/ia32/sys_ia32.c
1857 @@ -155,9 +155,6 @@ struct mmap_arg_struct {
1858 asmlinkage long sys32_mmap(struct mmap_arg_struct __user *arg)
1859 {
1860 struct mmap_arg_struct a;
1861 - struct file *file = NULL;
1862 - unsigned long retval;
1863 - struct mm_struct *mm ;
1864
1865 if (copy_from_user(&a, arg, sizeof(a)))
1866 return -EFAULT;
1867 @@ -165,22 +162,8 @@ asmlinkage long sys32_mmap(struct mmap_arg_struct __user *arg)
1868 if (a.offset & ~PAGE_MASK)
1869 return -EINVAL;
1870
1871 - if (!(a.flags & MAP_ANONYMOUS)) {
1872 - file = fget(a.fd);
1873 - if (!file)
1874 - return -EBADF;
1875 - }
1876 -
1877 - mm = current->mm;
1878 - down_write(&mm->mmap_sem);
1879 - retval = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags,
1880 + return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
1881 a.offset>>PAGE_SHIFT);
1882 - if (file)
1883 - fput(file);
1884 -
1885 - up_write(&mm->mmap_sem);
1886 -
1887 - return retval;
1888 }
1889
1890 asmlinkage long sys32_mprotect(unsigned long start, size_t len,
1891 @@ -539,30 +522,6 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
1892 return ret;
1893 }
1894
1895 -asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
1896 - unsigned long prot, unsigned long flags,
1897 - unsigned long fd, unsigned long pgoff)
1898 -{
1899 - struct mm_struct *mm = current->mm;
1900 - unsigned long error;
1901 - struct file *file = NULL;
1902 -
1903 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1904 - if (!(flags & MAP_ANONYMOUS)) {
1905 - file = fget(fd);
1906 - if (!file)
1907 - return -EBADF;
1908 - }
1909 -
1910 - down_write(&mm->mmap_sem);
1911 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1912 - up_write(&mm->mmap_sem);
1913 -
1914 - if (file)
1915 - fput(file);
1916 - return error;
1917 -}
1918 -
1919 asmlinkage long sys32_olduname(struct oldold_utsname __user *name)
1920 {
1921 char *arch = "x86_64";
1922 diff --git a/arch/x86/include/asm/sys_ia32.h b/arch/x86/include/asm/sys_ia32.h
1923 index 72a6dcd..77c1184 100644
1924 --- a/arch/x86/include/asm/sys_ia32.h
1925 +++ b/arch/x86/include/asm/sys_ia32.h
1926 @@ -62,9 +62,6 @@ asmlinkage long sys32_pwrite(unsigned int, char __user *, u32, u32, u32);
1927 asmlinkage long sys32_personality(unsigned long);
1928 asmlinkage long sys32_sendfile(int, int, compat_off_t __user *, s32);
1929
1930 -asmlinkage long sys32_mmap2(unsigned long, unsigned long, unsigned long,
1931 - unsigned long, unsigned long, unsigned long);
1932 -
1933 struct oldold_utsname;
1934 struct old_utsname;
1935 asmlinkage long sys32_olduname(struct oldold_utsname __user *);
1936 diff --git a/arch/x86/include/asm/syscalls.h b/arch/x86/include/asm/syscalls.h
1937 index 372b76e..1bb6e39 100644
1938 --- a/arch/x86/include/asm/syscalls.h
1939 +++ b/arch/x86/include/asm/syscalls.h
1940 @@ -55,8 +55,6 @@ struct sel_arg_struct;
1941 struct oldold_utsname;
1942 struct old_utsname;
1943
1944 -asmlinkage long sys_mmap2(unsigned long, unsigned long, unsigned long,
1945 - unsigned long, unsigned long, unsigned long);
1946 asmlinkage int old_mmap(struct mmap_arg_struct __user *);
1947 asmlinkage int old_select(struct sel_arg_struct __user *);
1948 asmlinkage int sys_ipc(uint, int, int, int, void __user *, long);
1949 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
1950 index 1884a8d..dee1ff7 100644
1951 --- a/arch/x86/kernel/sys_i386_32.c
1952 +++ b/arch/x86/kernel/sys_i386_32.c
1953 @@ -24,31 +24,6 @@
1954
1955 #include <asm/syscalls.h>
1956
1957 -asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
1958 - unsigned long prot, unsigned long flags,
1959 - unsigned long fd, unsigned long pgoff)
1960 -{
1961 - int error = -EBADF;
1962 - struct file *file = NULL;
1963 - struct mm_struct *mm = current->mm;
1964 -
1965 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1966 - if (!(flags & MAP_ANONYMOUS)) {
1967 - file = fget(fd);
1968 - if (!file)
1969 - goto out;
1970 - }
1971 -
1972 - down_write(&mm->mmap_sem);
1973 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1974 - up_write(&mm->mmap_sem);
1975 -
1976 - if (file)
1977 - fput(file);
1978 -out:
1979 - return error;
1980 -}
1981 -
1982 /*
1983 * Perform the select(nd, in, out, ex, tv) and mmap() system
1984 * calls. Linux/i386 didn't use to be able to handle more than
1985 @@ -77,7 +52,7 @@ asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
1986 if (a.offset & ~PAGE_MASK)
1987 goto out;
1988
1989 - err = sys_mmap2(a.addr, a.len, a.prot, a.flags,
1990 + err = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags,
1991 a.fd, a.offset >> PAGE_SHIFT);
1992 out:
1993 return err;
1994 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
1995 index 45e00eb..8aa2057 100644
1996 --- a/arch/x86/kernel/sys_x86_64.c
1997 +++ b/arch/x86/kernel/sys_x86_64.c
1998 @@ -23,26 +23,11 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
1999 unsigned long, fd, unsigned long, off)
2000 {
2001 long error;
2002 - struct file *file;
2003 -
2004 error = -EINVAL;
2005 if (off & ~PAGE_MASK)
2006 goto out;
2007
2008 - error = -EBADF;
2009 - file = NULL;
2010 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
2011 - if (!(flags & MAP_ANONYMOUS)) {
2012 - file = fget(fd);
2013 - if (!file)
2014 - goto out;
2015 - }
2016 - down_write(&current->mm->mmap_sem);
2017 - error = do_mmap_pgoff(file, addr, len, prot, flags, off >> PAGE_SHIFT);
2018 - up_write(&current->mm->mmap_sem);
2019 -
2020 - if (file)
2021 - fput(file);
2022 + error = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
2023 out:
2024 return error;
2025 }
2026 diff --git a/arch/x86/kernel/syscall_table_32.S b/arch/x86/kernel/syscall_table_32.S
2027 index 0157cd2..76d70a4 100644
2028 --- a/arch/x86/kernel/syscall_table_32.S
2029 +++ b/arch/x86/kernel/syscall_table_32.S
2030 @@ -191,7 +191,7 @@ ENTRY(sys_call_table)
2031 .long sys_ni_syscall /* reserved for streams2 */
2032 .long ptregs_vfork /* 190 */
2033 .long sys_getrlimit
2034 - .long sys_mmap2
2035 + .long sys_mmap_pgoff
2036 .long sys_truncate64
2037 .long sys_ftruncate64
2038 .long sys_stat64 /* 195 */
2039 diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/syscall.h
2040 index 05cebf8..4352dbe 100644
2041 --- a/arch/xtensa/include/asm/syscall.h
2042 +++ b/arch/xtensa/include/asm/syscall.h
2043 @@ -13,8 +13,6 @@ struct sigaction;
2044 asmlinkage long xtensa_execve(char*, char**, char**, struct pt_regs*);
2045 asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*);
2046 asmlinkage long xtensa_pipe(int __user *);
2047 -asmlinkage long xtensa_mmap2(unsigned long, unsigned long, unsigned long,
2048 - unsigned long, unsigned long, unsigned long);
2049 asmlinkage long xtensa_ptrace(long, long, long, long);
2050 asmlinkage long xtensa_sigreturn(struct pt_regs*);
2051 asmlinkage long xtensa_rt_sigreturn(struct pt_regs*);
2052 diff --git a/arch/xtensa/include/asm/unistd.h b/arch/xtensa/include/asm/unistd.h
2053 index c092c8f..9a5c354 100644
2054 --- a/arch/xtensa/include/asm/unistd.h
2055 +++ b/arch/xtensa/include/asm/unistd.h
2056 @@ -189,7 +189,7 @@ __SYSCALL( 79, sys_fremovexattr, 2)
2057 /* File Map / Shared Memory Operations */
2058
2059 #define __NR_mmap2 80
2060 -__SYSCALL( 80, xtensa_mmap2, 6)
2061 +__SYSCALL( 80, sys_mmap_pgoff, 6)
2062 #define __NR_munmap 81
2063 __SYSCALL( 81, sys_munmap, 2)
2064 #define __NR_mprotect 82
2065 diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c
2066 index ac15ecb..1e67bab 100644
2067 --- a/arch/xtensa/kernel/syscall.c
2068 +++ b/arch/xtensa/kernel/syscall.c
2069 @@ -57,31 +57,6 @@ asmlinkage long xtensa_pipe(int __user *userfds)
2070 return error;
2071 }
2072
2073 -
2074 -asmlinkage long xtensa_mmap2(unsigned long addr, unsigned long len,
2075 - unsigned long prot, unsigned long flags,
2076 - unsigned long fd, unsigned long pgoff)
2077 -{
2078 - int error = -EBADF;
2079 - struct file * file = NULL;
2080 -
2081 - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
2082 - if (!(flags & MAP_ANONYMOUS)) {
2083 - file = fget(fd);
2084 - if (!file)
2085 - goto out;
2086 - }
2087 -
2088 - down_write(&current->mm->mmap_sem);
2089 - error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
2090 - up_write(&current->mm->mmap_sem);
2091 -
2092 - if (file)
2093 - fput(file);
2094 -out:
2095 - return error;
2096 -}
2097 -
2098 asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
2099 {
2100 unsigned long ret;
2101 diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
2102 index 3cb56a0..4dcfef0 100644
2103 --- a/drivers/char/agp/intel-agp.c
2104 +++ b/drivers/char/agp/intel-agp.c
2105 @@ -178,6 +178,7 @@ static struct _intel_private {
2106 * popup and for the GTT.
2107 */
2108 int gtt_entries; /* i830+ */
2109 + int gtt_total_size;
2110 union {
2111 void __iomem *i9xx_flush_page;
2112 void *i8xx_flush_page;
2113 @@ -1153,7 +1154,7 @@ static int intel_i915_configure(void)
2114 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
2115
2116 if (agp_bridge->driver->needs_scratch_page) {
2117 - for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
2118 + for (i = intel_private.gtt_entries; i < intel_private.gtt_total_size; i++) {
2119 writel(agp_bridge->scratch_page, intel_private.gtt+i);
2120 }
2121 readl(intel_private.gtt+i-1); /* PCI Posting. */
2122 @@ -1308,6 +1309,8 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
2123 if (!intel_private.gtt)
2124 return -ENOMEM;
2125
2126 + intel_private.gtt_total_size = gtt_map_size / 4;
2127 +
2128 temp &= 0xfff80000;
2129
2130 intel_private.registers = ioremap(temp, 128 * 4096);
2131 @@ -1395,6 +1398,8 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
2132 if (!intel_private.gtt)
2133 return -ENOMEM;
2134
2135 + intel_private.gtt_total_size = gtt_size / 4;
2136 +
2137 intel_private.registers = ioremap(temp, 128 * 4096);
2138 if (!intel_private.registers) {
2139 iounmap(intel_private.gtt);
2140 diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
2141 index 6810443..73655ae 100644
2142 --- a/drivers/cpuidle/governors/menu.c
2143 +++ b/drivers/cpuidle/governors/menu.c
2144 @@ -18,6 +18,7 @@
2145 #include <linux/hrtimer.h>
2146 #include <linux/tick.h>
2147 #include <linux/sched.h>
2148 +#include <linux/math64.h>
2149
2150 #define BUCKETS 12
2151 #define RESOLUTION 1024
2152 @@ -169,6 +170,12 @@ static DEFINE_PER_CPU(struct menu_device, menu_devices);
2153
2154 static void menu_update(struct cpuidle_device *dev);
2155
2156 +/* This implements DIV_ROUND_CLOSEST but avoids 64 bit division */
2157 +static u64 div_round64(u64 dividend, u32 divisor)
2158 +{
2159 + return div_u64(dividend + (divisor / 2), divisor);
2160 +}
2161 +
2162 /**
2163 * menu_select - selects the next idle state to enter
2164 * @dev: the CPU
2165 @@ -209,9 +216,8 @@ static int menu_select(struct cpuidle_device *dev)
2166 data->correction_factor[data->bucket] = RESOLUTION * DECAY;
2167
2168 /* Make sure to round up for half microseconds */
2169 - data->predicted_us = DIV_ROUND_CLOSEST(
2170 - data->expected_us * data->correction_factor[data->bucket],
2171 - RESOLUTION * DECAY);
2172 + data->predicted_us = div_round64(data->expected_us * data->correction_factor[data->bucket],
2173 + RESOLUTION * DECAY);
2174
2175 /*
2176 * We want to default to C1 (hlt), not to busy polling
2177 diff --git a/drivers/gpu/drm/ati_pcigart.c b/drivers/gpu/drm/ati_pcigart.c
2178 index 628eae3..a1fce68 100644
2179 --- a/drivers/gpu/drm/ati_pcigart.c
2180 +++ b/drivers/gpu/drm/ati_pcigart.c
2181 @@ -39,8 +39,7 @@ static int drm_ati_alloc_pcigart_table(struct drm_device *dev,
2182 struct drm_ati_pcigart_info *gart_info)
2183 {
2184 gart_info->table_handle = drm_pci_alloc(dev, gart_info->table_size,
2185 - PAGE_SIZE,
2186 - gart_info->table_mask);
2187 + PAGE_SIZE);
2188 if (gart_info->table_handle == NULL)
2189 return -ENOMEM;
2190
2191 @@ -112,6 +111,13 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
2192 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
2193 DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n");
2194
2195 + if (pci_set_dma_mask(dev->pdev, gart_info->table_mask)) {
2196 + DRM_ERROR("fail to set dma mask to 0x%Lx\n",
2197 + gart_info->table_mask);
2198 + ret = 1;
2199 + goto done;
2200 + }
2201 +
2202 ret = drm_ati_alloc_pcigart_table(dev, gart_info);
2203 if (ret) {
2204 DRM_ERROR("cannot allocate PCI GART page!\n");
2205 diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
2206 index 3d09e30..8417cc4 100644
2207 --- a/drivers/gpu/drm/drm_bufs.c
2208 +++ b/drivers/gpu/drm/drm_bufs.c
2209 @@ -326,7 +326,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
2210 * As we're limiting the address to 2^32-1 (or less),
2211 * casting it down to 32 bits is no problem, but we
2212 * need to point to a 64bit variable first. */
2213 - dmah = drm_pci_alloc(dev, map->size, map->size, 0xffffffffUL);
2214 + dmah = drm_pci_alloc(dev, map->size, map->size);
2215 if (!dmah) {
2216 kfree(map);
2217 return -ENOMEM;
2218 @@ -885,7 +885,7 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
2219
2220 while (entry->buf_count < count) {
2221
2222 - dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000, 0xfffffffful);
2223 + dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000);
2224
2225 if (!dmah) {
2226 /* Set count correctly so we free the proper amount. */
2227 diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
2228 index 577094f..e68ebf9 100644
2229 --- a/drivers/gpu/drm/drm_pci.c
2230 +++ b/drivers/gpu/drm/drm_pci.c
2231 @@ -47,8 +47,7 @@
2232 /**
2233 * \brief Allocate a PCI consistent memory block, for DMA.
2234 */
2235 -drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t align,
2236 - dma_addr_t maxaddr)
2237 +drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t align)
2238 {
2239 drm_dma_handle_t *dmah;
2240 #if 1
2241 @@ -63,11 +62,6 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
2242 if (align > size)
2243 return NULL;
2244
2245 - if (pci_set_dma_mask(dev->pdev, maxaddr) != 0) {
2246 - DRM_ERROR("Setting pci dma mask failed\n");
2247 - return NULL;
2248 - }
2249 -
2250 dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL);
2251 if (!dmah)
2252 return NULL;
2253 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
2254 index e5b138b..bc2db7d 100644
2255 --- a/drivers/gpu/drm/i915/i915_dma.c
2256 +++ b/drivers/gpu/drm/i915/i915_dma.c
2257 @@ -123,7 +123,7 @@ static int i915_init_phys_hws(struct drm_device *dev)
2258 drm_i915_private_t *dev_priv = dev->dev_private;
2259 /* Program Hardware Status Page */
2260 dev_priv->status_page_dmah =
2261 - drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff);
2262 + drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE);
2263
2264 if (!dev_priv->status_page_dmah) {
2265 DRM_ERROR("Can not allocate hardware status page\n");
2266 @@ -1111,7 +1111,8 @@ static void i915_setup_compression(struct drm_device *dev, int size)
2267 {
2268 struct drm_i915_private *dev_priv = dev->dev_private;
2269 struct drm_mm_node *compressed_fb, *compressed_llb;
2270 - unsigned long cfb_base, ll_base;
2271 + unsigned long cfb_base;
2272 + unsigned long ll_base = 0;
2273
2274 /* Leave 1M for line length buffer & misc. */
2275 compressed_fb = drm_mm_search_free(&dev_priv->vram, size, 4096, 0);
2276 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
2277 index ecbafd0..791fded 100644
2278 --- a/drivers/gpu/drm/i915/i915_drv.h
2279 +++ b/drivers/gpu/drm/i915/i915_drv.h
2280 @@ -546,6 +546,7 @@ typedef struct drm_i915_private {
2281 struct timer_list idle_timer;
2282 bool busy;
2283 u16 orig_clock;
2284 + struct drm_connector *int_lvds_connector;
2285 } drm_i915_private_t;
2286
2287 /** driver private structure attached to each drm_gem_object */
2288 diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
2289 index 5ddbd38..df2c625 100644
2290 --- a/drivers/gpu/drm/i915/i915_gem.c
2291 +++ b/drivers/gpu/drm/i915/i915_gem.c
2292 @@ -2010,9 +2010,6 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
2293 /* blow away mappings if mapped through GTT */
2294 i915_gem_release_mmap(obj);
2295
2296 - if (obj_priv->fence_reg != I915_FENCE_REG_NONE)
2297 - i915_gem_clear_fence_reg(obj);
2298 -
2299 /* Move the object to the CPU domain to ensure that
2300 * any possible CPU writes while it's not in the GTT
2301 * are flushed when we go to remap it. This will
2302 @@ -2028,6 +2025,10 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
2303
2304 BUG_ON(obj_priv->active);
2305
2306 + /* release the fence reg _after_ flushing */
2307 + if (obj_priv->fence_reg != I915_FENCE_REG_NONE)
2308 + i915_gem_clear_fence_reg(obj);
2309 +
2310 if (obj_priv->agp_mem != NULL) {
2311 drm_unbind_agp(obj_priv->agp_mem);
2312 drm_free_agp(obj_priv->agp_mem, obj->size / PAGE_SIZE);
2313 @@ -2570,9 +2571,6 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
2314 bool retry_alloc = false;
2315 int ret;
2316
2317 - if (dev_priv->mm.suspended)
2318 - return -EBUSY;
2319 -
2320 if (obj_priv->madv != I915_MADV_WILLNEED) {
2321 DRM_ERROR("Attempting to bind a purgeable object\n");
2322 return -EINVAL;
2323 @@ -4639,7 +4637,7 @@ int i915_gem_init_phys_object(struct drm_device *dev,
2324
2325 phys_obj->id = id;
2326
2327 - phys_obj->handle = drm_pci_alloc(dev, size, 0, 0xffffffff);
2328 + phys_obj->handle = drm_pci_alloc(dev, size, 0);
2329 if (!phys_obj->handle) {
2330 ret = -ENOMEM;
2331 goto kfree_obj;
2332 diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
2333 index 1687edf..54e5907 100644
2334 --- a/drivers/gpu/drm/i915/i915_reg.h
2335 +++ b/drivers/gpu/drm/i915/i915_reg.h
2336 @@ -968,6 +968,8 @@
2337 #define LVDS_PORT_EN (1 << 31)
2338 /* Selects pipe B for LVDS data. Must be set on pre-965. */
2339 #define LVDS_PIPEB_SELECT (1 << 30)
2340 +/* LVDS dithering flag on 965/g4x platform */
2341 +#define LVDS_ENABLE_DITHER (1 << 25)
2342 /* Enable border for unscaled (or aspect-scaled) display */
2343 #define LVDS_BORDER_ENABLE (1 << 15)
2344 /*
2345 @@ -1737,6 +1739,8 @@
2346
2347 /* Display & cursor control */
2348
2349 +/* dithering flag on Ironlake */
2350 +#define PIPE_ENABLE_DITHER (1 << 4)
2351 /* Pipe A */
2352 #define PIPEADSL 0x70000
2353 #define PIPEACONF 0x70008
2354 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
2355 index f1de53b..121b92e 100644
2356 --- a/drivers/gpu/drm/i915/intel_display.c
2357 +++ b/drivers/gpu/drm/i915/intel_display.c
2358 @@ -1473,6 +1473,10 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
2359 int trans_vsync_reg = (pipe == 0) ? TRANS_VSYNC_A : TRANS_VSYNC_B;
2360 u32 temp;
2361 int tries = 5, j, n;
2362 + u32 pipe_bpc;
2363 +
2364 + temp = I915_READ(pipeconf_reg);
2365 + pipe_bpc = temp & PIPE_BPC_MASK;
2366
2367 /* XXX: When our outputs are all unaware of DPMS modes other than off
2368 * and on, we should map those modes to DRM_MODE_DPMS_OFF in the CRTC.
2369 @@ -1504,6 +1508,12 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
2370
2371 /* enable PCH FDI RX PLL, wait warmup plus DMI latency */
2372 temp = I915_READ(fdi_rx_reg);
2373 + /*
2374 + * make the BPC in FDI Rx be consistent with that in
2375 + * pipeconf reg.
2376 + */
2377 + temp &= ~(0x7 << 16);
2378 + temp |= (pipe_bpc << 11);
2379 I915_WRITE(fdi_rx_reg, temp | FDI_RX_PLL_ENABLE |
2380 FDI_SEL_PCDCLK |
2381 FDI_DP_PORT_WIDTH_X4); /* default 4 lanes */
2382 @@ -1644,6 +1654,12 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
2383
2384 /* enable PCH transcoder */
2385 temp = I915_READ(transconf_reg);
2386 + /*
2387 + * make the BPC in transcoder be consistent with
2388 + * that in pipeconf reg.
2389 + */
2390 + temp &= ~PIPE_BPC_MASK;
2391 + temp |= pipe_bpc;
2392 I915_WRITE(transconf_reg, temp | TRANS_ENABLE);
2393 I915_READ(transconf_reg);
2394
2395 @@ -1722,6 +1738,9 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
2396 I915_READ(fdi_tx_reg);
2397
2398 temp = I915_READ(fdi_rx_reg);
2399 + /* BPC in FDI rx is consistent with that in pipeconf */
2400 + temp &= ~(0x07 << 16);
2401 + temp |= (pipe_bpc << 11);
2402 I915_WRITE(fdi_rx_reg, temp & ~FDI_RX_ENABLE);
2403 I915_READ(fdi_rx_reg);
2404
2405 @@ -1765,7 +1784,12 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
2406 }
2407 }
2408 }
2409 -
2410 + temp = I915_READ(transconf_reg);
2411 + /* BPC in transcoder is consistent with that in pipeconf */
2412 + temp &= ~PIPE_BPC_MASK;
2413 + temp |= pipe_bpc;
2414 + I915_WRITE(transconf_reg, temp);
2415 + I915_READ(transconf_reg);
2416 udelay(100);
2417
2418 /* disable PCH DPLL */
2419 @@ -2877,6 +2901,18 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2420
2421 /* determine panel color depth */
2422 temp = I915_READ(pipeconf_reg);
2423 + temp &= ~PIPE_BPC_MASK;
2424 + if (is_lvds) {
2425 + int lvds_reg = I915_READ(PCH_LVDS);
2426 + /* the BPC will be 6 if it is 18-bit LVDS panel */
2427 + if ((lvds_reg & LVDS_A3_POWER_MASK) == LVDS_A3_POWER_UP)
2428 + temp |= PIPE_8BPC;
2429 + else
2430 + temp |= PIPE_6BPC;
2431 + } else
2432 + temp |= PIPE_8BPC;
2433 + I915_WRITE(pipeconf_reg, temp);
2434 + I915_READ(pipeconf_reg);
2435
2436 switch (temp & PIPE_BPC_MASK) {
2437 case PIPE_8BPC:
2438 @@ -3104,7 +3140,20 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2439 * appropriately here, but we need to look more thoroughly into how
2440 * panels behave in the two modes.
2441 */
2442 -
2443 + /* set the dithering flag */
2444 + if (IS_I965G(dev)) {
2445 + if (dev_priv->lvds_dither) {
2446 + if (IS_IGDNG(dev))
2447 + pipeconf |= PIPE_ENABLE_DITHER;
2448 + else
2449 + lvds |= LVDS_ENABLE_DITHER;
2450 + } else {
2451 + if (IS_IGDNG(dev))
2452 + pipeconf &= ~PIPE_ENABLE_DITHER;
2453 + else
2454 + lvds &= ~LVDS_ENABLE_DITHER;
2455 + }
2456 + }
2457 I915_WRITE(lvds_reg, lvds);
2458 I915_READ(lvds_reg);
2459 }
2460 @@ -3688,125 +3737,6 @@ static void intel_gpu_idle_timer(unsigned long arg)
2461 queue_work(dev_priv->wq, &dev_priv->idle_work);
2462 }
2463
2464 -void intel_increase_renderclock(struct drm_device *dev, bool schedule)
2465 -{
2466 - drm_i915_private_t *dev_priv = dev->dev_private;
2467 -
2468 - if (IS_IGDNG(dev))
2469 - return;
2470 -
2471 - if (!dev_priv->render_reclock_avail) {
2472 - DRM_DEBUG("not reclocking render clock\n");
2473 - return;
2474 - }
2475 -
2476 - /* Restore render clock frequency to original value */
2477 - if (IS_G4X(dev) || IS_I9XX(dev))
2478 - pci_write_config_word(dev->pdev, GCFGC, dev_priv->orig_clock);
2479 - else if (IS_I85X(dev))
2480 - pci_write_config_word(dev->pdev, HPLLCC, dev_priv->orig_clock);
2481 - DRM_DEBUG("increasing render clock frequency\n");
2482 -
2483 - /* Schedule downclock */
2484 - if (schedule)
2485 - mod_timer(&dev_priv->idle_timer, jiffies +
2486 - msecs_to_jiffies(GPU_IDLE_TIMEOUT));
2487 -}
2488 -
2489 -void intel_decrease_renderclock(struct drm_device *dev)
2490 -{
2491 - drm_i915_private_t *dev_priv = dev->dev_private;
2492 -
2493 - if (IS_IGDNG(dev))
2494 - return;
2495 -
2496 - if (!dev_priv->render_reclock_avail) {
2497 - DRM_DEBUG("not reclocking render clock\n");
2498 - return;
2499 - }
2500 -
2501 - if (IS_G4X(dev)) {
2502 - u16 gcfgc;
2503 -
2504 - /* Adjust render clock... */
2505 - pci_read_config_word(dev->pdev, GCFGC, &gcfgc);
2506 -
2507 - /* Down to minimum... */
2508 - gcfgc &= ~GM45_GC_RENDER_CLOCK_MASK;
2509 - gcfgc |= GM45_GC_RENDER_CLOCK_266_MHZ;
2510 -
2511 - pci_write_config_word(dev->pdev, GCFGC, gcfgc);
2512 - } else if (IS_I965G(dev)) {
2513 - u16 gcfgc;
2514 -
2515 - /* Adjust render clock... */
2516 - pci_read_config_word(dev->pdev, GCFGC, &gcfgc);
2517 -
2518 - /* Down to minimum... */
2519 - gcfgc &= ~I965_GC_RENDER_CLOCK_MASK;
2520 - gcfgc |= I965_GC_RENDER_CLOCK_267_MHZ;
2521 -
2522 - pci_write_config_word(dev->pdev, GCFGC, gcfgc);
2523 - } else if (IS_I945G(dev) || IS_I945GM(dev)) {
2524 - u16 gcfgc;
2525 -
2526 - /* Adjust render clock... */
2527 - pci_read_config_word(dev->pdev, GCFGC, &gcfgc);
2528 -
2529 - /* Down to minimum... */
2530 - gcfgc &= ~I945_GC_RENDER_CLOCK_MASK;
2531 - gcfgc |= I945_GC_RENDER_CLOCK_166_MHZ;
2532 -
2533 - pci_write_config_word(dev->pdev, GCFGC, gcfgc);
2534 - } else if (IS_I915G(dev)) {
2535 - u16 gcfgc;
2536 -
2537 - /* Adjust render clock... */
2538 - pci_read_config_word(dev->pdev, GCFGC, &gcfgc);
2539 -
2540 - /* Down to minimum... */
2541 - gcfgc &= ~I915_GC_RENDER_CLOCK_MASK;
2542 - gcfgc |= I915_GC_RENDER_CLOCK_166_MHZ;
2543 -
2544 - pci_write_config_word(dev->pdev, GCFGC, gcfgc);
2545 - } else if (IS_I85X(dev)) {
2546 - u16 hpllcc;
2547 -
2548 - /* Adjust render clock... */
2549 - pci_read_config_word(dev->pdev, HPLLCC, &hpllcc);
2550 -
2551 - /* Up to maximum... */
2552 - hpllcc &= ~GC_CLOCK_CONTROL_MASK;
2553 - hpllcc |= GC_CLOCK_133_200;
2554 -
2555 - pci_write_config_word(dev->pdev, HPLLCC, hpllcc);
2556 - }
2557 - DRM_DEBUG("decreasing render clock frequency\n");
2558 -}
2559 -
2560 -/* Note that no increase function is needed for this - increase_renderclock()
2561 - * will also rewrite these bits
2562 - */
2563 -void intel_decrease_displayclock(struct drm_device *dev)
2564 -{
2565 - if (IS_IGDNG(dev))
2566 - return;
2567 -
2568 - if (IS_I945G(dev) || IS_I945GM(dev) || IS_I915G(dev) ||
2569 - IS_I915GM(dev)) {
2570 - u16 gcfgc;
2571 -
2572 - /* Adjust render clock... */
2573 - pci_read_config_word(dev->pdev, GCFGC, &gcfgc);
2574 -
2575 - /* Down to minimum... */
2576 - gcfgc &= ~0xf0;
2577 - gcfgc |= 0x80;
2578 -
2579 - pci_write_config_word(dev->pdev, GCFGC, gcfgc);
2580 - }
2581 -}
2582 -
2583 #define CRTC_IDLE_TIMEOUT 1000 /* ms */
2584
2585 static void intel_crtc_idle_timer(unsigned long arg)
2586 @@ -3920,12 +3850,6 @@ static void intel_idle_update(struct work_struct *work)
2587
2588 mutex_lock(&dev->struct_mutex);
2589
2590 - /* GPU isn't processing, downclock it. */
2591 - if (!dev_priv->busy) {
2592 - intel_decrease_renderclock(dev);
2593 - intel_decrease_displayclock(dev);
2594 - }
2595 -
2596 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
2597 /* Skip inactive CRTCs */
2598 if (!crtc->fb)
2599 @@ -3960,7 +3884,6 @@ void intel_mark_busy(struct drm_device *dev, struct drm_gem_object *obj)
2600 return;
2601
2602 dev_priv->busy = true;
2603 - intel_increase_renderclock(dev, true);
2604
2605 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
2606 if (!crtc->fb)
2607 @@ -4465,7 +4388,6 @@ void intel_modeset_cleanup(struct drm_device *dev)
2608 del_timer_sync(&intel_crtc->idle_timer);
2609 }
2610
2611 - intel_increase_renderclock(dev, false);
2612 del_timer_sync(&dev_priv->idle_timer);
2613
2614 mutex_unlock(&dev->struct_mutex);
2615 diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
2616 index 05598ae..0e0e4b4 100644
2617 --- a/drivers/gpu/drm/i915/intel_lvds.c
2618 +++ b/drivers/gpu/drm/i915/intel_lvds.c
2619 @@ -679,7 +679,14 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
2620 struct drm_i915_private *dev_priv =
2621 container_of(nb, struct drm_i915_private, lid_notifier);
2622 struct drm_device *dev = dev_priv->dev;
2623 + struct drm_connector *connector = dev_priv->int_lvds_connector;
2624
2625 + /*
2626 + * check and update the status of LVDS connector after receiving
2627 + * the LID nofication event.
2628 + */
2629 + if (connector)
2630 + connector->status = connector->funcs->detect(connector);
2631 if (!acpi_lid_open()) {
2632 dev_priv->modeset_on_lid = 1;
2633 return NOTIFY_OK;
2634 @@ -1085,6 +1092,8 @@ out:
2635 DRM_DEBUG("lid notifier registration failed\n");
2636 dev_priv->lid_notifier.notifier_call = NULL;
2637 }
2638 + /* keep the LVDS connector */
2639 + dev_priv->int_lvds_connector = connector;
2640 drm_sysfs_connector_add(connector);
2641 return;
2642
2643 diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
2644 index 700e93a..c1f7ea0 100644
2645 --- a/drivers/hwmon/Kconfig
2646 +++ b/drivers/hwmon/Kconfig
2647 @@ -374,7 +374,7 @@ config SENSORS_GL520SM
2648
2649 config SENSORS_CORETEMP
2650 tristate "Intel Core/Core2/Atom temperature sensor"
2651 - depends on X86 && EXPERIMENTAL
2652 + depends on X86 && PCI && EXPERIMENTAL
2653 help
2654 If you say yes here you get support for the temperature
2655 sensor inside your CPU. Most of the family 6 CPUs
2656 diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c
2657 index 1852f27..262c133 100644
2658 --- a/drivers/hwmon/adt7462.c
2659 +++ b/drivers/hwmon/adt7462.c
2660 @@ -97,7 +97,7 @@ I2C_CLIENT_INSMOD_1(adt7462);
2661 #define ADT7462_PIN24_SHIFT 6
2662 #define ADT7462_PIN26_VOLT_INPUT 0x08
2663 #define ADT7462_PIN25_VOLT_INPUT 0x20
2664 -#define ADT7462_PIN28_SHIFT 6 /* cfg3 */
2665 +#define ADT7462_PIN28_SHIFT 4 /* cfg3 */
2666 #define ADT7462_PIN28_VOLT 0x5
2667
2668 #define ADT7462_REG_ALARM1 0xB8
2669 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
2670 index caef39c..2d7bcee 100644
2671 --- a/drivers/hwmon/coretemp.c
2672 +++ b/drivers/hwmon/coretemp.c
2673 @@ -33,6 +33,7 @@
2674 #include <linux/list.h>
2675 #include <linux/platform_device.h>
2676 #include <linux/cpu.h>
2677 +#include <linux/pci.h>
2678 #include <asm/msr.h>
2679 #include <asm/processor.h>
2680
2681 @@ -161,6 +162,7 @@ static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *
2682 int usemsr_ee = 1;
2683 int err;
2684 u32 eax, edx;
2685 + struct pci_dev *host_bridge;
2686
2687 /* Early chips have no MSR for TjMax */
2688
2689 @@ -168,11 +170,21 @@ static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *
2690 usemsr_ee = 0;
2691 }
2692
2693 - /* Atoms seems to have TjMax at 90C */
2694 + /* Atom CPUs */
2695
2696 if (c->x86_model == 0x1c) {
2697 usemsr_ee = 0;
2698 - tjmax = 90000;
2699 +
2700 + host_bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
2701 +
2702 + if (host_bridge && host_bridge->vendor == PCI_VENDOR_ID_INTEL
2703 + && (host_bridge->device == 0xa000 /* NM10 based nettop */
2704 + || host_bridge->device == 0xa010)) /* NM10 based netbook */
2705 + tjmax = 100000;
2706 + else
2707 + tjmax = 90000;
2708 +
2709 + pci_dev_put(host_bridge);
2710 }
2711
2712 if ((c->x86_model > 0xe) && (usemsr_ee)) {
2713 diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
2714 index 85f0e8c..1f552c6 100644
2715 --- a/drivers/mmc/card/block.c
2716 +++ b/drivers/mmc/card/block.c
2717 @@ -85,7 +85,14 @@ static void mmc_blk_put(struct mmc_blk_data *md)
2718 mutex_lock(&open_lock);
2719 md->usage--;
2720 if (md->usage == 0) {
2721 + int devmaj = MAJOR(disk_devt(md->disk));
2722 int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT;
2723 +
2724 + if (!devmaj)
2725 + devidx = md->disk->first_minor >> MMC_SHIFT;
2726 +
2727 + blk_cleanup_queue(md->queue.queue);
2728 +
2729 __clear_bit(devidx, dev_use);
2730
2731 put_disk(md->disk);
2732 @@ -613,6 +620,7 @@ static int mmc_blk_probe(struct mmc_card *card)
2733 return 0;
2734
2735 out:
2736 + mmc_cleanup_queue(&md->queue);
2737 mmc_blk_put(md);
2738
2739 return err;
2740 diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
2741 index 49e5823..c5a7a85 100644
2742 --- a/drivers/mmc/card/queue.c
2743 +++ b/drivers/mmc/card/queue.c
2744 @@ -90,9 +90,10 @@ static void mmc_request(struct request_queue *q)
2745 struct request *req;
2746
2747 if (!mq) {
2748 - printk(KERN_ERR "MMC: killing requests for dead queue\n");
2749 - while ((req = blk_fetch_request(q)) != NULL)
2750 + while ((req = blk_fetch_request(q)) != NULL) {
2751 + req->cmd_flags |= REQ_QUIET;
2752 __blk_end_request_all(req, -EIO);
2753 + }
2754 return;
2755 }
2756
2757 @@ -223,17 +224,18 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
2758 struct request_queue *q = mq->queue;
2759 unsigned long flags;
2760
2761 - /* Mark that we should start throwing out stragglers */
2762 - spin_lock_irqsave(q->queue_lock, flags);
2763 - q->queuedata = NULL;
2764 - spin_unlock_irqrestore(q->queue_lock, flags);
2765 -
2766 /* Make sure the queue isn't suspended, as that will deadlock */
2767 mmc_queue_resume(mq);
2768
2769 /* Then terminate our worker thread */
2770 kthread_stop(mq->thread);
2771
2772 + /* Empty the queue */
2773 + spin_lock_irqsave(q->queue_lock, flags);
2774 + q->queuedata = NULL;
2775 + blk_start_queue(q);
2776 + spin_unlock_irqrestore(q->queue_lock, flags);
2777 +
2778 if (mq->bounce_sg)
2779 kfree(mq->bounce_sg);
2780 mq->bounce_sg = NULL;
2781 @@ -245,8 +247,6 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
2782 kfree(mq->bounce_buf);
2783 mq->bounce_buf = NULL;
2784
2785 - blk_cleanup_queue(mq->queue);
2786 -
2787 mq->card = NULL;
2788 }
2789 EXPORT_SYMBOL(mmc_cleanup_queue);
2790 diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
2791 index 7918852..9a96550 100644
2792 --- a/drivers/net/wireless/ath/ath5k/eeprom.c
2793 +++ b/drivers/net/wireless/ath/ath5k/eeprom.c
2794 @@ -97,7 +97,7 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
2795 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
2796 int ret;
2797 u16 val;
2798 - u32 cksum, offset;
2799 + u32 cksum, offset, eep_max = AR5K_EEPROM_INFO_MAX;
2800
2801 /*
2802 * Read values from EEPROM and store them in the capability structure
2803 @@ -116,12 +116,38 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
2804 * Validate the checksum of the EEPROM date. There are some
2805 * devices with invalid EEPROMs.
2806 */
2807 - for (cksum = 0, offset = 0; offset < AR5K_EEPROM_INFO_MAX; offset++) {
2808 + AR5K_EEPROM_READ(AR5K_EEPROM_SIZE_UPPER, val);
2809 + if (val) {
2810 + eep_max = (val & AR5K_EEPROM_SIZE_UPPER_MASK) <<
2811 + AR5K_EEPROM_SIZE_ENDLOC_SHIFT;
2812 + AR5K_EEPROM_READ(AR5K_EEPROM_SIZE_LOWER, val);
2813 + eep_max = (eep_max | val) - AR5K_EEPROM_INFO_BASE;
2814 +
2815 + /*
2816 + * Fail safe check to prevent stupid loops due
2817 + * to busted EEPROMs. XXX: This value is likely too
2818 + * big still, waiting on a better value.
2819 + */
2820 + if (eep_max > (3 * AR5K_EEPROM_INFO_MAX)) {
2821 + ATH5K_ERR(ah->ah_sc, "Invalid max custom EEPROM size: "
2822 + "%d (0x%04x) max expected: %d (0x%04x)\n",
2823 + eep_max, eep_max,
2824 + 3 * AR5K_EEPROM_INFO_MAX,
2825 + 3 * AR5K_EEPROM_INFO_MAX);
2826 + return -EIO;
2827 + }
2828 + }
2829 +
2830 + for (cksum = 0, offset = 0; offset < eep_max; offset++) {
2831 AR5K_EEPROM_READ(AR5K_EEPROM_INFO(offset), val);
2832 cksum ^= val;
2833 }
2834 if (cksum != AR5K_EEPROM_INFO_CKSUM) {
2835 - ATH5K_ERR(ah->ah_sc, "Invalid EEPROM checksum 0x%04x\n", cksum);
2836 + ATH5K_ERR(ah->ah_sc, "Invalid EEPROM "
2837 + "checksum: 0x%04x eep_max: 0x%04x (%s)\n",
2838 + cksum, eep_max,
2839 + eep_max == AR5K_EEPROM_INFO_MAX ?
2840 + "default size" : "custom size");
2841 return -EIO;
2842 }
2843
2844 diff --git a/drivers/net/wireless/ath/ath5k/eeprom.h b/drivers/net/wireless/ath/ath5k/eeprom.h
2845 index 0123f35..473a483 100644
2846 --- a/drivers/net/wireless/ath/ath5k/eeprom.h
2847 +++ b/drivers/net/wireless/ath/ath5k/eeprom.h
2848 @@ -37,6 +37,14 @@
2849 #define AR5K_EEPROM_RFKILL_POLARITY_S 1
2850
2851 #define AR5K_EEPROM_REG_DOMAIN 0x00bf /* EEPROM regdom */
2852 +
2853 +/* FLASH(EEPROM) Defines for AR531X chips */
2854 +#define AR5K_EEPROM_SIZE_LOWER 0x1b /* size info -- lower */
2855 +#define AR5K_EEPROM_SIZE_UPPER 0x1c /* size info -- upper */
2856 +#define AR5K_EEPROM_SIZE_UPPER_MASK 0xfff0
2857 +#define AR5K_EEPROM_SIZE_UPPER_SHIFT 4
2858 +#define AR5K_EEPROM_SIZE_ENDLOC_SHIFT 12
2859 +
2860 #define AR5K_EEPROM_CHECKSUM 0x00c0 /* EEPROM checksum */
2861 #define AR5K_EEPROM_INFO_BASE 0x00c0 /* EEPROM header */
2862 #define AR5K_EEPROM_INFO_MAX (0x400 - AR5K_EEPROM_INFO_BASE)
2863 diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
2864 index f4e2e84..99331ed 100644
2865 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c
2866 +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
2867 @@ -2087,7 +2087,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2868 struct ieee80211_tx_info *info;
2869 struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
2870 u32 status = le32_to_cpu(tx_resp->u.status);
2871 - int tid = MAX_TID_COUNT;
2872 + int tid = MAX_TID_COUNT - 1;
2873 int sta_id;
2874 int freed;
2875 u8 *qc = NULL;
2876 diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
2877 index c2d9b7a..cea2ee2 100644
2878 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h
2879 +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
2880 @@ -703,7 +703,7 @@ extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
2881 extern int iwl_queue_space(const struct iwl_queue *q);
2882 static inline int iwl_queue_used(const struct iwl_queue *q, int i)
2883 {
2884 - return q->write_ptr > q->read_ptr ?
2885 + return q->write_ptr >= q->read_ptr ?
2886 (i >= q->read_ptr && i < q->write_ptr) :
2887 !(i < q->read_ptr && i >= q->write_ptr);
2888 }
2889 diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
2890 index 6c95af3..06d66a1 100644
2891 --- a/drivers/net/wireless/libertas/scan.c
2892 +++ b/drivers/net/wireless/libertas/scan.c
2893 @@ -399,11 +399,8 @@ int lbs_scan_networks(struct lbs_private *priv, int full_scan)
2894 chan_count = lbs_scan_create_channel_list(priv, chan_list);
2895
2896 netif_stop_queue(priv->dev);
2897 - netif_carrier_off(priv->dev);
2898 - if (priv->mesh_dev) {
2899 + if (priv->mesh_dev)
2900 netif_stop_queue(priv->mesh_dev);
2901 - netif_carrier_off(priv->mesh_dev);
2902 - }
2903
2904 /* Prepare to continue an interrupted scan */
2905 lbs_deb_scan("chan_count %d, scan_channel %d\n",
2906 @@ -467,16 +464,13 @@ out2:
2907 priv->scan_channel = 0;
2908
2909 out:
2910 - if (priv->connect_status == LBS_CONNECTED) {
2911 - netif_carrier_on(priv->dev);
2912 - if (!priv->tx_pending_len)
2913 - netif_wake_queue(priv->dev);
2914 - }
2915 - if (priv->mesh_dev && (priv->mesh_connect_status == LBS_CONNECTED)) {
2916 - netif_carrier_on(priv->mesh_dev);
2917 - if (!priv->tx_pending_len)
2918 - netif_wake_queue(priv->mesh_dev);
2919 - }
2920 + if (priv->connect_status == LBS_CONNECTED && !priv->tx_pending_len)
2921 + netif_wake_queue(priv->dev);
2922 +
2923 + if (priv->mesh_dev && (priv->mesh_connect_status == LBS_CONNECTED) &&
2924 + !priv->tx_pending_len)
2925 + netif_wake_queue(priv->mesh_dev);
2926 +
2927 kfree(chan_list);
2928
2929 lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
2930 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
2931 index f7a4701..473e5f2 100644
2932 --- a/drivers/rtc/rtc-cmos.c
2933 +++ b/drivers/rtc/rtc-cmos.c
2934 @@ -1099,9 +1099,9 @@ static int cmos_pnp_resume(struct pnp_dev *pnp)
2935 #define cmos_pnp_resume NULL
2936 #endif
2937
2938 -static void cmos_pnp_shutdown(struct device *pdev)
2939 +static void cmos_pnp_shutdown(struct pnp_dev *pnp)
2940 {
2941 - if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(pdev))
2942 + if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(&pnp->dev))
2943 return;
2944
2945 cmos_do_shutdown();
2946 @@ -1120,15 +1120,12 @@ static struct pnp_driver cmos_pnp_driver = {
2947 .id_table = rtc_ids,
2948 .probe = cmos_pnp_probe,
2949 .remove = __exit_p(cmos_pnp_remove),
2950 + .shutdown = cmos_pnp_shutdown,
2951
2952 /* flag ensures resume() gets called, and stops syslog spam */
2953 .flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
2954 .suspend = cmos_pnp_suspend,
2955 .resume = cmos_pnp_resume,
2956 - .driver = {
2957 - .name = (char *)driver_name,
2958 - .shutdown = cmos_pnp_shutdown,
2959 - }
2960 };
2961
2962 #endif /* CONFIG_PNP */
2963 diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
2964 index c499793..5d42d55 100644
2965 --- a/drivers/xen/manage.c
2966 +++ b/drivers/xen/manage.c
2967 @@ -102,15 +102,15 @@ static void do_suspend(void)
2968 goto out_thaw;
2969 }
2970
2971 + printk(KERN_DEBUG "suspending xenstore...\n");
2972 + xs_suspend();
2973 +
2974 err = dpm_suspend_noirq(PMSG_SUSPEND);
2975 if (err) {
2976 printk(KERN_ERR "dpm_suspend_noirq failed: %d\n", err);
2977 goto out_resume;
2978 }
2979
2980 - printk(KERN_DEBUG "suspending xenstore...\n");
2981 - xs_suspend();
2982 -
2983 err = stop_machine(xen_suspend, &cancelled, cpumask_of(0));
2984
2985 dpm_resume_noirq(PMSG_RESUME);
2986 @@ -120,13 +120,13 @@ static void do_suspend(void)
2987 cancelled = 1;
2988 }
2989
2990 +out_resume:
2991 if (!cancelled) {
2992 xen_arch_resume();
2993 xs_resume();
2994 } else
2995 xs_suspend_cancel();
2996
2997 -out_resume:
2998 dpm_resume_end(PMSG_RESUME);
2999
3000 /* Make sure timer events get retriggered on all CPUs */
3001 diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
3002 index 6c10f74..6f7df0f 100644
3003 --- a/fs/exofs/inode.c
3004 +++ b/fs/exofs/inode.c
3005 @@ -731,13 +731,28 @@ static int exofs_write_begin_export(struct file *file,
3006 fsdata);
3007 }
3008
3009 +static int exofs_write_end(struct file *file, struct address_space *mapping,
3010 + loff_t pos, unsigned len, unsigned copied,
3011 + struct page *page, void *fsdata)
3012 +{
3013 + struct inode *inode = mapping->host;
3014 + /* According to comment in simple_write_end i_mutex is held */
3015 + loff_t i_size = inode->i_size;
3016 + int ret;
3017 +
3018 + ret = simple_write_end(file, mapping,pos, len, copied, page, fsdata);
3019 + if (i_size != inode->i_size)
3020 + mark_inode_dirty(inode);
3021 + return ret;
3022 +}
3023 +
3024 const struct address_space_operations exofs_aops = {
3025 .readpage = exofs_readpage,
3026 .readpages = exofs_readpages,
3027 .writepage = exofs_writepage,
3028 .writepages = exofs_writepages,
3029 .write_begin = exofs_write_begin_export,
3030 - .write_end = simple_write_end,
3031 + .write_end = exofs_write_end,
3032 };
3033
3034 /******************************************************************************
3035 diff --git a/fs/fcntl.c b/fs/fcntl.c
3036 index 2cf93ec..97e01dc 100644
3037 --- a/fs/fcntl.c
3038 +++ b/fs/fcntl.c
3039 @@ -618,60 +618,90 @@ static DEFINE_RWLOCK(fasync_lock);
3040 static struct kmem_cache *fasync_cache __read_mostly;
3041
3042 /*
3043 - * fasync_helper() is used by almost all character device drivers
3044 - * to set up the fasync queue. It returns negative on error, 0 if it did
3045 - * no changes and positive if it added/deleted the entry.
3046 + * Remove a fasync entry. If successfully removed, return
3047 + * positive and clear the FASYNC flag. If no entry exists,
3048 + * do nothing and return 0.
3049 + *
3050 + * NOTE! It is very important that the FASYNC flag always
3051 + * match the state "is the filp on a fasync list".
3052 + *
3053 + * We always take the 'filp->f_lock', in since fasync_lock
3054 + * needs to be irq-safe.
3055 */
3056 -int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp)
3057 +static int fasync_remove_entry(struct file *filp, struct fasync_struct **fapp)
3058 {
3059 struct fasync_struct *fa, **fp;
3060 - struct fasync_struct *new = NULL;
3061 int result = 0;
3062
3063 - if (on) {
3064 - new = kmem_cache_alloc(fasync_cache, GFP_KERNEL);
3065 - if (!new)
3066 - return -ENOMEM;
3067 + spin_lock(&filp->f_lock);
3068 + write_lock_irq(&fasync_lock);
3069 + for (fp = fapp; (fa = *fp) != NULL; fp = &fa->fa_next) {
3070 + if (fa->fa_file != filp)
3071 + continue;
3072 + *fp = fa->fa_next;
3073 + kmem_cache_free(fasync_cache, fa);
3074 + filp->f_flags &= ~FASYNC;
3075 + result = 1;
3076 + break;
3077 }
3078 + write_unlock_irq(&fasync_lock);
3079 + spin_unlock(&filp->f_lock);
3080 + return result;
3081 +}
3082 +
3083 +/*
3084 + * Add a fasync entry. Return negative on error, positive if
3085 + * added, and zero if did nothing but change an existing one.
3086 + *
3087 + * NOTE! It is very important that the FASYNC flag always
3088 + * match the state "is the filp on a fasync list".
3089 + */
3090 +static int fasync_add_entry(int fd, struct file *filp, struct fasync_struct **fapp)
3091 +{
3092 + struct fasync_struct *new, *fa, **fp;
3093 + int result = 0;
3094 +
3095 + new = kmem_cache_alloc(fasync_cache, GFP_KERNEL);
3096 + if (!new)
3097 + return -ENOMEM;
3098
3099 - /*
3100 - * We need to take f_lock first since it's not an IRQ-safe
3101 - * lock.
3102 - */
3103 spin_lock(&filp->f_lock);
3104 write_lock_irq(&fasync_lock);
3105 for (fp = fapp; (fa = *fp) != NULL; fp = &fa->fa_next) {
3106 - if (fa->fa_file == filp) {
3107 - if(on) {
3108 - fa->fa_fd = fd;
3109 - kmem_cache_free(fasync_cache, new);
3110 - } else {
3111 - *fp = fa->fa_next;
3112 - kmem_cache_free(fasync_cache, fa);
3113 - result = 1;
3114 - }
3115 - goto out;
3116 - }
3117 + if (fa->fa_file != filp)
3118 + continue;
3119 + fa->fa_fd = fd;
3120 + kmem_cache_free(fasync_cache, new);
3121 + goto out;
3122 }
3123
3124 - if (on) {
3125 - new->magic = FASYNC_MAGIC;
3126 - new->fa_file = filp;
3127 - new->fa_fd = fd;
3128 - new->fa_next = *fapp;
3129 - *fapp = new;
3130 - result = 1;
3131 - }
3132 + new->magic = FASYNC_MAGIC;
3133 + new->fa_file = filp;
3134 + new->fa_fd = fd;
3135 + new->fa_next = *fapp;
3136 + *fapp = new;
3137 + result = 1;
3138 + filp->f_flags |= FASYNC;
3139 +
3140 out:
3141 - if (on)
3142 - filp->f_flags |= FASYNC;
3143 - else
3144 - filp->f_flags &= ~FASYNC;
3145 write_unlock_irq(&fasync_lock);
3146 spin_unlock(&filp->f_lock);
3147 return result;
3148 }
3149
3150 +/*
3151 + * fasync_helper() is used by almost all character device drivers
3152 + * to set up the fasync queue, and for regular files by the file
3153 + * lease code. It returns negative on error, 0 if it did no changes
3154 + * and positive if it added/deleted the entry.
3155 + */
3156 +int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp)
3157 +{
3158 + if (!on)
3159 + return fasync_remove_entry(filp, fapp);
3160 + return fasync_add_entry(fd, filp, fapp);
3161 +}
3162 +
3163 EXPORT_SYMBOL(fasync_helper);
3164
3165 void __kill_fasync(struct fasync_struct *fa, int sig, int band)
3166 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
3167 index a293f02..570dd1c 100644
3168 --- a/fs/nfsd/vfs.c
3169 +++ b/fs/nfsd/vfs.c
3170 @@ -774,12 +774,9 @@ static inline int nfsd_dosync(struct file *filp, struct dentry *dp,
3171 int (*fsync) (struct file *, struct dentry *, int);
3172 int err;
3173
3174 - err = filemap_fdatawrite(inode->i_mapping);
3175 + err = filemap_write_and_wait(inode->i_mapping);
3176 if (err == 0 && fop && (fsync = fop->fsync))
3177 err = fsync(filp, dp, 0);
3178 - if (err == 0)
3179 - err = filemap_fdatawait(inode->i_mapping);
3180 -
3181 return err;
3182 }
3183
3184 diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
3185 index c4d07a8..2534987 100644
3186 --- a/fs/quota/dquot.c
3187 +++ b/fs/quota/dquot.c
3188 @@ -1425,6 +1425,9 @@ static void inode_sub_rsv_space(struct inode *inode, qsize_t number)
3189 static qsize_t inode_get_rsv_space(struct inode *inode)
3190 {
3191 qsize_t ret;
3192 +
3193 + if (!inode->i_sb->dq_op->get_reserved_space)
3194 + return 0;
3195 spin_lock(&inode->i_lock);
3196 ret = *inode_reserved_space(inode);
3197 spin_unlock(&inode->i_lock);
3198 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
3199 index 9d3d684..7ad3faa 100644
3200 --- a/include/drm/drmP.h
3201 +++ b/include/drm/drmP.h
3202 @@ -1402,7 +1402,7 @@ extern int drm_ati_pcigart_cleanup(struct drm_device *dev,
3203 struct drm_ati_pcigart_info * gart_info);
3204
3205 extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
3206 - size_t align, dma_addr_t maxaddr);
3207 + size_t align);
3208 extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
3209 extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
3210
3211 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
3212 index a990ace..93515c6 100644
3213 --- a/include/linux/syscalls.h
3214 +++ b/include/linux/syscalls.h
3215 @@ -879,4 +879,8 @@ int kernel_execve(const char *filename, char *const argv[], char *const envp[]);
3216 asmlinkage long sys_perf_event_open(
3217 struct perf_event_attr __user *attr_uptr,
3218 pid_t pid, int cpu, int group_fd, unsigned long flags);
3219 +
3220 +asmlinkage long sys_mmap_pgoff(unsigned long addr, unsigned long len,
3221 + unsigned long prot, unsigned long flags,
3222 + unsigned long fd, unsigned long pgoff);
3223 #endif
3224 diff --git a/ipc/shm.c b/ipc/shm.c
3225 index 464694e..11bec62 100644
3226 --- a/ipc/shm.c
3227 +++ b/ipc/shm.c
3228 @@ -290,28 +290,28 @@ static unsigned long shm_get_unmapped_area(struct file *file,
3229 unsigned long flags)
3230 {
3231 struct shm_file_data *sfd = shm_file_data(file);
3232 - return get_unmapped_area(sfd->file, addr, len, pgoff, flags);
3233 -}
3234 -
3235 -int is_file_shm_hugepages(struct file *file)
3236 -{
3237 - int ret = 0;
3238 -
3239 - if (file->f_op == &shm_file_operations) {
3240 - struct shm_file_data *sfd;
3241 - sfd = shm_file_data(file);
3242 - ret = is_file_hugepages(sfd->file);
3243 - }
3244 - return ret;
3245 + return sfd->file->f_op->get_unmapped_area(sfd->file, addr, len,
3246 + pgoff, flags);
3247 }
3248
3249 static const struct file_operations shm_file_operations = {
3250 .mmap = shm_mmap,
3251 .fsync = shm_fsync,
3252 .release = shm_release,
3253 +};
3254 +
3255 +static const struct file_operations shm_file_operations_huge = {
3256 + .mmap = shm_mmap,
3257 + .fsync = shm_fsync,
3258 + .release = shm_release,
3259 .get_unmapped_area = shm_get_unmapped_area,
3260 };
3261
3262 +int is_file_shm_hugepages(struct file *file)
3263 +{
3264 + return file->f_op == &shm_file_operations_huge;
3265 +}
3266 +
3267 static const struct vm_operations_struct shm_vm_ops = {
3268 .open = shm_open, /* callback for a new vm-area open */
3269 .close = shm_close, /* callback for when the vm-area is released */
3270 @@ -889,7 +889,10 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
3271 if (!sfd)
3272 goto out_put_dentry;
3273
3274 - file = alloc_file(path.mnt, path.dentry, f_mode, &shm_file_operations);
3275 + file = alloc_file(path.mnt, path.dentry, f_mode,
3276 + is_file_hugepages(shp->shm_file) ?
3277 + &shm_file_operations_huge :
3278 + &shm_file_operations);
3279 if (!file)
3280 goto out_free;
3281 ima_counts_get(file);
3282 diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
3283 index 2451dc6..4b05bd9 100644
3284 --- a/kernel/audit_tree.c
3285 +++ b/kernel/audit_tree.c
3286 @@ -277,7 +277,7 @@ static void untag_chunk(struct node *p)
3287 owner->root = NULL;
3288 }
3289
3290 - for (i = j = 0; i < size; i++, j++) {
3291 + for (i = j = 0; j <= size; i++, j++) {
3292 struct audit_tree *s;
3293 if (&chunk->owners[j] == p) {
3294 list_del_init(&p->list);
3295 @@ -290,7 +290,7 @@ static void untag_chunk(struct node *p)
3296 if (!s) /* result of earlier fallback */
3297 continue;
3298 get_tree(s);
3299 - list_replace_init(&chunk->owners[i].list, &new->owners[j].list);
3300 + list_replace_init(&chunk->owners[j].list, &new->owners[i].list);
3301 }
3302
3303 list_replace_rcu(&chunk->hash, &new->hash);
3304 @@ -373,15 +373,17 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
3305 for (n = 0; n < old->count; n++) {
3306 if (old->owners[n].owner == tree) {
3307 spin_unlock(&hash_lock);
3308 - put_inotify_watch(watch);
3309 + put_inotify_watch(&old->watch);
3310 return 0;
3311 }
3312 }
3313 spin_unlock(&hash_lock);
3314
3315 chunk = alloc_chunk(old->count + 1);
3316 - if (!chunk)
3317 + if (!chunk) {
3318 + put_inotify_watch(&old->watch);
3319 return -ENOMEM;
3320 + }
3321
3322 mutex_lock(&inode->inotify_mutex);
3323 if (inotify_clone_watch(&old->watch, &chunk->watch) < 0) {
3324 @@ -425,7 +427,8 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
3325 spin_unlock(&hash_lock);
3326 inotify_evict_watch(&old->watch);
3327 mutex_unlock(&inode->inotify_mutex);
3328 - put_inotify_watch(&old->watch);
3329 + put_inotify_watch(&old->watch); /* pair to inotify_find_watch */
3330 + put_inotify_watch(&old->watch); /* and kill it */
3331 return 0;
3332 }
3333
3334 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
3335 index 0249f4b..1fbcc74 100644
3336 --- a/kernel/cgroup.c
3337 +++ b/kernel/cgroup.c
3338 @@ -2468,7 +2468,6 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
3339 /* make sure l doesn't vanish out from under us */
3340 down_write(&l->mutex);
3341 mutex_unlock(&cgrp->pidlist_mutex);
3342 - l->use_count++;
3343 return l;
3344 }
3345 }
3346 diff --git a/kernel/module.c b/kernel/module.c
3347 index 5842a71..dfa33e8 100644
3348 --- a/kernel/module.c
3349 +++ b/kernel/module.c
3350 @@ -1030,11 +1030,23 @@ static int try_to_force_load(struct module *mod, const char *reason)
3351 }
3352
3353 #ifdef CONFIG_MODVERSIONS
3354 +/* If the arch applies (non-zero) relocations to kernel kcrctab, unapply it. */
3355 +static unsigned long maybe_relocated(unsigned long crc,
3356 + const struct module *crc_owner)
3357 +{
3358 +#ifdef ARCH_RELOCATES_KCRCTAB
3359 + if (crc_owner == NULL)
3360 + return crc - (unsigned long)reloc_start;
3361 +#endif
3362 + return crc;
3363 +}
3364 +
3365 static int check_version(Elf_Shdr *sechdrs,
3366 unsigned int versindex,
3367 const char *symname,
3368 struct module *mod,
3369 - const unsigned long *crc)
3370 + const unsigned long *crc,
3371 + const struct module *crc_owner)
3372 {
3373 unsigned int i, num_versions;
3374 struct modversion_info *versions;
3375 @@ -1055,10 +1067,10 @@ static int check_version(Elf_Shdr *sechdrs,
3376 if (strcmp(versions[i].name, symname) != 0)
3377 continue;
3378
3379 - if (versions[i].crc == *crc)
3380 + if (versions[i].crc == maybe_relocated(*crc, crc_owner))
3381 return 1;
3382 DEBUGP("Found checksum %lX vs module %lX\n",
3383 - *crc, versions[i].crc);
3384 + maybe_relocated(*crc, crc_owner), versions[i].crc);
3385 goto bad_version;
3386 }
3387
3388 @@ -1081,7 +1093,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
3389 if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL,
3390 &crc, true, false))
3391 BUG();
3392 - return check_version(sechdrs, versindex, "module_layout", mod, crc);
3393 + return check_version(sechdrs, versindex, "module_layout", mod, crc,
3394 + NULL);
3395 }
3396
3397 /* First part is kernel version, which we ignore if module has crcs. */
3398 @@ -1099,7 +1112,8 @@ static inline int check_version(Elf_Shdr *sechdrs,
3399 unsigned int versindex,
3400 const char *symname,
3401 struct module *mod,
3402 - const unsigned long *crc)
3403 + const unsigned long *crc,
3404 + const struct module *crc_owner)
3405 {
3406 return 1;
3407 }
3408 @@ -1134,8 +1148,8 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs,
3409 /* use_module can fail due to OOM,
3410 or module initialization or unloading */
3411 if (sym) {
3412 - if (!check_version(sechdrs, versindex, name, mod, crc) ||
3413 - !use_module(mod, owner))
3414 + if (!check_version(sechdrs, versindex, name, mod, crc, owner)
3415 + || !use_module(mod, owner))
3416 sym = NULL;
3417 }
3418 return sym;
3419 @@ -1146,6 +1160,12 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs,
3420 * J. Corbet <corbet@lwn.net>
3421 */
3422 #if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS)
3423 +
3424 +static inline bool sect_empty(const Elf_Shdr *sect)
3425 +{
3426 + return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
3427 +}
3428 +
3429 struct module_sect_attr
3430 {
3431 struct module_attribute mattr;
3432 @@ -1187,8 +1207,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect,
3433
3434 /* Count loaded sections and allocate structures */
3435 for (i = 0; i < nsect; i++)
3436 - if (sechdrs[i].sh_flags & SHF_ALLOC
3437 - && sechdrs[i].sh_size)
3438 + if (!sect_empty(&sechdrs[i]))
3439 nloaded++;
3440 size[0] = ALIGN(sizeof(*sect_attrs)
3441 + nloaded * sizeof(sect_attrs->attrs[0]),
3442 @@ -1206,9 +1225,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect,
3443 sattr = &sect_attrs->attrs[0];
3444 gattr = &sect_attrs->grp.attrs[0];
3445 for (i = 0; i < nsect; i++) {
3446 - if (! (sechdrs[i].sh_flags & SHF_ALLOC))
3447 - continue;
3448 - if (!sechdrs[i].sh_size)
3449 + if (sect_empty(&sechdrs[i]))
3450 continue;
3451 sattr->address = sechdrs[i].sh_addr;
3452 sattr->name = kstrdup(secstrings + sechdrs[i].sh_name,
3453 @@ -1292,7 +1309,7 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect,
3454 /* Count notes sections and allocate structures. */
3455 notes = 0;
3456 for (i = 0; i < nsect; i++)
3457 - if ((sechdrs[i].sh_flags & SHF_ALLOC) &&
3458 + if (!sect_empty(&sechdrs[i]) &&
3459 (sechdrs[i].sh_type == SHT_NOTE))
3460 ++notes;
3461
3462 @@ -1308,7 +1325,7 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect,
3463 notes_attrs->notes = notes;
3464 nattr = &notes_attrs->attrs[0];
3465 for (loaded = i = 0; i < nsect; ++i) {
3466 - if (!(sechdrs[i].sh_flags & SHF_ALLOC))
3467 + if (sect_empty(&sechdrs[i]))
3468 continue;
3469 if (sechdrs[i].sh_type == SHT_NOTE) {
3470 nattr->attr.name = mod->sect_attrs->attrs[loaded].name;
3471 diff --git a/kernel/signal.c b/kernel/signal.c
3472 index 6705320..4d0658d 100644
3473 --- a/kernel/signal.c
3474 +++ b/kernel/signal.c
3475 @@ -939,7 +939,8 @@ static void print_fatal_signal(struct pt_regs *regs, int signr)
3476 for (i = 0; i < 16; i++) {
3477 unsigned char insn;
3478
3479 - __get_user(insn, (unsigned char *)(regs->ip + i));
3480 + if (get_user(insn, (unsigned char *)(regs->ip + i)))
3481 + break;
3482 printk("%02x ", insn);
3483 }
3484 }
3485 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
3486 index dd84be9..b8bd058 100644
3487 --- a/kernel/sysctl.c
3488 +++ b/kernel/sysctl.c
3489 @@ -1200,7 +1200,6 @@ static struct ctl_table vm_table[] = {
3490 .extra2 = (void *)&hugetlb_infinity,
3491 },
3492 #endif
3493 -#ifdef CONFIG_MMU
3494 {
3495 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
3496 .procname = "lowmem_reserve_ratio",
3497 @@ -1346,6 +1345,7 @@ static struct ctl_table vm_table[] = {
3498 .strategy = &sysctl_jiffies,
3499 },
3500 #endif
3501 +#ifdef CONFIG_MMU
3502 {
3503 .ctl_name = CTL_UNNUMBERED,
3504 .procname = "mmap_min_addr",
3505 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
3506 index 5a77c7c..084e879 100644
3507 --- a/lib/dma-debug.c
3508 +++ b/lib/dma-debug.c
3509 @@ -913,6 +913,9 @@ static void check_sync(struct device *dev,
3510 ref->size);
3511 }
3512
3513 + if (entry->direction == DMA_BIDIRECTIONAL)
3514 + goto out;
3515 +
3516 if (ref->direction != entry->direction) {
3517 err_printk(dev, entry, "DMA-API: device driver syncs "
3518 "DMA memory with different direction "
3519 @@ -923,9 +926,6 @@ static void check_sync(struct device *dev,
3520 dir2name[ref->direction]);
3521 }
3522
3523 - if (entry->direction == DMA_BIDIRECTIONAL)
3524 - goto out;
3525 -
3526 if (to_cpu && !(entry->direction == DMA_FROM_DEVICE) &&
3527 !(ref->direction == DMA_TO_DEVICE))
3528 err_printk(dev, entry, "DMA-API: device driver syncs "
3529 @@ -948,7 +948,6 @@ static void check_sync(struct device *dev,
3530
3531 out:
3532 put_hash_bucket(bucket, &flags);
3533 -
3534 }
3535
3536 void debug_dma_map_page(struct device *dev, struct page *page, size_t offset,
3537 diff --git a/lib/rational.c b/lib/rational.c
3538 index b3c099b..3ed247b 100644
3539 --- a/lib/rational.c
3540 +++ b/lib/rational.c
3541 @@ -7,6 +7,7 @@
3542 */
3543
3544 #include <linux/rational.h>
3545 +#include <linux/module.h>
3546
3547 /*
3548 * calculate best rational approximation for a given fraction
3549 diff --git a/mm/mmap.c b/mm/mmap.c
3550 index 73f5e4b..ae19746 100644
3551 --- a/mm/mmap.c
3552 +++ b/mm/mmap.c
3553 @@ -932,13 +932,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
3554 if (!(flags & MAP_FIXED))
3555 addr = round_hint_to_min(addr);
3556
3557 - error = arch_mmap_check(addr, len, flags);
3558 - if (error)
3559 - return error;
3560 -
3561 /* Careful about overflows.. */
3562 len = PAGE_ALIGN(len);
3563 - if (!len || len > TASK_SIZE)
3564 + if (!len)
3565 return -ENOMEM;
3566
3567 /* offset overflow? */
3568 @@ -949,24 +945,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
3569 if (mm->map_count > sysctl_max_map_count)
3570 return -ENOMEM;
3571
3572 - if (flags & MAP_HUGETLB) {
3573 - struct user_struct *user = NULL;
3574 - if (file)
3575 - return -EINVAL;
3576 -
3577 - /*
3578 - * VM_NORESERVE is used because the reservations will be
3579 - * taken when vm_ops->mmap() is called
3580 - * A dummy user value is used because we are not locking
3581 - * memory so no accounting is necessary
3582 - */
3583 - len = ALIGN(len, huge_page_size(&default_hstate));
3584 - file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, VM_NORESERVE,
3585 - &user, HUGETLB_ANONHUGE_INODE);
3586 - if (IS_ERR(file))
3587 - return PTR_ERR(file);
3588 - }
3589 -
3590 /* Obtain the address to map to. we verify (or select) it and ensure
3591 * that it represents a valid section of the address space.
3592 */
3593 @@ -1459,6 +1437,14 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
3594 unsigned long (*get_area)(struct file *, unsigned long,
3595 unsigned long, unsigned long, unsigned long);
3596
3597 + unsigned long error = arch_mmap_check(addr, len, flags);
3598 + if (error)
3599 + return error;
3600 +
3601 + /* Careful about overflows.. */
3602 + if (len > TASK_SIZE)
3603 + return -ENOMEM;
3604 +
3605 get_area = current->mm->get_unmapped_area;
3606 if (file && file->f_op && file->f_op->get_unmapped_area)
3607 get_area = file->f_op->get_unmapped_area;
3608 @@ -2003,20 +1989,14 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
3609 if (!len)
3610 return addr;
3611
3612 - if ((addr + len) > TASK_SIZE || (addr + len) < addr)
3613 - return -EINVAL;
3614 -
3615 - if (is_hugepage_only_range(mm, addr, len))
3616 - return -EINVAL;
3617 -
3618 error = security_file_mmap(NULL, 0, 0, 0, addr, 1);
3619 if (error)
3620 return error;
3621
3622 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
3623
3624 - error = arch_mmap_check(addr, len, flags);
3625 - if (error)
3626 + error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
3627 + if (error & ~PAGE_MASK)
3628 return error;
3629
3630 /*
3631 diff --git a/mm/mremap.c b/mm/mremap.c
3632 index 97bff25..8451908 100644
3633 --- a/mm/mremap.c
3634 +++ b/mm/mremap.c
3635 @@ -261,6 +261,137 @@ static unsigned long move_vma(struct vm_area_struct *vma,
3636 return new_addr;
3637 }
3638
3639 +static struct vm_area_struct *vma_to_resize(unsigned long addr,
3640 + unsigned long old_len, unsigned long new_len, unsigned long *p)
3641 +{
3642 + struct mm_struct *mm = current->mm;
3643 + struct vm_area_struct *vma = find_vma(mm, addr);
3644 +
3645 + if (!vma || vma->vm_start > addr)
3646 + goto Efault;
3647 +
3648 + if (is_vm_hugetlb_page(vma))
3649 + goto Einval;
3650 +
3651 + /* We can't remap across vm area boundaries */
3652 + if (old_len > vma->vm_end - addr)
3653 + goto Efault;
3654 +
3655 + if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP)) {
3656 + if (new_len > old_len)
3657 + goto Efault;
3658 + }
3659 +
3660 + if (vma->vm_flags & VM_LOCKED) {
3661 + unsigned long locked, lock_limit;
3662 + locked = mm->locked_vm << PAGE_SHIFT;
3663 + lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
3664 + locked += new_len - old_len;
3665 + if (locked > lock_limit && !capable(CAP_IPC_LOCK))
3666 + goto Eagain;
3667 + }
3668 +
3669 + if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT))
3670 + goto Enomem;
3671 +
3672 + if (vma->vm_flags & VM_ACCOUNT) {
3673 + unsigned long charged = (new_len - old_len) >> PAGE_SHIFT;
3674 + if (security_vm_enough_memory(charged))
3675 + goto Efault;
3676 + *p = charged;
3677 + }
3678 +
3679 + return vma;
3680 +
3681 +Efault: /* very odd choice for most of the cases, but... */
3682 + return ERR_PTR(-EFAULT);
3683 +Einval:
3684 + return ERR_PTR(-EINVAL);
3685 +Enomem:
3686 + return ERR_PTR(-ENOMEM);
3687 +Eagain:
3688 + return ERR_PTR(-EAGAIN);
3689 +}
3690 +
3691 +static unsigned long mremap_to(unsigned long addr,
3692 + unsigned long old_len, unsigned long new_addr,
3693 + unsigned long new_len)
3694 +{
3695 + struct mm_struct *mm = current->mm;
3696 + struct vm_area_struct *vma;
3697 + unsigned long ret = -EINVAL;
3698 + unsigned long charged = 0;
3699 + unsigned long map_flags;
3700 +
3701 + if (new_addr & ~PAGE_MASK)
3702 + goto out;
3703 +
3704 + if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
3705 + goto out;
3706 +
3707 + /* Check if the location we're moving into overlaps the
3708 + * old location at all, and fail if it does.
3709 + */
3710 + if ((new_addr <= addr) && (new_addr+new_len) > addr)
3711 + goto out;
3712 +
3713 + if ((addr <= new_addr) && (addr+old_len) > new_addr)
3714 + goto out;
3715 +
3716 + ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);
3717 + if (ret)
3718 + goto out;
3719 +
3720 + ret = do_munmap(mm, new_addr, new_len);
3721 + if (ret)
3722 + goto out;
3723 +
3724 + if (old_len >= new_len) {
3725 + ret = do_munmap(mm, addr+new_len, old_len - new_len);
3726 + if (ret && old_len != new_len)
3727 + goto out;
3728 + old_len = new_len;
3729 + }
3730 +
3731 + vma = vma_to_resize(addr, old_len, new_len, &charged);
3732 + if (IS_ERR(vma)) {
3733 + ret = PTR_ERR(vma);
3734 + goto out;
3735 + }
3736 +
3737 + map_flags = MAP_FIXED;
3738 + if (vma->vm_flags & VM_MAYSHARE)
3739 + map_flags |= MAP_SHARED;
3740 +
3741 + ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff +
3742 + ((addr - vma->vm_start) >> PAGE_SHIFT),
3743 + map_flags);
3744 + if (ret & ~PAGE_MASK)
3745 + goto out1;
3746 +
3747 + ret = move_vma(vma, addr, old_len, new_len, new_addr);
3748 + if (!(ret & ~PAGE_MASK))
3749 + goto out;
3750 +out1:
3751 + vm_unacct_memory(charged);
3752 +
3753 +out:
3754 + return ret;
3755 +}
3756 +
3757 +static int vma_expandable(struct vm_area_struct *vma, unsigned long delta)
3758 +{
3759 + unsigned long end = vma->vm_end + delta;
3760 + if (end < vma->vm_end) /* overflow */
3761 + return 0;
3762 + if (vma->vm_next && vma->vm_next->vm_start < end) /* intersection */
3763 + return 0;
3764 + if (get_unmapped_area(NULL, vma->vm_start, end - vma->vm_start,
3765 + 0, MAP_FIXED) & ~PAGE_MASK)
3766 + return 0;
3767 + return 1;
3768 +}
3769 +
3770 /*
3771 * Expand (or shrink) an existing mapping, potentially moving it at the
3772 * same time (controlled by the MREMAP_MAYMOVE flag and available VM space)
3773 @@ -294,32 +425,10 @@ unsigned long do_mremap(unsigned long addr,
3774 if (!new_len)
3775 goto out;
3776
3777 - /* new_addr is only valid if MREMAP_FIXED is specified */
3778 if (flags & MREMAP_FIXED) {
3779 - if (new_addr & ~PAGE_MASK)
3780 - goto out;
3781 - if (!(flags & MREMAP_MAYMOVE))
3782 - goto out;
3783 -
3784 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
3785 - goto out;
3786 -
3787 - /* Check if the location we're moving into overlaps the
3788 - * old location at all, and fail if it does.
3789 - */
3790 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
3791 - goto out;
3792 -
3793 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
3794 - goto out;
3795 -
3796 - ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);
3797 - if (ret)
3798 - goto out;
3799 -
3800 - ret = do_munmap(mm, new_addr, new_len);
3801 - if (ret)
3802 - goto out;
3803 + if (flags & MREMAP_MAYMOVE)
3804 + ret = mremap_to(addr, old_len, new_addr, new_len);
3805 + goto out;
3806 }
3807
3808 /*
3809 @@ -332,60 +441,23 @@ unsigned long do_mremap(unsigned long addr,
3810 if (ret && old_len != new_len)
3811 goto out;
3812 ret = addr;
3813 - if (!(flags & MREMAP_FIXED) || (new_addr == addr))
3814 - goto out;
3815 - old_len = new_len;
3816 + goto out;
3817 }
3818
3819 /*
3820 - * Ok, we need to grow.. or relocate.
3821 + * Ok, we need to grow..
3822 */
3823 - ret = -EFAULT;
3824 - vma = find_vma(mm, addr);
3825 - if (!vma || vma->vm_start > addr)
3826 - goto out;
3827 - if (is_vm_hugetlb_page(vma)) {
3828 - ret = -EINVAL;
3829 - goto out;
3830 - }
3831 - /* We can't remap across vm area boundaries */
3832 - if (old_len > vma->vm_end - addr)
3833 - goto out;
3834 - if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP)) {
3835 - if (new_len > old_len)
3836 - goto out;
3837 - }
3838 - if (vma->vm_flags & VM_LOCKED) {
3839 - unsigned long locked, lock_limit;
3840 - locked = mm->locked_vm << PAGE_SHIFT;
3841 - lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
3842 - locked += new_len - old_len;
3843 - ret = -EAGAIN;
3844 - if (locked > lock_limit && !capable(CAP_IPC_LOCK))
3845 - goto out;
3846 - }
3847 - if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
3848 - ret = -ENOMEM;
3849 + vma = vma_to_resize(addr, old_len, new_len, &charged);
3850 + if (IS_ERR(vma)) {
3851 + ret = PTR_ERR(vma);
3852 goto out;
3853 }
3854
3855 - if (vma->vm_flags & VM_ACCOUNT) {
3856 - charged = (new_len - old_len) >> PAGE_SHIFT;
3857 - if (security_vm_enough_memory(charged))
3858 - goto out_nc;
3859 - }
3860 -
3861 /* old_len exactly to the end of the area..
3862 - * And we're not relocating the area.
3863 */
3864 - if (old_len == vma->vm_end - addr &&
3865 - !((flags & MREMAP_FIXED) && (addr != new_addr)) &&
3866 - (old_len != new_len || !(flags & MREMAP_MAYMOVE))) {
3867 - unsigned long max_addr = TASK_SIZE;
3868 - if (vma->vm_next)
3869 - max_addr = vma->vm_next->vm_start;
3870 + if (old_len == vma->vm_end - addr) {
3871 /* can we just expand the current mapping? */
3872 - if (max_addr - addr >= new_len) {
3873 + if (vma_expandable(vma, new_len - old_len)) {
3874 int pages = (new_len - old_len) >> PAGE_SHIFT;
3875
3876 vma_adjust(vma, vma->vm_start,
3877 @@ -409,28 +481,27 @@ unsigned long do_mremap(unsigned long addr,
3878 */
3879 ret = -ENOMEM;
3880 if (flags & MREMAP_MAYMOVE) {
3881 - if (!(flags & MREMAP_FIXED)) {
3882 - unsigned long map_flags = 0;
3883 - if (vma->vm_flags & VM_MAYSHARE)
3884 - map_flags |= MAP_SHARED;
3885 -
3886 - new_addr = get_unmapped_area(vma->vm_file, 0, new_len,
3887 - vma->vm_pgoff, map_flags);
3888 - if (new_addr & ~PAGE_MASK) {
3889 - ret = new_addr;
3890 - goto out;
3891 - }
3892 -
3893 - ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);
3894 - if (ret)
3895 - goto out;
3896 + unsigned long map_flags = 0;
3897 + if (vma->vm_flags & VM_MAYSHARE)
3898 + map_flags |= MAP_SHARED;
3899 +
3900 + new_addr = get_unmapped_area(vma->vm_file, 0, new_len,
3901 + vma->vm_pgoff +
3902 + ((addr - vma->vm_start) >> PAGE_SHIFT),
3903 + map_flags);
3904 + if (new_addr & ~PAGE_MASK) {
3905 + ret = new_addr;
3906 + goto out;
3907 }
3908 +
3909 + ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);
3910 + if (ret)
3911 + goto out;
3912 ret = move_vma(vma, addr, old_len, new_len, new_addr);
3913 }
3914 out:
3915 if (ret & ~PAGE_MASK)
3916 vm_unacct_memory(charged);
3917 -out_nc:
3918 return ret;
3919 }
3920
3921 diff --git a/mm/util.c b/mm/util.c
3922 index 7c35ad9..b377ce4 100644
3923 --- a/mm/util.c
3924 +++ b/mm/util.c
3925 @@ -4,6 +4,10 @@
3926 #include <linux/module.h>
3927 #include <linux/err.h>
3928 #include <linux/sched.h>
3929 +#include <linux/hugetlb.h>
3930 +#include <linux/syscalls.h>
3931 +#include <linux/mman.h>
3932 +#include <linux/file.h>
3933 #include <asm/uaccess.h>
3934
3935 #define CREATE_TRACE_POINTS
3936 @@ -268,6 +272,46 @@ int __attribute__((weak)) get_user_pages_fast(unsigned long start,
3937 }
3938 EXPORT_SYMBOL_GPL(get_user_pages_fast);
3939
3940 +SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
3941 + unsigned long, prot, unsigned long, flags,
3942 + unsigned long, fd, unsigned long, pgoff)
3943 +{
3944 + struct file * file = NULL;
3945 + unsigned long retval = -EBADF;
3946 +
3947 + if (!(flags & MAP_ANONYMOUS)) {
3948 + if (unlikely(flags & MAP_HUGETLB))
3949 + return -EINVAL;
3950 + file = fget(fd);
3951 + if (!file)
3952 + goto out;
3953 + } else if (flags & MAP_HUGETLB) {
3954 + struct user_struct *user = NULL;
3955 + /*
3956 + * VM_NORESERVE is used because the reservations will be
3957 + * taken when vm_ops->mmap() is called
3958 + * A dummy user value is used because we are not locking
3959 + * memory so no accounting is necessary
3960 + */
3961 + len = ALIGN(len, huge_page_size(&default_hstate));
3962 + file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, VM_NORESERVE,
3963 + &user, HUGETLB_ANONHUGE_INODE);
3964 + if (IS_ERR(file))
3965 + return PTR_ERR(file);
3966 + }
3967 +
3968 + flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
3969 +
3970 + down_write(&current->mm->mmap_sem);
3971 + retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
3972 + up_write(&current->mm->mmap_sem);
3973 +
3974 + if (file)
3975 + fput(file);
3976 +out:
3977 + return retval;
3978 +}
3979 +
3980 /* Tracepoints definitions. */
3981 EXPORT_TRACEPOINT_SYMBOL(kmalloc);
3982 EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc);
3983 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
3984 index bd1c654..0b7f262 100644
3985 --- a/net/bridge/netfilter/ebtables.c
3986 +++ b/net/bridge/netfilter/ebtables.c
3987 @@ -1406,6 +1406,9 @@ static int do_ebt_set_ctl(struct sock *sk,
3988 {
3989 int ret;
3990
3991 + if (!capable(CAP_NET_ADMIN))
3992 + return -EPERM;
3993 +
3994 switch(cmd) {
3995 case EBT_SO_SET_ENTRIES:
3996 ret = do_replace(sock_net(sk), user, len);
3997 @@ -1425,6 +1428,9 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
3998 struct ebt_replace tmp;
3999 struct ebt_table *t;
4000
4001 + if (!capable(CAP_NET_ADMIN))
4002 + return -EPERM;
4003 +
4004 if (copy_from_user(&tmp, user, sizeof(tmp)))
4005 return -EFAULT;
4006
4007 diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
4008 index df159ff..4bac362 100644
4009 --- a/net/ipv6/exthdrs.c
4010 +++ b/net/ipv6/exthdrs.c
4011 @@ -559,6 +559,11 @@ static inline struct inet6_dev *ipv6_skb_idev(struct sk_buff *skb)
4012 return skb_dst(skb) ? ip6_dst_idev(skb_dst(skb)) : __in6_dev_get(skb->dev);
4013 }
4014
4015 +static inline struct net *ipv6_skb_net(struct sk_buff *skb)
4016 +{
4017 + return skb_dst(skb) ? dev_net(skb_dst(skb)->dev) : dev_net(skb->dev);
4018 +}
4019 +
4020 /* Router Alert as of RFC 2711 */
4021
4022 static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
4023 @@ -580,8 +585,8 @@ static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
4024 static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
4025 {
4026 const unsigned char *nh = skb_network_header(skb);
4027 + struct net *net = ipv6_skb_net(skb);
4028 u32 pkt_len;
4029 - struct net *net = dev_net(skb_dst(skb)->dev);
4030
4031 if (nh[optoff + 1] != 4 || (optoff & 3) != 2) {
4032 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n",
4033 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
4034 index b8295cb..079c500 100644
4035 --- a/net/mac80211/iface.c
4036 +++ b/net/mac80211/iface.c
4037 @@ -15,12 +15,14 @@
4038 #include <linux/netdevice.h>
4039 #include <linux/rtnetlink.h>
4040 #include <net/mac80211.h>
4041 +#include <net/ieee80211_radiotap.h>
4042 #include "ieee80211_i.h"
4043 #include "sta_info.h"
4044 #include "debugfs_netdev.h"
4045 #include "mesh.h"
4046 #include "led.h"
4047 #include "driver-ops.h"
4048 +#include "wme.h"
4049
4050 /**
4051 * DOC: Interface list locking
4052 @@ -642,6 +644,12 @@ static void ieee80211_teardown_sdata(struct net_device *dev)
4053 WARN_ON(flushed);
4054 }
4055
4056 +static u16 ieee80211_netdev_select_queue(struct net_device *dev,
4057 + struct sk_buff *skb)
4058 +{
4059 + return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
4060 +}
4061 +
4062 static const struct net_device_ops ieee80211_dataif_ops = {
4063 .ndo_open = ieee80211_open,
4064 .ndo_stop = ieee80211_stop,
4065 @@ -650,8 +658,35 @@ static const struct net_device_ops ieee80211_dataif_ops = {
4066 .ndo_set_multicast_list = ieee80211_set_multicast_list,
4067 .ndo_change_mtu = ieee80211_change_mtu,
4068 .ndo_set_mac_address = eth_mac_addr,
4069 + .ndo_select_queue = ieee80211_netdev_select_queue,
4070 };
4071
4072 +static u16 ieee80211_monitor_select_queue(struct net_device *dev,
4073 + struct sk_buff *skb)
4074 +{
4075 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4076 + struct ieee80211_local *local = sdata->local;
4077 + struct ieee80211_hdr *hdr;
4078 + struct ieee80211_radiotap_header *rtap = (void *)skb->data;
4079 +
4080 + if (local->hw.queues < 4)
4081 + return 0;
4082 +
4083 + if (skb->len < 4 ||
4084 + skb->len < le16_to_cpu(rtap->it_len) + 2 /* frame control */)
4085 + return 0; /* doesn't matter, frame will be dropped */
4086 +
4087 + hdr = (void *)((u8 *)skb->data + le16_to_cpu(rtap->it_len));
4088 +
4089 + if (!ieee80211_is_data(hdr->frame_control)) {
4090 + skb->priority = 7;
4091 + return ieee802_1d_to_ac[skb->priority];
4092 + }
4093 +
4094 + skb->priority = 0;
4095 + return ieee80211_downgrade_queue(local, skb);
4096 +}
4097 +
4098 static const struct net_device_ops ieee80211_monitorif_ops = {
4099 .ndo_open = ieee80211_open,
4100 .ndo_stop = ieee80211_stop,
4101 @@ -660,6 +695,7 @@ static const struct net_device_ops ieee80211_monitorif_ops = {
4102 .ndo_set_multicast_list = ieee80211_set_multicast_list,
4103 .ndo_change_mtu = ieee80211_change_mtu,
4104 .ndo_set_mac_address = eth_mac_addr,
4105 + .ndo_select_queue = ieee80211_monitor_select_queue,
4106 };
4107
4108 static void ieee80211_if_setup(struct net_device *dev)
4109 @@ -768,8 +804,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
4110
4111 ASSERT_RTNL();
4112
4113 - ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size,
4114 - name, ieee80211_if_setup);
4115 + ndev = alloc_netdev_mq(sizeof(*sdata) + local->hw.vif_data_size,
4116 + name, ieee80211_if_setup, local->hw.queues);
4117 if (!ndev)
4118 return -ENOMEM;
4119 dev_net_set(ndev, wiphy_net(local->hw.wiphy));
4120 diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
4121 index f13d181..6cae295 100644
4122 --- a/net/mac80211/mlme.c
4123 +++ b/net/mac80211/mlme.c
4124 @@ -1953,7 +1953,9 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
4125 rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len);
4126 break;
4127 case IEEE80211_STYPE_ACTION:
4128 - /* XXX: differentiate, can only happen for CSA now! */
4129 + if (mgmt->u.action.category != WLAN_CATEGORY_SPECTRUM_MGMT)
4130 + break;
4131 +
4132 ieee80211_sta_process_chanswitch(sdata,
4133 &mgmt->u.action.u.chan_switch.sw_elem,
4134 ifmgd->associated);
4135 diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
4136 index 4e14754..16c6cdc 100644
4137 --- a/net/mac80211/rx.c
4138 +++ b/net/mac80211/rx.c
4139 @@ -1548,7 +1548,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
4140 memset(info, 0, sizeof(*info));
4141 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
4142 info->control.vif = &rx->sdata->vif;
4143 - ieee80211_select_queue(local, fwd_skb);
4144 + skb_set_queue_mapping(skb,
4145 + ieee80211_select_queue(rx->sdata, fwd_skb));
4146 + ieee80211_set_qos_hdr(local, skb);
4147 if (is_multicast_ether_addr(fwd_hdr->addr1))
4148 IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh,
4149 fwded_mcast);
4150 @@ -1808,6 +1810,10 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
4151 }
4152 break;
4153 default:
4154 + /* do not process rejected action frames */
4155 + if (mgmt->u.action.category & 0x80)
4156 + return RX_DROP_MONITOR;
4157 +
4158 return RX_CONTINUE;
4159 }
4160
4161 diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
4162 index d398197..441f68e 100644
4163 --- a/net/mac80211/tx.c
4164 +++ b/net/mac80211/tx.c
4165 @@ -1482,7 +1482,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
4166 return;
4167 }
4168
4169 - ieee80211_select_queue(local, skb);
4170 + ieee80211_set_qos_hdr(local, skb);
4171 ieee80211_tx(sdata, skb, false);
4172 dev_put(sdata->dev);
4173 }
4174 @@ -2226,6 +2226,9 @@ void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
4175 if (!encrypt)
4176 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
4177
4178 + /* send all internal mgmt frames on VO */
4179 + skb_set_queue_mapping(skb, 0);
4180 +
4181 /*
4182 * The other path calling ieee80211_xmit is from the tasklet,
4183 * and while we can handle concurrent transmissions locking
4184 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
4185 index 51e0bd2..553cffe 100644
4186 --- a/net/mac80211/util.c
4187 +++ b/net/mac80211/util.c
4188 @@ -269,6 +269,7 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
4189 enum queue_stop_reason reason)
4190 {
4191 struct ieee80211_local *local = hw_to_local(hw);
4192 + struct ieee80211_sub_if_data *sdata;
4193
4194 if (WARN_ON(queue >= hw->queues))
4195 return;
4196 @@ -281,6 +282,11 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
4197
4198 if (!skb_queue_empty(&local->pending[queue]))
4199 tasklet_schedule(&local->tx_pending_tasklet);
4200 +
4201 + rcu_read_lock();
4202 + list_for_each_entry_rcu(sdata, &local->interfaces, list)
4203 + netif_tx_wake_queue(netdev_get_tx_queue(sdata->dev, queue));
4204 + rcu_read_unlock();
4205 }
4206
4207 void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
4208 @@ -305,11 +311,17 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
4209 enum queue_stop_reason reason)
4210 {
4211 struct ieee80211_local *local = hw_to_local(hw);
4212 + struct ieee80211_sub_if_data *sdata;
4213
4214 if (WARN_ON(queue >= hw->queues))
4215 return;
4216
4217 __set_bit(reason, &local->queue_stop_reasons[queue]);
4218 +
4219 + rcu_read_lock();
4220 + list_for_each_entry_rcu(sdata, &local->interfaces, list)
4221 + netif_tx_stop_queue(netdev_get_tx_queue(sdata->dev, queue));
4222 + rcu_read_unlock();
4223 }
4224
4225 void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
4226 diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
4227 index b19b769..6d32ebf 100644
4228 --- a/net/mac80211/wme.c
4229 +++ b/net/mac80211/wme.c
4230 @@ -44,22 +44,62 @@ static int wme_downgrade_ac(struct sk_buff *skb)
4231 }
4232
4233
4234 -/* Indicate which queue to use. */
4235 -static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb)
4236 +/* Indicate which queue to use. */
4237 +u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
4238 + struct sk_buff *skb)
4239 {
4240 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
4241 + struct ieee80211_local *local = sdata->local;
4242 + struct sta_info *sta = NULL;
4243 + u32 sta_flags = 0;
4244 + const u8 *ra = NULL;
4245 + bool qos = false;
4246
4247 - if (!ieee80211_is_data(hdr->frame_control)) {
4248 - /* management frames go on AC_VO queue, but are sent
4249 - * without QoS control fields */
4250 - return 0;
4251 + if (local->hw.queues < 4 || skb->len < 6) {
4252 + skb->priority = 0; /* required for correct WPA/11i MIC */
4253 + return min_t(u16, local->hw.queues - 1,
4254 + ieee802_1d_to_ac[skb->priority]);
4255 }
4256
4257 - if (0 /* injected */) {
4258 - /* use AC from radiotap */
4259 + rcu_read_lock();
4260 + switch (sdata->vif.type) {
4261 + case NL80211_IFTYPE_AP_VLAN:
4262 + case NL80211_IFTYPE_AP:
4263 + ra = skb->data;
4264 + break;
4265 + case NL80211_IFTYPE_WDS:
4266 + ra = sdata->u.wds.remote_addr;
4267 + break;
4268 +#ifdef CONFIG_MAC80211_MESH
4269 + case NL80211_IFTYPE_MESH_POINT:
4270 + /*
4271 + * XXX: This is clearly broken ... but already was before,
4272 + * because ieee80211_fill_mesh_addresses() would clear A1
4273 + * except for multicast addresses.
4274 + */
4275 + break;
4276 +#endif
4277 + case NL80211_IFTYPE_STATION:
4278 + ra = sdata->u.mgd.bssid;
4279 + break;
4280 + case NL80211_IFTYPE_ADHOC:
4281 + ra = skb->data;
4282 + break;
4283 + default:
4284 + break;
4285 }
4286
4287 - if (!ieee80211_is_data_qos(hdr->frame_control)) {
4288 + if (!sta && ra && !is_multicast_ether_addr(ra)) {
4289 + sta = sta_info_get(local, ra);
4290 + if (sta)
4291 + sta_flags = get_sta_flags(sta);
4292 + }
4293 +
4294 + if (sta_flags & WLAN_STA_WME)
4295 + qos = true;
4296 +
4297 + rcu_read_unlock();
4298 +
4299 + if (!qos) {
4300 skb->priority = 0; /* required for correct WPA/11i MIC */
4301 return ieee802_1d_to_ac[skb->priority];
4302 }
4303 @@ -68,6 +108,12 @@ static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb)
4304 * data frame has */
4305 skb->priority = cfg80211_classify8021d(skb);
4306
4307 + return ieee80211_downgrade_queue(local, skb);
4308 +}
4309 +
4310 +u16 ieee80211_downgrade_queue(struct ieee80211_local *local,
4311 + struct sk_buff *skb)
4312 +{
4313 /* in case we are a client verify acm is not set for this ac */
4314 while (unlikely(local->wmm_acm & BIT(skb->priority))) {
4315 if (wme_downgrade_ac(skb)) {
4316 @@ -85,24 +131,17 @@ static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb)
4317 return ieee802_1d_to_ac[skb->priority];
4318 }
4319
4320 -void ieee80211_select_queue(struct ieee80211_local *local, struct sk_buff *skb)
4321 +void ieee80211_set_qos_hdr(struct ieee80211_local *local, struct sk_buff *skb)
4322 {
4323 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
4324 - u16 queue;
4325 - u8 tid;
4326 -
4327 - queue = classify80211(local, skb);
4328 - if (unlikely(queue >= local->hw.queues))
4329 - queue = local->hw.queues - 1;
4330 -
4331 - /*
4332 - * Now we know the 1d priority, fill in the QoS header if
4333 - * there is one (and we haven't done this before).
4334 - */
4335 + struct ieee80211_hdr *hdr = (void *)skb->data;
4336 +
4337 + /* Fill in the QoS header if there is one. */
4338 if (ieee80211_is_data_qos(hdr->frame_control)) {
4339 u8 *p = ieee80211_get_qos_ctl(hdr);
4340 - u8 ack_policy = 0;
4341 + u8 ack_policy = 0, tid;
4342 +
4343 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
4344 +
4345 if (unlikely(local->wifi_wme_noack_test))
4346 ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK <<
4347 QOS_CONTROL_ACK_POLICY_SHIFT;
4348 @@ -110,6 +149,4 @@ void ieee80211_select_queue(struct ieee80211_local *local, struct sk_buff *skb)
4349 *p++ = ack_policy | tid;
4350 *p = 0;
4351 }
4352 -
4353 - skb_set_queue_mapping(skb, queue);
4354 }
4355 diff --git a/net/mac80211/wme.h b/net/mac80211/wme.h
4356 index d4fd87c..6053b1c 100644
4357 --- a/net/mac80211/wme.h
4358 +++ b/net/mac80211/wme.h
4359 @@ -20,7 +20,11 @@
4360
4361 extern const int ieee802_1d_to_ac[8];
4362
4363 -void ieee80211_select_queue(struct ieee80211_local *local,
4364 - struct sk_buff *skb);
4365 +u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
4366 + struct sk_buff *skb);
4367 +void ieee80211_set_qos_hdr(struct ieee80211_local *local, struct sk_buff *skb);
4368 +u16 ieee80211_downgrade_queue(struct ieee80211_local *local,
4369 + struct sk_buff *skb);
4370 +
4371
4372 #endif /* _WME_H */
4373 diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
4374 index 5509dd1..7dfd469 100644
4375 --- a/net/netfilter/nf_conntrack_ftp.c
4376 +++ b/net/netfilter/nf_conntrack_ftp.c
4377 @@ -323,24 +323,24 @@ static void update_nl_seq(struct nf_conn *ct, u32 nl_seq,
4378 struct nf_ct_ftp_master *info, int dir,
4379 struct sk_buff *skb)
4380 {
4381 - unsigned int i, oldest = NUM_SEQ_TO_REMEMBER;
4382 + unsigned int i, oldest;
4383
4384 /* Look for oldest: if we find exact match, we're done. */
4385 for (i = 0; i < info->seq_aft_nl_num[dir]; i++) {
4386 if (info->seq_aft_nl[dir][i] == nl_seq)
4387 return;
4388 -
4389 - if (oldest == info->seq_aft_nl_num[dir] ||
4390 - before(info->seq_aft_nl[dir][i],
4391 - info->seq_aft_nl[dir][oldest]))
4392 - oldest = i;
4393 }
4394
4395 if (info->seq_aft_nl_num[dir] < NUM_SEQ_TO_REMEMBER) {
4396 info->seq_aft_nl[dir][info->seq_aft_nl_num[dir]++] = nl_seq;
4397 - } else if (oldest != NUM_SEQ_TO_REMEMBER &&
4398 - after(nl_seq, info->seq_aft_nl[dir][oldest])) {
4399 - info->seq_aft_nl[dir][oldest] = nl_seq;
4400 + } else {
4401 + if (before(info->seq_aft_nl[dir][0], info->seq_aft_nl[dir][1]))
4402 + oldest = 0;
4403 + else
4404 + oldest = 1;
4405 +
4406 + if (after(nl_seq, info->seq_aft_nl[dir][oldest]))
4407 + info->seq_aft_nl[dir][oldest] = nl_seq;
4408 }
4409 }
4410
4411 diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
4412 index 129d75e..9c5a19d 100644
4413 --- a/net/sunrpc/auth_gss/auth_gss.c
4414 +++ b/net/sunrpc/auth_gss/auth_gss.c
4415 @@ -644,7 +644,22 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
4416 p = gss_fill_context(p, end, ctx, gss_msg->auth->mech);
4417 if (IS_ERR(p)) {
4418 err = PTR_ERR(p);
4419 - gss_msg->msg.errno = (err == -EAGAIN) ? -EAGAIN : -EACCES;
4420 + switch (err) {
4421 + case -EACCES:
4422 + gss_msg->msg.errno = err;
4423 + err = mlen;
4424 + break;
4425 + case -EFAULT:
4426 + case -ENOMEM:
4427 + case -EINVAL:
4428 + case -ENOSYS:
4429 + gss_msg->msg.errno = -EAGAIN;
4430 + break;
4431 + default:
4432 + printk(KERN_CRIT "%s: bad return from "
4433 + "gss_fill_context: %ld\n", __func__, err);
4434 + BUG();
4435 + }
4436 goto err_release_msg;
4437 }
4438 gss_msg->ctx = gss_get_ctx(ctx);
4439 diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c
4440 index ef45eba..2deb0ed 100644
4441 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c
4442 +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c
4443 @@ -131,8 +131,10 @@ gss_import_sec_context_kerberos(const void *p,
4444 struct krb5_ctx *ctx;
4445 int tmp;
4446
4447 - if (!(ctx = kzalloc(sizeof(*ctx), GFP_NOFS)))
4448 + if (!(ctx = kzalloc(sizeof(*ctx), GFP_NOFS))) {
4449 + p = ERR_PTR(-ENOMEM);
4450 goto out_err;
4451 + }
4452
4453 p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate));
4454 if (IS_ERR(p))
4455 diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c
4456 index 6efbb0c..76e4c6f 100644
4457 --- a/net/sunrpc/auth_gss/gss_mech_switch.c
4458 +++ b/net/sunrpc/auth_gss/gss_mech_switch.c
4459 @@ -252,7 +252,7 @@ gss_import_sec_context(const void *input_token, size_t bufsize,
4460 struct gss_ctx **ctx_id)
4461 {
4462 if (!(*ctx_id = kzalloc(sizeof(**ctx_id), GFP_KERNEL)))
4463 - return GSS_S_FAILURE;
4464 + return -ENOMEM;
4465 (*ctx_id)->mech_type = gss_mech_get(mech);
4466
4467 return mech->gm_ops
4468 diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
4469 index df124f7..0266cca 100644
4470 --- a/net/sunrpc/svc_xprt.c
4471 +++ b/net/sunrpc/svc_xprt.c
4472 @@ -711,7 +711,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
4473 spin_unlock_bh(&pool->sp_lock);
4474
4475 len = 0;
4476 - if (test_bit(XPT_LISTENER, &xprt->xpt_flags)) {
4477 + if (test_bit(XPT_LISTENER, &xprt->xpt_flags) &&
4478 + !test_bit(XPT_CLOSE, &xprt->xpt_flags)) {
4479 struct svc_xprt *newxpt;
4480 newxpt = xprt->xpt_ops->xpo_accept(xprt);
4481 if (newxpt) {
4482 diff --git a/net/wireless/reg.c b/net/wireless/reg.c
4483 index f256dff..efd24a7 100644
4484 --- a/net/wireless/reg.c
4485 +++ b/net/wireless/reg.c
4486 @@ -1714,7 +1714,7 @@ int regulatory_hint_user(const char *alpha2)
4487 request->wiphy_idx = WIPHY_IDX_STALE;
4488 request->alpha2[0] = alpha2[0];
4489 request->alpha2[1] = alpha2[1];
4490 - request->initiator = NL80211_REGDOM_SET_BY_USER,
4491 + request->initiator = NL80211_REGDOM_SET_BY_USER;
4492
4493 queue_regulatory_request(request);
4494
4495 diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
4496 index 7337abd..67ca440 100644
4497 --- a/sound/pci/ac97/ac97_patch.c
4498 +++ b/sound/pci/ac97/ac97_patch.c
4499 @@ -1870,6 +1870,7 @@ static unsigned int ad1981_jacks_blacklist[] = {
4500 0x10140554, /* Thinkpad T42p/R50p */
4501 0x10140567, /* Thinkpad T43p 2668-G7U */
4502 0x10140581, /* Thinkpad X41-2527 */
4503 + 0x10280160, /* Dell Dimension 2400 */
4504 0x104380b0, /* Asus A7V8X-MX */
4505 0x11790241, /* Toshiba Satellite A-15 S127 */
4506 0x144dc01a, /* Samsung NP-X20C004/SEG */
4507 diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
4508 index d6752df..42b4fbb 100644
4509 --- a/sound/pci/atiixp.c
4510 +++ b/sound/pci/atiixp.c
4511 @@ -297,6 +297,7 @@ static struct pci_device_id snd_atiixp_ids[] = {
4512 MODULE_DEVICE_TABLE(pci, snd_atiixp_ids);
4513
4514 static struct snd_pci_quirk atiixp_quirks[] __devinitdata = {
4515 + SND_PCI_QUIRK(0x105b, 0x0c81, "Foxconn RC4107MA-RS2", 0),
4516 SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0),
4517 { } /* terminator */
4518 };
4519 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4520 index e40d31f..a4cb183 100644
4521 --- a/sound/pci/hda/patch_realtek.c
4522 +++ b/sound/pci/hda/patch_realtek.c
4523 @@ -15323,7 +15323,7 @@ static struct alc_config_preset alc861vd_presets[] = {
4524 static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
4525 const struct auto_pin_cfg *cfg)
4526 {
4527 - return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
4528 + return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0);
4529 }
4530
4531
4532 diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
4533 index 593d5b9..2089fe7 100644
4534 --- a/sound/soc/codecs/wm8350.c
4535 +++ b/sound/soc/codecs/wm8350.c
4536 @@ -925,7 +925,7 @@ static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
4537 iface |= 0x3 << 8;
4538 break;
4539 case SND_SOC_DAIFMT_DSP_B:
4540 - iface |= 0x3 << 8; /* lg not sure which mode */
4541 + iface |= 0x3 << 8 | WM8350_AIF_LRCLK_INV;
4542 break;
4543 default:
4544 return -EINVAL;
4545 diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c
4546 index 060d5d0..8db62e2 100644
4547 --- a/sound/soc/codecs/wm8510.c
4548 +++ b/sound/soc/codecs/wm8510.c
4549 @@ -425,23 +425,23 @@ static int wm8510_pcm_hw_params(struct snd_pcm_substream *substream,
4550
4551 /* filter coefficient */
4552 switch (params_rate(params)) {
4553 - case SNDRV_PCM_RATE_8000:
4554 + case 8000:
4555 adn |= 0x5 << 1;
4556 break;
4557 - case SNDRV_PCM_RATE_11025:
4558 + case 11025:
4559 adn |= 0x4 << 1;
4560 break;
4561 - case SNDRV_PCM_RATE_16000:
4562 + case 16000:
4563 adn |= 0x3 << 1;
4564 break;
4565 - case SNDRV_PCM_RATE_22050:
4566 + case 22050:
4567 adn |= 0x2 << 1;
4568 break;
4569 - case SNDRV_PCM_RATE_32000:
4570 + case 32000:
4571 adn |= 0x1 << 1;
4572 break;
4573 - case SNDRV_PCM_RATE_44100:
4574 - case SNDRV_PCM_RATE_48000:
4575 + case 44100:
4576 + case 48000:
4577 break;
4578 }
4579
4580 diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c
4581 index 1ef2454..63bc2ae 100644
4582 --- a/sound/soc/codecs/wm8940.c
4583 +++ b/sound/soc/codecs/wm8940.c
4584 @@ -379,23 +379,23 @@ static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream,
4585 iface |= (1 << 9);
4586
4587 switch (params_rate(params)) {
4588 - case SNDRV_PCM_RATE_8000:
4589 + case 8000:
4590 addcntrl |= (0x5 << 1);
4591 break;
4592 - case SNDRV_PCM_RATE_11025:
4593 + case 11025:
4594 addcntrl |= (0x4 << 1);
4595 break;
4596 - case SNDRV_PCM_RATE_16000:
4597 + case 16000:
4598 addcntrl |= (0x3 << 1);
4599 break;
4600 - case SNDRV_PCM_RATE_22050:
4601 + case 22050:
4602 addcntrl |= (0x2 << 1);
4603 break;
4604 - case SNDRV_PCM_RATE_32000:
4605 + case 32000:
4606 addcntrl |= (0x1 << 1);
4607 break;
4608 - case SNDRV_PCM_RATE_44100:
4609 - case SNDRV_PCM_RATE_48000:
4610 + case 44100:
4611 + case 48000:
4612 break;
4613 }
4614 ret = snd_soc_write(codec, WM8940_ADDCNTRL, addcntrl);
4615 diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c
4616 index b0bd1c0..0dbf6fe 100644
4617 --- a/sound/soc/codecs/wm8974.c
4618 +++ b/sound/soc/codecs/wm8974.c
4619 @@ -480,23 +480,23 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream,
4620
4621 /* filter coefficient */
4622 switch (params_rate(params)) {
4623 - case SNDRV_PCM_RATE_8000:
4624 + case 8000:
4625 adn |= 0x5 << 1;
4626 break;
4627 - case SNDRV_PCM_RATE_11025:
4628 + case 11025:
4629 adn |= 0x4 << 1;
4630 break;
4631 - case SNDRV_PCM_RATE_16000:
4632 + case 16000:
4633 adn |= 0x3 << 1;
4634 break;
4635 - case SNDRV_PCM_RATE_22050:
4636 + case 22050:
4637 adn |= 0x2 << 1;
4638 break;
4639 - case SNDRV_PCM_RATE_32000:
4640 + case 32000:
4641 adn |= 0x1 << 1;
4642 break;
4643 - case SNDRV_PCM_RATE_44100:
4644 - case SNDRV_PCM_RATE_48000:
4645 + case 44100:
4646 + case 48000:
4647 break;
4648 }
4649

  ViewVC Help
Powered by ViewVC 1.1.20