linux-bk/mm/mmap.c
<<
>>
Prefs
   1/*
   2 * mm/mmap.c
   3 *
   4 * Written by obz.
   5 *
   6 * Address space accounting code        <alan@redhat.com>
   7 */
   8
   9#include <linux/slab.h>
  10#include <linux/shm.h>
  11#include <linux/mman.h>
  12#include <linux/pagemap.h>
  13#include <linux/swap.h>
  14#include <linux/init.h>
  15#include <linux/file.h>
  16#include <linux/fs.h>
  17#include <linux/personality.h>
  18#include <linux/security.h>
  19
  20#include <asm/uaccess.h>
  21#include <asm/pgalloc.h>
  22#include <asm/tlb.h>
  23
  24extern void unmap_page_range(mmu_gather_t *,struct vm_area_struct *vma, unsigned long address, unsigned long size);
  25extern void clear_page_tables(mmu_gather_t *tlb, unsigned long first, int nr);
  26
  27/*
  28 * WARNING: the debugging will use recursive algorithms so never enable this
  29 * unless you know what you are doing.
  30 */
  31#undef DEBUG_MM_RB
  32
  33/* description of effects of mapping type and prot in current implementation.
  34 * this is due to the limited x86 page protection hardware.  The expected
  35 * behavior is in parens:
  36 *
  37 * map_type     prot
  38 *              PROT_NONE       PROT_READ       PROT_WRITE      PROT_EXEC
  39 * MAP_SHARED   r: (no) no      r: (yes) yes    r: (no) yes     r: (no) yes
  40 *              w: (no) no      w: (no) no      w: (yes) yes    w: (no) no
  41 *              x: (no) no      x: (no) yes     x: (no) yes     x: (yes) yes
  42 *              
  43 * MAP_PRIVATE  r: (no) no      r: (yes) yes    r: (no) yes     r: (no) yes
  44 *              w: (no) no      w: (no) no      w: (copy) copy  w: (no) no
  45 *              x: (no) no      x: (no) yes     x: (no) yes     x: (yes) yes
  46 *
  47 */
  48pgprot_t protection_map[16] = {
  49        __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
  50        __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
  51};
  52
  53int sysctl_overcommit_memory = 0;       /* default is heuristic overcommit */
  54int sysctl_overcommit_ratio = 50;       /* default is 50% */
  55atomic_t vm_committed_space = ATOMIC_INIT(0);
  56
  57inline void vm_unacct_memory(long pages)
  58{       
  59        atomic_sub(pages, &vm_committed_space);
  60}
  61
  62/*
  63 * Check that a process has enough memory to allocate a new virtual
  64 * mapping. 1 means there is enough memory for the allocation to
  65 * succeed and 0 implies there is not.
  66 *
  67 * We currently support three overcommit policies, which are set via the
  68 * vm.overcommit_memory sysctl.  See Documentation/vm/overcommit-acounting
  69 *
  70 * Strict overcommit modes added 2002 Feb 26 by Alan Cox.
  71 * Additional code 2002 Jul 20 by Robert Love.
  72 */
  73int vm_enough_memory(long pages)
  74{
  75        unsigned long free, allowed;
  76        struct sysinfo i;
  77
  78        atomic_add(pages, &vm_committed_space);
  79
  80        /*
  81         * Sometimes we want to use more memory than we have
  82         */
  83        if (sysctl_overcommit_memory == 1)
  84                return 1;
  85
  86        if (sysctl_overcommit_memory == 0) {
  87                free = get_page_cache_size();
  88                free += nr_free_pages();
  89                free += nr_swap_pages;
  90
  91                /*
  92                 * This double-counts: the nrpages are both in the
  93                 * page-cache and in the swapper space. At the same time,
  94                 * this compensates for the swap-space over-allocation
  95                 * (ie "nr_swap_pages" being too small).
  96                 */
  97                free += swapper_space.nrpages;
  98
  99                /*
 100                 * The code below doesn't account for free space in the
 101                 * inode and dentry slab cache, slab cache fragmentation,
 102                 * inodes and dentries which will become freeable under
 103                 * VM load, etc. Lets just hope all these (complex)
 104                 * factors balance out...
 105                 */
 106                free += (dentry_stat.nr_unused * sizeof(struct dentry)) >>
 107                        PAGE_SHIFT;
 108                free += (inodes_stat.nr_unused * sizeof(struct inode)) >>
 109                        PAGE_SHIFT;
 110
 111                if (free > pages)
 112                        return 1;
 113                vm_unacct_memory(pages);
 114                return 0;
 115        }
 116
 117        /*
 118         * FIXME: need to add arch hooks to get the bits we need
 119         * without this higher overhead crap
 120         */
 121        si_meminfo(&i);
 122        allowed = i.totalram * sysctl_overcommit_ratio / 100;
 123        allowed += total_swap_pages;
 124
 125        if (atomic_read(&vm_committed_space) < allowed)
 126                return 1;
 127
 128        vm_unacct_memory(pages);
 129
 130        return 0;
 131}
 132
 133/* Remove one vm structure from the inode's i_mapping address space. */
 134static inline void remove_shared_vm_struct(struct vm_area_struct *vma)
 135{
 136        struct file *file = vma->vm_file;
 137
 138        if (file) {
 139                struct inode *inode = file->f_dentry->d_inode;
 140
 141                spin_lock(&inode->i_mapping->i_shared_lock);
 142                if (vma->vm_flags & VM_DENYWRITE)
 143                        atomic_inc(&inode->i_writecount);
 144                list_del_init(&vma->shared);
 145                spin_unlock(&inode->i_mapping->i_shared_lock);
 146        }
 147}
 148
 149/*
 150 *  sys_brk() for the most part doesn't need the global kernel
 151 *  lock, except when an application is doing something nasty
 152 *  like trying to un-brk an area that has already been mapped
 153 *  to a regular file.  in this case, the unmapping will need
 154 *  to invoke file system routines that need the global lock.
 155 */
 156asmlinkage unsigned long sys_brk(unsigned long brk)
 157{
 158        unsigned long rlim, retval;
 159        unsigned long newbrk, oldbrk;
 160        struct mm_struct *mm = current->mm;
 161
 162        down_write(&mm->mmap_sem);
 163
 164        if (brk < mm->end_code)
 165                goto out;
 166        newbrk = PAGE_ALIGN(brk);
 167        oldbrk = PAGE_ALIGN(mm->brk);
 168        if (oldbrk == newbrk)
 169                goto set_brk;
 170
 171        /* Always allow shrinking brk. */
 172        if (brk <= mm->brk) {
 173                if (!do_munmap(mm, newbrk, oldbrk-newbrk))
 174                        goto set_brk;
 175                goto out;
 176        }
 177
 178        /* Check against rlimit.. */
 179        rlim = current->rlim[RLIMIT_DATA].rlim_cur;
 180        if (rlim < RLIM_INFINITY && brk - mm->start_data > rlim)
 181                goto out;
 182
 183        /* Check against existing mmap mappings. */
 184        if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE))
 185                goto out;
 186
 187        /* Ok, looks good - let it rip. */
 188        if (do_brk(oldbrk, newbrk-oldbrk) != oldbrk)
 189                goto out;
 190set_brk:
 191        mm->brk = brk;
 192out:
 193        retval = mm->brk;
 194        up_write(&mm->mmap_sem);
 195        return retval;
 196}
 197
 198/* Combine the mmap "prot" and "flags" argument into one "vm_flags" used
 199 * internally. Essentially, translate the "PROT_xxx" and "MAP_xxx" bits
 200 * into "VM_xxx".
 201 */
 202static inline unsigned long calc_vm_flags(unsigned long prot, unsigned long flags)
 203{
 204#define _trans(x,bit1,bit2) \
 205((bit1==bit2)?(x&bit1):(x&bit1)?bit2:0)
 206
 207        unsigned long prot_bits, flag_bits;
 208        prot_bits =
 209                _trans(prot, PROT_READ, VM_READ) |
 210                _trans(prot, PROT_WRITE, VM_WRITE) |
 211                _trans(prot, PROT_EXEC, VM_EXEC);
 212        flag_bits =
 213                _trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN) |
 214                _trans(flags, MAP_DENYWRITE, VM_DENYWRITE) |
 215                _trans(flags, MAP_EXECUTABLE, VM_EXECUTABLE);
 216        return prot_bits | flag_bits;
 217#undef _trans
 218}
 219
 220#ifdef DEBUG_MM_RB
 221static int browse_rb(struct rb_node * rb_node) {
 222        int i = 0;
 223        if (rb_node) {
 224                i++;
 225                i += browse_rb(rb_node->rb_left);
 226                i += browse_rb(rb_node->rb_right);
 227        }
 228        return i;
 229}
 230
 231static void validate_mm(struct mm_struct * mm) {
 232        int bug = 0;
 233        int i = 0;
 234        struct vm_area_struct * tmp = mm->mmap;
 235        while (tmp) {
 236                tmp = tmp->vm_next;
 237                i++;
 238        }
 239        if (i != mm->map_count)
 240                printk("map_count %d vm_next %d\n", mm->map_count, i), bug = 1;
 241        i = browse_rb(mm->mm_rb.rb_node);
 242        if (i != mm->map_count)
 243                printk("map_count %d rb %d\n", mm->map_count, i), bug = 1;
 244        if (bug)
 245                BUG();
 246}
 247#else
 248#define validate_mm(mm) do { } while (0)
 249#endif
 250
 251static struct vm_area_struct * find_vma_prepare(struct mm_struct * mm, unsigned long addr,
 252                                                struct vm_area_struct ** pprev,
 253                                                struct rb_node *** rb_link,
 254                                                struct rb_node ** rb_parent)
 255{
 256        struct vm_area_struct * vma;
 257        struct rb_node ** __rb_link, * __rb_parent, * rb_prev;
 258
 259        __rb_link = &mm->mm_rb.rb_node;
 260        rb_prev = __rb_parent = NULL;
 261        vma = NULL;
 262
 263        while (*__rb_link) {
 264                struct vm_area_struct *vma_tmp;
 265
 266                __rb_parent = *__rb_link;
 267                vma_tmp = rb_entry(__rb_parent, struct vm_area_struct, vm_rb);
 268
 269                if (vma_tmp->vm_end > addr) {
 270                        vma = vma_tmp;
 271                        if (vma_tmp->vm_start <= addr)
 272                                return vma;
 273                        __rb_link = &__rb_parent->rb_left;
 274                } else {
 275                        rb_prev = __rb_parent;
 276                        __rb_link = &__rb_parent->rb_right;
 277                }
 278        }
 279
 280        *pprev = NULL;
 281        if (rb_prev)
 282                *pprev = rb_entry(rb_prev, struct vm_area_struct, vm_rb);
 283        *rb_link = __rb_link;
 284        *rb_parent = __rb_parent;
 285        return vma;
 286}
 287
 288static inline void __vma_link_list(struct mm_struct * mm, struct vm_area_struct * vma,
 289                                   struct vm_area_struct * prev, struct rb_node * rb_parent)
 290{
 291        if (prev) {
 292                vma->vm_next = prev->vm_next;
 293                prev->vm_next = vma;
 294        } else {
 295                mm->mmap = vma;
 296                if (rb_parent)
 297                        vma->vm_next = rb_entry(rb_parent, struct vm_area_struct, vm_rb);
 298                else
 299                        vma->vm_next = NULL;
 300        }
 301}
 302
 303static inline void __vma_link_rb(struct mm_struct * mm, struct vm_area_struct * vma,
 304                                 struct rb_node ** rb_link, struct rb_node * rb_parent)
 305{
 306        rb_link_node(&vma->vm_rb, rb_parent, rb_link);
 307        rb_insert_color(&vma->vm_rb, &mm->mm_rb);
 308}
 309
 310static inline void __vma_link_file(struct vm_area_struct * vma)
 311{
 312        struct file * file;
 313
 314        file = vma->vm_file;
 315        if (file) {
 316                struct inode * inode = file->f_dentry->d_inode;
 317                struct address_space *mapping = inode->i_mapping;
 318
 319                if (vma->vm_flags & VM_DENYWRITE)
 320                        atomic_dec(&inode->i_writecount);
 321
 322                if (vma->vm_flags & VM_SHARED)
 323                        list_add_tail(&vma->shared, &mapping->i_mmap_shared);
 324                else
 325                        list_add_tail(&vma->shared, &mapping->i_mmap);
 326        }
 327}
 328
 329static void __vma_link(struct mm_struct * mm, struct vm_area_struct * vma,  struct vm_area_struct * prev,
 330                       struct rb_node ** rb_link, struct rb_node * rb_parent)
 331{
 332        __vma_link_list(mm, vma, prev, rb_parent);
 333        __vma_link_rb(mm, vma, rb_link, rb_parent);
 334        __vma_link_file(vma);
 335}
 336
 337static inline void vma_link(struct mm_struct * mm, struct vm_area_struct * vma, struct vm_area_struct * prev,
 338                            struct rb_node ** rb_link, struct rb_node * rb_parent)
 339{
 340        struct address_space *mapping = NULL;
 341
 342        if (vma->vm_file)
 343                mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
 344
 345        if (mapping)
 346                spin_lock(&mapping->i_shared_lock);
 347        spin_lock(&mm->page_table_lock);
 348        __vma_link(mm, vma, prev, rb_link, rb_parent);
 349        spin_unlock(&mm->page_table_lock);
 350        if (mapping)
 351                spin_unlock(&mapping->i_shared_lock);
 352
 353        mm->map_count++;
 354        validate_mm(mm);
 355}
 356
 357static int vma_merge(struct mm_struct * mm, struct vm_area_struct * prev,
 358                     struct rb_node * rb_parent, unsigned long addr, 
 359                     unsigned long end, unsigned long vm_flags)
 360{
 361        spinlock_t * lock = &mm->page_table_lock;
 362        if (!prev) {
 363                prev = rb_entry(rb_parent, struct vm_area_struct, vm_rb);
 364                goto merge_next;
 365        }
 366        if (prev->vm_end == addr && can_vma_merge(prev, vm_flags)) {
 367                struct vm_area_struct * next;
 368
 369                spin_lock(lock);
 370                prev->vm_end = end;
 371                next = prev->vm_next;
 372                if (next && prev->vm_end == next->vm_start && can_vma_merge(next, vm_flags)) {
 373                        prev->vm_end = next->vm_end;
 374                        __vma_unlink(mm, next, prev);
 375                        spin_unlock(lock);
 376
 377                        mm->map_count--;
 378                        kmem_cache_free(vm_area_cachep, next);
 379                        return 1;
 380                }
 381                spin_unlock(lock);
 382                return 1;
 383        }
 384
 385        prev = prev->vm_next;
 386        if (prev) {
 387 merge_next:
 388                if (!can_vma_merge(prev, vm_flags))
 389                        return 0;
 390                if (end == prev->vm_start) {
 391                        spin_lock(lock);
 392                        prev->vm_start = addr;
 393                        spin_unlock(lock);
 394                        return 1;
 395                }
 396        }
 397
 398        return 0;
 399}
 400
 401unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
 402                        unsigned long len, unsigned long prot,
 403                        unsigned long flags, unsigned long pgoff)
 404{
 405        struct mm_struct * mm = current->mm;
 406        struct vm_area_struct * vma, * prev;
 407        struct inode *inode = NULL;
 408        unsigned int vm_flags;
 409        int correct_wcount = 0;
 410        int error;
 411        struct rb_node ** rb_link, * rb_parent;
 412        unsigned long charged = 0;
 413
 414        if (file && (!file->f_op || !file->f_op->mmap))
 415                return -ENODEV;
 416
 417        if (!len)
 418                return addr;
 419
 420        if (len > TASK_SIZE)
 421                return -EINVAL;
 422
 423        len = PAGE_ALIGN(len);
 424
 425        /* offset overflow? */
 426        if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
 427                return -EINVAL;
 428
 429        /* Too many mappings? */
 430        if (mm->map_count > MAX_MAP_COUNT)
 431                return -ENOMEM;
 432
 433        /* Obtain the address to map to. we verify (or select) it and ensure
 434         * that it represents a valid section of the address space.
 435         */
 436        addr = get_unmapped_area(file, addr, len, pgoff, flags);
 437        if (addr & ~PAGE_MASK)
 438                return addr;
 439
 440        /* Do simple checking here so the lower-level routines won't have
 441         * to. we assume access permissions have been handled by the open
 442         * of the memory object, so we don't do any here.
 443         */
 444        vm_flags = calc_vm_flags(prot,flags) | mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
 445
 446        if (flags & MAP_LOCKED) {
 447                if (!capable(CAP_IPC_LOCK))
 448                        return -EPERM;
 449                vm_flags |= VM_LOCKED;
 450        }
 451        /* mlock MCL_FUTURE? */
 452        if (vm_flags & VM_LOCKED) {
 453                unsigned long locked = mm->locked_vm << PAGE_SHIFT;
 454                locked += len;
 455                if (locked > current->rlim[RLIMIT_MEMLOCK].rlim_cur)
 456                        return -EAGAIN;
 457        }
 458
 459        if (file) {
 460                inode = file->f_dentry->d_inode;
 461                switch (flags & MAP_TYPE) {
 462                case MAP_SHARED:
 463                        if ((prot & PROT_WRITE) && !(file->f_mode & FMODE_WRITE))
 464                                return -EACCES;
 465
 466                        /* Make sure we don't allow writing to an append-only file.. */
 467                        if (IS_APPEND(inode) && (file->f_mode & FMODE_WRITE))
 468                                return -EACCES;
 469
 470                        /* make sure there are no mandatory locks on the file. */
 471                        if (locks_verify_locked(inode))
 472                                return -EAGAIN;
 473
 474                        vm_flags |= VM_SHARED | VM_MAYSHARE;
 475                        if (!(file->f_mode & FMODE_WRITE))
 476                                vm_flags &= ~(VM_MAYWRITE | VM_SHARED);
 477
 478                        /* fall through */
 479                case MAP_PRIVATE:
 480                        if (!(file->f_mode & FMODE_READ))
 481                                return -EACCES;
 482                        break;
 483
 484                default:
 485                        return -EINVAL;
 486                }
 487        } else {
 488                vm_flags |= VM_SHARED | VM_MAYSHARE;
 489                switch (flags & MAP_TYPE) {
 490                default:
 491                        return -EINVAL;
 492                case MAP_PRIVATE:
 493                        vm_flags &= ~(VM_SHARED | VM_MAYSHARE);
 494                        /* fall through */
 495                case MAP_SHARED:
 496                        break;
 497                }
 498        }
 499
 500        error = security_ops->file_mmap(file, prot, flags);
 501        if (error)
 502                return error;
 503                
 504        /* Clear old maps */
 505        error = -ENOMEM;
 506munmap_back:
 507        vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
 508        if (vma && vma->vm_start < addr + len) {
 509                if (do_munmap(mm, addr, len))
 510                        return -ENOMEM;
 511                goto munmap_back;
 512        }
 513
 514        /* Check against address space limit. */
 515        if ((mm->total_vm << PAGE_SHIFT) + len
 516            > current->rlim[RLIMIT_AS].rlim_cur)
 517                return -ENOMEM;
 518
 519        if (!(flags & MAP_NORESERVE) || sysctl_overcommit_memory > 1) {
 520                if (vm_flags & VM_SHARED) {
 521                        /* Check memory availability in shmem_file_setup? */
 522                        vm_flags |= VM_ACCOUNT;
 523                } else if (vm_flags & VM_WRITE) {
 524                        /* Private writable mapping: check memory availability */
 525                        charged = len >> PAGE_SHIFT;
 526                        if (!vm_enough_memory(charged))
 527                                return -ENOMEM;
 528                        vm_flags |= VM_ACCOUNT;
 529                }
 530        }
 531
 532        /* Can we just expand an old anonymous mapping? */
 533        if (!file && !(vm_flags & VM_SHARED) && rb_parent)
 534                if (vma_merge(mm, prev, rb_parent, addr, addr + len, vm_flags))
 535                        goto out;
 536
 537        /* Determine the object being mapped and call the appropriate
 538         * specific mapper. the address has already been validated, but
 539         * not unmapped, but the maps are removed from the list.
 540         */
 541        vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
 542        error = -ENOMEM;
 543        if (!vma)
 544                goto unacct_error;
 545
 546        vma->vm_mm = mm;
 547        vma->vm_start = addr;
 548        vma->vm_end = addr + len;
 549        vma->vm_flags = vm_flags;
 550        vma->vm_page_prot = protection_map[vm_flags & 0x0f];
 551        vma->vm_ops = NULL;
 552        vma->vm_pgoff = pgoff;
 553        vma->vm_file = NULL;
 554        vma->vm_private_data = NULL;
 555        vma->vm_raend = 0;
 556
 557        if (file) {
 558                error = -EINVAL;
 559                if (vm_flags & (VM_GROWSDOWN|VM_GROWSUP))
 560                        goto free_vma;
 561                if (vm_flags & VM_DENYWRITE) {
 562                        error = deny_write_access(file);
 563                        if (error)
 564                                goto free_vma;
 565                        correct_wcount = 1;
 566                }
 567                vma->vm_file = file;
 568                get_file(file);
 569                error = file->f_op->mmap(file, vma);
 570                if (error)
 571                        goto unmap_and_free_vma;
 572        } else if (vm_flags & VM_SHARED) {
 573                error = shmem_zero_setup(vma);
 574                if (error)
 575                        goto free_vma;
 576        }
 577
 578        /* We set VM_ACCOUNT in a shared mapping's vm_flags, to inform
 579         * shmem_zero_setup (perhaps called through /dev/zero's ->mmap)
 580         * that memory reservation must be checked; but that reservation
 581         * belongs to shared memory object, not to vma: so now clear it.
 582         */
 583        if ((vm_flags & (VM_SHARED|VM_ACCOUNT)) == (VM_SHARED|VM_ACCOUNT))
 584                vma->vm_flags &= ~VM_ACCOUNT;
 585
 586        /* Can addr have changed??
 587         *
 588         * Answer: Yes, several device drivers can do it in their
 589         *         f_op->mmap method. -DaveM
 590         */
 591        addr = vma->vm_start;
 592
 593        vma_link(mm, vma, prev, rb_link, rb_parent);
 594        if (correct_wcount)
 595                atomic_inc(&inode->i_writecount);
 596
 597out:    
 598        mm->total_vm += len >> PAGE_SHIFT;
 599        if (vm_flags & VM_LOCKED) {
 600                mm->locked_vm += len >> PAGE_SHIFT;
 601                make_pages_present(addr, addr + len);
 602        }
 603        return addr;
 604
 605unmap_and_free_vma:
 606        if (correct_wcount)
 607                atomic_inc(&inode->i_writecount);
 608        vma->vm_file = NULL;
 609        fput(file);
 610
 611        /* Undo any partial mapping done by a device driver. */
 612        zap_page_range(vma, vma->vm_start, vma->vm_end - vma->vm_start);
 613free_vma:
 614        kmem_cache_free(vm_area_cachep, vma);
 615unacct_error:
 616        if (charged)
 617                vm_unacct_memory(charged);
 618        return error;
 619}
 620
 621/* Get an address range which is currently unmapped.
 622 * For shmat() with addr=0.
 623 *
 624 * Ugly calling convention alert:
 625 * Return value with the low bits set means error value,
 626 * ie
 627 *      if (ret & ~PAGE_MASK)
 628 *              error = ret;
 629 *
 630 * This function "knows" that -ENOMEM has the bits set.
 631 */
 632#ifndef HAVE_ARCH_UNMAPPED_AREA
 633static inline unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
 634{
 635        struct vm_area_struct *vma;
 636
 637        if (len > TASK_SIZE)
 638                return -ENOMEM;
 639
 640        if (addr) {
 641                addr = PAGE_ALIGN(addr);
 642                vma = find_vma(current->mm, addr);
 643                if (TASK_SIZE - len >= addr &&
 644                    (!vma || addr + len <= vma->vm_start))
 645                        return addr;
 646        }
 647        addr = PAGE_ALIGN(TASK_UNMAPPED_BASE);
 648
 649        for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
 650                /* At this point:  (!vma || addr < vma->vm_end). */
 651                if (TASK_SIZE - len < addr)
 652                        return -ENOMEM;
 653                if (!vma || addr + len <= vma->vm_start)
 654                        return addr;
 655                addr = vma->vm_end;
 656        }
 657}
 658#else
 659extern unsigned long arch_get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 660#endif  
 661
 662unsigned long get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
 663{
 664        if (flags & MAP_FIXED) {
 665                if (addr > TASK_SIZE - len)
 666                        return -ENOMEM;
 667                if (addr & ~PAGE_MASK)
 668                        return -EINVAL;
 669                return addr;
 670        }
 671
 672        if (file && file->f_op && file->f_op->get_unmapped_area)
 673                return file->f_op->get_unmapped_area(file, addr, len, pgoff, flags);
 674
 675        return arch_get_unmapped_area(file, addr, len, pgoff, flags);
 676}
 677
 678/* Look up the first VMA which satisfies  addr < vm_end,  NULL if none. */
 679struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr)
 680{
 681        struct vm_area_struct *vma = NULL;
 682
 683        if (mm) {
 684                /* Check the cache first. */
 685                /* (Cache hit rate is typically around 35%.) */
 686                vma = mm->mmap_cache;
 687                if (!(vma && vma->vm_end > addr && vma->vm_start <= addr)) {
 688                        struct rb_node * rb_node;
 689
 690                        rb_node = mm->mm_rb.rb_node;
 691                        vma = NULL;
 692
 693                        while (rb_node) {
 694                                struct vm_area_struct * vma_tmp;
 695
 696                                vma_tmp = rb_entry(rb_node, struct vm_area_struct, vm_rb);
 697
 698                                if (vma_tmp->vm_end > addr) {
 699                                        vma = vma_tmp;
 700                                        if (vma_tmp->vm_start <= addr)
 701                                                break;
 702                                        rb_node = rb_node->rb_left;
 703                                } else
 704                                        rb_node = rb_node->rb_right;
 705                        }
 706                        if (vma)
 707                                mm->mmap_cache = vma;
 708                }
 709        }
 710        return vma;
 711}
 712
 713/* Same as find_vma, but also return a pointer to the previous VMA in *pprev. */
 714struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
 715                                      struct vm_area_struct **pprev)
 716{
 717        struct vm_area_struct *vma = NULL, *prev = NULL;
 718        struct rb_node * rb_node;
 719        if (!mm)
 720                goto out;
 721
 722        /* Guard against addr being lower than the first VMA */
 723        vma = mm->mmap;
 724
 725        /* Go through the RB tree quickly. */
 726        rb_node = mm->mm_rb.rb_node;
 727
 728        while (rb_node) {
 729                struct vm_area_struct *vma_tmp;
 730                vma_tmp = rb_entry(rb_node, struct vm_area_struct, vm_rb);
 731
 732                if (addr < vma_tmp->vm_end) {
 733                        rb_node = rb_node->rb_left;
 734                } else {
 735                        prev = vma_tmp;
 736                        if (!prev->vm_next || (addr < prev->vm_next->vm_end))
 737                                break;
 738                        rb_node = rb_node->rb_right;
 739                }
 740        }
 741
 742 out:
 743        *pprev = prev;
 744        return prev ? prev->vm_next : vma;
 745}
 746
 747#ifdef ARCH_STACK_GROWSUP
 748/*
 749 * vma is the first one with address > vma->vm_end.  Have to extend vma.
 750 */
 751int expand_stack(struct vm_area_struct * vma, unsigned long address)
 752{
 753        unsigned long grow;
 754
 755        if (!(vma->vm_flags & VM_GROWSUP))
 756                return -EFAULT;
 757
 758        /*
 759         * vma->vm_start/vm_end cannot change under us because the caller
 760         * is required to hold the mmap_sem in read mode. We need to get
 761         * the spinlock only before relocating the vma range ourself.
 762         */
 763        address += 4 + PAGE_SIZE - 1;
 764        address &= PAGE_MASK;
 765        spin_lock(&vma->vm_mm->page_table_lock);
 766        grow = (address - vma->vm_end) >> PAGE_SHIFT;
 767
 768        /* Overcommit.. */
 769        if (!vm_enough_memory(grow)) {
 770                spin_unlock(&vma->vm_mm->page_table_lock);
 771                return -ENOMEM;
 772        }
 773        
 774        if (address - vma->vm_start > current->rlim[RLIMIT_STACK].rlim_cur ||
 775                        ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) >
 776                        current->rlim[RLIMIT_AS].rlim_cur) {
 777                spin_unlock(&vma->vm_mm->page_table_lock);
 778                vm_unacct_memory(grow);
 779                return -ENOMEM;
 780        }
 781        vma->vm_end = address;
 782        vma->vm_mm->total_vm += grow;
 783        if (vma->vm_flags & VM_LOCKED)
 784                vma->vm_mm->locked_vm += grow;
 785        spin_unlock(&vma->vm_mm->page_table_lock);
 786        return 0;
 787}
 788
 789struct vm_area_struct * find_extend_vma(struct mm_struct * mm, unsigned long addr)
 790{
 791        struct vm_area_struct *vma, *prev;
 792
 793        addr &= PAGE_MASK;
 794        vma = find_vma_prev(mm, addr, &prev);
 795        if (vma && (vma->vm_start <= addr))
 796                return vma;
 797        if (!prev || expand_stack(prev, addr))
 798                return NULL;
 799        if (prev->vm_flags & VM_LOCKED) {
 800                make_pages_present(addr, prev->vm_end);
 801        }
 802        return prev;
 803}
 804#else
 805/*
 806 * vma is the first one with address < vma->vm_start.  Have to extend vma.
 807 */
 808int expand_stack(struct vm_area_struct * vma, unsigned long address)
 809{
 810        unsigned long grow;
 811
 812        /*
 813         * vma->vm_start/vm_end cannot change under us because the caller
 814         * is required to hold the mmap_sem in read mode. We need to get
 815         * the spinlock only before relocating the vma range ourself.
 816         */
 817        address &= PAGE_MASK;
 818        spin_lock(&vma->vm_mm->page_table_lock);
 819        grow = (vma->vm_start - address) >> PAGE_SHIFT;
 820
 821        /* Overcommit.. */
 822        if (!vm_enough_memory(grow)) {
 823                spin_unlock(&vma->vm_mm->page_table_lock);
 824                return -ENOMEM;
 825        }
 826        
 827        if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur ||
 828                        ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) >
 829                        current->rlim[RLIMIT_AS].rlim_cur) {
 830                spin_unlock(&vma->vm_mm->page_table_lock);
 831                vm_unacct_memory(grow);
 832                return -ENOMEM;
 833        }
 834        vma->vm_start = address;
 835        vma->vm_pgoff -= grow;
 836        vma->vm_mm->total_vm += grow;
 837        if (vma->vm_flags & VM_LOCKED)
 838                vma->vm_mm->locked_vm += grow;
 839        spin_unlock(&vma->vm_mm->page_table_lock);
 840        return 0;
 841}
 842
 843struct vm_area_struct * find_extend_vma(struct mm_struct * mm, unsigned long addr)
 844{
 845        struct vm_area_struct * vma;
 846        unsigned long start;
 847
 848        addr &= PAGE_MASK;
 849        vma = find_vma(mm,addr);
 850        if (!vma)
 851                return NULL;
 852        if (vma->vm_start <= addr)
 853                return vma;
 854        if (!(vma->vm_flags & VM_GROWSDOWN))
 855                return NULL;
 856        start = vma->vm_start;
 857        if (expand_stack(vma, addr))
 858                return NULL;
 859        if (vma->vm_flags & VM_LOCKED) {
 860                make_pages_present(addr, start);
 861        }
 862        return vma;
 863}
 864#endif
 865
 866/*
 867 * Try to free as many page directory entries as we can,
 868 * without having to work very hard at actually scanning
 869 * the page tables themselves.
 870 *
 871 * Right now we try to free page tables if we have a nice
 872 * PGDIR-aligned area that got free'd up. We could be more
 873 * granular if we want to, but this is fast and simple,
 874 * and covers the bad cases.
 875 *
 876 * "prev", if it exists, points to a vma before the one
 877 * we just free'd - but there's no telling how much before.
 878 */
 879static void free_pgtables(mmu_gather_t *tlb, struct vm_area_struct *prev,
 880        unsigned long start, unsigned long end)
 881{
 882        unsigned long first = start & PGDIR_MASK;
 883        unsigned long last = end + PGDIR_SIZE - 1;
 884        unsigned long start_index, end_index;
 885        struct mm_struct *mm = tlb->mm;
 886
 887        if (!prev) {
 888                prev = mm->mmap;
 889                if (!prev)
 890                        goto no_mmaps;
 891                if (prev->vm_end > start) {
 892                        if (last > prev->vm_start)
 893                                last = prev->vm_start;
 894                        goto no_mmaps;
 895                }
 896        }
 897        for (;;) {
 898                struct vm_area_struct *next = prev->vm_next;
 899
 900                if (next) {
 901                        if (next->vm_start < start) {
 902                                prev = next;
 903                                continue;
 904                        }
 905                        if (last > next->vm_start)
 906                                last = next->vm_start;
 907                }
 908                if (prev->vm_end > first)
 909                        first = prev->vm_end + PGDIR_SIZE - 1;
 910                break;
 911        }
 912no_mmaps:
 913        if (last < first)       /* needed for arches with discontiguous pgd indices */
 914                return;
 915        /*
 916         * If the PGD bits are not consecutive in the virtual address, the
 917         * old method of shifting the VA >> by PGDIR_SHIFT doesn't work.
 918         */
 919        start_index = pgd_index(first);
 920        if (start_index < FIRST_USER_PGD_NR)
 921                start_index = FIRST_USER_PGD_NR;
 922        end_index = pgd_index(last);
 923        if (end_index > start_index) {
 924                clear_page_tables(tlb, start_index, end_index - start_index);
 925                flush_tlb_pgtables(mm, first & PGDIR_MASK, last & PGDIR_MASK);
 926        }
 927}
 928
 929/* Normal function to fix up a mapping
 930 * This function is the default for when an area has no specific
 931 * function.  This may be used as part of a more specific routine.
 932 *
 933 * By the time this function is called, the area struct has been
 934 * removed from the process mapping list.
 935 */
 936static void unmap_vma(struct mm_struct *mm, struct vm_area_struct *area)
 937{
 938        size_t len = area->vm_end - area->vm_start;
 939
 940        area->vm_mm->total_vm -= len >> PAGE_SHIFT;
 941        if (area->vm_flags & VM_LOCKED)
 942                area->vm_mm->locked_vm -= len >> PAGE_SHIFT;
 943
 944        remove_shared_vm_struct(area);
 945
 946        if (area->vm_ops && area->vm_ops->close)
 947                area->vm_ops->close(area);
 948        if (area->vm_file)
 949                fput(area->vm_file);
 950        kmem_cache_free(vm_area_cachep, area);
 951}
 952
 953/*
 954 * Update the VMA and inode share lists.
 955 *
 956 * Ok - we have the memory areas we should free on the 'free' list,
 957 * so release them, and do the vma updates.
 958 */
 959static void unmap_vma_list(struct mm_struct *mm,
 960        struct vm_area_struct *mpnt)
 961{
 962        do {
 963                struct vm_area_struct *next = mpnt->vm_next;
 964                unmap_vma(mm, mpnt);
 965                mpnt = next;
 966        } while (mpnt != NULL);
 967        validate_mm(mm);
 968}
 969
 970/*
 971 * Get rid of page table information in the indicated region.
 972 *
 973 * Called with the page table lock held.
 974 */
 975static void unmap_region(struct mm_struct *mm,
 976        struct vm_area_struct *mpnt,
 977        struct vm_area_struct *prev,
 978        unsigned long start,
 979        unsigned long end)
 980{
 981        mmu_gather_t *tlb;
 982
 983        tlb = tlb_gather_mmu(mm, 0);
 984
 985        do {
 986                unsigned long from, to, len;
 987
 988                from = start < mpnt->vm_start ? mpnt->vm_start : start;
 989                to = end > mpnt->vm_end ? mpnt->vm_end : end;
 990
 991                unmap_page_range(tlb, mpnt, from, to);
 992
 993                if (mpnt->vm_flags & VM_ACCOUNT) {
 994                        len = to - from;
 995                        vm_unacct_memory(len >> PAGE_SHIFT);
 996                }
 997        } while ((mpnt = mpnt->vm_next) != NULL);
 998
 999        free_pgtables(tlb, prev, start, end);
1000        tlb_finish_mmu(tlb, start, end);
1001}
1002
1003/*
1004 * Create a list of vma's touched by the unmap,
1005 * removing them from the VM lists as we go..
1006 *
1007 * Called with the page_table_lock held.
1008 */
1009static struct vm_area_struct *touched_by_munmap(struct mm_struct *mm,
1010        struct vm_area_struct *mpnt,
1011        struct vm_area_struct *prev,
1012        unsigned long end)
1013{
1014        struct vm_area_struct **npp, *touched;
1015
1016        npp = (prev ? &prev->vm_next : &mm->mmap);
1017
1018        touched = NULL;
1019        do {
1020                struct vm_area_struct *next = mpnt->vm_next;
1021                if (!(is_vm_hugetlb_page(mpnt))) {
1022                        mpnt->vm_next = touched;
1023                        touched = mpnt;
1024                        rb_erase(&mpnt->vm_rb, &mm->mm_rb);
1025                        mm->map_count--;
1026                }
1027                else
1028                        free_hugepages(mpnt);
1029                mpnt = next;
1030        } while (mpnt && mpnt->vm_start < end);
1031        *npp = mpnt;
1032        mm->mmap_cache = NULL;  /* Kill the cache. */
1033        return touched;
1034}
1035
1036/*
1037 * Split a vma into two pieces at address 'addr', a new vma is allocated
1038 * either for the first part or the the tail.
1039 */
1040int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
1041              unsigned long addr, int new_below)
1042{
1043        struct vm_area_struct *new;
1044
1045        if (mm->map_count >= MAX_MAP_COUNT)
1046                return -ENOMEM;
1047
1048        new = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
1049        if (!new)
1050                return -ENOMEM;
1051
1052        /* most fields are the same, copy all, and then fixup */
1053        *new = *vma;
1054
1055        if (new_below) {
1056                new->vm_end = addr;
1057                vma->vm_start = addr;
1058                vma->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
1059        } else {
1060                vma->vm_end = addr;
1061                new->vm_start = addr;
1062                new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
1063        }
1064
1065        new->vm_raend = 0;
1066
1067        if (new->vm_file)
1068                get_file(new->vm_file);
1069
1070        if (new->vm_ops && new->vm_ops->open)
1071                new->vm_ops->open(new);
1072
1073        insert_vm_struct(mm, new);
1074        return 0;
1075}
1076
1077/* Munmap is split into 2 main parts -- this part which finds
1078 * what needs doing, and the areas themselves, which do the
1079 * work.  This now handles partial unmappings.
1080 * Jeremy Fitzhardinge <jeremy@goop.org>
1081 */
1082int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
1083{
1084        unsigned long end;
1085        struct vm_area_struct *mpnt, *prev, *last;
1086
1087        if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
1088                return -EINVAL;
1089
1090        if ((len = PAGE_ALIGN(len)) == 0)
1091                return -EINVAL;
1092
1093        /* Find the first overlapping VMA */
1094        mpnt = find_vma_prev(mm, start, &prev);
1095        if (!mpnt)
1096                return 0;
1097        /* we have  start < mpnt->vm_end  */
1098
1099        /* if it doesn't overlap, we have nothing.. */
1100        end = start + len;
1101        if (mpnt->vm_start >= end)
1102                return 0;
1103
1104        /*
1105         * If we need to split any vma, do it now to save pain later.
1106         */
1107        if (start > mpnt->vm_start) {
1108                if (split_vma(mm, mpnt, start, 0))
1109                        return -ENOMEM;
1110                prev = mpnt;
1111                mpnt = mpnt->vm_next;
1112        }
1113
1114        /* Does it split the last one? */
1115        last = find_vma(mm, end);
1116        if (last && end > last->vm_start) {
1117                if (split_vma(mm, last, end, 0))
1118                        return -ENOMEM;
1119        }
1120
1121        /*
1122         * Remove the vma's, and unmap the actual pages
1123         */
1124        spin_lock(&mm->page_table_lock);
1125        mpnt = touched_by_munmap(mm, mpnt, prev, end);
1126        unmap_region(mm, mpnt, prev, start, end);
1127        spin_unlock(&mm->page_table_lock);
1128
1129        /* Fix up all other VM information */
1130        unmap_vma_list(mm, mpnt);
1131
1132        return 0;
1133}
1134
1135asmlinkage long sys_munmap(unsigned long addr, size_t len)
1136{
1137        int ret;
1138        struct mm_struct *mm = current->mm;
1139
1140        down_write(&mm->mmap_sem);
1141        ret = do_munmap(mm, addr, len);
1142        up_write(&mm->mmap_sem);
1143        return ret;
1144}
1145
1146/*
1147 *  this is really a simplified "do_mmap".  it only handles
1148 *  anonymous maps.  eventually we may be able to do some
1149 *  brk-specific accounting here.
1150 */
1151unsigned long do_brk(unsigned long addr, unsigned long len)
1152{
1153        struct mm_struct * mm = current->mm;
1154        struct vm_area_struct * vma, * prev;
1155        unsigned long flags;
1156        struct rb_node ** rb_link, * rb_parent;
1157
1158        len = PAGE_ALIGN(len);
1159        if (!len)
1160                return addr;
1161
1162        /*
1163         * mlock MCL_FUTURE?
1164         */
1165        if (mm->def_flags & VM_LOCKED) {
1166                unsigned long locked = mm->locked_vm << PAGE_SHIFT;
1167                locked += len;
1168                if (locked > current->rlim[RLIMIT_MEMLOCK].rlim_cur)
1169                        return -EAGAIN;
1170        }
1171
1172        /*
1173         * Clear old maps.  this also does some error checking for us
1174         */
1175 munmap_back:
1176        vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
1177        if (vma && vma->vm_start < addr + len) {
1178                if (do_munmap(mm, addr, len))
1179                        return -ENOMEM;
1180                goto munmap_back;
1181        }
1182
1183        /* Check against address space limits *after* clearing old maps... */
1184        if ((mm->total_vm << PAGE_SHIFT) + len
1185            > current->rlim[RLIMIT_AS].rlim_cur)
1186                return -ENOMEM;
1187
1188        if (mm->map_count > MAX_MAP_COUNT)
1189                return -ENOMEM;
1190
1191        if (!vm_enough_memory(len >> PAGE_SHIFT))
1192                return -ENOMEM;
1193
1194        flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
1195
1196        /* Can we just expand an old anonymous mapping? */
1197        if (rb_parent && vma_merge(mm, prev, rb_parent, addr, addr + len, flags))
1198                goto out;
1199
1200        /*
1201         * create a vma struct for an anonymous mapping
1202         */
1203        vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
1204        if (!vma) {
1205                vm_unacct_memory(len >> PAGE_SHIFT);
1206                return -ENOMEM;
1207        }
1208
1209        vma->vm_mm = mm;
1210        vma->vm_start = addr;
1211        vma->vm_end = addr + len;
1212        vma->vm_flags = flags;
1213        vma->vm_page_prot = protection_map[flags & 0x0f];
1214        vma->vm_ops = NULL;
1215        vma->vm_pgoff = 0;
1216        vma->vm_file = NULL;
1217        vma->vm_private_data = NULL;
1218
1219        vma_link(mm, vma, prev, rb_link, rb_parent);
1220
1221out:
1222        mm->total_vm += len >> PAGE_SHIFT;
1223        if (flags & VM_LOCKED) {
1224                mm->locked_vm += len >> PAGE_SHIFT;
1225                make_pages_present(addr, addr + len);
1226        }
1227        return addr;
1228}
1229
1230/* Build the RB tree corresponding to the VMA list. */
1231void build_mmap_rb(struct mm_struct * mm)
1232{
1233        struct vm_area_struct * vma;
1234        struct rb_node ** rb_link, * rb_parent;
1235
1236        mm->mm_rb = RB_ROOT;
1237        rb_link = &mm->mm_rb.rb_node;
1238        rb_parent = NULL;
1239        for (vma = mm->mmap; vma; vma = vma->vm_next) {
1240                __vma_link_rb(mm, vma, rb_link, rb_parent);
1241                rb_parent = &vma->vm_rb;
1242                rb_link = &rb_parent->rb_right;
1243        }
1244}
1245
1246/* Release all mmaps. */
1247void exit_mmap(struct mm_struct * mm)
1248{
1249        mmu_gather_t *tlb;
1250        struct vm_area_struct * mpnt;
1251
1252        release_segments(mm);
1253        spin_lock(&mm->page_table_lock);
1254
1255        tlb = tlb_gather_mmu(mm, 1);
1256
1257        flush_cache_mm(mm);
1258        mpnt = mm->mmap;
1259        while (mpnt) {
1260                unsigned long start = mpnt->vm_start;
1261                unsigned long end = mpnt->vm_end;
1262
1263                /*
1264                 * If the VMA has been charged for, account for its
1265                 * removal
1266                 */
1267                if (mpnt->vm_flags & VM_ACCOUNT)
1268                        vm_unacct_memory((end - start) >> PAGE_SHIFT);
1269
1270                mm->map_count--;
1271                if (!(is_vm_hugetlb_page(mpnt)))
1272                        unmap_page_range(tlb, mpnt, start, end);
1273                else
1274                        mpnt->vm_ops->close(mpnt);
1275                mpnt = mpnt->vm_next;
1276        }
1277
1278        /* This is just debugging */
1279        if (mm->map_count)
1280                BUG();
1281
1282        clear_page_tables(tlb, FIRST_USER_PGD_NR, USER_PTRS_PER_PGD);
1283        tlb_finish_mmu(tlb, 0, TASK_SIZE);
1284
1285        mpnt = mm->mmap;
1286        mm->mmap = mm->mmap_cache = NULL;
1287        mm->mm_rb = RB_ROOT;
1288        mm->rss = 0;
1289        mm->total_vm = 0;
1290        mm->locked_vm = 0;
1291
1292        spin_unlock(&mm->page_table_lock);
1293
1294        /*
1295         * Walk the list again, actually closing and freeing it
1296         * without holding any MM locks.
1297         */
1298        while (mpnt) {
1299                struct vm_area_struct * next = mpnt->vm_next;
1300                remove_shared_vm_struct(mpnt);
1301                if (mpnt->vm_ops) {
1302                        if (mpnt->vm_ops->close)
1303                                mpnt->vm_ops->close(mpnt);
1304                }
1305                if (mpnt->vm_file)
1306                        fput(mpnt->vm_file);
1307                kmem_cache_free(vm_area_cachep, mpnt);
1308                mpnt = next;
1309        }
1310                
1311}
1312
1313/* Insert vm structure into process list sorted by address
1314 * and into the inode's i_mmap ring.  If vm_file is non-NULL
1315 * then the i_shared_lock must be held here.
1316 */
1317void insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma)
1318{
1319        struct vm_area_struct * __vma, * prev;
1320        struct rb_node ** rb_link, * rb_parent;
1321
1322        __vma = find_vma_prepare(mm, vma->vm_start, &prev, &rb_link, &rb_parent);
1323        if (__vma && __vma->vm_start < vma->vm_end)
1324                BUG();
1325        vma_link(mm, vma, prev, rb_link, rb_parent);
1326        validate_mm(mm);
1327}
1328
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.