Changeset 5a7d9d1 in mainline for generic/src/mm/as.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.