aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Stoakes <lstoakes@gmail.com>2016-10-24 05:57:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-24 22:13:20 -0400
commit0d7317598214134d73da59990b846481a9527a00 (patch)
tree2f72c1cdfd6c417a16d0697f50b9bdf909fc71fa
parent272ddc8b37354c3fe111ab26d25e792629148eee (diff)
mm: unexport __get_user_pages()
This patch unexports the low-level __get_user_pages() function. Recent refactoring of the get_user_pages* functions allow flags to be passed through get_user_pages() which eliminates the need for access to this function from its one user, kvm. We can see that the two calls to get_user_pages() which replace __get_user_pages() in kvm_main.c are equivalent by examining their call stacks: get_user_page_nowait(): get_user_pages(start, 1, flags, page, NULL) __get_user_pages_locked(current, current->mm, start, 1, page, NULL, NULL, false, flags | FOLL_TOUCH) __get_user_pages(current, current->mm, start, 1, flags | FOLL_TOUCH | FOLL_GET, page, NULL, NULL) check_user_page_hwpoison(): get_user_pages(addr, 1, flags, NULL, NULL) __get_user_pages_locked(current, current->mm, addr, 1, NULL, NULL, NULL, false, flags | FOLL_TOUCH) __get_user_pages(current, current->mm, addr, 1, flags | FOLL_TOUCH, NULL, NULL, NULL) Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/mm.h4
-rw-r--r--mm/gup.c3
-rw-r--r--mm/nommu.c2
-rw-r--r--virt/kvm/kvm_main.c10
4 files changed, 6 insertions, 13 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3a191853faaa..a92c8d73aeaf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1271,10 +1271,6 @@ extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *
1271extern int access_remote_vm(struct mm_struct *mm, unsigned long addr, 1271extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
1272 void *buf, int len, unsigned int gup_flags); 1272 void *buf, int len, unsigned int gup_flags);
1273 1273
1274long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1275 unsigned long start, unsigned long nr_pages,
1276 unsigned int foll_flags, struct page **pages,
1277 struct vm_area_struct **vmas, int *nonblocking);
1278long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm, 1274long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm,
1279 unsigned long start, unsigned long nr_pages, 1275 unsigned long start, unsigned long nr_pages,
1280 unsigned int gup_flags, struct page **pages, 1276 unsigned int gup_flags, struct page **pages,
diff --git a/mm/gup.c b/mm/gup.c
index 7aa113c2d373..ec4f82704b6f 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -526,7 +526,7 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
526 * instead of __get_user_pages. __get_user_pages should be used only if 526 * instead of __get_user_pages. __get_user_pages should be used only if
527 * you need some special @gup_flags. 527 * you need some special @gup_flags.
528 */ 528 */
529long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 529static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
530 unsigned long start, unsigned long nr_pages, 530 unsigned long start, unsigned long nr_pages,
531 unsigned int gup_flags, struct page **pages, 531 unsigned int gup_flags, struct page **pages,
532 struct vm_area_struct **vmas, int *nonblocking) 532 struct vm_area_struct **vmas, int *nonblocking)
@@ -631,7 +631,6 @@ next_page:
631 } while (nr_pages); 631 } while (nr_pages);
632 return i; 632 return i;
633} 633}
634EXPORT_SYMBOL(__get_user_pages);
635 634
636bool vma_permits_fault(struct vm_area_struct *vma, unsigned int fault_flags) 635bool vma_permits_fault(struct vm_area_struct *vma, unsigned int fault_flags)
637{ 636{
diff --git a/mm/nommu.c b/mm/nommu.c
index db5fd1795298..8b8faaf2a9e9 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -109,7 +109,7 @@ unsigned int kobjsize(const void *objp)
109 return PAGE_SIZE << compound_order(page); 109 return PAGE_SIZE << compound_order(page);
110} 110}
111 111
112long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 112static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
113 unsigned long start, unsigned long nr_pages, 113 unsigned long start, unsigned long nr_pages,
114 unsigned int foll_flags, struct page **pages, 114 unsigned int foll_flags, struct page **pages,
115 struct vm_area_struct **vmas, int *nonblocking) 115 struct vm_area_struct **vmas, int *nonblocking)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 28510e72618a..2907b7b78654 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1346,21 +1346,19 @@ unsigned long kvm_vcpu_gfn_to_hva_prot(struct kvm_vcpu *vcpu, gfn_t gfn, bool *w
1346static int get_user_page_nowait(unsigned long start, int write, 1346static int get_user_page_nowait(unsigned long start, int write,
1347 struct page **page) 1347 struct page **page)
1348{ 1348{
1349 int flags = FOLL_TOUCH | FOLL_NOWAIT | FOLL_HWPOISON | FOLL_GET; 1349 int flags = FOLL_NOWAIT | FOLL_HWPOISON;
1350 1350
1351 if (write) 1351 if (write)
1352 flags |= FOLL_WRITE; 1352 flags |= FOLL_WRITE;
1353 1353
1354 return __get_user_pages(current, current->mm, start, 1, flags, page, 1354 return get_user_pages(start, 1, flags, page, NULL);
1355 NULL, NULL);
1356} 1355}
1357 1356
1358static inline int check_user_page_hwpoison(unsigned long addr) 1357static inline int check_user_page_hwpoison(unsigned long addr)
1359{ 1358{
1360 int rc, flags = FOLL_TOUCH | FOLL_HWPOISON | FOLL_WRITE; 1359 int rc, flags = FOLL_HWPOISON | FOLL_WRITE;
1361 1360
1362 rc = __get_user_pages(current, current->mm, addr, 1, 1361 rc = get_user_pages(addr, 1, flags, NULL, NULL);
1363 flags, NULL, NULL, NULL);
1364 return rc == -EHWPOISON; 1362 return rc == -EHWPOISON;
1365} 1363}
1366 1364