From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org, Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t] i915/gem_userptr_blits: Check for allowed GTT mmaps
Date: Wed, 2 Oct 2019 09:42:01 +0100 [thread overview]
Message-ID: <0ae718ca-00f1-8ed5-6a46-c2142f84693e@linux.intel.com> (raw)
In-Reply-To: <20191001174924.20227-1-chris@chris-wilson.co.uk>
On 01/10/2019 18:49, Chris Wilson wrote:
> Having decided to close the GTT mmap of userptr objects loophole in the
> kernel, we need to adjust the test suite to avoid tripping over GTT
> mmaps when required.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
> tests/i915/gem_userptr_blits.c | 32 ++++++++++++++++++++++++++++----
> 1 file changed, 28 insertions(+), 4 deletions(-)
>
> diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
> index 3fad7d1b3..3f5edaeab 100644
> --- a/tests/i915/gem_userptr_blits.c
> +++ b/tests/i915/gem_userptr_blits.c
> @@ -69,11 +69,33 @@
>
> static uint32_t userptr_flags = LOCAL_I915_USERPTR_UNSYNCHRONIZED;
>
> +static bool can_gtt_mmap;
> +
> #define WIDTH 512
> #define HEIGHT 512
>
> static uint32_t linear[WIDTH*HEIGHT];
>
> +static bool has_gtt_mmap(int i915)
> +{
> + void *ptr, *map;
> + uint32_t handle;
> +
> + igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0);
> +
> + gem_userptr(i915, ptr, 4096, 0, 0, &handle);
> + igt_assert(handle != 0);
> +
> + map = __gem_mmap__gtt(i915, handle, 4096, PROT_WRITE);
> + if (map)
> + munmap(map, 4096);
> +
> + gem_close(i915, handle);
> + free(ptr);
> +
> + return map != NULL;
> +}
> +
> static void gem_userptr_test_unsynchronized(void)
> {
> userptr_flags = LOCAL_I915_USERPTR_UNSYNCHRONIZED;
> @@ -853,7 +875,7 @@ static void *umap(int fd, uint32_t handle)
> {
> void *ptr;
>
> - if (gem_has_llc(fd)) {
> + if (can_gtt_mmap) {
> ptr = gem_mmap__gtt(fd, handle, sizeof(linear),
> PROT_READ | PROT_WRITE);
> } else {
> @@ -884,7 +906,7 @@ check_bo(int fd1, uint32_t handle1, int is_userptr, int fd2, uint32_t handle2)
> sigbus_start = (unsigned long)ptr2;
> igt_assert(memcmp(ptr1, ptr2, sizeof(linear)) == 0);
>
> - if (gem_has_llc(fd1)) {
> + if (can_gtt_mmap) {
> counter++;
> memset(ptr1, counter, size);
> memset(ptr2, counter, size);
> @@ -971,7 +993,7 @@ static int test_dmabuf(void)
> free_userptr_bo(fd1, handle);
> close(fd1);
>
> - if (gem_has_llc(fd2)) {
> + if (can_gtt_mmap) {
Kudos to myself I think for coming up with this convoluted test which I
needed 15 minutes to reverse engineer. :) Okay it was many years ago so
that's my excuse. In all cases mmap__gtt is either on userptr or on
dmabuf import of userptr so I think it's correct.
> struct sigaction sigact, orig_sigact;
>
> memset(&sigact, 0, sizeof(sigact));
> @@ -1225,7 +1247,7 @@ static void test_readonly_mmap(int i915)
> original = g_compute_checksum_for_data(G_CHECKSUM_SHA1, pages, sz);
>
> ptr = __gem_mmap__gtt(i915, handle, sz, PROT_WRITE);
> - igt_assert(ptr == NULL);
> + igt_require(ptr != NULL);
This should be able to stay unchanged, no? Whether read-only or mmap_gtt
is disallowed it must always be NULL here. Non-NULL should be test fail.
>
> ptr = gem_mmap__gtt(i915, handle, sz, PROT_READ);
> gem_close(i915, handle);
> @@ -1834,6 +1856,8 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL)
> igt_require_gem(fd);
> gem_require_blitter(fd);
>
> + can_gtt_mmap = has_gtt_mmap(fd) && gem_has_llc(fd);
> +
> size = sizeof(linear);
>
> aperture_size = gem_aperture_size(fd);
>
Regards,
Tvrtko
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-10-02 8:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 17:49 [igt-dev] [PATCH i-g-t] i915/gem_userptr_blits: Check for allowed GTT mmaps Chris Wilson
2019-10-01 19:21 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-10-02 5:05 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-10-02 8:42 ` Tvrtko Ursulin [this message]
2019-10-02 8:47 ` [igt-dev] [PATCH i-g-t] " Chris Wilson
2019-10-02 8:50 ` [Intel-gfx] [PATCH i-g-t v2] " Chris Wilson
2019-10-02 9:18 ` [igt-dev] " Tvrtko Ursulin
2019-10-02 9:40 ` [igt-dev] ✓ Fi.CI.BAT: success for i915/gem_userptr_blits: Check for allowed GTT mmaps (rev2) Patchwork
2019-10-02 13:51 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ae718ca-00f1-8ed5-6a46-c2142f84693e@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=tvrtko.ursulin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox