arch/parisc/kernel/sys_parisc.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c index 31ffa9b55322..dd643459cbef 100644 --- a/arch/parisc/kernel/sys_parisc.c +++ b/arch/parisc/kernel/sys_parisc.c @@ -36,12 +36,32 @@ #include #include -/* we construct an artificial offset for the mapping based on the physical - * address of the kernel mapping variable */ -#define GET_LAST_MMAP(filp) \ - (filp ? ((unsigned long) filp->f_mapping) >> 8 : 0UL) -#define SET_LAST_MMAP(filp, val) \ - { /* nothing */ } +static inline unsigned long find_shared_mapping_address(struct address_space *mapping) +{ + struct rb_node *nd; + + for (nd = rb_first(root); nd; nd = rb_next(nd)) { + struct vm_area_struct *vma; + vma = rb_entry(nd, struct vm_area_struct, vm_rb); + if (vma->vm_flags & VM_SHARED) + return vma->start; + } + /* Shouldn't happen */ + return 0; +} + +/* the address_space struct holds a field i_mmap_lastmmap with the last mapping + * of this file for us */ +static inline unsigned long GET_LAST_MMAP(struct file *filp) +{ + if (filp) { + struct address_space *mapping = filp->f_mapping; + if (mapping->i_mmap_writable) + return find_shared_mapping_address(mapping); + } + return 0; +} + static int get_offset(unsigned int last_mmap) { @@ -127,9 +147,6 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, addr = vm_unmapped_area(&info); found_addr: - if (do_color_align && !last_mmap && !(addr & ~PAGE_MASK)) - SET_LAST_MMAP(filp, addr - (pgoff << PAGE_SHIFT)); - return addr; } @@ -198,9 +215,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, return arch_get_unmapped_area(filp, addr0, len, pgoff, flags); found_addr: - if (do_color_align && !last_mmap && !(addr & ~PAGE_MASK)) - SET_LAST_MMAP(filp, addr - (pgoff << PAGE_SHIFT)); - return addr; }