From patchwork Fri Jan 15 17:42:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 12023481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64465C433E0 for ; Fri, 15 Jan 2021 17:43:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D4C6E23A59 for ; Fri, 15 Jan 2021 17:43:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4C6E23A59 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48C4C89C1E; Fri, 15 Jan 2021 17:43:06 +0000 (UTC) Received: from fireflyinternet.com (unknown [77.68.26.236]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8C54289C1E; Fri, 15 Jan 2021 17:43:04 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 23609665-1500050 for multiple; Fri, 15 Jan 2021 17:42:58 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 15 Jan 2021 17:42:56 +0000 Message-Id: <20210115174256.1244801-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] i915/gem_userptr_blits: Check set-domain on userptr for validation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, Chris Wilson Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We use set-domain on userptr to validate that get-user-pages is applicable to the address range. Let's perform a very basic test to exercise this combination. Signed-off-by: Chris Wilson --- tests/i915/gem_userptr_blits.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c index 8765123e0..1add307a2 100644 --- a/tests/i915/gem_userptr_blits.c +++ b/tests/i915/gem_userptr_blits.c @@ -2185,6 +2185,29 @@ static void test_invalidate_close_race(int fd, bool overlap, int timeout) free(t_data.ptr); } +static void test_sd_probe(int i915) +{ + uint32_t handle; + void *page; + + page = mmap(NULL, 4096, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + + gem_userptr(i915, page, 4096, 0, 0, &handle); + igt_assert_eq(__gem_set_domain(i915, handle, + I915_GEM_DOMAIN_GTT, 0), + 0); + gem_close(i915, handle); + + munmap(page, 4096); + + gem_userptr(i915, page, 4096, 0, 0, &handle); + igt_assert_eq(__gem_set_domain(i915, handle, + I915_GEM_DOMAIN_GTT, 0), + -EFAULT); + gem_close(i915, handle); +} + struct ufd_thread { uint32_t *page; int i915; @@ -2379,6 +2402,9 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL) igt_subtest("forbidden-operations") test_forbidden_ops(fd); + igt_subtest("sd-probe") + test_sd_probe(fd); + igt_subtest("userfault") test_userfault(fd);