aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/mm.h8
-rw-r--r--mm/memory.c15
-rw-r--r--mm/mmap.c3
3 files changed, 18 insertions, 8 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 709f6728fc90..831c693416b2 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -78,7 +78,11 @@ extern unsigned int kobjsize(const void *objp);
78#define VM_MAYSHARE 0x00000080 78#define VM_MAYSHARE 0x00000080
79 79
80#define VM_GROWSDOWN 0x00000100 /* general info on the segment */ 80#define VM_GROWSDOWN 0x00000100 /* general info on the segment */
81#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
81#define VM_GROWSUP 0x00000200 82#define VM_GROWSUP 0x00000200
83#else
84#define VM_GROWSUP 0x00000000
85#endif
82#define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */ 86#define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */
83#define VM_DENYWRITE 0x00000800 /* ETXTBSY on write attempts.. */ 87#define VM_DENYWRITE 0x00000800 /* ETXTBSY on write attempts.. */
84 88
@@ -1330,8 +1334,10 @@ unsigned long ra_submit(struct file_ra_state *ra,
1330 1334
1331/* Do stack extension */ 1335/* Do stack extension */
1332extern int expand_stack(struct vm_area_struct *vma, unsigned long address); 1336extern int expand_stack(struct vm_area_struct *vma, unsigned long address);
1333#ifdef CONFIG_IA64 1337#if VM_GROWSUP
1334extern int expand_upwards(struct vm_area_struct *vma, unsigned long address); 1338extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);
1339#else
1340 #define expand_upwards(vma, address) do { } while (0)
1335#endif 1341#endif
1336extern int expand_stack_downwards(struct vm_area_struct *vma, 1342extern int expand_stack_downwards(struct vm_area_struct *vma,
1337 unsigned long address); 1343 unsigned long address);
diff --git a/mm/memory.c b/mm/memory.c
index 2ed2267439df..6b2ab1051851 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2760,11 +2760,9 @@ out_release:
2760} 2760}
2761 2761
2762/* 2762/*
2763 * This is like a special single-page "expand_downwards()", 2763 * This is like a special single-page "expand_{down|up}wards()",
2764 * except we must first make sure that 'address-PAGE_SIZE' 2764 * except we must first make sure that 'address{-|+}PAGE_SIZE'
2765 * doesn't hit another vma. 2765 * doesn't hit another vma.
2766 *
2767 * The "find_vma()" will do the right thing even if we wrap
2768 */ 2766 */
2769static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address) 2767static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
2770{ 2768{
@@ -2783,6 +2781,15 @@ static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned lo
2783 2781
2784 expand_stack(vma, address - PAGE_SIZE); 2782 expand_stack(vma, address - PAGE_SIZE);
2785 } 2783 }
2784 if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
2785 struct vm_area_struct *next = vma->vm_next;
2786
2787 /* As VM_GROWSDOWN but s/below/above/ */
2788 if (next && next->vm_start == address + PAGE_SIZE)
2789 return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
2790
2791 expand_upwards(vma, address + PAGE_SIZE);
2792 }
2786 return 0; 2793 return 0;
2787} 2794}
2788 2795
diff --git a/mm/mmap.c b/mm/mmap.c
index 331e51af38c9..6128dc8e5ede 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1716,9 +1716,6 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
1716 * PA-RISC uses this for its stack; IA64 for its Register Backing Store. 1716 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
1717 * vma is the last one with address > vma->vm_end. Have to extend vma. 1717 * vma is the last one with address > vma->vm_end. Have to extend vma.
1718 */ 1718 */
1719#ifndef CONFIG_IA64
1720static
1721#endif
1722int expand_upwards(struct vm_area_struct *vma, unsigned long address) 1719int expand_upwards(struct vm_area_struct *vma, unsigned long address)
1723{ 1720{
1724 int error; 1721 int error;