Changeset 5a7d9d1 in mainline


Ignore:
Timestamp:
2006-03-17T10:07:28Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4e49572
Parents:
226a654
Message:

More checks for address space area conflicts.

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/mm/as.h

    r226a654 r5a7d9d1  
    3030#define __amd64_AS_H__
    3131
    32 #include <arch/types.h>
     32#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      0
    3333
    3434#define KERNEL_ADDRESS_SPACE_START_ARCH         (__address) 0xffff800000000000
  • arch/ia32/include/mm/as.h

    r226a654 r5a7d9d1  
    3030#define __ia32_AS_H__
    3131
    32 #include <arch/types.h>
     32#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      0
    3333
    3434#define KERNEL_ADDRESS_SPACE_START_ARCH         ((__address) 0x80000000)
  • arch/ia64/include/mm/as.h

    r226a654 r5a7d9d1  
    3030#define __ia64_AS_H__
    3131
    32 #include <arch/types.h>
     32#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      0
    3333
    3434#define KERNEL_ADDRESS_SPACE_START_ARCH         (__address) 0xe000000000000000ULL
  • arch/mips32/include/mm/as.h

    r226a654 r5a7d9d1  
    3030#define __mips32_AS_H__
    3131
    32 #include <arch/types.h>
    33 #include <typedefs.h>
     32#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      0
    3433
    3534#define KERNEL_ADDRESS_SPACE_START_ARCH         (__address) 0x80000000
  • arch/ppc32/include/mm/as.h

    r226a654 r5a7d9d1  
    3030#define __ppc32_AS_H__
    3131
    32 #include <arch/types.h>
     32#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      0
    3333
    3434#define KERNEL_ADDRESS_SPACE_START_ARCH         ((__address) 0x80000000)
  • arch/sparc64/include/mm/as.h

    r226a654 r5a7d9d1  
    3030#define __sparc64_AS_H__
    3131
    32 #include <arch/types.h>
     32#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH      1
    3333
    3434#define KERNEL_ADDRESS_SPACE_START_ARCH         (__address) 0x0000000000000000
  • generic/include/macros.h

    r226a654 r5a7d9d1  
    4040#define max(a,b)        ((a)>(b)?(a):(b))
    4141
    42 /* Return true if the interlvals overlap */
    43 static inline int overlaps(__address s1,size_t sz1, __address s2, size_t sz2)
     42/** Return true if the interlvals overlap. */
     43static inline int overlaps(__address s1, size_t sz1, __address s2, size_t sz2)
    4444{
    4545        __address e1 = s1+sz1;
  • generic/include/mm/as.h

    r226a654 r5a7d9d1  
    3737#include <synch/spinlock.h>
    3838#include <adt/list.h>
     39
     40/** Defined to be true if user address space and kernel address space shadow each other. */
     41#define KERNEL_ADDRESS_SPACE_SHADOWED   KERNEL_ADDRESS_SPACE_SHADOWED_ARCH
    3942
    4043#define KERNEL_ADDRESS_SPACE_START      KERNEL_ADDRESS_SPACE_START_ARCH
  • generic/src/lib/elf.c

    r226a654 r5a7d9d1  
    166166        }
    167167
    168         /*
    169          * Check if the segment doesn't interfere with kernel address space.
    170          */
    171         if (entry->p_vaddr + ALIGN_UP(entry->p_memsz, PAGE_SIZE) >= USER_ADDRESS_SPACE_END)
    172                 return EE_MEMORY;
    173        
    174168        if (entry->p_flags & PF_X)
    175169                flags |= AS_AREA_EXEC;
     
    196190        a = as_area_create(as, flags, entry->p_memsz, entry->p_vaddr);
    197191        if (!a)
    198                 return EE_IRRECOVERABLE;
     192                return EE_MEMORY;
    199193       
    200194        for (i = 0; i < SIZE2FRAMES(entry->p_filesz); i++) {
  • generic/src/mm/as.c

    r226a654 r5a7d9d1  
    5252#include <debug.h>
    5353#include <memstr.h>
     54#include <macros.h>
    5455#include <arch.h>
    5556#include <print.h>
     
    538539        as_area_t *a;
    539540       
     541        /*
     542         * We don't want any area to have conflicts with NULL page.
     543         */
     544        if (overlaps(va, size, NULL, PAGE_SIZE))
     545                return false;
     546       
    540547        for (cur = as->as_area_head.next; cur != &as->as_area_head; cur = cur->next) {
    541                 __address start;
    542                 __address end;
     548                __address a_start;
     549                size_t a_size;
    543550       
    544551                a = list_get_instance(cur, as_area_t, link);
     
    548555                spinlock_lock(&a->lock);
    549556
    550                 start = a->base;
    551                 end = a->base + a->pages * PAGE_SIZE - 1;
     557                a_start = a->base;
     558                a_size = a->pages * PAGE_SIZE;
    552559
    553560                spinlock_unlock(&a->lock);
    554561
    555                 if ((va >= start) && (va <= end)) {
    556                         /*
    557                          * Tested area is inside another area.
    558                          */
    559                         return false;
    560                 }
    561                
    562                 if ((start >= va) && (start < va + size)) {
    563                         /*
    564                          * Another area starts in tested area.
    565                          */
    566                         return false;
    567                 }
    568                
    569                 if ((end >= va) && (end < va + size)) {
    570                         /*
    571                          * Another area ends in tested area.
    572                          */
    573                         return false;
    574                 }
    575 
     562                if (overlaps(va, size, a_start, a_size))
     563                        return false;           
     564
     565        }
     566
     567        /*
     568         * So far, the area does not conflict with other areas.
     569         * Check if it doesn't conflict with kernel address space.
     570         */     
     571        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
     572                return !overlaps(va, size,
     573                        KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START);
    576574        }
    577575
Note: See TracChangeset for help on using the changeset viewer.