From 5a7c7575b5bb9542f722ed6ba095b9d62609cd56 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 14 Mar 2019 17:48:09 +0000 Subject: i915/gem_tiled_w[bc]: Tighten computation of upper bound Fix the off-by-one in computing the last page that caused us to try and mmap the page beyond the end of the object. Signed-off-by: Chris Wilson Reviewed-by: Antonio Argenziano --- tests/i915/gem_tiled_wb.c | 4 ++-- tests/i915/gem_tiled_wc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/i915') diff --git a/tests/i915/gem_tiled_wb.c b/tests/i915/gem_tiled_wb.c index 67d54bd3..827c2d9d 100644 --- a/tests/i915/gem_tiled_wb.c +++ b/tests/i915/gem_tiled_wb.c @@ -174,8 +174,8 @@ igt_simple_main len = size; } - first_page = offset & ~(PAGE_SIZE-1); - last_page = (offset + len + PAGE_SIZE) & ~(PAGE_SIZE-1); + first_page = offset & -PAGE_SIZE; + last_page = (offset + len + PAGE_SIZE - 1) & -PAGE_SIZE; offset -= first_page; linear = gem_mmap__cpu(fd, handle, first_page, last_page - first_page, PROT_READ); diff --git a/tests/i915/gem_tiled_wc.c b/tests/i915/gem_tiled_wc.c index 21390729..67ebbc94 100644 --- a/tests/i915/gem_tiled_wc.c +++ b/tests/i915/gem_tiled_wc.c @@ -149,8 +149,8 @@ igt_simple_main len = size; } - first_page = offset & ~(PAGE_SIZE-1); - last_page = (offset + len + PAGE_SIZE) & ~(PAGE_SIZE-1); + first_page = offset & -PAGE_SIZE; + last_page = (offset + len + PAGE_SIZE - 1) & -PAGE_SIZE; linear = gem_mmap__wc(fd, handle, first_page, last_page - first_page, PROT_READ); -- cgit v1.2.3