From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 08/10] drm/msm: Validate lazy VM in GEM_NEW
Date: Thu, 16 Jul 2026 20:29:57 +0000 [thread overview]
Message-ID: <20260716202958.29FD11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716201538.365824-9-robin.clark@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] The fallback logic for shared VMs in `msm_gpu_create_private_vm()` is inverted, causing VM_BIND contexts to incorrectly fall back to the shared VM while legacy contexts fail to do so.
Pre-existing issues:
- [High] Concurrent modification of `obj->resv` after publishing the GEM object to `priv->objects` causes a mismatched lock/unlock sequence if accessed via debugfs.
--
--- Patch [8]: [PATCH v5 08/10] drm/msm: Validate lazy VM in GEM_NEW ---
commit b2a817e93a22417a9189cd5ad2d48b886f18f14d
Author: Rob Clark <robin.clark@oss.qualcomm.com>
drm/msm: Validate lazy VM in GEM_NEW
Otherwise creating a _NO_SHARE BO before any BOs are mapped could cause
a NPE.
> diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> index 2cb3ab04f1250..9bdbcf1279b00 100644
> --- a/drivers/gpu/drm/msm/msm_gem.c
> +++ b/drivers/gpu/drm/msm/msm_gem.c
> @@ -1147,8 +1147,16 @@ int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
> msm_gem_object_set_name(obj, "%s", name);
>
> if (flags & MSM_BO_NO_SHARE) {
> + struct msm_drm_private *priv = dev->dev_private;
> struct msm_context *ctx = file->driver_priv;
> - struct drm_gem_object *r_obj = drm_gpuvm_resv_obj(ctx->vm);
> + struct drm_gpuvm *vm = msm_context_vm(dev, ctx);
[Severity: High]
Does this call to msm_context_vm() trigger inverted fallback logic for shared
VMs in drivers/gpu/drm/msm/msm_gpu.c?
When msm_context_vm() evaluates !ctx->userspace_managed_vm, it passes this as
the kernel_managed parameter to msm_gpu_create_private_vm().
In msm_gpu_create_private_vm(), the fallback condition is:
if (IS_ERR_OR_NULL(vm) && !kernel_managed)
vm = drm_gpuvm_get(gpu->vm);
This causes VM_BIND contexts (where kernel_managed is false) to silently fall
back to the shared VM, directly violating the intent described in the commit
'drm/msm: Don't fallback to shared VM for VM_BIND'.
Conversely, for legacy contexts (where kernel_managed is true), the fallback
is skipped. This leaves vm as NULL on legacy targets that lack private VM
support, which would break context initialization completely.
> +
> + if (!priv->gpu || !vm) {
> + ret = UERR(EINVAL, dev, "not supported with shared VM");
> + goto out_put;
> + }
> +
> + struct drm_gem_object *r_obj = drm_gpuvm_resv_obj(vm);
>
> drm_gem_object_get(r_obj);
>
> obj->resv = r_obj->resv;
[Severity: High]
This is a pre-existing issue, but can this concurrent modification of
obj->resv cause a mismatched lock/unlock sequence if accessed via debugfs?
In drivers/gpu/drm/msm/msm_gem.c:msm_gem_new(), the BO is allocated,
obj->resv is initialized to &obj->_resv, and it is added to the global
priv->objects list under priv->obj_lock. This makes the object globally
visible.
If debugfs iterates over priv->objects concurrently via msm_gem_show(), it
calls msm_gem_describe(obj) which evaluates msm_gem_trylock(obj) and locks
the original &obj->_resv.
If the ioctl thread executing msm_gem_new_handle() then overwrites obj->resv
here without holding any locks, the subsequent msm_gem_unlock(obj) in debugfs
will unlock the new r_obj->resv (which it never locked).
This mismatched sequence would cause a kernel BUG in ww_mutex_unlock or a
lockdep splat.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716201538.365824-1-robin.clark@oss.qualcomm.com?part=8
next prev parent reply other threads:[~2026-07-16 20:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 20:15 [PATCH v5 00/10] drm/msm: A couple lazy-vm fixes Rob Clark
2026-07-16 20:15 ` [PATCH v5 01/10] drm/msm: Fix barriers accessing ctx vm Rob Clark
2026-07-16 20:31 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 02/10] drm/msm: Rework queuelock Rob Clark
2026-07-16 20:39 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 03/10] drm/msm: Synchronize VM creation on ctxlock Rob Clark
2026-07-16 20:33 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 04/10] drm/msm/a6xx: Access VM directly in submit path Rob Clark
2026-07-16 20:43 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 05/10] drm/msm: Add helper to check for per-process pgtables VM Rob Clark
2026-07-16 20:15 ` [PATCH v5 06/10] drm/msm: Allow lazy VM creation to fail Rob Clark
2026-07-16 20:33 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 07/10] drm/msm: Don't fallback to shared VM for VM_BIND Rob Clark
2026-07-16 20:28 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 08/10] drm/msm: Validate lazy VM in GEM_NEW Rob Clark
2026-07-16 20:29 ` sashiko-bot [this message]
2026-07-16 20:15 ` [PATCH v5 09/10] drm/msm: Fix per-process-pgtables check Rob Clark
2026-07-16 20:48 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 10/10] drm/msm: Remove invalid overflow check Rob Clark
2026-07-16 20:34 ` sashiko-bot
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=20260716202958.29FD11F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robin.clark@oss.qualcomm.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.