Changeset 25eec4e in mainline for kernel/generic/src/mm/as.c
- Timestamp:
- 2013-04-19T18:38:18Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6d717a4
- Parents:
- a1e2df13 (diff), 289cb7dd (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/as.c
ra1e2df13 r25eec4e 79 79 #include <syscall/copy.h> 80 80 #include <arch/interrupt.h> 81 #include <interrupt.h> 81 82 82 83 /** … … 426 427 /* 427 428 * So far, the area does not conflict with other areas. 428 * Check if it doesn't conflict with kerneladdress space.429 * Check if it is contained in the user address space. 429 430 */ 430 431 if (!KERNEL_ADDRESS_SPACE_SHADOWED) { 431 return !overlaps(addr, P2SZ(count), KERNEL_ADDRESS_SPACE_START, 432 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)); 433 435 } 434 436 … … 542 544 mem_backend_data_t *backend_data, uintptr_t *base, uintptr_t bound) 543 545 { 544 if ((*base != (uintptr_t) -1) && ((*base % PAGE_SIZE) != 0))546 if ((*base != (uintptr_t) -1) && !IS_ALIGNED(*base, PAGE_SIZE)) 545 547 return NULL; 546 548 … … 686 688 int as_area_resize(as_t *as, uintptr_t address, size_t size, unsigned int flags) 687 689 { 690 if (!IS_ALIGNED(address, PAGE_SIZE)) 691 return EINVAL; 692 688 693 mutex_lock(&as->lock); 689 694 … … 696 701 return ENOENT; 697 702 } 698 699 if (area->backend == &phys_backend) { 700 /* 701 * Remapping of address space areas associated 702 * with memory mapped devices is not supported. 703 704 if (!area->backend->is_resizable(area)) { 705 /* 706 * The backend does not support resizing for this area. 703 707 */ 704 708 mutex_unlock(&area->lock); … … 1057 1061 } 1058 1062 1059 if ((!src_area->backend) || (!src_area->backend->share)) { 1060 /* 1061 * There is no backend or the backend does not 1062 * know how to share the area. 1063 if (!src_area->backend->is_shareable(src_area)) { 1064 /* 1065 * The backend does not permit sharing of this area. 1063 1066 */ 1064 1067 mutex_unlock(&src_area->lock); … … 1350 1353 * Interrupts are assumed disabled. 1351 1354 * 1352 * @param page Faulting page.1353 * @param access Access mode that caused the page fault (i.e.1354 * read/write/exec).1355 * @param istate Pointer to the interrupted state.1355 * @param address Faulting address. 1356 * @param access Access mode that caused the page fault (i.e. 1357 * read/write/exec). 1358 * @param istate Pointer to the interrupted state. 1356 1359 * 1357 1360 * @return AS_PF_FAULT on page fault. … … 1361 1364 * 1362 1365 */ 1363 int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate) 1364 { 1366 int as_page_fault(uintptr_t address, pf_access_t access, istate_t *istate) 1367 { 1368 uintptr_t page = ALIGN_DOWN(address, PAGE_SIZE); 1369 int rc = AS_PF_FAULT; 1370 1365 1371 if (!THREAD) 1366 return AS_PF_FAULT;1372 goto page_fault; 1367 1373 1368 1374 if (!AS) 1369 return AS_PF_FAULT;1375 goto page_fault; 1370 1376 1371 1377 mutex_lock(&AS->lock); … … 1423 1429 * Resort to the backend page fault handler. 1424 1430 */ 1425 if (area->backend->page_fault(area, page, access) != AS_PF_OK) { 1431 rc = area->backend->page_fault(area, page, access); 1432 if (rc != AS_PF_OK) { 1426 1433 page_table_unlock(AS, false); 1427 1434 mutex_unlock(&area->lock); … … 1444 1451 istate_set_retaddr(istate, 1445 1452 (uintptr_t) &memcpy_to_uspace_failover_address); 1453 } else if (rc == AS_PF_SILENT) { 1454 printf("Killing task %" PRIu64 " due to a " 1455 "failed late reservation request.\n", TASK->taskid); 1456 task_kill_self(true); 1446 1457 } else { 1447 return AS_PF_FAULT; 1458 fault_if_from_uspace(istate, "Page fault: %p.", (void *) address); 1459 panic_memtrap(istate, access, address, NULL); 1448 1460 } 1449 1461 … … 1671 1683 { 1672 1684 ASSERT(mutex_locked(&area->lock)); 1673 ASSERT( page == ALIGN_DOWN(page, PAGE_SIZE));1685 ASSERT(IS_ALIGNED(page, PAGE_SIZE)); 1674 1686 ASSERT(count); 1675 1687 … … 1955 1967 { 1956 1968 ASSERT(mutex_locked(&area->lock)); 1957 ASSERT( page == ALIGN_DOWN(page, PAGE_SIZE));1969 ASSERT(IS_ALIGNED(page, PAGE_SIZE)); 1958 1970 ASSERT(count); 1959 1971 … … 2132 2144 { 2133 2145 uintptr_t virt = base; 2134 as_area_t *area = as_area_create(AS, flags | AS_AREA_CACHEABLE, size,2146 as_area_t *area = as_area_create(AS, flags, size, 2135 2147 AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, bound); 2136 2148 if (area == NULL)
Note:
See TracChangeset
for help on using the changeset viewer.