Commit 3935ed6a3a533c1736e3ca65bff72afd1773be27

Authored by Stefani Seibold
Committed by H. Peter Anvin
1 parent d2312e3379

mm: Add new func _install_special_mapping() to mmap.c

The _install_special_mapping() is the new base function for
install_special_mapping(). This function will return a pointer of the
created VMA or a error code in an ERR_PTR()

This new function will be needed by the for the vdso 32 bit support to map the
additonal vvar and hpet pages into the 32 bit address space. This will be done
with io_remap_pfn_range() and remap_pfn_range, which requieres a vm_area_struct.

Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Stefani Seibold <stefani@seibold.net>
Link: http://lkml.kernel.org/r/1395094933-14252-3-git-send-email-stefani@seibold.net
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

Showing 2 changed files with 19 additions and 4 deletions Side-by-side Diff

... ... @@ -1750,6 +1750,9 @@
1750 1750 extern struct file *get_mm_exe_file(struct mm_struct *mm);
1751 1751  
1752 1752 extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
  1753 +extern struct vm_area_struct *_install_special_mapping(struct mm_struct *mm,
  1754 + unsigned long addr, unsigned long len,
  1755 + unsigned long flags, struct page **pages);
1753 1756 extern int install_special_mapping(struct mm_struct *mm,
1754 1757 unsigned long addr, unsigned long len,
1755 1758 unsigned long flags, struct page **pages);
... ... @@ -2918,7 +2918,7 @@
2918 2918 * The array pointer and the pages it points to are assumed to stay alive
2919 2919 * for as long as this mapping might exist.
2920 2920 */
2921   -int install_special_mapping(struct mm_struct *mm,
  2921 +struct vm_area_struct *_install_special_mapping(struct mm_struct *mm,
2922 2922 unsigned long addr, unsigned long len,
2923 2923 unsigned long vm_flags, struct page **pages)
2924 2924 {
... ... @@ -2927,7 +2927,7 @@
2927 2927  
2928 2928 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
2929 2929 if (unlikely(vma == NULL))
2930   - return -ENOMEM;
  2930 + return ERR_PTR(-ENOMEM);
2931 2931  
2932 2932 INIT_LIST_HEAD(&vma->anon_vma_chain);
2933 2933 vma->vm_mm = mm;
2934 2934  
... ... @@ -2948,11 +2948,23 @@
2948 2948  
2949 2949 perf_event_mmap(vma);
2950 2950  
2951   - return 0;
  2951 + return vma;
2952 2952  
2953 2953 out:
2954 2954 kmem_cache_free(vm_area_cachep, vma);
2955   - return ret;
  2955 + return ERR_PTR(ret);
  2956 +}
  2957 +
  2958 +int install_special_mapping(struct mm_struct *mm,
  2959 + unsigned long addr, unsigned long len,
  2960 + unsigned long vm_flags, struct page **pages)
  2961 +{
  2962 + struct vm_area_struct *vma = _install_special_mapping(mm,
  2963 + addr, len, vm_flags, pages);
  2964 +
  2965 + if (IS_ERR(vma))
  2966 + return PTR_ERR(vma);
  2967 + return 0;
2956 2968 }
2957 2969  
2958 2970 static DEFINE_MUTEX(mm_all_locks_mutex);