From patchwork Mon Nov 7 22:27:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9416177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6E28560585 for ; Mon, 7 Nov 2016 22:27:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CAB328C33 for ; Mon, 7 Nov 2016 22:27:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 505F828E53; Mon, 7 Nov 2016 22:27:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CE08728C33 for ; Mon, 7 Nov 2016 22:27:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA1646E2F0; Mon, 7 Nov 2016 22:27:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id E1B1B6E2C7 for ; Mon, 7 Nov 2016 22:27:13 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id a20so8169560wme.2 for ; Mon, 07 Nov 2016 14:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dKNGU+zCHl1d8a9fHKysFQ2407uXEbbJVTzepwgAhuo=; b=o8FCRJVBhL/e558LaROKAJug5nYcthvXtQQQysRf13h43JPMuANB0QY8DdcFiL/lBT GsKRY9pgPK3RDzAd9Jqi+MuWDdhB1daut9cIB2zEcZwRhcCnX06lBdESdVwXamWKKQNV 9gB2us3xvfKnS2KmqKjsW4UnV4+ldb2AxbiWqv1qjL1vCG+fnXgIAa2EQVywd0ew/ls2 JCr10YL5jyqSrPE3V/noguWjL2vln5bqzkuxJjErBE2WJwx3HJSWF+Zu4JAGAwGiCm3g KAYthJsuojVdzCFg1mxaMcE150ZrNI1Pyxbt+iOE+Fk+cVaRuOybEFkR9TnaOVjsE4k7 ZWQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=dKNGU+zCHl1d8a9fHKysFQ2407uXEbbJVTzepwgAhuo=; b=ec9CR4Sun442Gebo0EFiw8XTORCCiFfTEyGAm/iCLB9IyQRkRGsdDFdmtGkr3sgcgz OLZTSvJDmfrREmoGcwjbjBX8pA9aSWrLadL8/Y0LYYm12ycyaaVzh94LcUxzhfdAI6FX yBuHsRFqIGZTCS/63KPE9h8uE1qLmzTENyxdybieEVIIEVuaKdDKpDFJ74Nzn3LEgffG eeBsP7cm3fM6OCBYAjLYxR3eUfxbDth00yoAzw68CLI5kALGfECluwwNmOyDcJgD5SyW XVWZOSLZlZRyHdz50GeDBdHGeu8gqmmpEo9oZm6ot0bcMVrIOW5SKI0CbGzaumvBN7P9 GHDQ== X-Gm-Message-State: ABUngvc4Ve+4nYeVZoAt++bJrcrLWewmYkDy5iGT+cWviKlmJhDmDia2P8H5NZsjUwcG/g== X-Received: by 10.28.4.199 with SMTP id 190mr12690861wme.11.1478557632136; Mon, 07 Nov 2016 14:27:12 -0800 (PST) Received: from sixbynine.org (cpc26-heme10-2-0-cust305.9-1.cable.virginm.net. [86.3.57.50]) by smtp.gmail.com with ESMTPSA id jq10sm33484121wjb.46.2016.11.07.14.27.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Nov 2016 14:27:11 -0800 (PST) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Mon, 7 Nov 2016 22:27:03 +0000 Message-Id: <20161107222703.10784-7-robert@sixbynine.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161107222703.10784-1-robert@sixbynine.org> References: <20161107222703.10784-1-robert@sixbynine.org> Subject: [Intel-gfx] [PATCH igt v2 6/6] igt/gem_exec_parse: update for version 8 changes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This adapts the tests to account for the parser no longer reporting privilege violations back to userspace as EINVAL errors (they are left to the HW command parser to squash the commands to NOOPS). The interface change isn't expected to affect userspace and in fact it looks like the previous behaviour was liable to break userspace, such as Mesa which explicitly tries to observe whether OACONTROL LRIs are squashed to NOOPs but Mesa will abort for execbuffer errors. Signed-off-by: Robert Bragg --- tests/gem_exec_parse.c | 95 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 21 deletions(-) diff --git a/tests/gem_exec_parse.c b/tests/gem_exec_parse.c index 1c09cf2..c98f809 100644 --- a/tests/gem_exec_parse.c +++ b/tests/gem_exec_parse.c @@ -37,6 +37,7 @@ #define ARRAY_LEN(A) (sizeof(A) / sizeof(A[0])) #define DERRMR 0x44050 +#define OACONTROL 0x2360 #define SO_WRITE_OFFSET_0 0x5280 #define HSW_CS_GPR(n) (0x2600 + 8*(n)) @@ -310,10 +311,21 @@ static void hsw_load_register_reg(void) } for (int i = 0 ; i < ARRAY_LEN(disallowed_regs); i++) { + exec_batch(fd, handle, init_gpr0, sizeof(init_gpr0), + I915_EXEC_RENDER, + 0); + exec_batch_patched(fd, handle, + store_gpr0, sizeof(store_gpr0), + 2 * sizeof(uint32_t), /* reloc */ + 0xabcdabc0); do_lrr[1] = disallowed_regs[i]; exec_batch(fd, handle, do_lrr, sizeof(do_lrr), I915_EXEC_RENDER, - -EINVAL); + 0); + exec_batch_patched(fd, handle, + store_gpr0, sizeof(store_gpr0), + 2 * sizeof(uint32_t), /* reloc */ + 0xabcdabc0); } close(fd); @@ -360,57 +372,95 @@ igt_main } igt_subtest("basic-rejected") { - uint32_t arb_on_off[] = { - MI_ARB_ON_OFF, + uint32_t invalid_cmd[] = { + (0x7<<29), /* Reserved command type, + across all engines */ MI_BATCH_BUFFER_END, }; - uint32_t display_flip[] = { - MI_DISPLAY_FLIP, - 0, 0, 0, + uint32_t invalid_set_context[] = { + MI_SET_CONTEXT | 32, /* invalid length */ MI_BATCH_BUFFER_END, - 0 }; exec_batch(fd, handle, - arb_on_off, sizeof(arb_on_off), + invalid_cmd, sizeof(invalid_cmd), I915_EXEC_RENDER, -EINVAL); exec_batch(fd, handle, - arb_on_off, sizeof(arb_on_off), + invalid_cmd, sizeof(invalid_cmd), I915_EXEC_BSD, -EINVAL); + if (gem_has_blt(fd)) { + exec_batch(fd, handle, + invalid_cmd, sizeof(invalid_cmd), + I915_EXEC_BLT, + -EINVAL); + } if (gem_has_vebox(fd)) { exec_batch(fd, handle, - arb_on_off, sizeof(arb_on_off), + invalid_cmd, sizeof(invalid_cmd), I915_EXEC_VEBOX, -EINVAL); } + exec_batch(fd, handle, - display_flip, sizeof(display_flip), - I915_EXEC_BLT, + invalid_set_context, sizeof(invalid_set_context), + I915_EXEC_RENDER, -EINVAL); } igt_subtest("registers") { uint32_t lri_bad[] = { MI_LOAD_REGISTER_IMM, - 0, /* disallowed register address */ - 0x12000000, + OACONTROL, /* disallowed register address */ + 0x31337000, MI_BATCH_BUFFER_END, }; uint32_t lri_ok[] = { MI_LOAD_REGISTER_IMM, - 0x5280, /* allowed register address (SO_WRITE_OFFSET[0]) */ - 0x1, + SO_WRITE_OFFSET_0, /* allowed register address */ + 0xabcdabc0, /* [1:0] MBZ */ MI_BATCH_BUFFER_END, }; + uint32_t store_reg[] = { + MI_STORE_REGISTER_MEM | (3 - 2), + 0, /* reg */ + 0, /* reloc */ + MI_BATCH_BUFFER_END, + }; + uint64_t val; + + /* Note: we intentionally pick OACONTROL as the disallowed + * register to test here since it used to be white listed by + * the command parser. + * + * It's especially important to check that an LRI to OACONTROL + * doesn't result in an EINVAL error because Mesa attempts + * writing to OACONTROL to determine what extensions to expose + * and will abort() for execbuffer() errors. + * + * Mesa can gracefully recognise and handle the LRI becoming + * a NOOP. + */ exec_batch(fd, handle, lri_bad, sizeof(lri_bad), I915_EXEC_RENDER, - -EINVAL); + 0); + store_reg[1] = OACONTROL; + val = __exec_batch_patched(fd, handle, + store_reg, sizeof(store_reg), + 8); /* reloc offset */ + igt_assert_neq(val, 0x31337000); + exec_batch(fd, handle, lri_ok, sizeof(lri_ok), I915_EXEC_RENDER, 0); + store_reg[1] = SO_WRITE_OFFSET_0; + exec_batch_patched(fd, handle, + store_reg, + sizeof(store_reg), + 2 * sizeof(uint32_t), /* reloc offset */ + 0xabcdabc0); } igt_subtest("bitmasks") { @@ -423,10 +473,13 @@ igt_main 0, MI_BATCH_BUFFER_END, }; - exec_batch(fd, handle, - pc, sizeof(pc), - I915_EXEC_RENDER, - -EINVAL); + /* Expect to read back zero since the command should be + * squashed to a NOOP + */ + exec_batch_patched(fd, handle, + pc, sizeof(pc), + 8, /* patch offset, */ + 0x0); } igt_subtest("batch-without-end") {