From: Matthew Brost <matthew.brost@intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH] tests/xe/xe_vm: Add a userptr-invalid test
Date: Wed, 15 Mar 2023 15:18:23 +0000 [thread overview]
Message-ID: <ZBHhv9SSxicwKjV9@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20230315141453.39733-1-thomas.hellstrom@linux.intel.com>
On Wed, Mar 15, 2023 at 03:14:53PM +0100, Thomas Hellström wrote:
> 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>
Reviewed-by: Matthew Brost <matthew.brost@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 prev parent reply other threads:[~2023-03-15 15:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 14:14 [igt-dev] [PATCH] tests/xe/xe_vm: Add a userptr-invalid test Thomas Hellström
2023-03-15 15:12 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2023-03-15 15:18 ` Matthew Brost [this message]
2023-03-16 3:07 ` [igt-dev] ✓ 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=ZBHhv9SSxicwKjV9@DUT025-TGLU.fm.intel.com \
--to=matthew.brost@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=thomas.hellstrom@linux.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