lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1486456749-19142-1-git-send-email-mark.yao@rock-chips.com>
Date:   Tue,  7 Feb 2017 16:39:09 +0800
From:   Mark Yao <mark.yao@...k-chips.com>
To:     David Airlie <airlied@...ux.ie>, Heiko Stuebner <heiko@...ech.de>,
        dri-devel@...ts.freedesktop.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc:     Ørjan Eide <orjan.eide@....com>,
        Tomasz Figa <tfiga@...omium.org>,
        Mark Yao <mark.yao@...k-chips.com>
Subject: [PATCH v2 6/7] drm/rockchip: Respect page offset in IOMMU mmap

From: Ørjan Eide <orjan.eide@....com>

When mapping buffers through the PRIME DMA-buf mmap path we might be
given an offset which has to be respected. The DRM GEM mmap path already
takes care of zeroing out the fake mmap offset, so we can just make the
IOMMU mmap implementation always respect the offset.

TEST=graphics_GLBench

Signed-off-by: rjan Eide <orjan.eide@....com>
Signed-off-by: Tomasz Figa <tfiga@...omium.org>
Signed-off-by: Mark Yao <mark.yao@...k-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/386477
Reviewed-by: Daniel Kurtz <djkurtz@...omium.org>
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 1daa531..1769146 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -221,12 +221,16 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj,
 	unsigned int i, count = obj->size >> PAGE_SHIFT;
 	unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
 	unsigned long uaddr = vma->vm_start;
+	unsigned long offset = vma->vm_pgoff;
+	unsigned long end = user_count + offset;
 	int ret;
 
-	if (user_count == 0 || user_count > count)
+	if (user_count == 0)
+		return -ENXIO;
+	if (end > count)
 		return -ENXIO;
 
-	for (i = 0; i < user_count; i++) {
+	for (i = offset; i < end; i++) {
 		ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]);
 		if (ret)
 			return ret;
-- 
1.9.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