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

Skip to content
Commit 3ccfe379 authored by Andi Shyti's avatar Andi Shyti Committed by Vegard Nossum
Browse files

drm/i915/gem: Fix Virtual Memory mapping boundaries calculation



commit 8bdd9ef7e9b1b2a73e394712b72b22055e0e26c3 upstream.

Calculating the size of the mapped area as the lesser value
between the requested size and the actual size does not consider
the partial mapping offset. This can cause page fault access.

Fix the calculation of the starting and ending addresses, the
total size is now deduced from the difference between the end and
start addresses.

Additionally, the calculations have been rewritten in a clearer
and more understandable form.

Fixes: c58305af ("drm/i915: Use remap_io_mapping() to prefault all PTE in a single pass")
Reported-by: default avatarJann Horn <jannh@google.com>
Co-developed-by: default avatarChris Wilson <chris.p.wilson@linux.intel.com>
Signed-off-by: default avatarChris Wilson <chris.p.wilson@linux.intel.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: <stable@vger.kernel.org> # v4.9+
Reviewed-by: default avatarJann Horn <jannh@google.com>
Reviewed-by: default avatarJonathan Cavitt <Jonathan.cavitt@intel.com>
[Joonas: Add Requires: tag]
Requires: 60a2066c5005 ("drm/i915/gem: Adjust vma offset for framebuffer mmap offset")
Signed-off-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240802083850.103694-3-andi.shyti@linux.intel.com


(cherry picked from commit 97b6784753da06d9d40232328efc5c5367e53417)
Signed-off-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3e06073d24807f04b4694108a8474decb7b99e60)
[Vegard: resolve conflict due to missing commit
 a65adaf8a834504a4acdc0deca7fa790771add8a ("drm/i915: Track user GTT
 faulting per-vma") from v4.15 and commit 73ebd503034c1abe ("drm/i915:
 make mappable struct resource centric") which motivates the start ->
 mappable_base and iomap -> mappable changes. Remove 'goto err_fence' as
 we have nothing else to do on failure; it should be OK to leave the GEM
 object on the mm's userfaultfd list.]
Signed-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
parent 827a6992
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment