From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: [igt-dev] [PATCH] tests/xe/xe_vm: Add a userptr-invalid test
Date: Wed, 15 Mar 2023 15:14:53 +0100 [thread overview]
Message-ID: <20230315141453.39733-1-thomas.hellstrom@linux.intel.com> (raw)
Add a small userptr-invalid test that adds some coverage for the
error paths in the userptr binding code.
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
tests/xe/xe_vm.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tests/xe/xe_vm.c b/tests/xe/xe_vm.c
index 4103bd7c..80dcda72 100644
--- a/tests/xe/xe_vm.c
+++ b/tests/xe/xe_vm.c
@@ -292,6 +292,32 @@ static void unbind_all(int fd, int n_vmas)
xe_vm_destroy(fd, vm);
}
+#define MAP_ADDRESS 0x00007fadeadbe000
+
+/*
+ * This tests verifies that mapping an invalid userptr returns -EFAULT,
+ * and that it is correctly handled.
+ */
+static void userptr_invalid(int fd)
+{
+ size_t size = xe_get_default_alignment(fd);
+ uint32_t vm;
+ void *data;
+ int ret;
+
+ data = mmap((void *)MAP_ADDRESS, size, PROT_READ |
+ PROT_WRITE, MAP_SHARED | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
+ igt_assert(data != MAP_FAILED);
+
+ vm = xe_vm_create(fd, 0, 0);
+ munmap(data, size);
+ ret = __xe_vm_bind(fd, vm, 0, 0, to_user_pointer(data), 0x40000,
+ size, XE_VM_BIND_OP_MAP_USERPTR, NULL, 0, 0, 0);
+ igt_assert(ret == -EFAULT);
+
+ xe_vm_destroy(fd, vm);
+}
+
struct vm_thread_data {
pthread_t thread;
struct drm_xe_vm_bind_op_error_capture *capture;
@@ -1618,6 +1644,9 @@ igt_main
igt_subtest("unbind-all-8-vmas")
unbind_all(fd, 8);
+ igt_subtest("userptr-invalid")
+ userptr_invalid(fd);
+
igt_subtest("vm-async-ops-err")
vm_async_ops_err(fd, false);
--
2.39.2
next reply other threads:[~2023-03-15 14:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 14:14 Thomas Hellström [this message]
2023-03-15 15:12 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/xe/xe_vm: Add a userptr-invalid test Patchwork
2023-03-15 15:18 ` [igt-dev] [PATCH] " Matthew Brost
2023-03-16 3:07 ` [igt-dev] ✓ Fi.CI.IGT: success for " 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=20230315141453.39733-1-thomas.hellstrom@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=igt-dev@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