Changes in kernel/generic/src/mm/as.c [c964521:336db295] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/as.c
rc964521 r336db295 1 1 /* 2 * Copyright (c) 20 10Jakub Jermar2 * Copyright (c) 2001-2006 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 75 75 #include <config.h> 76 76 #include <align.h> 77 #include < typedefs.h>77 #include <arch/types.h> 78 78 #include <syscall/copy.h> 79 79 #include <arch/interrupt.h> … … 152 152 * reference count never drops to zero. 153 153 */ 154 a s_hold(AS_KERNEL);154 atomic_set(&AS_KERNEL->refcount, 1); 155 155 } 156 156 … … 200 200 DEADLOCK_PROBE_INIT(p_asidlock); 201 201 202 ASSERT(as != AS);203 202 ASSERT(atomic_get(&as->refcount) == 0); 204 203 205 204 /* 206 * Since there is no reference to this a ddress space, it is safe not to207 * lock its mutex.205 * Since there is no reference to this area, 206 * it is safe not to lock its mutex. 208 207 */ 209 208 … … 226 225 preemption_enable(); /* Interrupts disabled, enable preemption */ 227 226 if (as->asid != ASID_INVALID && as != AS_KERNEL) { 228 if (as ->cpu_refcount == 0)227 if (as != AS && as->cpu_refcount == 0) 229 228 list_remove(&as->inactive_as_with_asid_link); 230 229 asid_put(as->asid); … … 259 258 260 259 slab_free(as_slab, as); 261 }262 263 /** Hold a reference to an address space.264 *265 * Holding a reference to an address space prevents destruction of that address266 * space.267 *268 * @param a Address space to be held.269 */270 void as_hold(as_t *as)271 {272 atomic_inc(&as->refcount);273 }274 275 /** Release a reference to an address space.276 *277 * The last one to release a reference to an address space destroys the address278 * space.279 *280 * @param a Address space to be released.281 */282 void as_release(as_t *as)283 {284 if (atomic_predec(&as->refcount) == 0)285 as_destroy(as);286 260 } 287 261 … … 422 396 * No need to check for overlaps. 423 397 */ 424 425 page_table_lock(as, false);426 398 427 399 /* … … 488 460 pte_t *pte; 489 461 462 page_table_lock(as, false); 490 463 pte = page_mapping_find(as, b + 491 464 i * PAGE_SIZE); … … 500 473 page_mapping_remove(as, b + 501 474 i * PAGE_SIZE); 475 page_table_unlock(as, false); 502 476 } 503 477 } … … 510 484 tlb_invalidate_pages(as->asid, area->base + pages * PAGE_SIZE, 511 485 area->pages - pages); 512 513 486 /* 514 487 * Invalidate software translation caches (e.g. TSB on sparc64). … … 517 490 pages * PAGE_SIZE, area->pages - pages); 518 491 tlb_shootdown_finalize(); 519 520 page_table_unlock(as, false);521 492 522 493 } else { … … 568 539 569 540 base = area->base; 570 571 page_table_lock(as, false);572 541 573 542 /* … … 591 560 592 561 for (j = 0; j < (size_t) node->value[i]; j++) { 562 page_table_lock(as, false); 593 563 pte = page_mapping_find(as, b + j * PAGE_SIZE); 594 564 ASSERT(pte && PTE_VALID(pte) && … … 600 570 } 601 571 page_mapping_remove(as, b + j * PAGE_SIZE); 572 page_table_unlock(as, false); 602 573 } 603 574 } … … 609 580 610 581 tlb_invalidate_pages(as->asid, area->base, area->pages); 611 612 582 /* 613 583 * Invalidate potential software translation caches (e.g. TSB on … … 616 586 as_invalidate_translation_cache(as, area->base, area->pages); 617 587 tlb_shootdown_finalize(); 618 619 page_table_unlock(as, false);620 588 621 589 btree_destroy(&area->used_space); … … 816 784 { 817 785 as_area_t *area; 786 uintptr_t base; 818 787 link_t *cur; 819 788 ipl_t ipl; … … 844 813 return ENOTSUP; 845 814 } 815 816 base = area->base; 846 817 847 818 /* … … 863 834 /* An array for storing frame numbers */ 864 835 old_frame = malloc(used_pages * sizeof(uintptr_t), 0); 865 866 page_table_lock(as, false);867 836 868 837 /* … … 889 858 890 859 for (j = 0; j < (size_t) node->value[i]; j++) { 860 page_table_lock(as, false); 891 861 pte = page_mapping_find(as, b + j * PAGE_SIZE); 892 862 ASSERT(pte && PTE_VALID(pte) && … … 896 866 /* Remove old mapping */ 897 867 page_mapping_remove(as, b + j * PAGE_SIZE); 868 page_table_unlock(as, false); 898 869 } 899 870 } … … 912 883 as_invalidate_translation_cache(as, area->base, area->pages); 913 884 tlb_shootdown_finalize(); 914 915 page_table_unlock(as, false);916 885 917 886 /* … … 983 952 if (!THREAD) 984 953 return AS_PF_FAULT; 985 986 if (!AS) 987 return AS_PF_FAULT; 988 954 955 ASSERT(AS); 956 989 957 mutex_lock(&AS->lock); 990 area = find_area_and_lock(AS, page); 958 area = find_area_and_lock(AS, page); 991 959 if (!area) { 992 960 /*
Note:
See TracChangeset
for help on using the changeset viewer.