Ignore:
File:
1 edited

Legend:

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

    rf97f1e51 r826599a2  
    7979#include <syscall/copy.h>
    8080#include <arch/interrupt.h>
     81#include <interrupt.h>
    8182
    8283/**
     
    285286/** Check area conflicts with other areas.
    286287 *
    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.
     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.
    291293 *
    292294 * @return True if there is no conflict, false otherwise.
     
    294296 */
    295297NO_TRACE static bool check_area_conflicts(as_t *as, uintptr_t addr,
    296     size_t count, as_area_t *avoid)
     298    size_t count, bool guarded, as_area_t *avoid)
    297299{
    298300        ASSERT((addr % PAGE_SIZE) == 0);
    299301        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;
    300309       
    301310        /*
     
    304313        if (overlaps(addr, P2SZ(count), (uintptr_t) NULL, PAGE_SIZE))
    305314                return false;
    306        
     315
    307316        /*
    308317         * The leaf node is found in O(log n), where n is proportional to
     
    328337                if (area != avoid) {
    329338                        mutex_lock(&area->lock);
    330                        
     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                         */
    331355                        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,
    332386                            P2SZ(area->pages))) {
    333387                                mutex_unlock(&area->lock);
     
    339393        }
    340394       
    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        
    358395        /* Second, check the leaf node. */
    359396        btree_key_t i;
    360397        for (i = 0; i < leaf->keys; i++) {
    361398                area = (as_area_t *) leaf->value[i];
     399                int agp;
     400                int gp;
    362401               
    363402                if (area == avoid)
     
    365404               
    366405                mutex_lock(&area->lock);
    367                
    368                 if (overlaps(addr, P2SZ(count), area->base,
    369                     P2SZ(area->pages))) {
     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))) {
    370420                        mutex_unlock(&area->lock);
    371421                        return false;
     
    377427        /*
    378428         * So far, the area does not conflict with other areas.
    379          * Check if it doesn't conflict with kernel address space.
     429         * Check if it is contained in the user address space.
    380430         */
    381431        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    382                 return !overlaps(addr, P2SZ(count), KERNEL_ADDRESS_SPACE_START,
    383                     KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START);
     432                return iswithin(USER_ADDRESS_SPACE_START,
     433                    (USER_ADDRESS_SPACE_END - USER_ADDRESS_SPACE_START) + 1,
     434                    addr, P2SZ(count));
    384435        }
    385436       
     
    392443 * this function.
    393444 *
    394  * @param as    Address space.
    395  * @param bound Lowest address bound.
    396  * @param size  Requested size of the allocation.
     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.
    397449 *
    398450 * @return Address of the beginning of unmapped address space area.
     
    401453 */
    402454NO_TRACE static uintptr_t as_get_unmapped_area(as_t *as, uintptr_t bound,
    403     size_t size)
     455    size_t size, bool guarded)
    404456{
    405457        ASSERT(mutex_locked(&as->lock));
     
    423475        /* First check the bound address itself */
    424476        uintptr_t addr = ALIGN_UP(bound, PAGE_SIZE);
    425         if ((addr >= bound) &&
    426             (check_area_conflicts(as, addr, pages, NULL)))
    427                 return addr;
     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        }
    428488       
    429489        /* Eventually check the addresses behind each area */
    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);
     490        list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t, node) {
    433491               
    434492                for (btree_key_t i = 0; i < node->keys; i++) {
     
    439497                        addr =
    440498                            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
    441507                        bool avail =
    442508                            ((addr >= bound) && (addr >= area->base) &&
    443                             (check_area_conflicts(as, addr, pages, area)));
     509                            (check_area_conflicts(as, addr, pages, guarded, area)));
    444510                       
    445511                        mutex_unlock(&area->lock);
     
    453519        return (uintptr_t) -1;
    454520}
     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 */
     529NO_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
    455564
    456565/** Create address space area of common attributes.
     
    463572 * @param attrs        Attributes of the area.
    464573 * @param backend      Address space area backend. NULL if no backend is used.
    465  * @param backend_data NULL or a pointer to an array holding two void *.
     574 * @param backend_data NULL or a pointer to custom backend data.
    466575 * @param base         Starting virtual address of the area.
    467576 *                     If set to -1, a suitable mappable area is found.
     
    476585    mem_backend_data_t *backend_data, uintptr_t *base, uintptr_t bound)
    477586{
    478         if ((*base != (uintptr_t) -1) && ((*base % PAGE_SIZE) != 0))
     587        if ((*base != (uintptr_t) -1) && !IS_ALIGNED(*base, PAGE_SIZE))
    479588                return NULL;
    480589       
    481590        if (size == 0)
    482591                return NULL;
    483        
     592
    484593        size_t pages = SIZE2FRAMES(size);
    485594       
     
    487596        if ((flags & AS_AREA_EXEC) && (flags & AS_AREA_WRITE))
    488597                return NULL;
     598
     599        bool const guarded = flags & AS_AREA_GUARD;
    489600       
    490601        mutex_lock(&as->lock);
    491602       
    492603        if (*base == (uintptr_t) -1) {
    493                 *base = as_get_unmapped_area(as, bound, size);
     604                *base = as_get_unmapped_area(as, bound, size, guarded);
    494605                if (*base == (uintptr_t) -1) {
    495606                        mutex_unlock(&as->lock);
     
    497608                }
    498609        }
    499        
    500         if (!check_area_conflicts(as, *base, pages, NULL)) {
     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)) {
    501617                mutex_unlock(&as->lock);
    502618                return NULL;
     
    513629        area->resident = 0;
    514630        area->base = *base;
     631        area->backend = backend;
    515632        area->sh_info = NULL;
    516         area->backend = backend;
    517633       
    518634        if (backend_data)
     
    520636        else
    521637                memsetb(&area->backend_data, sizeof(area->backend_data), 0);
    522        
     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
    523667        if (area->backend && area->backend->create) {
    524668                if (!area->backend->create(area)) {
    525669                        free(area);
    526670                        mutex_unlock(&as->lock);
     671                        if (!(attrs & AS_AREA_ATTR_PARTIAL))
     672                                sh_info_remove_reference(si);
    527673                        return NULL;
    528674                }
    529675        }
    530        
     676
    531677        btree_create(&area->used_space);
    532678        btree_insert(&as->as_area_btree, *base, (void *) area,
     
    615761int as_area_resize(as_t *as, uintptr_t address, size_t size, unsigned int flags)
    616762{
     763        if (!IS_ALIGNED(address, PAGE_SIZE))
     764                return EINVAL;
     765
    617766        mutex_lock(&as->lock);
    618767       
     
    625774                return ENOENT;
    626775        }
    627        
    628         if (area->backend == &phys_backend) {
    629                 /*
    630                  * Remapping of address space areas associated
    631                  * with memory mapped devices is not supported.
     776
     777        if (!area->backend->is_resizable(area)) {
     778                /*
     779                 * The backend does not support resizing for this area.
    632780                 */
    633781                mutex_unlock(&area->lock);
     
    636784        }
    637785       
    638         if (area->sh_info) {
     786        mutex_lock(&area->sh_info->lock);
     787        if (area->sh_info->shared) {
    639788                /*
    640789                 * Remapping of shared address space areas
    641790                 * is not supported.
    642791                 */
     792                mutex_unlock(&area->sh_info->lock);
    643793                mutex_unlock(&area->lock);
    644794                mutex_unlock(&as->lock);
    645795                return ENOTSUP;
    646796        }
     797        mutex_unlock(&area->sh_info->lock);
    647798       
    648799        size_t pages = SIZE2FRAMES((address - area->base) + size);
     
    665816               
    666817                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);
    673818               
    674819                /*
     
    726871                                }
    727872                               
     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               
    728889                                for (; i < size; i++) {
    729890                                        pte_t *pte = page_mapping_find(as,
     
    743904                                        page_mapping_remove(as, ptr + P2SZ(i));
    744905                                }
     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);
    745923                        }
    746924                }
    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                
    763925                page_table_unlock(as, false);
    764926        } else {
    765927                /*
    766928                 * Growing the area.
     929                 */
     930
     931                if (overflows_into_positive(address, P2SZ(pages)))
     932                        return EINVAL;
     933
     934                /*
    767935                 * Check for overlaps with other address space areas.
    768936                 */
    769                 if (!check_area_conflicts(as, address, pages, area)) {
     937                bool const guarded = area->flags & AS_AREA_GUARD;
     938                if (!check_area_conflicts(as, address, pages, guarded, area)) {
    770939                        mutex_unlock(&area->lock);
    771940                        mutex_unlock(&as->lock);
     
    790959}
    791960
    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  */
    799 NO_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 
    831961/** Destroy address space area.
    832962 *
     
    863993         * Visit only the pages mapped by used_space B+tree.
    864994         */
    865         list_foreach(area->used_space.leaf_list, cur) {
    866                 btree_node_t *node;
     995        list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
     996            node) {
    867997                btree_key_t i;
    868998               
    869                 node = list_get_instance(cur, btree_node_t, leaf_link);
    870999                for (i = 0; i < node->keys; i++) {
    8711000                        uintptr_t ptr = node->key[i];
     
    9111040        area->attributes |= AS_AREA_ATTR_PARTIAL;
    9121041       
    913         if (area->sh_info)
    914                 sh_info_remove_reference(area->sh_info);
     1042        sh_info_remove_reference(area->sh_info);
    9151043       
    9161044        mutex_unlock(&area->lock);
     
    9681096        }
    9691097       
    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.
     1098        if (!src_area->backend->is_shareable(src_area)) {
     1099                /*
     1100                 * The backend does not permit sharing of this area.
    9741101                 */
    9751102                mutex_unlock(&src_area->lock);
     
    10001127         */
    10011128        share_info_t *sh_info = src_area->sh_info;
    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                
     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) {
    10091137                /*
    10101138                 * Call the backend to setup sharing.
     1139                 * This only happens once for each sh_info.
    10111140                 */
    10121141                src_area->backend->share(src_area);
    1013         } else {
    1014                 mutex_lock(&sh_info->lock);
    1015                 sh_info->refcount++;
    1016                 mutex_unlock(&sh_info->lock);
    10171142        }
    10181143       
     
    11331258        }
    11341259       
    1135         if ((area->sh_info) || (area->backend != &anon_backend)) {
    1136                 /* Copying shared areas not supported yet */
     1260        if (area->backend != &anon_backend) {
    11371261                /* Copying non-anonymous memory not supported yet */
    11381262                mutex_unlock(&area->lock);
     
    11401264                return ENOTSUP;
    11411265        }
     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);
    11421276       
    11431277        /*
     
    11461280        size_t used_pages = 0;
    11471281       
    1148         list_foreach(area->used_space.leaf_list, cur) {
    1149                 btree_node_t *node
    1150                     = list_get_instance(cur, btree_node_t, leaf_link);
     1282        list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
     1283            node) {
    11511284                btree_key_t i;
    11521285               
     
    11721305        size_t frame_idx = 0;
    11731306       
    1174         list_foreach(area->used_space.leaf_list, cur) {
    1175                 btree_node_t *node = list_get_instance(cur, btree_node_t,
    1176                     leaf_link);
     1307        list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
     1308            node) {
    11771309                btree_key_t i;
    11781310               
     
    12241356        frame_idx = 0;
    12251357       
    1226         list_foreach(area->used_space.leaf_list, cur) {
    1227                 btree_node_t *node
    1228                     = list_get_instance(cur, btree_node_t, leaf_link);
     1358        list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
     1359            node) {
    12291360                btree_key_t i;
    12301361               
     
    12611392 * Interrupts are assumed disabled.
    12621393 *
    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.
     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.
    12671398 *
    12681399 * @return AS_PF_FAULT on page fault.
     
    12721403 *
    12731404 */
    1274 int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate)
    1275 {
     1405int 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
    12761410        if (!THREAD)
    1277                 return AS_PF_FAULT;
     1411                goto page_fault;
    12781412       
    12791413        if (!AS)
    1280                 return AS_PF_FAULT;
     1414                goto page_fault;
    12811415       
    12821416        mutex_lock(&AS->lock);
     
    13341468         * Resort to the backend page fault handler.
    13351469         */
    1336         if (area->backend->page_fault(area, page, access) != AS_PF_OK) {
     1470        rc = area->backend->page_fault(area, page, access);
     1471        if (rc != AS_PF_OK) {
    13371472                page_table_unlock(AS, false);
    13381473                mutex_unlock(&area->lock);
     
    13551490                istate_set_retaddr(istate,
    13561491                    (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);
    13571496        } else {
    1358                 return AS_PF_FAULT;
     1497                fault_if_from_uspace(istate, "Page fault: %p.", (void *) address);
     1498                panic_memtrap(istate, access, address, NULL);
    13591499        }
    13601500       
     
    15821722{
    15831723        ASSERT(mutex_locked(&area->lock));
    1584         ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
     1724        ASSERT(IS_ALIGNED(page, PAGE_SIZE));
    15851725        ASSERT(count);
    15861726       
    1587         btree_node_t *leaf;
     1727        btree_node_t *leaf = NULL;
    15881728        size_t pages = (size_t) btree_search(&area->used_space, page, &leaf);
    15891729        if (pages) {
     
    15931733                return false;
    15941734        }
     1735
     1736        ASSERT(leaf != NULL);
    15951737       
    15961738        if (!leaf->keys) {
     
    18662008{
    18672009        ASSERT(mutex_locked(&area->lock));
    1868         ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
     2010        ASSERT(IS_ALIGNED(page, PAGE_SIZE));
    18692011        ASSERT(count);
    18702012       
     
    20432185{
    20442186        uintptr_t virt = base;
    2045         as_area_t *area = as_area_create(AS, flags | AS_AREA_CACHEABLE, size,
     2187        as_area_t *area = as_area_create(AS, flags, size,
    20462188            AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, bound);
    20472189        if (area == NULL)
     
    20812223        size_t area_cnt = 0;
    20822224       
    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);
     2225        list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
     2226            node) {
    20862227                area_cnt += node->keys;
    20872228        }
     
    20942235        size_t area_idx = 0;
    20952236       
    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);
     2237        list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
     2238            node) {
    20992239                btree_key_t i;
    21002240               
     
    21302270       
    21312271        /* Print out info about address space areas */
    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);
     2272        list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
     2273            node) {
    21352274                btree_key_t i;
    21362275               
Note: See TracChangeset for help on using the changeset viewer.