ia64/xen-unstable

view linux-2.6.7-xen-sparse/arch/xen/i386/mm/mmap.c @ 2256:821d32bd8ce0

bitkeeper revision 1.1159.34.2 (4120f82bRcTbpXEs-zb6q77ty9n_Ig)

Add debugging to the new mmap() failure path.
author kaf24@scramble.cl.cam.ac.uk
date Mon Aug 16 18:08:43 2004 +0000 (2004-08-16)
parents 193f9a5f845c
children bb91ba552d34
line source
2 #include <linux/slab.h>
3 #include <linux/version.h>
4 #include <linux/mman.h>
5 #include <linux/init.h>
6 #include <asm/pgalloc.h>
8 unsigned long
9 arch_get_unmapped_area(struct file *filp, unsigned long addr,
10 unsigned long len, unsigned long pgoff, unsigned long flags)
11 {
12 struct mm_struct *mm = current->mm;
13 struct vm_area_struct *vma;
14 unsigned long start_addr;
16 if (len > TASK_SIZE)
17 return -ENOMEM;
19 if (addr) {
20 addr = PAGE_ALIGN(addr);
21 vma = find_vma(mm, addr);
22 if (((TASK_SIZE - len) >= addr) &&
23 (addr >= (FIRST_USER_PGD_NR<<PGDIR_SHIFT)) &&
24 (!vma || ((addr + len) <= vma->vm_start)))
25 return addr;
26 }
27 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
28 start_addr = addr = mm->free_area_cache;
29 #else
30 start_addr = addr = PAGE_ALIGN(TASK_UNMAPPED_BASE);
31 #endif
33 full_search:
34 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
35 /* At this point: (!vma || addr < vma->vm_end). */
36 if (TASK_SIZE - len < addr) {
37 /*
38 * Start a new search - just in case we missed
39 * some holes.
40 */
41 if (start_addr != TASK_UNMAPPED_BASE) {
42 start_addr = addr = TASK_UNMAPPED_BASE;
43 goto full_search;
44 }
45 return -ENOMEM;
46 }
47 if (!vma || addr + len <= vma->vm_start) {
48 /*
49 * Remember the place where we stopped the search:
50 */
51 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
52 mm->free_area_cache = addr + len;
53 #endif
54 return addr;
55 }
56 addr = vma->vm_end;
57 }
58 }
60 unsigned long
61 arch_check_fixed_mapping(struct file *filp, unsigned long addr,
62 unsigned long len, unsigned long pgoff, unsigned long flags)
63 {
64 if (addr < (FIRST_USER_PGD_NR<<PGDIR_SHIFT)) {
65 printk(KERN_ALERT "WARNING: Preventing a mmap() request by %s at 0x%08lx, len %08lx\n",
66 current->comm, addr, len);
67 return -EINVAL;
68 }
69 return 0;
70 }