Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1d432f9 in mainline


Ignore:
Timestamp:
2010-05-31T22:33:44Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
179d052
Parents:
3a2b636
Message:

Reflect assumptions about lock and interrupt state in functions themselves.

Location:
kernel
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/src/mm/tlb.c

    r3a2b636 r1d432f9  
    369369        entry_hi_t hi;
    370370        pte_t *pte;
     371
     372        ASSERT(mutex_locked(&AS->lock));
    371373
    372374        hi.value = cp0_entry_hi_read();
  • kernel/arch/ppc32/src/mm/tlb.c

    r3a2b636 r1d432f9  
    6767    istate_t *istate, int *pfrc)
    6868{
     69        ASSERT(mutex_locked(&as->lock));
     70
    6971        /*
    7072         * Check if the mapping exists in page tables.
  • kernel/genarch/src/mm/asid.c

    r3a2b636 r1d432f9  
    7070/** Allocate free address space identifier.
    7171 *
    72  * Interrupts must be disabled and inactive_as_with_asid_lock must be held
    73  * prior to this call
     72 * Interrupts must be disabled and asidlock must be held prior to this call
    7473 *
    7574 * @return New ASID.
     
    8079        link_t *tmp;
    8180        as_t *as;
     81
     82        ASSERT(interrupts_disabled());
     83        ASSERT(spinlock_locked(&asidlock));
    8284
    8385        /*
  • kernel/genarch/src/mm/page_ht.c

    r3a2b636 r1d432f9  
    186186                page = ALIGN_DOWN(page, PAGE_SIZE)
    187187        };
     188
     189        ASSERT(interrupts_disabled());
     190        ASSERT(page_table_locked(as));
    188191       
    189192        if (!hash_table_find(&page_ht, key)) {
     
    226229                page = ALIGN_DOWN(page, PAGE_SIZE)
    227230        };
     231
     232        ASSERT(interrupts_disabled());
     233        ASSERT(page_table_locked(as));
    228234       
    229235        /*
     
    253259                page = ALIGN_DOWN(page, PAGE_SIZE)
    254260        };
     261
     262        ASSERT(interrupts_disabled());
     263        ASSERT(page_table_locked(as));
    255264       
    256265        link_t *cur = hash_table_find(&page_ht, key);
  • kernel/genarch/src/mm/page_pt.c

    r3a2b636 r1d432f9  
    7373{
    7474        pte_t *ptl0 = (pte_t *) PA2KA((uintptr_t) as->genarch.page_table);
     75
     76        ASSERT(interrupts_disabled());
     77        ASSERT(page_table_locked(as));
    7578       
    7679        if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
     
    121124void pt_mapping_remove(as_t *as, uintptr_t page)
    122125{
     126        ASSERT(interrupts_disabled());
     127        ASSERT(page_table_locked(as));
     128
    123129        /*
    124130         * First, remove the mapping, if it exists.
     
    251257pte_t *pt_mapping_find(as_t *as, uintptr_t page)
    252258{
     259        ASSERT(interrupts_disabled());
     260        ASSERT(page_table_locked(as));
     261
    253262        pte_t *ptl0 = (pte_t *) PA2KA((uintptr_t) as->genarch.page_table);
    254263        if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
  • kernel/generic/src/ipc/irq.c

    r3a2b636 r1d432f9  
    430430{
    431431        ASSERT(irq);
     432
     433        ASSERT(interrupts_disabled());
     434        ASSERT(irq_spinlock_locked(&irq->lock));
    432435       
    433436        if (irq->notif_cfg.answerbox) {
  • kernel/generic/src/mm/as.c

    r3a2b636 r1d432f9  
    817817                [PF_ACCESS_EXEC] = AS_AREA_EXEC
    818818        };
     819
     820        ASSERT(interrupts_disabled());
     821        ASSERT(mutex_locked(&area->lock));
    819822       
    820823        if (!(area->flags & flagmap[access]))
     
    12211224unsigned int as_area_get_flags(as_area_t *area)
    12221225{
     1226        ASSERT(interrupts_disabled());
     1227        ASSERT(mutex_locked(&area->lock));
     1228
    12231229        return area_flags_to_page_flags(area->flags);
    12241230}
     
    13221328as_area_t *find_area_and_lock(as_t *as, uintptr_t va)
    13231329{
     1330        ASSERT(interrupts_disabled());
     1331        ASSERT(mutex_locked(&as->lock));
     1332
    13241333        btree_node_t *leaf;
    13251334        as_area_t *area = (as_area_t *) btree_search(&as->as_area_btree, va, &leaf);
     
    13861395    as_area_t *avoid_area)
    13871396{
     1397        ASSERT(interrupts_disabled());
     1398        ASSERT(mutex_locked(&as->lock));
     1399
    13881400        /*
    13891401         * We don't want any area to have conflicts with NULL page.
     
    14731485/** Return size of the address space area with given base.
    14741486 *
    1475  * @param base Arbitrary address insede the address space area.
     1487 * @param base Arbitrary address inside the address space area.
    14761488 *
    14771489 * @return Size of the address space area in bytes or zero if it
     
    14841496       
    14851497        ipl_t ipl = interrupts_disable();
     1498        page_table_lock(AS, true);
    14861499        as_area_t *src_area = find_area_and_lock(AS, base);
    14871500       
     
    14921505                size = 0;
    14931506       
     1507        page_table_unlock(AS, true);
    14941508        interrupts_restore(ipl);
    14951509        return size;
     
    15091523int used_space_insert(as_area_t *area, uintptr_t page, size_t count)
    15101524{
     1525        ASSERT(mutex_locked(&area->lock));
    15111526        ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
    15121527        ASSERT(count);
     
    18151830int used_space_remove(as_area_t *area, uintptr_t page, size_t count)
    18161831{
     1832        ASSERT(mutex_locked(&area->lock));
    18171833        ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
    18181834        ASSERT(count);
  • kernel/generic/src/mm/backend_anon.c

    r3a2b636 r1d432f9  
    7979{
    8080        uintptr_t frame;
     81
     82        ASSERT(page_table_locked(AS));
     83        ASSERT(mutex_locked(&area->lock));
    8184
    8285        if (!as_area_check_access(area, access))
     
    168171void anon_frame_free(as_area_t *area, uintptr_t page, uintptr_t frame)
    169172{
     173        ASSERT(page_table_locked(area->as));
     174        ASSERT(mutex_locked(&area->lock));
     175
    170176        frame_free(frame);
    171177}
     
    183189{
    184190        link_t *cur;
     191
     192        ASSERT(mutex_locked(&area->as->lock));
     193        ASSERT(mutex_locked(&area->lock));
    185194
    186195        /*
  • kernel/generic/src/mm/backend_elf.c

    r3a2b636 r1d432f9  
    8686        bool dirty = false;
    8787
     88        ASSERT(page_table_locked(AS));
     89        ASSERT(mutex_locked(&area->lock));
     90
    8891        if (!as_area_check_access(area, access))
    8992                return AS_PF_FAULT;
     
    235238        uintptr_t start_anon;
    236239
    237         ASSERT((page >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) &&
    238             (page < entry->p_vaddr + entry->p_memsz));
     240        ASSERT(page_table_locked(area->as));
     241        ASSERT(mutex_locked(&area->lock));
     242
     243        ASSERT(page >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE));
     244        ASSERT(page < entry->p_vaddr + entry->p_memsz);
     245
    239246        start_anon = entry->p_vaddr + entry->p_filesz;
    240247
     
    273280        btree_node_t *leaf, *node;
    274281        uintptr_t start_anon = entry->p_vaddr + entry->p_filesz;
     282
     283        ASSERT(mutex_locked(&area->as->lock));
     284        ASSERT(mutex_locked(&area->lock));
    275285
    276286        /*
  • kernel/generic/src/mm/backend_phys.c

    r3a2b636 r1d432f9  
    7272        uintptr_t base = area->backend_data.base;
    7373
     74        ASSERT(page_table_locked(AS));
     75        ASSERT(mutex_locked(&area->lock));
     76
    7477        if (!as_area_check_access(area, access))
    7578                return AS_PF_FAULT;
     
    9396void phys_share(as_area_t *area)
    9497{
     98        ASSERT(mutex_locked(&area->as->lock));
     99        ASSERT(mutex_locked(&area->lock));
    95100}
    96101
  • kernel/generic/src/mm/page.c

    r3a2b636 r1d432f9  
    120120    unsigned int flags)
    121121{
     122        ASSERT(interrupts_disabled());
     123        ASSERT(page_table_locked(as));
     124       
    122125        ASSERT(page_mapping_operations);
    123126        ASSERT(page_mapping_operations->mapping_insert);
    124        
     127
    125128        page_mapping_operations->mapping_insert(as, page, frame, flags);
    126129       
     
    143146void page_mapping_remove(as_t *as, uintptr_t page)
    144147{
     148        ASSERT(interrupts_disabled());
     149        ASSERT(page_table_locked(as));
     150       
    145151        ASSERT(page_mapping_operations);
    146152        ASSERT(page_mapping_operations->mapping_remove);
     
    167173pte_t *page_mapping_find(as_t *as, uintptr_t page)
    168174{
     175        ASSERT(interrupts_disabled());
     176        ASSERT(page_table_locked(as));
     177       
    169178        ASSERT(page_mapping_operations);
    170179        ASSERT(page_mapping_operations->mapping_find);
  • kernel/generic/src/proc/task.c

    r3a2b636 r1d432f9  
    351351task_t *task_find_by_id(task_id_t id)
    352352{
     353        ASSERT(interrupts_disabled());
     354        ASSERT(irq_spinlock_locked(&tasks_lock));
     355
    353356        avltree_node_t *node =
    354357            avltree_search(&tasks_tree, (avltree_key_t) id);
     
    362365/** Get accounting data of given task.
    363366 *
    364  * Note that task lock of 't' must be already held and interrupts must be
     367 * Note that task lock of 'task' must be already held and interrupts must be
    365368 * already disabled.
    366369 *
     
    372375void task_get_accounting(task_t *task, uint64_t *ucycles, uint64_t *kcycles)
    373376{
     377        ASSERT(interrupts_disabled());
     378        ASSERT(irq_spinlock_locked(&task->lock));
     379
    374380        /* Accumulated values of task */
    375381        uint64_t uret = task->ucycles;
  • kernel/generic/src/proc/thread.c

    r3a2b636 r1d432f9  
    683683bool thread_exists(thread_t *thread)
    684684{
     685        ASSERT(interrupts_disabled());
     686        ASSERT(irq_spinlock_locked(&threads_lock));
     687
    685688        avltree_node_t *node =
    686689            avltree_search(&threads_tree, (avltree_key_t) ((uintptr_t) thread));
     
    700703{
    701704        uint64_t time = get_cycle();
     705
     706        ASSERT(interrupts_disabled());
     707        ASSERT(irq_spinlock_locked(&THREAD->lock));
    702708       
    703709        if (user)
     
    735741thread_t *thread_find_by_id(thread_id_t thread_id)
    736742{
     743        ASSERT(interrupts_disabled());
     744        ASSERT(irq_spinlock_locked(&threads_lock));
     745
    737746        thread_iterator_t iterator;
    738747       
  • kernel/generic/src/synch/waitq.c

    r3a2b636 r1d432f9  
    459459{
    460460        size_t count = 0;
     461
     462        ASSERT(interrupts_disabled());
     463        ASSERT(irq_spinlock_locked(&wq->lock));
    461464       
    462465loop:
  • kernel/generic/src/sysinfo/stats.c

    r3a2b636 r1d432f9  
    204204static void produce_stats_task(task_t *task, stats_task_t *stats_task)
    205205{
     206        ASSERT(interrupts_disabled());
     207        ASSERT(irq_spinlock_locked(&task->lock));
     208
    206209        stats_task->task_id = task->taskid;
    207210        str_cpy(stats_task->name, TASK_NAME_BUFLEN, task->name);
     
    303306static void produce_stats_thread(thread_t *thread, stats_thread_t *stats_thread)
    304307{
     308        ASSERT(interrupts_disabled());
     309        ASSERT(irq_spinlock_locked(&thread->lock));
     310
    305311        stats_thread->thread_id = thread->tid;
    306312        stats_thread->task_id = thread->task->taskid;
  • kernel/generic/src/udebug/udebug.c

    r3a2b636 r1d432f9  
    389389 * FINISHED event for each of them.
    390390 *
    391  * @param task Task structure. ta->udebug.lock must be already locked.
     391 * @param task Task structure. task->udebug.lock must be already locked.
    392392 *
    393393 * @return Zero on success or negative error code.
     
    396396int udebug_task_cleanup(struct task *task)
    397397{
     398        ASSERT(mutex_locked(&task->udebug.lock));
     399
    398400        if ((task->udebug.dt_state != UDEBUG_TS_BEGINNING) &&
    399401            (task->udebug.dt_state != UDEBUG_TS_ACTIVE)) {
Note: See TracChangeset for help on using the changeset viewer.