Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e50b8b0 authored by Lorenzo Stoakes's avatar Lorenzo Stoakes Committed by Greg Kroah-Hartman
Browse files

mm: replace get_user_pages() write/force parameters with gup_flags



commit 768ae309a96103ed02eb1e111e838c87854d8b51 upstream.

This removes the 'write' and 'force' from get_user_pages() and replaces
them with 'gup_flags' to make the use of FOLL_FORCE explicit in callers
as use of this flag can result in surprising behaviour (and hence bugs)
within the mm subsystem.

Signed-off-by: default avatarLorenzo Stoakes <lstoakes@gmail.com>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Acked-by: default avatarJesper Nilsson <jesper.nilsson@axis.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
[bwh: Backported to 4.4:
 - Drop changes in rapidio, vchiq, goldfish
 - Keep the "write" variable in amdgpu_ttm_tt_pin_userptr() as it's still
   needed
 - Also update calls from various other places that now use
   get_user_pages_remote() upstream, which were updated there by commit
   9beae1ea8930 "mm: replace get_user_pages_remote() write/force ..."
 - Also update calls from hfi1 and ipath
 - Adjust context]
Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3ec22a6b
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -2724,7 +2724,6 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
			     (unsigned long int)(oper.indata + prev_ix),
			     noinpages,
			     0,  /* read access only for in data */
			     0, /* no force */
			     inpages,
			     NULL);

@@ -2740,8 +2739,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
				     current->mm,
				     (unsigned long int)oper.cipher_outdata,
				     nooutpages,
				     1, /* write access for out data */
				     0, /* no force */
				     FOLL_WRITE, /* write access for out data */
				     outpages,
				     NULL);
		up_read(&current->mm->mmap_sem);
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ store_virtual_to_phys(struct device *dev, struct device_attribute *attr,
	int ret;

        ret = get_user_pages(current, current->mm, virt_addr,
                        1, VM_READ, 0, NULL, NULL);
			     1, FOLL_WRITE, NULL, NULL);
	if (ret<=0) {
#ifdef ERR_INJ_DEBUG
		printk("Virtual address %lx is not existing.\n",virt_addr);
+1 −2
Original line number Diff line number Diff line
@@ -536,10 +536,9 @@ static int mpx_resolve_fault(long __user *addr, int write)
{
	long gup_ret;
	int nr_pages = 1;
	int force = 0;

	gup_ret = get_user_pages(current, current->mm, (unsigned long)addr,
				 nr_pages, write, force, NULL, NULL);
				 nr_pages, write ? FOLL_WRITE : 0, NULL, NULL);
	/*
	 * get_user_pages() returns number of pages gotten.
	 * 0 means we failed to fault in and get anything,
+5 −1
Original line number Diff line number Diff line
@@ -496,9 +496,13 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm)
	int r;

	int write = !(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY);
	unsigned int flags = 0;
	enum dma_data_direction direction = write ?
		DMA_BIDIRECTIONAL : DMA_TO_DEVICE;

	if (write)
		flags |= FOLL_WRITE;

	if (current->mm != gtt->usermm)
		return -EPERM;

@@ -519,7 +523,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm)
		struct page **pages = ttm->pages + pinned;

		r = get_user_pages(current, current->mm, userptr, num_pages,
				   write, 0, pages, NULL);
				   flags, pages, NULL);
		if (r < 0)
			goto release_pages;

+5 −1
Original line number Diff line number Diff line
@@ -581,13 +581,17 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
		pvec = drm_malloc_ab(npages, sizeof(struct page *));
	if (pvec != NULL) {
		struct mm_struct *mm = obj->userptr.mm->mm;
		unsigned int flags = 0;

		if (!obj->userptr.read_only)
			flags |= FOLL_WRITE;

		down_read(&mm->mmap_sem);
		while (pinned < npages) {
			ret = get_user_pages(work->task, mm,
					     obj->userptr.ptr + pinned * PAGE_SIZE,
					     npages - pinned,
					     !obj->userptr.read_only, 0,
					     flags,
					     pvec + pinned, NULL);
			if (ret < 0)
				break;
Loading