aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2014-03-17 18:22:02 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2014-03-18 15:51:56 -0400
commit3935ed6a3a533c1736e3ca65bff72afd1773be27 (patch)
treef8f9eb07a9b3e05f5b143e032e4b59a4b62836a6
parentd2312e3379d581d2c3603357a0181046448e1de3 (diff)
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>
-rw-r--r--include/linux/mm.h3
-rw-r--r--mm/mmap.c20
2 files changed, 19 insertions, 4 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index c1b7414c7bef..6c7fedf5db2b 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1750,6 +1750,9 @@ extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
1750extern struct file *get_mm_exe_file(struct mm_struct *mm); 1750extern struct file *get_mm_exe_file(struct mm_struct *mm);
1751 1751
1752extern int may_expand_vm(struct mm_struct *mm, unsigned long npages); 1752extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
1753extern 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);
1753extern int install_special_mapping(struct mm_struct *mm, 1756extern int install_special_mapping(struct mm_struct *mm,
1754 unsigned long addr, unsigned long len, 1757 unsigned long addr, unsigned long len,
1755 unsigned long flags, struct page **pages); 1758 unsigned long flags, struct page **pages);
diff --git a/mm/mmap.c b/mm/mmap.c
index 20ff0c33274c..81ba54ff96c7 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2918,7 +2918,7 @@ static const struct vm_operations_struct special_mapping_vmops = {
2918 * The array pointer and the pages it points to are assumed to stay alive 2918 * The array pointer and the pages it points to are assumed to stay alive
2919 * for as long as this mapping might exist. 2919 * for as long as this mapping might exist.
2920 */ 2920 */
2921int install_special_mapping(struct mm_struct *mm, 2921struct vm_area_struct *_install_special_mapping(struct mm_struct *mm,
2922 unsigned long addr, unsigned long len, 2922 unsigned long addr, unsigned long len,
2923 unsigned long vm_flags, struct page **pages) 2923 unsigned long vm_flags, struct page **pages)
2924{ 2924{
@@ -2927,7 +2927,7 @@ int install_special_mapping(struct mm_struct *mm,
2927 2927
2928 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 2928 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
2929 if (unlikely(vma == NULL)) 2929 if (unlikely(vma == NULL))
2930 return -ENOMEM; 2930 return ERR_PTR(-ENOMEM);
2931 2931
2932 INIT_LIST_HEAD(&vma->anon_vma_chain); 2932 INIT_LIST_HEAD(&vma->anon_vma_chain);
2933 vma->vm_mm = mm; 2933 vma->vm_mm = mm;
@@ -2948,11 +2948,23 @@ int install_special_mapping(struct mm_struct *mm,
2948 2948
2949 perf_event_mmap(vma); 2949 perf_event_mmap(vma);
2950 2950
2951 return 0; 2951 return vma;
2952 2952
2953out: 2953out:
2954 kmem_cache_free(vm_area_cachep, vma); 2954 kmem_cache_free(vm_area_cachep, vma);
2955 return ret; 2955 return ERR_PTR(ret);
2956}
2957
2958int 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
2958static DEFINE_MUTEX(mm_all_locks_mutex); 2970static DEFINE_MUTEX(mm_all_locks_mutex);