Skip to content

Commit 0d73175

Browse files
lorenzo-stoakestorvalds
authored andcommitted
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 <[email protected]> Acked-by: Paolo Bonzini <[email protected]> Acked-by: Michal Hocko <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 272ddc8 commit 0d73175

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

include/linux/mm.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,10 +1271,6 @@ extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *
12711271
extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
12721272
void *buf, int len, unsigned int gup_flags);
12731273

1274-
long __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);
12781274
long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm,
12791275
unsigned long start, unsigned long nr_pages,
12801276
unsigned int gup_flags, struct page **pages,

mm/gup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
526526
* instead of __get_user_pages. __get_user_pages should be used only if
527527
* you need some special @gup_flags.
528528
*/
529-
long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
529+
static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
530530
unsigned long start, unsigned long nr_pages,
531531
unsigned int gup_flags, struct page **pages,
532532
struct vm_area_struct **vmas, int *nonblocking)
@@ -631,7 +631,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
631631
} while (nr_pages);
632632
return i;
633633
}
634-
EXPORT_SYMBOL(__get_user_pages);
635634

636635
bool vma_permits_fault(struct vm_area_struct *vma, unsigned int fault_flags)
637636
{

mm/nommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ unsigned int kobjsize(const void *objp)
109109
return PAGE_SIZE << compound_order(page);
110110
}
111111

112-
long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
112+
static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
113113
unsigned long start, unsigned long nr_pages,
114114
unsigned int foll_flags, struct page **pages,
115115
struct vm_area_struct **vmas, int *nonblocking)

virt/kvm/kvm_main.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,21 +1346,19 @@ unsigned long kvm_vcpu_gfn_to_hva_prot(struct kvm_vcpu *vcpu, gfn_t gfn, bool *w
13461346
static int get_user_page_nowait(unsigned long start, int write,
13471347
struct page **page)
13481348
{
1349-
int flags = FOLL_TOUCH | FOLL_NOWAIT | FOLL_HWPOISON | FOLL_GET;
1349+
int flags = FOLL_NOWAIT | FOLL_HWPOISON;
13501350

13511351
if (write)
13521352
flags |= FOLL_WRITE;
13531353

1354-
return __get_user_pages(current, current->mm, start, 1, flags, page,
1355-
NULL, NULL);
1354+
return get_user_pages(start, 1, flags, page, NULL);
13561355
}
13571356

13581357
static inline int check_user_page_hwpoison(unsigned long addr)
13591358
{
1360-
int rc, flags = FOLL_TOUCH | FOLL_HWPOISON | FOLL_WRITE;
1359+
int rc, flags = FOLL_HWPOISON | FOLL_WRITE;
13611360

1362-
rc = __get_user_pages(current, current->mm, addr, 1,
1363-
flags, NULL, NULL, NULL);
1361+
rc = get_user_pages(addr, 1, flags, NULL, NULL);
13641362
return rc == -EHWPOISON;
13651363
}
13661364

0 commit comments

Comments
 (0)