mirror-linux/drivers/gpu/drm
Lorenzo Stoakes 54d020692b mm/gup: remove unused vmas parameter from get_user_pages()
Patch series "remove the vmas parameter from GUP APIs", v6.

(pin_/get)_user_pages[_remote]() each provide an optional output parameter
for an array of VMA objects associated with each page in the input range.

These provide the means for VMAs to be returned, as long as mm->mmap_lock
is never released during the GUP operation (i.e.  the internal flag
FOLL_UNLOCKABLE is not specified).

In addition, these VMAs can only be accessed with the mmap_lock held and
become invalidated the moment it is released.

The vast majority of invocations do not use this functionality and of
those that do, all but one case retrieve a single VMA to perform checks
upon.

It is not egregious in the single VMA cases to simply replace the
operation with a vma_lookup().  In these cases we duplicate the (fast)
lookup on a slow path already under the mmap_lock, abstracted to a new
get_user_page_vma_remote() inline helper function which also performs
error checking and reference count maintenance.

The special case is io_uring, where io_pin_pages() specifically needs to
assert that the VMAs underlying the range do not result in broken
long-term GUP file-backed mappings.

As GUP now internally asserts that FOLL_LONGTERM mappings are not
file-backed in a broken fashion (i.e.  requiring dirty tracking) - as
implemented in "mm/gup: disallow FOLL_LONGTERM GUP-nonfast writing to
file-backed mappings" - this logic is no longer required and so we can
simply remove it altogether from io_uring.

Eliminating the vmas parameter eliminates an entire class of danging
pointer errors that might have occured should the lock have been
incorrectly released.

In addition, the API is simplified and now clearly expresses what it is
intended for - applying the specified GUP flags and (if pinning) returning
pinned pages.

This change additionally opens the door to further potential improvements
in GUP and the possible marrying of disparate code paths.

I have run this series against gup_test with no issues.

Thanks to Matthew Wilcox for suggesting this refactoring!


This patch (of 6):

No invocation of get_user_pages() use the vmas parameter, so remove it.

The GUP API is confusing and caveated.  Recent changes have done much to
improve that, however there is more we can do.  Exporting vmas is a prime
target as the caller has to be extremely careful to preclude their use
after the mmap_lock has expired or otherwise be left with dangling
pointers.

Removing the vmas parameter focuses the GUP functions upon their primary
purpose - pinning (and outputting) pages as well as performing the actions
implied by the input flags.

This is part of a patch series aiming to remove the vmas parameter
altogether.

