From: Petri Latvala <petri.latvala@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 3/4] hw-tests: Fix and update gem_bad_address
Date: Wed, 13 Dec 2017 14:58:15 +0200 [thread overview]
Message-ID: <20171213125816.18371-4-petri.latvala@intel.com> (raw)
In-Reply-To: <20171213125816.18371-1-petri.latvala@intel.com>
From: Antonio Argenziano <antonio.argenziano@intel.com>
When writing to an invalid memory location, the HW should be clever
enough to silently discard the write without disrupting execution.
gem_bad_address aim at just that. The test has been updated to move away
from the libDrm wrappers and use the IOCTL wrappers instead. Also the
invalid address has been updated to be just outside of the GTT space.
v2 (Petri): Split the directory changes to separate commits, fix
indentation
Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
tests/hw-tests/gem_bad_address.c | 69 +++++++++++++++++++++++-----------------
1 file changed, 39 insertions(+), 30 deletions(-)
diff --git a/tests/hw-tests/gem_bad_address.c b/tests/hw-tests/gem_bad_address.c
index a970dfa4..2d6112bd 100644
--- a/tests/hw-tests/gem_bad_address.c
+++ b/tests/hw-tests/gem_bad_address.c
@@ -23,37 +23,53 @@
* Authors:
* Eric Anholt <eric@anholt.net>
* Jesse Barnes <jbarnes@virtuousgeek.org> (based on gem_bad_blit.c)
+ * Antonio Argenziano <antonio.argenziano@intel.com>
*
*/
#include "igt.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include "drm.h"
-#include "intel_bufmgr.h"
-static drm_intel_bufmgr *bufmgr;
-struct intel_batchbuffer *batch;
-
-#define BAD_GTT_DEST ((512*1024*1024)) /* past end of aperture */
+/*
+ * This test aims at verifying that writing to an invalid location in memory,
+ * doesn't cause hangs. The store command should be ignored completely by the
+ * HW and the whole process should be transparent to the user. Therefore,
+ * the test doesn't perform any validation check but expects the wrapping
+ * execution environment to check no hangs have occurred.
+ *
+ * The test needs to send a privileged batch to be able to write to the GTT.
+ */
static void
-bad_store(void)
+bad_store(uint32_t fd, uint32_t engine)
{
- BEGIN_BATCH(4, 0);
- OUT_BATCH(MI_STORE_DWORD_IMM | MI_MEM_VIRTUAL | 1 << 21);
- OUT_BATCH(0);
- OUT_BATCH(BAD_GTT_DEST);
- OUT_BATCH(0xdeadbeef);
- ADVANCE_BATCH();
+ struct drm_i915_gem_exec_object2 obj;
+ struct drm_i915_gem_execbuffer2 execbuf;
+
+ uint32_t batch[16];
+ int i = 0;
+
+ memset(&obj, 0, sizeof(obj));
+ memset(&execbuf, 0, sizeof(execbuf));
+
+ execbuf.buffers_ptr = to_user_pointer(&obj);
+ execbuf.buffer_count = 1;
+ execbuf.flags = engine;
+ execbuf.flags |= I915_EXEC_SECURE;
- intel_batchbuffer_flush(batch);
+ obj.handle = gem_create(fd, 4096);
+
+ batch[i++] = MI_STORE_DWORD_IMM | MI_MEM_VIRTUAL;
+ batch[i++] = 0x0; //Low part of the GTT address = 4GByte
+ batch[i++] = 0x1; //High part of the GTT address > GTT size
+ batch[i++] = 0xdeadbeef;
+
+ batch[i++] = MI_BATCH_BUFFER_END;
+ batch[i++] = 0x0;
+
+ gem_write(fd, obj.handle, 0, batch, sizeof(batch));
+ gem_execbuf(fd, &execbuf);
+
+ gem_close(fd, obj.handle);
}
igt_simple_main
@@ -62,14 +78,7 @@ igt_simple_main
fd = drm_open_driver(DRIVER_INTEL);
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- drm_intel_bufmgr_gem_enable_reuse(bufmgr);
- batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
-
- bad_store();
-
- intel_batchbuffer_free(batch);
- drm_intel_bufmgr_destroy(bufmgr);
+ bad_store(fd, I915_EXEC_BLT);
close(fd);
}
--
2.14.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-12-13 12:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-13 12:58 [PATCH i-g-t 0/4] Create a new directory for hardware-targeting tests Petri Latvala
2017-12-13 12:58 ` [PATCH i-g-t 1/4] tests: Add a hw-tests subdirectory Petri Latvala
2017-12-13 12:58 ` [PATCH i-g-t 2/4] tests: Move gem_bad_address to hw-tests Petri Latvala
2017-12-13 13:26 ` Chris Wilson
2017-12-15 19:43 ` Antonio Argenziano
2017-12-13 12:58 ` Petri Latvala [this message]
2017-12-15 20:46 ` [PATCH i-g-t 3/4] hw-tests: Fix and update gem_bad_address Chris Wilson
2017-12-13 12:58 ` [PATCH i-g-t 4/4] run-tests.sh: Allow users to override IGT_TEST_ROOT Petri Latvala
2017-12-13 16:04 ` Arkadiusz Hiler
2017-12-13 16:41 ` ✓ Fi.CI.BAT: success for Create a new directory for hardware-targeting tests Patchwork
2017-12-13 18:31 ` ✓ Fi.CI.IGT: " 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=20171213125816.18371-4-petri.latvala@intel.com \
--to=petri.latvala@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/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;
as well as URLs for NNTP newsgroup(s).