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