Changeset 2a2fbc8 in mainline for kernel/genarch/src/mm/page_ht.c


Ignore:
Timestamp:
2016-09-01T17:05:13Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42d08592
Parents:
f126c87 (diff), fb63c06 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jakub/helenos/pt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/mm/page_ht.c

    rf126c87 r2a2fbc8  
    5959static void ht_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int);
    6060static void ht_mapping_remove(as_t *, uintptr_t);
    61 static pte_t *ht_mapping_find(as_t *, uintptr_t, bool);
     61static bool ht_mapping_find(as_t *, uintptr_t, bool, pte_t *);
     62static void ht_mapping_update(as_t *, uintptr_t, bool, pte_t *);
    6263static void ht_mapping_make_global(uintptr_t, size_t);
    6364
     
    7071 *
    7172 */
    72 mutex_t page_ht_lock;
     73IRQ_SPINLOCK_STATIC_INITIALIZE(page_ht_lock);
    7374
    7475/** Page hash table.
     
    9192        .mapping_remove = ht_mapping_remove,
    9293        .mapping_find = ht_mapping_find,
     94        .mapping_update = ht_mapping_update,
    9395        .mapping_make_global = ht_mapping_make_global
    9496};
     
    191193
    192194        ASSERT(page_table_locked(as));
     195
     196        irq_spinlock_lock(&page_ht_lock, true);
    193197       
    194198        if (!hash_table_find(&page_ht, key)) {
     
    217221                hash_table_insert(&page_ht, key, &pte->link);
    218222        }
     223
     224        irq_spinlock_unlock(&page_ht_lock, true);
    219225}
    220226
     
    238244        ASSERT(page_table_locked(as));
    239245       
     246        irq_spinlock_lock(&page_ht_lock, true);
     247
    240248        /*
    241249         * Note that removed PTE's will be freed
     
    243251         */
    244252        hash_table_remove(&page_ht, key, 2);
    245 }
    246 
    247 
    248 /** Find mapping for virtual page in page hash table.
    249  *
    250  * @param as     Address space to which page belongs.
    251  * @param page   Virtual page.
    252  * @param nolock True if the page tables need not be locked.
    253  *
    254  * @return NULL if there is no such mapping; requested mapping otherwise.
    255  *
    256  */
    257 pte_t *ht_mapping_find(as_t *as, uintptr_t page, bool nolock)
     253
     254        irq_spinlock_unlock(&page_ht_lock, true);
     255}
     256
     257static pte_t *ht_mapping_find_internal(as_t *as, uintptr_t page, bool nolock)
    258258{
    259259        sysarg_t key[2] = {
     
    263263
    264264        ASSERT(nolock || page_table_locked(as));
    265        
     265
    266266        link_t *cur = hash_table_find(&page_ht, key);
    267267        if (cur)
     
    271271}
    272272
     273/** Find mapping for virtual page in page hash table.
     274 *
     275 * @param as       Address space to which page belongs.
     276 * @param page     Virtual page.
     277 * @param nolock   True if the page tables need not be locked.
     278 * @param[out] pte Structure that will receive a copy of the found PTE.
     279 *
     280 * @return True if the mapping was found, false otherwise.
     281 */
     282bool ht_mapping_find(as_t *as, uintptr_t page, bool nolock, pte_t *pte)
     283{
     284        irq_spinlock_lock(&page_ht_lock, true);
     285
     286        pte_t *t = ht_mapping_find_internal(as, page, nolock);
     287        if (t)
     288                *pte = *t;
     289
     290        irq_spinlock_unlock(&page_ht_lock, true);
     291       
     292        return t != NULL;
     293}
     294
     295/** Update mapping for virtual page in page hash table.
     296 *
     297 * @param as       Address space to which page belongs.
     298 * @param page     Virtual page.
     299 * @param nolock   True if the page tables need not be locked.
     300 * @param pte      New PTE.
     301 */
     302void ht_mapping_update(as_t *as, uintptr_t page, bool nolock, pte_t *pte)
     303{
     304        irq_spinlock_lock(&page_ht_lock, true);
     305
     306        pte_t *t = ht_mapping_find_internal(as, page, nolock);
     307        if (!t)
     308                panic("Updating non-existent PTE");
     309       
     310        ASSERT(pte->as == t->as);
     311        ASSERT(pte->page == t->page);
     312        ASSERT(pte->frame == t->frame);
     313        ASSERT(pte->g == t->g);
     314        ASSERT(pte->x == t->x);
     315        ASSERT(pte->w == t->w);
     316        ASSERT(pte->k == t->k);
     317        ASSERT(pte->c == t->c);
     318        ASSERT(pte->p == t->p);
     319
     320        t->a = pte->a;
     321        t->d = pte->d;
     322
     323        irq_spinlock_unlock(&page_ht_lock, true);
     324}
     325
    273326void ht_mapping_make_global(uintptr_t base, size_t size)
    274327{
Note: See TracChangeset for help on using the changeset viewer.