From: Jonathan Cavitt <jonathan.cavitt@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com,
jonathan.cavitt@intel.com, joonas.lahtinen@linux.intel.com,
matthew.brost@intel.com, jianxun.zhang@intel.com,
shuicheng.lin@intel.com
Subject: [PATCH 3/4] tests/intel/xe_vm: Add DRM_IOCTL_XE_VM_GET_FAULTS validation tests
Date: Mon, 10 Mar 2025 21:03:42 +0000 [thread overview]
Message-ID: <20250310210343.204246-4-jonathan.cavitt@intel.com> (raw)
In-Reply-To: <20250310210343.204246-1-jonathan.cavitt@intel.com>
Add tests to xe_vm that exercise the new DRM_IOCTL_XE_VM_GET_FAULTS
ioctl. Specifically, add input validation tests that exercise the
return values for improperly formatted ioctl structures.
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
---
tests/intel/xe_vm.c | 79 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
index fdf74c1140..40928b441c 100644
--- a/tests/intel/xe_vm.c
+++ b/tests/intel/xe_vm.c
@@ -2343,6 +2343,69 @@ static void invalid_vm_id(int fd)
do_ioctl_err(fd, DRM_IOCTL_XE_VM_DESTROY, &destroy, ENOENT);
}
+/**
+ * SUBTEST: vm-get-faults-invalid-reserved
+ * Functionality: ioctl_input_validation
+ * Description: Check query with invalid reserved returns expected error code
+ *
+ * SUBTEST: vm-get-faults-invalid-vm-id
+ * Functionality: ioctl_input_validation
+ * Description: Check query with invalid vm_id returns expected error code
+ *
+ * SUBTEST: vm-get-faults-invalid-size
+ * Functionality: ioctl_input_validation
+ * Description: Check query with invalid size returns expected error code
+ *
+ * SUBTEST: vm-get-faults-invalid-fault-count
+ * Functionality: ioctl_input_validation
+ * Description: Check query with invalid fault_count returns expected error code
+ */
+static void get_faults_invalid_reserved(int fd, uint32_t vm)
+{
+ struct drm_xe_vm_get_faults query = {
+ .reserved[0] = 0xdeadbeef,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_GET_FAULTS, &query, EINVAL);
+}
+
+static void get_faults_invalid_vm_id(int fd, uint32_t vm)
+{
+ struct drm_xe_vm_get_faults query = {
+ .vm_id = 0xdeadbeef,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_GET_FAULTS, &query, ENOENT);
+}
+
+static void get_faults_invalid_size(int fd, uint32_t vm)
+{
+ struct drm_xe_vm_get_faults query = {
+ .size = 1,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_GET_FAULTS, &query, EINVAL);
+}
+
+static void get_faults_invalid_fault_count(int fd, uint32_t vm)
+{
+ struct drm_xe_vm_get_faults query = {
+ .fault_count = 1,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_XE_VM_GET_FAULTS, &query, EINVAL);
+}
+
+static void test_get_faults(int fd, void (*func)(int fd, uint32_t vm))
+{
+ uint32_t vm;
+
+ vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE ||
+ DRM_XE_VM_CREATE_FLAG_FAULT_MODE, 0);
+ func(fd, vm);
+ xe_vm_destroy(fd, vm);
+}
+
igt_main
{
struct drm_xe_engine_class_instance *hwe, *hwe_non_copy = NULL;
@@ -2455,6 +2518,17 @@ igt_main
{ }
};
+ const struct vm_get_faults {
+ const char *name;
+ void (*test)(int fd, uint32_t vm);
+ } xe_vm_get_faults_tests[] = {
+ { "invalid-reserved", get_faults_invalid_reserved },
+ { "invalid-vm-id", get_faults_invalid_vm_id },
+ { "invalid-size", get_faults_invalid_size },
+ { "invalid-fault-count", get_faults_invalid_fault_count },
+ { }
+ };
+
igt_fixture {
fd = drm_open_driver(DRIVER_XE);
@@ -2734,6 +2808,11 @@ igt_main
igt_subtest("invalid-vm-id")
invalid_vm_id(fd);
+ for (const struct vm_get_faults *f = xe_vm_get_faults_tests; f->name; f++) {
+ igt_subtest_f("vm-get-faults-%s", f->name)
+ test_get_faults(fd, f->test);
+ }
+
igt_fixture
drm_close_driver(fd);
}
--
2.43.0
next prev parent reply other threads:[~2025-03-10 21:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 21:03 [PATCH 0/4] tests/intel/xe_vm: Add drm_xe_vm_get_faults tests Jonathan Cavitt
2025-03-10 21:03 ` [PATCH 1/4] drm-uapi/xe: Declare xe_vm_get_faults_ioctl Jonathan Cavitt
2025-03-10 21:03 ` [PATCH 2/4] lib/xe/xe_ioctl: Add xe_vm_get_faults helper function Jonathan Cavitt
2025-03-10 21:03 ` Jonathan Cavitt [this message]
2025-03-10 21:03 ` [PATCH 4/4] tests/intel/xe_vm: Test DRM_IOCTL_XE_VM_GET_FAULTS fault reporting Jonathan Cavitt
2025-03-11 3:28 ` ✓ Xe.CI.BAT: success for tests/intel/xe_vm: Add drm_xe_vm_get_faults tests Patchwork
2025-03-11 3:46 ` ✓ i915.CI.BAT: " Patchwork
2025-03-11 5:55 ` ✗ i915.CI.Full: failure " Patchwork
2025-03-11 23:33 ` ✗ Xe.CI.Full: " 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=20250310210343.204246-4-jonathan.cavitt@intel.com \
--to=jonathan.cavitt@intel.com \
--cc=alex.zuo@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jianxun.zhang@intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=saurabhg.gupta@intel.com \
--cc=shuicheng.lin@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