Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/as.c

    r826599a2 rf97f1e51  
    7979#include <syscall/copy.h>
    8080#include <arch/interrupt.h>
    81 #include <interrupt.h>
    8281
    8382/**
     
    286285/** Check area conflicts with other areas.
    287286 *
    288  * @param as      Address space.
    289  * @param addr    Starting virtual address of the area being tested.
    290  * @param count   Number of pages in the area being tested.
    291  * @param guarded True if the area being tested is protected by guard pages.
    292  * @param avoid   Do not touch this area.
     287 * @param as    Address space.
     288 * @param addr  Starting virtual address of the area being tested.
     289 * @param count Number of pages in the area being tested.
     290 * @param avoid Do not touch this area.
    293291 *
    294292 * @return True if there is no conflict, false otherwise.
     
    296294 */
    297295NO_TRACE static bool check_area_conflicts(as_t *as, uintptr_t addr,
    298     size_t count, bool guarded, as_area_t *avoid)
     296    size_t count, as_area_t *avoid)
    299297{
    300298        ASSERT((addr % PAGE_SIZE) == 0);
    301299        ASSERT(mutex_locked(&as->lock));
    302 
    303         /*
    304          * If the addition of the supposed area address and size overflows,
    305          * report conflict.
    306          */
    307         if (overflows_into_positive(addr, P2SZ(count)))
    308                 return false;
    309300       
    310301        /*
     
    313304        if (overlaps(addr, P2SZ(count), (uintptr_t) NULL, PAGE_SIZE))
    314305                return false;
    315 
     306       
    316307        /*
    317308         * The leaf node is found in O(log n), where n is proportional to
     
    337328                if (area != avoid) {
    338329                        mutex_lock(&area->lock);
    339 
    340                         /*
    341                          * If at least one of the two areas are protected
    342                          * by the AS_AREA_GUARD flag then we must be sure
    343                          * that they are separated by at least one unmapped
    344                          * page.
    345                          */
    346                         int const gp = (guarded ||
    347                             (area->flags & AS_AREA_GUARD)) ? 1 : 0;
    348                        
    349                         /*
    350                          * The area comes from the left neighbour node, which
    351                          * means that there already are some areas in the leaf
    352                          * node, which in turn means that adding gp is safe and
    353                          * will not cause an integer overflow.
    354                          */
     330                       
    355331                        if (overlaps(addr, P2SZ(count), area->base,
    356                             P2SZ(area->pages + gp))) {
    357                                 mutex_unlock(&area->lock);
    358                                 return false;
    359                         }
    360                        
    361                         mutex_unlock(&area->lock);
    362                 }
    363         }
    364        
    365         node = btree_leaf_node_right_neighbour(&as->as_area_btree, leaf);
    366         if (node) {
    367                 area = (as_area_t *) node->value[0];
    368                
    369                 if (area != avoid) {
    370                         int gp;
    371 
    372                         mutex_lock(&area->lock);
    373 
    374                         gp = (guarded || (area->flags & AS_AREA_GUARD)) ? 1 : 0;
    375                         if (gp && overflows(addr, P2SZ(count))) {
    376                                 /*
    377                                  * Guard page not needed if the supposed area
    378                                  * is adjacent to the end of the address space.
    379                                  * We already know that the following test is
    380                                  * going to fail...
    381                                  */
    382                                 gp--;
    383                         }
    384                        
    385                         if (overlaps(addr, P2SZ(count + gp), area->base,
    386332                            P2SZ(area->pages))) {
    387333                                mutex_unlock(&area->lock);
     
    393339        }
    394340       
     341        node = btree_leaf_node_right_neighbour(&as->as_area_btree, leaf);
     342        if (node) {
     343                area = (as_area_t *) node->value[0];
     344               
     345                if (area != avoid) {
     346                        mutex_lock(&area->lock);
     347                       
     348                        if (overlaps(addr, P2SZ(count), area->base,
     349                            P2SZ(area->pages))) {
     350                                mutex_unlock(&area->lock);
     351                                return false;
     352                        }
     353                       
     354                        mutex_unlock(&area->lock);
     355                }
     356        }
     357       
    395358        /* Second, check the leaf node. */
    396359        btree_key_t i;
    397360        for (i = 0; i < leaf->keys; i++) {
    398361                area = (as_area_t *) leaf->value[i];
    399                 int agp;
    400                 int gp;
    401362               
    402363                if (area == avoid)
     
    404365               
    405366                mutex_lock(&area->lock);
    406 
    407                 gp = (guarded || (area->flags & AS_AREA_GUARD)) ? 1 : 0;
    408                 agp = gp;
    409 
    410                 /*
    411                  * Sanitize the two possible unsigned integer overflows.
    412                  */
    413                 if (gp && overflows(addr, P2SZ(count)))
    414                         gp--;
    415                 if (agp && overflows(area->base, P2SZ(area->pages)))
    416                         agp--;
    417 
    418                 if (overlaps(addr, P2SZ(count + gp), area->base,
    419                     P2SZ(area->pages + agp))) {
     367               
     368                if (overlaps(addr, P2SZ(count), area->base,
     369                    P2SZ(area->pages))) {
    420370                        mutex_unlock(&area->lock);
    421371                        return false;
     
    427377        /*
    428378         * So far, the area does not conflict with other areas.
    429          * Check if it is contained in the user address space.
     379         * Check if it doesn't conflict with kernel address space.
    430380         */
    431381        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    432                 return iswithin(USER_ADDRESS_SPACE_START,
    433                     (USER_ADDRESS_SPACE_END - USER_ADDRESS_SPACE_START) + 1,
    434                     addr, P2SZ(count));
     382                return !overlaps(addr, P2SZ(count), KERNEL_ADDRESS_SPACE_START,
     383                    KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START);
    435384        }
    436385       
     
    443392 * this function.
    444393 *
    445  * @param as      Address space.
    446  * @param bound   Lowest address bound.
    447  * @param size    Requested size of the allocation.
    448  * @param guarded True if the allocation must be protected by guard pages.
     394 * @param as    Address space.
     395 * @param bound Lowest address bound.
     396 * @param size  Requested size of the allocation.
    449397 *
    450398 * @return Address of the beginning of unmapped address space area.
     
    453401 */
    454402NO_TRACE static uintptr_t as_get_unmapped_area(as_t *as, uintptr_t bound,
    455     size_t size, bool guarded)
     403    size_t size)
    456404{
    457405        ASSERT(mutex_locked(&as->lock));
     
    475423        /* First check the bound address itself */
    476424        uintptr_t addr = ALIGN_UP(bound, PAGE_SIZE);
    477         if (addr >= bound) {
    478                 if (guarded) {
    479                         /* Leave an unmapped page between the lower
    480                          * bound and the area's start address.
    481                          */
    482                         addr += P2SZ(1);
    483                 }
    484 
    485                 if (check_area_conflicts(as, addr, pages, guarded, NULL))
    486                         return addr;
    487         }
     425        if ((addr >= bound) &&
     426            (check_area_conflicts(as, addr, pages, NULL)))
     427                return addr;
    488428       
    489429        /* Eventually check the addresses behind each area */
    490         list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t, node) {
     430        list_foreach(as->as_area_btree.leaf_list, cur) {
     431                btree_node_t *node =
     432                    list_get_instance(cur, btree_node_t, leaf_link);
    491433               
    492434                for (btree_key_t i = 0; i < node->keys; i++) {
     
    497439                        addr =
    498440                            ALIGN_UP(area->base + P2SZ(area->pages), PAGE_SIZE);
    499 
    500                         if (guarded || area->flags & AS_AREA_GUARD) {
    501                                 /* We must leave an unmapped page
    502                                  * between the two areas.
    503                                  */
    504                                 addr += P2SZ(1);
    505                         }
    506 
    507441                        bool avail =
    508442                            ((addr >= bound) && (addr >= area->base) &&
    509                             (check_area_conflicts(as, addr, pages, guarded, area)));
     443                            (check_area_conflicts(as, addr, pages, area)));
    510444                       
    511445                        mutex_unlock(&area->lock);
     
    519453        return (uintptr_t) -1;
    520454}
    521 
    522 /** Remove reference to address space area share info.
    523  *
    524  * If the reference count drops to 0, the sh_info is deallocated.
    525  *
    526  * @param sh_info Pointer to address space area share info.
    527  *
    528  */
    529 NO_TRACE static void sh_info_remove_reference(share_info_t *sh_info)
    530 {
    531         bool dealloc = false;
    532        
    533         mutex_lock(&sh_info->lock);
    534         ASSERT(sh_info->refcount);
    535        
    536         if (--sh_info->refcount == 0) {
    537                 dealloc = true;
    538                
    539                 /*
    540                  * Now walk carefully the pagemap B+tree and free/remove
    541                  * reference from all frames found there.
    542                  */
    543                 list_foreach(sh_info->pagemap.leaf_list, leaf_link,
    544                     btree_node_t, node) {
    545                         btree_key_t i;
    546                        
    547                         for (i = 0; i < node->keys; i++)
    548                                 frame_free((uintptr_t) node->value[i], 1);
    549                 }
    550                
    551         }
    552         mutex_unlock(&sh_info->lock);
    553        
    554         if (dealloc) {
    555                 if (sh_info->backend && sh_info->backend->destroy_shared_data) {
    556                         sh_info->backend->destroy_shared_data(
    557                             sh_info->backend_shared_data);
    558                 }
    559                 btree_destroy(&sh_info->pagemap);
    560                 free(sh_info);
    561         }
    562 }
    563 
    564455
    565456/** Create address space area of common attributes.
     
    572463 * @param attrs        Attributes of the area.
    573464 * @param backend      Address space area backend. NULL if no backend is used.
    574  * @param backend_data NULL or a pointer to custom backend data.
     465 * @param backend_data NULL or a pointer to an array holding two void *.
    575466 * @param base         Starting virtual address of the area.
    576467 *                     If set to -1, a suitable mappable area is found.
     
    585476    mem_backend_data_t *backend_data, uintptr_t *base, uintptr_t bound)
    586477{
    587         if ((*base != (uintptr_t) -1) && !IS_ALIGNED(*base, PAGE_SIZE))
     478        if ((*base != (uintptr_t) -1) && ((*base % PAGE_SIZE) != 0))
    588479                return NULL;
    589480       
    590481        if (size == 0)
    591482                return NULL;
    592 
     483       
    593484        size_t pages = SIZE2FRAMES(size);
    594485       
     
    596487        if ((flags & AS_AREA_EXEC) && (flags & AS_AREA_WRITE))
    597488                return NULL;
    598 
    599         bool const guarded = flags & AS_AREA_GUARD;
    600489       
    601490        mutex_lock(&as->lock);
    602491       
    603492        if (*base == (uintptr_t) -1) {
    604                 *base = as_get_unmapped_area(as, bound, size, guarded);
     493                *base = as_get_unmapped_area(as, bound, size);
    605494                if (*base == (uintptr_t) -1) {
    606495                        mutex_unlock(&as->lock);
     
    608497                }
    609498        }
    610 
    611         if (overflows_into_positive(*base, size)) {
    612                 mutex_unlock(&as->lock);
    613                 return NULL;
    614         }
    615 
    616         if (!check_area_conflicts(as, *base, pages, guarded, NULL)) {
     499       
     500        if (!check_area_conflicts(as, *base, pages, NULL)) {
    617501                mutex_unlock(&as->lock);
    618502                return NULL;
     
    629513        area->resident = 0;
    630514        area->base = *base;
     515        area->sh_info = NULL;
    631516        area->backend = backend;
    632         area->sh_info = NULL;
    633517       
    634518        if (backend_data)
     
    636520        else
    637521                memsetb(&area->backend_data, sizeof(area->backend_data), 0);
    638 
    639         share_info_t *si = NULL;
    640 
    641         /*
    642          * Create the sharing info structure.
    643          * We do this in advance for every new area, even if it is not going
    644          * to be shared.
    645          */
    646         if (!(attrs & AS_AREA_ATTR_PARTIAL)) {
    647                 si = (share_info_t *) malloc(sizeof(share_info_t), 0);
    648                 mutex_initialize(&si->lock, MUTEX_PASSIVE);
    649                 si->refcount = 1;
    650                 si->shared = false;
    651                 si->backend_shared_data = NULL;
    652                 si->backend = backend;
    653                 btree_create(&si->pagemap);
    654 
    655                 area->sh_info = si;
    656        
    657                 if (area->backend && area->backend->create_shared_data) {
    658                         if (!area->backend->create_shared_data(area)) {
    659                                 free(area);
    660                                 mutex_unlock(&as->lock);
    661                                 sh_info_remove_reference(si);
    662                                 return NULL;
    663                         }
    664                 }
    665         }
    666 
     522       
    667523        if (area->backend && area->backend->create) {
    668524                if (!area->backend->create(area)) {
    669525                        free(area);
    670526                        mutex_unlock(&as->lock);
    671                         if (!(attrs & AS_AREA_ATTR_PARTIAL))
    672                                 sh_info_remove_reference(si);
    673527                        return NULL;
    674528                }
    675529        }
    676 
     530       
    677531        btree_create(&area->used_space);
    678532        btree_insert(&as->as_area_btree, *base, (void *) area,
     
    761615int as_area_resize(as_t *as, uintptr_t address, size_t size, unsigned int flags)
    762616{
    763         if (!IS_ALIGNED(address, PAGE_SIZE))
    764                 return EINVAL;
    765 
    766617        mutex_lock(&as->lock);
    767618       
     
    774625                return ENOENT;
    775626        }
    776 
    777         if (!area->backend->is_resizable(area)) {
    778                 /*
    779                  * The backend does not support resizing for this area.
     627       
     628        if (area->backend == &phys_backend) {
     629                /*
     630                 * Remapping of address space areas associated
     631                 * with memory mapped devices is not supported.
    780632                 */
    781633                mutex_unlock(&area->lock);
     
    784636        }
    785637       
    786         mutex_lock(&area->sh_info->lock);
    787         if (area->sh_info->shared) {
     638        if (area->sh_info) {
    788639                /*
    789640                 * Remapping of shared address space areas
    790641                 * is not supported.
    791642                 */
    792                 mutex_unlock(&area->sh_info->lock);
    793643                mutex_unlock(&area->lock);
    794644                mutex_unlock(&as->lock);
    795645                return ENOTSUP;
    796646        }
    797         mutex_unlock(&area->sh_info->lock);
    798647       
    799648        size_t pages = SIZE2FRAMES((address - area->base) + size);
     
    816665               
    817666                page_table_lock(as, false);
     667               
     668                /*
     669                 * Start TLB shootdown sequence.
     670                 */
     671                ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid,
     672                    area->base + P2SZ(pages), area->pages - pages);
    818673               
    819674                /*
     
    871726                                }
    872727                               
    873                                 /*
    874                                  * Start TLB shootdown sequence.
    875                                  *
    876                                  * The sequence is rather short and can be
    877                                  * repeated multiple times. The reason is that
    878                                  * we don't want to have used_space_remove()
    879                                  * inside the sequence as it may use a blocking
    880                                  * memory allocation for its B+tree. Blocking
    881                                  * while holding the tlblock spinlock is
    882                                  * forbidden and would hit a kernel assertion.
    883                                  */
    884 
    885                                 ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES,
    886                                     as->asid, area->base + P2SZ(pages),
    887                                     area->pages - pages);
    888                
    889728                                for (; i < size; i++) {
    890729                                        pte_t *pte = page_mapping_find(as,
     
    904743                                        page_mapping_remove(as, ptr + P2SZ(i));
    905744                                }
    906                
    907                                 /*
    908                                  * Finish TLB shootdown sequence.
    909                                  */
    910                
    911                                 tlb_invalidate_pages(as->asid,
    912                                     area->base + P2SZ(pages),
    913                                     area->pages - pages);
    914                
    915                                 /*
    916                                  * Invalidate software translation caches
    917                                  * (e.g. TSB on sparc64, PHT on ppc32).
    918                                  */
    919                                 as_invalidate_translation_cache(as,
    920                                     area->base + P2SZ(pages),
    921                                     area->pages - pages);
    922                                 tlb_shootdown_finalize(ipl);
    923745                        }
    924746                }
     747               
     748                /*
     749                 * Finish TLB shootdown sequence.
     750                 */
     751               
     752                tlb_invalidate_pages(as->asid, area->base + P2SZ(pages),
     753                    area->pages - pages);
     754               
     755                /*
     756                 * Invalidate software translation caches
     757                 * (e.g. TSB on sparc64, PHT on ppc32).
     758                 */
     759                as_invalidate_translation_cache(as, area->base + P2SZ(pages),
     760                    area->pages - pages);
     761                tlb_shootdown_finalize(ipl);
     762               
    925763                page_table_unlock(as, false);
    926764        } else {
    927765                /*
    928766                 * Growing the area.
    929                  */
    930 
    931                 if (overflows_into_positive(address, P2SZ(pages)))
    932                         return EINVAL;
    933 
    934                 /*
    935767                 * Check for overlaps with other address space areas.
    936768                 */
    937                 bool const guarded = area->flags & AS_AREA_GUARD;
    938                 if (!check_area_conflicts(as, address, pages, guarded, area)) {
     769                if (!check_area_conflicts(as, address, pages, area)) {
    939770                        mutex_unlock(&area->lock);
    940771                        mutex_unlock(&as->lock);
     
    959790}
    960791
     792/** Remove reference to address space area share info.
     793 *
     794 * If the reference count drops to 0, the sh_info is deallocated.
     795 *
     796 * @param sh_info Pointer to address space area share info.
     797 *
     798 */
     799NO_TRACE static void sh_info_remove_reference(share_info_t *sh_info)
     800{
     801        bool dealloc = false;
     802       
     803        mutex_lock(&sh_info->lock);
     804        ASSERT(sh_info->refcount);
     805       
     806        if (--sh_info->refcount == 0) {
     807                dealloc = true;
     808               
     809                /*
     810                 * Now walk carefully the pagemap B+tree and free/remove
     811                 * reference from all frames found there.
     812                 */
     813                list_foreach(sh_info->pagemap.leaf_list, cur) {
     814                        btree_node_t *node
     815                            = list_get_instance(cur, btree_node_t, leaf_link);
     816                        btree_key_t i;
     817                       
     818                        for (i = 0; i < node->keys; i++)
     819                                frame_free((uintptr_t) node->value[i]);
     820                }
     821               
     822        }
     823        mutex_unlock(&sh_info->lock);
     824       
     825        if (dealloc) {
     826                btree_destroy(&sh_info->pagemap);
     827                free(sh_info);
     828        }
     829}
     830
    961831/** Destroy address space area.
    962832 *
     
    993863         * Visit only the pages mapped by used_space B+tree.
    994864         */
    995         list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
    996             node) {
     865        list_foreach(area->used_space.leaf_list, cur) {
     866                btree_node_t *node;
    997867                btree_key_t i;
    998868               
     869                node = list_get_instance(cur, btree_node_t, leaf_link);
    999870                for (i = 0; i < node->keys; i++) {
    1000871                        uintptr_t ptr = node->key[i];
     
    1040911        area->attributes |= AS_AREA_ATTR_PARTIAL;
    1041912       
    1042         sh_info_remove_reference(area->sh_info);
     913        if (area->sh_info)
     914                sh_info_remove_reference(area->sh_info);
    1043915       
    1044916        mutex_unlock(&area->lock);
     
    1096968        }
    1097969       
    1098         if (!src_area->backend->is_shareable(src_area)) {
    1099                 /*
    1100                  * The backend does not permit sharing of this area.
     970        if ((!src_area->backend) || (!src_area->backend->share)) {
     971                /*
     972                 * There is no backend or the backend does not
     973                 * know how to share the area.
    1101974                 */
    1102975                mutex_unlock(&src_area->lock);
     
    11271000         */
    11281001        share_info_t *sh_info = src_area->sh_info;
    1129        
    1130         mutex_lock(&sh_info->lock);
    1131         sh_info->refcount++;
    1132         bool shared = sh_info->shared;
    1133         sh_info->shared = true;
    1134         mutex_unlock(&sh_info->lock);
    1135 
    1136         if (!shared) {
     1002        if (!sh_info) {
     1003                sh_info = (share_info_t *) malloc(sizeof(share_info_t), 0);
     1004                mutex_initialize(&sh_info->lock, MUTEX_PASSIVE);
     1005                sh_info->refcount = 2;
     1006                btree_create(&sh_info->pagemap);
     1007                src_area->sh_info = sh_info;
     1008               
    11371009                /*
    11381010                 * Call the backend to setup sharing.
    1139                  * This only happens once for each sh_info.
    11401011                 */
    11411012                src_area->backend->share(src_area);
     1013        } else {
     1014                mutex_lock(&sh_info->lock);
     1015                sh_info->refcount++;
     1016                mutex_unlock(&sh_info->lock);
    11421017        }
    11431018       
     
    12581133        }
    12591134       
    1260         if (area->backend != &anon_backend) {
     1135        if ((area->sh_info) || (area->backend != &anon_backend)) {
     1136                /* Copying shared areas not supported yet */
    12611137                /* Copying non-anonymous memory not supported yet */
    12621138                mutex_unlock(&area->lock);
     
    12641140                return ENOTSUP;
    12651141        }
    1266 
    1267         mutex_lock(&area->sh_info->lock);
    1268         if (area->sh_info->shared) {
    1269                 /* Copying shared areas not supported yet */
    1270                 mutex_unlock(&area->sh_info->lock);
    1271                 mutex_unlock(&area->lock);
    1272                 mutex_unlock(&as->lock);
    1273                 return ENOTSUP;
    1274         }
    1275         mutex_unlock(&area->sh_info->lock);
    12761142       
    12771143        /*
     
    12801146        size_t used_pages = 0;
    12811147       
    1282         list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
    1283             node) {
     1148        list_foreach(area->used_space.leaf_list, cur) {
     1149                btree_node_t *node
     1150                    = list_get_instance(cur, btree_node_t, leaf_link);
    12841151                btree_key_t i;
    12851152               
     
    13051172        size_t frame_idx = 0;
    13061173       
    1307         list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
    1308             node) {
     1174        list_foreach(area->used_space.leaf_list, cur) {
     1175                btree_node_t *node = list_get_instance(cur, btree_node_t,
     1176                    leaf_link);
    13091177                btree_key_t i;
    13101178               
     
    13561224        frame_idx = 0;
    13571225       
    1358         list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
    1359             node) {
     1226        list_foreach(area->used_space.leaf_list, cur) {
     1227                btree_node_t *node
     1228                    = list_get_instance(cur, btree_node_t, leaf_link);
    13601229                btree_key_t i;
    13611230               
     
    13921261 * Interrupts are assumed disabled.
    13931262 *
    1394  * @param address Faulting address.
    1395  * @param access  Access mode that caused the page fault (i.e.
    1396  *                read/write/exec).
    1397  * @param istate  Pointer to the interrupted state.
     1263 * @param page   Faulting page.
     1264 * @param access Access mode that caused the page fault (i.e.
     1265 *               read/write/exec).
     1266 * @param istate Pointer to the interrupted state.
    13981267 *
    13991268 * @return AS_PF_FAULT on page fault.
     
    14031272 *
    14041273 */
    1405 int as_page_fault(uintptr_t address, pf_access_t access, istate_t *istate)
    1406 {
    1407         uintptr_t page = ALIGN_DOWN(address, PAGE_SIZE);
    1408         int rc = AS_PF_FAULT;
    1409 
     1274int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate)
     1275{
    14101276        if (!THREAD)
    1411                 goto page_fault;
     1277                return AS_PF_FAULT;
    14121278       
    14131279        if (!AS)
    1414                 goto page_fault;
     1280                return AS_PF_FAULT;
    14151281       
    14161282        mutex_lock(&AS->lock);
     
    14681334         * Resort to the backend page fault handler.
    14691335         */
    1470         rc = area->backend->page_fault(area, page, access);
    1471         if (rc != AS_PF_OK) {
     1336        if (area->backend->page_fault(area, page, access) != AS_PF_OK) {
    14721337                page_table_unlock(AS, false);
    14731338                mutex_unlock(&area->lock);
     
    14901355                istate_set_retaddr(istate,
    14911356                    (uintptr_t) &memcpy_to_uspace_failover_address);
    1492         } else if (rc == AS_PF_SILENT) {
    1493                 printf("Killing task %" PRIu64 " due to a "
    1494                     "failed late reservation request.\n", TASK->taskid);
    1495                 task_kill_self(true);
    14961357        } else {
    1497                 fault_if_from_uspace(istate, "Page fault: %p.", (void *) address);
    1498                 panic_memtrap(istate, access, address, NULL);
     1358                return AS_PF_FAULT;
    14991359        }
    15001360       
     
    17221582{
    17231583        ASSERT(mutex_locked(&area->lock));
    1724         ASSERT(IS_ALIGNED(page, PAGE_SIZE));
     1584        ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
    17251585        ASSERT(count);
    17261586       
    1727         btree_node_t *leaf = NULL;
     1587        btree_node_t *leaf;
    17281588        size_t pages = (size_t) btree_search(&area->used_space, page, &leaf);
    17291589        if (pages) {
     
    17331593                return false;
    17341594        }
    1735 
    1736         ASSERT(leaf != NULL);
    17371595       
    17381596        if (!leaf->keys) {
     
    20081866{
    20091867        ASSERT(mutex_locked(&area->lock));
    2010         ASSERT(IS_ALIGNED(page, PAGE_SIZE));
     1868        ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
    20111869        ASSERT(count);
    20121870       
     
    21852043{
    21862044        uintptr_t virt = base;
    2187         as_area_t *area = as_area_create(AS, flags, size,
     2045        as_area_t *area = as_area_create(AS, flags | AS_AREA_CACHEABLE, size,
    21882046            AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, bound);
    21892047        if (area == NULL)
     
    22232081        size_t area_cnt = 0;
    22242082       
    2225         list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
    2226             node) {
     2083        list_foreach(as->as_area_btree.leaf_list, cur) {
     2084                btree_node_t *node =
     2085                    list_get_instance(cur, btree_node_t, leaf_link);
    22272086                area_cnt += node->keys;
    22282087        }
     
    22352094        size_t area_idx = 0;
    22362095       
    2237         list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
    2238             node) {
     2096        list_foreach(as->as_area_btree.leaf_list, cur) {
     2097                btree_node_t *node =
     2098                    list_get_instance(cur, btree_node_t, leaf_link);
    22392099                btree_key_t i;
    22402100               
     
    22702130       
    22712131        /* Print out info about address space areas */
    2272         list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
    2273             node) {
     2132        list_foreach(as->as_area_btree.leaf_list, cur) {
     2133                btree_node_t *node
     2134                    = list_get_instance(cur, btree_node_t, leaf_link);
    22742135                btree_key_t i;
    22752136               
Note: See TracChangeset for help on using the changeset viewer.