Rev 1417 | Rev 1424 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1417 | Rev 1423 | ||
---|---|---|---|
Line 630... | Line 630... | ||
630 | mutex_unlock(&area->lock); |
630 | mutex_unlock(&area->lock); |
631 | page_table_unlock(as, true); |
631 | page_table_unlock(as, true); |
632 | interrupts_restore(ipl); |
632 | interrupts_restore(ipl); |
633 | } |
633 | } |
634 | 634 | ||
- | 635 | /** Check access mode for address space area. |
|
- | 636 | * |
|
- | 637 | * The address space area must be locked prior to this call. |
|
- | 638 | * |
|
- | 639 | * @param area Address space area. |
|
- | 640 | * @param access Access mode. |
|
- | 641 | * |
|
- | 642 | * @return False if access violates area's permissions, true otherwise. |
|
- | 643 | */ |
|
- | 644 | bool as_area_check_access(as_area_t *area, pf_access_t access) |
|
- | 645 | { |
|
- | 646 | int flagmap[] = { |
|
- | 647 | [PF_ACCESS_READ] = AS_AREA_READ, |
|
- | 648 | [PF_ACCESS_WRITE] = AS_AREA_WRITE, |
|
- | 649 | [PF_ACCESS_EXEC] = AS_AREA_EXEC |
|
- | 650 | }; |
|
- | 651 | ||
- | 652 | if (!(area->flags & flagmap[access])) |
|
- | 653 | return false; |
|
- | 654 | ||
- | 655 | return true; |
|
- | 656 | } |
|
- | 657 | ||
635 | /** Handle page fault within the current address space. |
658 | /** Handle page fault within the current address space. |
636 | * |
659 | * |
637 | * This is the high-level page fault handler. It decides |
660 | * This is the high-level page fault handler. It decides |
638 | * whether the page fault can be resolved by any backend |
661 | * whether the page fault can be resolved by any backend |
639 | * and if so, it invokes the backend to resolve the page |
662 | * and if so, it invokes the backend to resolve the page |
Line 696... | Line 719... | ||
696 | * on the same address, we need to make sure |
719 | * on the same address, we need to make sure |
697 | * the mapping has not been already inserted. |
720 | * the mapping has not been already inserted. |
698 | */ |
721 | */ |
699 | if ((pte = page_mapping_find(AS, page))) { |
722 | if ((pte = page_mapping_find(AS, page))) { |
700 | if (PTE_PRESENT(pte)) { |
723 | if (PTE_PRESENT(pte)) { |
- | 724 | if (((access == PF_ACCESS_READ) && PTE_READABLE(pte)) || |
|
- | 725 | (access == PF_ACCESS_WRITE && PTE_WRITABLE(pte)) || |
|
- | 726 | (access == PF_ACCESS_EXEC && PTE_EXECUTABLE(pte))) { |
|
701 | page_table_unlock(AS, false); |
727 | page_table_unlock(AS, false); |
702 | mutex_unlock(&area->lock); |
728 | mutex_unlock(&area->lock); |
703 | mutex_unlock(&AS->lock); |
729 | mutex_unlock(&AS->lock); |
704 | return AS_PF_OK; |
730 | return AS_PF_OK; |
- | 731 | } |
|
705 | } |
732 | } |
706 | } |
733 | } |
707 | 734 | ||
708 | /* |
735 | /* |
709 | * Resort to the backend page fault handler. |
736 | * Resort to the backend page fault handler. |
Line 1493... | Line 1520... | ||
1493 | */ |
1520 | */ |
1494 | int anon_page_fault(as_area_t *area, __address addr, pf_access_t access) |
1521 | int anon_page_fault(as_area_t *area, __address addr, pf_access_t access) |
1495 | { |
1522 | { |
1496 | __address frame; |
1523 | __address frame; |
1497 | 1524 | ||
- | 1525 | if (!as_area_check_access(area, access)) |
|
- | 1526 | return AS_PF_FAULT; |
|
- | 1527 | ||
1498 | if (area->sh_info) { |
1528 | if (area->sh_info) { |
1499 | btree_node_t *leaf; |
1529 | btree_node_t *leaf; |
1500 | 1530 | ||
1501 | /* |
1531 | /* |
1502 | * The area is shared, chances are that the mapping can be found |
1532 | * The area is shared, chances are that the mapping can be found |