Link: https://lkml.kernel.org/r/cover.1684350871.git.lstoakes@gmail.com
Link: https://lkml.kernel.org/r/589e0c64794668ffc799651e8d85e703262b1e9d.1684350871.git.lstoakes@gmail.com
Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Christian König <christian.koenig@amd.com> (for radeon parts)
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Sean Christopherson <seanjc@google.com> (KVM)
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Cc: Janosch Frank <frankja@linux.ibm.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-06-09 16:25:25 -07:00
..
amd drm/amd/display: Have Payload Properly Created After Resume 2023-05-24 16:37:00 -04:00
arm drm/arm/hdlcd: Use devm_platform_ioremap_resource() 2023-03-17 14:57:17 +00:00
armada drm/armada: Fix a potential double free in an error handling path 2023-04-11 20:29:33 +02:00
aspeed drm/aspeed: Use GEM DMA fbdev emulation 2023-03-14 17:07:47 +01:00
ast Merge drm/drm-fixes into drm-misc-fixes 2023-05-12 09:47:12 +02:00
atmel-hlcdc drm/atmel-hlcdc: Use GEM DMA fbdev emulation 2023-03-14 17:07:47 +01:00
bridge Merge tag 'drm-msm-next-2023-04-10' of https://gitlab.freedesktop.org/drm/msm into drm-next 2023-04-11 12:21:50 +02:00
display Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
etnaviv Revert "drm/etnaviv: export client GPU usage statistics via fdinfo" 2023-03-30 17:47:05 +02:00
exynos drm/exynos: fix g2d_open/close helper function definitions 2023-05-15 14:10:34 +09:00
fsl-dcu drm/fsl-dcu: Use GEM DMA fbdev emulation 2023-03-14 17:07:48 +01:00
gma500 drm/gma500: remove unused gma_pipe_event function 2023-03-21 09:16:54 +01:00
gud drm/gud: use new debugfs device-centered functions 2023-01-06 16:15:08 -03:00
hisilicon drm: Only select I2C_ALGOBIT for drivers that actually need it 2023-01-10 11:15:44 +01:00
hyperv Drivers: hv: Make remove callback of hyperv driver void returned 2023-01-17 13:41:27 +00:00
i2c drm-misc-next for $kernel-version: 2023-01-24 17:36:29 +01:00
i915 drm/i915: Fix PIPEDMC disabling for a bigjoiner configuration 2023-05-22 17:10:11 +03:00
imx Merge tag 'drm-misc-next-2023-03-16' of git://anongit.freedesktop.org/drm/drm-misc into drm-next 2023-03-22 04:42:36 +10:00
ingenic drm/ingenic: Remove unnecessary include statements for drm_crtc_helper.h 2023-01-18 09:25:31 +01:00
kmb drm/kmb: Use GEM DMA fbdev emulation 2023-03-14 17:07:48 +01:00
lib
lima Revert "drm/lima: add usage counting method to ctx_mgr" 2023-04-05 08:40:47 +08:00
logicvc drm/logicvc: Use GEM DMA fbdev emulation 2023-03-14 17:07:48 +01:00
mcde drm/mcde: Use GEM DMA fbdev emulation 2023-03-14 17:07:49 +01:00
mediatek drm/mediatek: dp: Change the aux retries times when receiving AUX_DEFER 2023-04-03 16:49:49 +00:00
meson Linux 6.3-rc4 2023-03-29 16:00:23 +02:00
mgag200 Merge drm/drm-fixes into drm-misc-fixes 2023-05-12 09:47:12 +02:00
msm Merge tag 'drm-msm-fixes-2023-05-17' of https://gitlab.freedesktop.org/drm/msm into drm-fixes 2023-05-19 11:22:23 +10:00
mxsfb drm/mxsfb: Use GEM DMA fbdev emulation 2023-03-14 17:07:48 +01:00
nouveau Merge drm/drm-fixes into drm-misc-fixes 2023-05-12 09:47:12 +02:00
omapdrm drm/omapdrm: Implement fbdev emulation as in-kernel client 2023-04-06 15:50:10 +03:00
panel drm/panel: novatek-nt35950: Only unregister DSI1 if it exists 2023-04-18 10:20:26 +02:00
panfrost drm next for 6.4-rc1 2023-04-25 16:12:15 -07:00
pl111 drm/pl111: Fix FB depth on IMPD-1 framebuffer 2023-05-16 09:46:21 +02:00
qxl drm/qxl: handle NULL bo->resource in move callback 2023-02-23 10:29:14 +01:00
radeon mm/gup: remove unused vmas parameter from get_user_pages() 2023-06-09 16:25:25 -07:00
rcar-du drm: rcar-du: Fix a NULL vs IS_ERR() bug 2023-03-25 22:38:10 +02:00
rockchip drm next for 6.4-rc1 2023-04-25 16:12:15 -07:00
scheduler drm/sched: Remove redundant check 2023-05-19 09:39:05 -04:00
shmobile drm/shmobile: Remove unnecessary include statements for drm_crtc_helper.h 2023-01-18 09:25:32 +01:00
solomon drm next for 6.3-rc1 2023-02-22 18:28:03 -08:00
sprd drm/sprd: Remove unnecessary include statements for drm_crtc_helper.h 2023-01-18 09:25:32 +01:00
sti drm/sti: Use GEM DMA fbdev emulation 2023-03-14 17:07:48 +01:00
stm drm/stm: Use GEM DMA fbdev emulation 2023-03-14 17:07:48 +01:00
sun4i Merge remote-tracking branch 'drm/drm-next' into drm-misc-next 2023-03-30 08:53:12 +02:00
tegra drm/tegra: Changes for v6.4-rc1 2023-04-06 15:02:17 +02:00
tests drm next for 6.4-rc1 2023-04-25 16:12:15 -07:00
tidss drm/tidss: Use GEM DMA fbdev emulation 2023-03-14 17:07:49 +01:00
tilcdc drm/tilcdc: Use GEM DMA fbdev emulation 2023-03-14 17:07:49 +01:00
tiny drm: Use of_property_read_bool() for boolean properties 2023-03-30 13:46:07 -05:00
ttm - Nick Piggin's "shoot lazy tlbs" series, to improve the peformance of 2023-04-27 19:42:02 -07:00
tve200 drm/tve200: Use GEM DMA fbdev emulation 2023-03-14 17:07:49 +01:00
udl drm/udl: Remove unnecessary include statements for drm_crtc_helper.h 2023-01-18 09:25:32 +01:00
v3d drm/v3d: Use drm_sched_job_add_syncobj_dependency() 2023-02-24 17:23:43 -03:00
vboxvideo drm/vboxvideo: Remove unnecessary include statements for drm_crtc_helper.h 2023-01-18 09:25:32 +01:00
vc4 drm/vc4: remove unused render_wait variable 2023-04-11 14:15:18 +02:00
vgem drm/vgem: Drop struct drm_vgem_gem_object 2023-03-20 08:14:27 -03:00
virtio Linux 6.3-rc4 2023-03-29 16:00:23 +02:00
vkms drm/vkms: Remove <drm/drm_simple_kms_helper.h> include 2023-04-07 13:16:38 +02:00
vmwgfx flexible-array transformations for 6.4-rc1 2023-04-26 08:25:57 -07:00
xen mm: replace vma->vm_flags direct modifications with modifier calls 2023-02-09 16:51:39 -08:00
xlnx drm/xlnx: Use GEM DMA fbdev emulation 2023-03-14 17:07:49 +01:00
Kconfig Merge tag 'drm-misc-next-2023-03-07' of git://anongit.freedesktop.org/drm/drm-misc into drm-next 2023-03-14 12:18:54 +10:00
Makefile drm/fbdev-dma: Implement fbdev emulation for GEM DMA helpers 2023-03-14 17:07:47 +01:00
drm_agpsupport.c
drm_aperture.c
drm_atomic.c Merge remote-tracking branch 'drm/drm-next' into msm-next 2023-03-20 10:31:25 -07:00
drm_atomic_helper.c drm/atomic-helper: Don't set deadline for modesets 2023-04-06 07:33:25 +02:00
drm_atomic_state_helper.c drm/atomic-helper: fix kernel-doc problems 2023-01-19 09:16:04 +01:00
drm_atomic_uapi.c
drm_auth.c
drm_blend.c drm/drm_blend: Remove usage of deprecated DRM_DEBUG_ATOMIC 2023-01-10 16:14:13 +01:00
drm_bridge.c
drm_bridge_connector.c drm/bridge_connector: drop drm_bridge_connector_en/disable_hpd() 2023-01-05 15:08:10 +01:00
drm_buddy.c drm: buddy_allocator: Fix buddy allocator init on 32-bit systems 2023-03-29 17:14:07 +02:00
drm_bufs.c drm/nouveau: Remove support for legacy contexts/buffers 2023-01-13 09:22:02 +01:00
drm_cache.c
drm_client.c drm next for 6.3-rc1 2023-02-22 18:28:03 -08:00
drm_client_modeset.c
drm_color_mgmt.c
drm_connector.c drm: fix typo in margin connector properties docs 2023-03-18 15:59:37 +01:00
drm_context.c drm/nouveau: Remove support for legacy contexts/buffers 2023-01-13 09:22:02 +01:00
drm_crtc.c
drm_crtc_helper.c
drm_crtc_helper_internal.h
drm_crtc_internal.h
drm_damage_helper.c
drm_debugfs.c drm: Track clients by tgid and not tid 2023-03-15 14:03:00 +01:00
drm_debugfs_crc.c
drm_displayid.c drm/displayid: provide access to DisplayID version and primary use case 2023-02-27 02:58:38 +03:00
drm_dma.c
drm_drv.c drm: remove drm_dev_set_unique 2023-03-22 10:24:47 +01:00
drm_dumb_buffers.c drm: remove dumb_destroy callback 2023-02-10 12:19:27 +01:00
drm_edid.c Linux 6.3-rc4 2023-03-29 16:00:23 +02:00
drm_edid_load.c
drm_encoder.c
drm_encoder_slave.c
drm_fb_dma_helper.c
drm_fb_helper.c Merge drm/drm-fixes into drm-misc-fixes 2023-05-12 09:47:12 +02:00
drm_fbdev_dma.c drm/fb-helper: Consolidate CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM 2023-03-22 13:32:52 +01:00
drm_fbdev_generic.c drm/fbdev-generic: Rename symbols 2023-03-22 13:32:54 +01:00
drm_file.c drm: Track clients by tgid and not tid 2023-03-15 14:03:00 +01:00
drm_flip_work.c
drm_format_helper.c drm/format-helper: Support the AB24/XB24 formats 2023-01-23 15:02:41 +01:00
drm_fourcc.c
drm_framebuffer.c drm: use new debugfs device-centered functions on DRM core files 2022-12-22 14:58:21 -03:00
drm_gem.c Merge tag 'drm-msm-next-2023-04-10' of https://gitlab.freedesktop.org/drm/msm into drm-next 2023-04-11 12:21:50 +02:00
drm_gem_atomic_helper.c
drm_gem_dma_helper.c - Daniel Verkamp has contributed a memfd series ("mm/memfd: add 2023-02-23 17:09:35 -08:00
drm_gem_framebuffer_helper.c
drm_gem_shmem_helper.c Linux 6.3-rc4 2023-03-29 16:00:23 +02:00
drm_gem_ttm_helper.c
drm_gem_vram_helper.c drm/gem-vram: handle NULL bo->resource in move callback 2023-02-23 10:29:00 +01:00
drm_hashtab.c
drm_internal.h drm: remove dumb_destroy callback 2023-02-10 12:19:27 +01:00
drm_ioc32.c drm: Replace DRM_DEBUG with drm_dbg_core in file and ioctl handling 2023-01-03 18:20:57 +01:00
drm_ioctl.c drm: Replace DRM_DEBUG with drm_dbg_core in file and ioctl handling 2023-01-03 18:20:57 +01:00
drm_irq.c
drm_kms_helper_common.c
drm_lease.c drm: Remove unnecessary include statements for drm_crtc_helper.h 2023-01-18 09:25:30 +01:00
drm_legacy.h
drm_legacy_misc.c
drm_lock.c
drm_managed.c drm: fix drmm_mutex_init() 2023-05-22 12:23:50 +02:00
drm_memory.c
drm_mipi_dbi.c
drm_mipi_dsi.c Merge drm/drm-fixes into drm-misc-fixes 2023-05-12 09:47:12 +02:00
drm_mm.c
drm_mode_config.c drm/debugfs: create debugfs late register functions 2022-12-22 14:58:55 -03:00
drm_mode_object.c
drm_modes.c drm: Fix comment on mode parsing 2023-02-20 14:56:52 +01:00
drm_modeset_helper.c
drm_modeset_lock.c
drm_of.c drm: of: Add drm_of_get_dsi_bus helper function 2023-01-27 09:39:21 +01:00
drm_panel.c
drm_panel_orientation_quirks.c drm: panel-orientation-quirks: Change Air's quirk to support Air Plus 2023-05-17 11:46:49 +02:00
drm_pci.c
drm_plane.c drm/docs: Explicitly document default CRTC background behavior 2023-01-04 16:12:15 +00:00
drm_plane_helper.c drm: Remove unnecessary include statements for drm_crtc_helper.h 2023-01-18 09:25:30 +01:00
drm_prime.c drm/prime: reject DMA-BUF attach when get_sg_table is missing 2023-04-03 14:31:24 +02:00
drm_print.c
drm_privacy_screen.c
drm_privacy_screen_x86.c
drm_probe_helper.c drm/probe-helper: Cancel previous job before starting new one 2023-02-27 16:19:14 +01:00
drm_property.c
drm_rect.c
drm_scatter.c
drm_self_refresh_helper.c
drm_simple_kms_helper.c
drm_suballoc.c drm/suballoc: Extract amdgpu_sa.c as generic suballocation helper 2023-03-01 17:18:19 +01:00
drm_syncobj.c
drm_sysfs.c driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
drm_trace.h
drm_trace_points.c
drm_vblank.c drm/vblank: Fix for drivers that do not drm_vblank_init() 2023-04-04 22:38:03 +02:00
drm_vblank_work.c
drm_vm.c mm: replace vma->vm_flags direct modifications with modifier calls 2023-02-09 16:51:39 -08:00
drm_vma_manager.c drm/drm_vma_manager: Add drm_vma_node_allow_once() 2023-01-19 14:16:55 +01:00
drm_writeback.c