Re: [PATCH v6 1/2] drm/i915/selftests: Prevent userspace mapping invalidation

Andi Shyti
2026-04-15T22:21:16Z

Hi Krzysztof,

...

> @@ -201,6 +238,21 @@ static int __run_selftests(const char *name,
> pr_info(DRIVER_NAME ": Performing %s selftests with st_random_seed=0x%x st_timeout=%u\n",
> name, i915_selftest.random_seed, i915_selftest.timeout_ms);
>
> + /**
> + * If we are running in a kthread on a multi NUMA system and the user passed
> + * a valid PID of a userspace task, then we may borrow its address space
> + * to prepare a safe environment for the mmap selftests.
> + */
> + if (!current->mm && u_pid_nr) {
> + mm = get_mm(u_pid_nr);
> + if (mm) {
> + kthread_use_mm(mm);
> + mmput_async(mm);
> + if (unlikely(!current->mm))
> + pr_warn("Could not set mm as current->mm\n");
> + }
> + }
> +
> /* Tests are listed in order in i915_*_selftests.h */
> for (; count--; st++) {

In this loop you have a few returns and we skip the mm cleanup.

Andi

> if (!st->enabled)
> @@ -226,6 +278,9 @@ static int __run_selftests(const char *name,
> st->name, err))
> err = -1;
>
> + if (mm)
> + kthread_unuse_mm(mm);
> +
> return err;
> }