diff options
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 61 |
1 files changed, 35 insertions, 26 deletions
@@ -1571,33 +1571,11 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address) | |||
1571 | } | 1571 | } |
1572 | #endif /* CONFIG_STACK_GROWSUP || CONFIG_IA64 */ | 1572 | #endif /* CONFIG_STACK_GROWSUP || CONFIG_IA64 */ |
1573 | 1573 | ||
1574 | #ifdef CONFIG_STACK_GROWSUP | ||
1575 | int expand_stack(struct vm_area_struct *vma, unsigned long address) | ||
1576 | { | ||
1577 | return expand_upwards(vma, address); | ||
1578 | } | ||
1579 | |||
1580 | struct vm_area_struct * | ||
1581 | find_extend_vma(struct mm_struct *mm, unsigned long addr) | ||
1582 | { | ||
1583 | struct vm_area_struct *vma, *prev; | ||
1584 | |||
1585 | addr &= PAGE_MASK; | ||
1586 | vma = find_vma_prev(mm, addr, &prev); | ||
1587 | if (vma && (vma->vm_start <= addr)) | ||
1588 | return vma; | ||
1589 | if (!prev || expand_stack(prev, addr)) | ||
1590 | return NULL; | ||
1591 | if (prev->vm_flags & VM_LOCKED) { | ||
1592 | make_pages_present(addr, prev->vm_end); | ||
1593 | } | ||
1594 | return prev; | ||
1595 | } | ||
1596 | #else | ||
1597 | /* | 1574 | /* |
1598 | * vma is the first one with address < vma->vm_start. Have to extend vma. | 1575 | * vma is the first one with address < vma->vm_start. Have to extend vma. |
1599 | */ | 1576 | */ |
1600 | int expand_stack(struct vm_area_struct *vma, unsigned long address) | 1577 | static inline int expand_downwards(struct vm_area_struct *vma, |
1578 | unsigned long address) | ||
1601 | { | 1579 | { |
1602 | int error; | 1580 | int error; |
1603 | 1581 | ||
@@ -1634,6 +1612,38 @@ int expand_stack(struct vm_area_struct *vma, unsigned long address) | |||
1634 | return error; | 1612 | return error; |
1635 | } | 1613 | } |
1636 | 1614 | ||
1615 | int expand_stack_downwards(struct vm_area_struct *vma, unsigned long address) | ||
1616 | { | ||
1617 | return expand_downwards(vma, address); | ||
1618 | } | ||
1619 | |||
1620 | #ifdef CONFIG_STACK_GROWSUP | ||
1621 | int expand_stack(struct vm_area_struct *vma, unsigned long address) | ||
1622 | { | ||
1623 | return expand_upwards(vma, address); | ||
1624 | } | ||
1625 | |||
1626 | struct vm_area_struct * | ||
1627 | find_extend_vma(struct mm_struct *mm, unsigned long addr) | ||
1628 | { | ||
1629 | struct vm_area_struct *vma, *prev; | ||
1630 | |||
1631 | addr &= PAGE_MASK; | ||
1632 | vma = find_vma_prev(mm, addr, &prev); | ||
1633 | if (vma && (vma->vm_start <= addr)) | ||
1634 | return vma; | ||
1635 | if (!prev || expand_stack(prev, addr)) | ||
1636 | return NULL; | ||
1637 | if (prev->vm_flags & VM_LOCKED) | ||
1638 | make_pages_present(addr, prev->vm_end); | ||
1639 | return prev; | ||
1640 | } | ||
1641 | #else | ||
1642 | int expand_stack(struct vm_area_struct *vma, unsigned long address) | ||
1643 | { | ||
1644 | return expand_downwards(vma, address); | ||
1645 | } | ||
1646 | |||
1637 | struct vm_area_struct * | 1647 | struct vm_area_struct * |
1638 | find_extend_vma(struct mm_struct * mm, unsigned long addr) | 1648 | find_extend_vma(struct mm_struct * mm, unsigned long addr) |
1639 | { | 1649 | { |
@@ -1651,9 +1661,8 @@ find_extend_vma(struct mm_struct * mm, unsigned long addr) | |||
1651 | start = vma->vm_start; | 1661 | start = vma->vm_start; |
1652 | if (expand_stack(vma, addr)) | 1662 | if (expand_stack(vma, addr)) |
1653 | return NULL; | 1663 | return NULL; |
1654 | if (vma->vm_flags & VM_LOCKED) { | 1664 | if (vma->vm_flags & VM_LOCKED) |
1655 | make_pages_present(addr, start); | 1665 | make_pages_present(addr, start); |
1656 | } | ||
1657 | return vma; | 1666 | return vma; |
1658 | } | 1667 | } |
1659 | #endif | 1668 | #endif |