* [PATCH v1] drm/i915/gvt: Don't replace a DMA mapping that is still in use
@ 2026-10-04 21:22 Yuho Choi
2026-10-06 0:31 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Yuho Choi @ 2026-10-04 21:22 UTC (permalink / raw)
To: Zhenyu Wang, Zhi Wang
Cc: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
Xiaolin Zhang, intel-gfx, dri-devel, linux-kernel, Yuho Choi,
stable
intel_gvt_dma_map_guest_page() unmaps and frees the cache entry of a
gfn when it is requested with a different size, and maps the page again.
The entry is still referenced: shadow GTT entries and dma-bufs keep
using its DMA address after the page is unpinned and the DMA mapping is
torn down. When the new mapping gets the same DMA address, their later
intel_gvt_dma_unmap_guest_page() calls also drop the references of the
new entry.
Keep the existing entry instead. A 2M mapping covers a 4K request for
its first page, so take a reference on it. If the entry is smaller than
the request, fail and let the caller split the 2M entry into 4K pages,
as it already does when a 2M mapping cannot be set up.
Fixes: 7366aeb77cd8 ("drm/i915/gvt: fix incorrect cache entry for guest page mapping")
Cc: stable@vger.kernel.org
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Compile-tested only (x86_64 defconfig + DRM_I915_GVT_KVMGT, W=1, sparse).
drivers/gpu/drm/i915/gvt/kvmgt.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index ec62db5cc3675..9a3e305253469 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1626,19 +1626,15 @@ int intel_gvt_dma_map_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
ret = __gvt_cache_add(vgpu, gfn, *dma_addr, size);
if (ret)
goto err_unmap;
- } else if (entry->size != size) {
- /* the same gfn with different size: unmap and re-map */
- gvt_dma_unmap_page(vgpu, gfn, entry->dma_addr, entry->size);
- __gvt_cache_remove_entry(vgpu, entry);
-
- ret = gvt_dma_map_page(vgpu, gfn, dma_addr, size);
- if (ret)
- goto err_unlock;
-
- ret = __gvt_cache_add(vgpu, gfn, *dma_addr, size);
- if (ret)
- goto err_unmap;
+ } else if (entry->size < size) {
+ /*
+ * The smaller mapping may still be in use, so don't replace
+ * it. Fail and let the caller map the range in smaller pages.
+ */
+ ret = -EBUSY;
+ goto err_unlock;
} else {
+ /* A mapping of the same or a larger size covers the request */
kref_get(&entry->ref);
*dma_addr = entry->dma_addr;
}
base-commit: 7704c4c5bb127673b4f0ead839919db573559e38
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* ✗ LGCI.VerificationFailed: failure for drm/i915/gvt: Don't replace a DMA mapping that is still in use
2026-10-04 21:22 [PATCH v1] drm/i915/gvt: Don't replace a DMA mapping that is still in use Yuho Choi
@ 2026-10-06 0:31 ` Patchwork
2026-10-06 7:41 ` [PATCH v1] " Jani Nikula
2026-10-10 3:59 ` Zhenyu Wang
2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2026-10-06 0:31 UTC (permalink / raw)
To: Yuho Choi; +Cc: intel-gfx
== Series Details ==
Series: drm/i915/gvt: Don't replace a DMA mapping that is still in use
URL : https://patchwork.freedesktop.org/series/175582/
State : failure
== Summary ==
Series author address 'oss.patchbox@gmail.com' is not on the allowlist, which prevents CI from being automatically triggered.
If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork.
Exception occurred during validation, bailing out!
Build URL: http://gfx-ci.igk.intel.com:8080/job/CI_PW_kernel/189633/ (on built-in)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] drm/i915/gvt: Don't replace a DMA mapping that is still in use
2026-10-04 21:22 [PATCH v1] drm/i915/gvt: Don't replace a DMA mapping that is still in use Yuho Choi
2026-10-06 0:31 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
@ 2026-10-06 7:41 ` Jani Nikula
2026-10-06 22:14 ` Yuho Choi
2026-10-10 3:59 ` Zhenyu Wang
2 siblings, 1 reply; 5+ messages in thread
From: Jani Nikula @ 2026-10-06 7:41 UTC (permalink / raw)
To: Yuho Choi, Zhenyu Wang, Zhi Wang
Cc: Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin, Xiaolin Zhang,
intel-gfx, dri-devel, linux-kernel, Yuho Choi, stable
On Sun, 04 Oct 2026, Yuho Choi <oss.patchbox@gmail.com> wrote:
> intel_gvt_dma_map_guest_page() unmaps and frees the cache entry of a
> gfn when it is requested with a different size, and maps the page again.
> The entry is still referenced: shadow GTT entries and dma-bufs keep
> using its DMA address after the page is unpinned and the DMA mapping is
> torn down. When the new mapping gets the same DMA address, their later
> intel_gvt_dma_unmap_guest_page() calls also drop the references of the
> new entry.
>
> Keep the existing entry instead. A 2M mapping covers a 4K request for
> its first page, so take a reference on it. If the entry is smaller than
> the request, fail and let the caller split the 2M entry into 4K pages,
> as it already does when a 2M mapping cannot be set up.
>
> Fixes: 7366aeb77cd8 ("drm/i915/gvt: fix incorrect cache entry for guest page mapping")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
> ---
> Compile-tested only (x86_64 defconfig + DRM_I915_GVT_KVMGT, W=1, sparse).
IOW, you're not hitting the issue yourself? How did you find the issue?
Did you use LLM to write the patch?
BR,
Jani.
>
> drivers/gpu/drm/i915/gvt/kvmgt.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index ec62db5cc3675..9a3e305253469 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -1626,19 +1626,15 @@ int intel_gvt_dma_map_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
> ret = __gvt_cache_add(vgpu, gfn, *dma_addr, size);
> if (ret)
> goto err_unmap;
> - } else if (entry->size != size) {
> - /* the same gfn with different size: unmap and re-map */
> - gvt_dma_unmap_page(vgpu, gfn, entry->dma_addr, entry->size);
> - __gvt_cache_remove_entry(vgpu, entry);
> -
> - ret = gvt_dma_map_page(vgpu, gfn, dma_addr, size);
> - if (ret)
> - goto err_unlock;
> -
> - ret = __gvt_cache_add(vgpu, gfn, *dma_addr, size);
> - if (ret)
> - goto err_unmap;
> + } else if (entry->size < size) {
> + /*
> + * The smaller mapping may still be in use, so don't replace
> + * it. Fail and let the caller map the range in smaller pages.
> + */
> + ret = -EBUSY;
> + goto err_unlock;
> } else {
> + /* A mapping of the same or a larger size covers the request */
> kref_get(&entry->ref);
> *dma_addr = entry->dma_addr;
> }
>
> base-commit: 7704c4c5bb127673b4f0ead839919db573559e38
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] drm/i915/gvt: Don't replace a DMA mapping that is still in use
2026-10-06 7:41 ` [PATCH v1] " Jani Nikula
@ 2026-10-06 22:14 ` Yuho Choi
0 siblings, 0 replies; 5+ messages in thread
From: Yuho Choi @ 2026-10-06 22:14 UTC (permalink / raw)
To: Jani Nikula
Cc: Zhenyu Wang, Zhi Wang, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, Xiaolin Zhang, intel-gfx, dri-devel, linux-kernel,
stable
Thank you for reviewing.
On Tue, 6 Oct 2026 at 03:41, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>
> IOW, you're not hitting the issue yourself? How did you find the issue?
> Did you use LLM to write the patch?
As part of security research, I am reviewing how virtualization code manages
the lifetime of resources it shares with guests and devices.
> Did you use LLM to write the patch?
While preparing this patch, I asked an AI assistant questions to confirm my
understanding of how the driver works. So technically yes, an LLM was used
in making this patch. I should have disclosed this in the submission; v2 will
carry it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] drm/i915/gvt: Don't replace a DMA mapping that is still in use
2026-10-04 21:22 [PATCH v1] drm/i915/gvt: Don't replace a DMA mapping that is still in use Yuho Choi
2026-10-06 0:31 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
2026-10-06 7:41 ` [PATCH v1] " Jani Nikula
@ 2026-10-10 3:59 ` Zhenyu Wang
2 siblings, 0 replies; 5+ messages in thread
From: Zhenyu Wang @ 2026-10-10 3:59 UTC (permalink / raw)
To: Yuho Choi
Cc: Zhi Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, Xiaolin Zhang, intel-gfx, dri-devel, linux-kernel,
stable, zhiw
On Sun, Oct 04, 2026 at 05:22:39PM -0400, Yuho Choi wrote:
> intel_gvt_dma_map_guest_page() unmaps and frees the cache entry of a
> gfn when it is requested with a different size, and maps the page again.
> The entry is still referenced: shadow GTT entries and dma-bufs keep
> using its DMA address after the page is unpinned and the DMA mapping is
> torn down.
I don't think this is *real*, as code would simply destroy entry in
that case, and there won't be on-the-fly dma operation on that, as
guest mem setup is totally before execlist submission, if guest driver
changed mapping by ignoring gvt emulated execlist status, that's just bad...
> When the new mapping gets the same DMA address, their later
> intel_gvt_dma_unmap_guest_page() calls also drop the references of the
> new entry.
>
> Keep the existing entry instead. A 2M mapping covers a 4K request for
> its first page, so take a reference on it. If the entry is smaller than
> the request, fail and let the caller split the 2M entry into 4K pages,
> as it already does when a 2M mapping cannot be set up.
>
So this change would always force 2M to split into 4K? why?
> Fixes: 7366aeb77cd8 ("drm/i915/gvt: fix incorrect cache entry for guest page mapping")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
> ---
> Compile-tested only (x86_64 defconfig + DRM_I915_GVT_KVMGT, W=1, sparse).
>
> drivers/gpu/drm/i915/gvt/kvmgt.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index ec62db5cc3675..9a3e305253469 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -1626,19 +1626,15 @@ int intel_gvt_dma_map_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
> ret = __gvt_cache_add(vgpu, gfn, *dma_addr, size);
> if (ret)
> goto err_unmap;
> - } else if (entry->size != size) {
> - /* the same gfn with different size: unmap and re-map */
> - gvt_dma_unmap_page(vgpu, gfn, entry->dma_addr, entry->size);
> - __gvt_cache_remove_entry(vgpu, entry);
> -
> - ret = gvt_dma_map_page(vgpu, gfn, dma_addr, size);
> - if (ret)
> - goto err_unlock;
> -
> - ret = __gvt_cache_add(vgpu, gfn, *dma_addr, size);
> - if (ret)
> - goto err_unmap;
> + } else if (entry->size < size) {
> + /*
> + * The smaller mapping may still be in use, so don't replace
> + * it. Fail and let the caller map the range in smaller pages.
> + */
> + ret = -EBUSY;
> + goto err_unlock;
> } else {
> + /* A mapping of the same or a larger size covers the request */
> kref_get(&entry->ref);
> *dma_addr = entry->dma_addr;
> }
>
> base-commit: 7704c4c5bb127673b4f0ead839919db573559e38
> --
> 2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-10 3:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-04 21:22 [PATCH v1] drm/i915/gvt: Don't replace a DMA mapping that is still in use Yuho Choi
2026-10-06 0:31 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
2026-10-06 7:41 ` [PATCH v1] " Jani Nikula
2026-10-06 22:14 ` Yuho Choi
2026-10-10 3:59 ` Zhenyu Wang
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.