* [PATCH v2 07/13] mm/vma: rename vma_get_page_prot to vma_flags_to_page_prot
From: Lorenzo Stoakes @ 2026-07-11 18:45 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Thomas Bogendoerfer, Benjamin LaHaise, Alexander Viro,
Christian Brauner, Jan Kara, Hugh Dickins, Baolin Wang, Jann Horn,
Pedro Falcato, Muchun Song, Oscar Salvador, Zi Yan, Nico Pache,
Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Usama Arif,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Lucas Stach,
Russell King, Christian Gmeiner, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Tomi Valkeinen, Sandy Huang, Heiko Stübner, Andy Yan,
Thierry Reding, Mikko Perttunen, Jonathan Hunter, Gerd Hoffmann,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Matthew Brost,
Thomas Hellström, Oleksandr Andrushchenko, Helge Deller,
Kees Cook, Jaroslav Kysela, Takashi Iwai, Boris Brezillon,
Steven Price, Liviu Dudau
Cc: Lorenzo Stoakes, linux-mm, linux-kernel, linux-mips, linux-aio,
linux-fsdevel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-sound
In-Reply-To: <20260711-b4-vma-flags-mm-v2-0-0fa2357d5431@kernel.org>
Having vma_get_page_prot() refer to VMA flags and vma_set_page_prot() refer
to a VMA is confusing.
Rename vma_get_page_prot() to vma_flags_to_page_prot() to resolve this
confusion.
No functional change intended.
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
---
include/linux/mm.h | 4 ++--
mm/vma.c | 2 +-
mm/vma.h | 2 +-
tools/testing/vma/include/dup.h | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5b3825fddf58..b8fe40f89d87 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4603,7 +4603,7 @@ static inline bool range_in_vma_desc(const struct vm_area_desc *desc,
#ifdef CONFIG_MMU
pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
-static inline pgprot_t vma_get_page_prot(vma_flags_t vma_flags)
+static inline pgprot_t vma_flags_to_page_prot(vma_flags_t vma_flags)
{
const vm_flags_t vm_flags = vma_flags_to_legacy(vma_flags);
@@ -4616,7 +4616,7 @@ static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
{
return __pgprot(0);
}
-static inline pgprot_t vma_get_page_prot(vma_flags_t vma_flags)
+static inline pgprot_t vma_flags_to_page_prot(vma_flags_t vma_flags)
{
return __pgprot(0);
}
diff --git a/mm/vma.c b/mm/vma.c
index a74a0e467c63..38481aca7321 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -56,7 +56,7 @@ struct mmap_state {
.pglen = PHYS_PFN(len_), \
.vma_flags = vma_flags_, \
.file = file_, \
- .page_prot = vma_get_page_prot(vma_flags_), \
+ .page_prot = vma_flags_to_page_prot(vma_flags_), \
}
#define VMG_MMAP_STATE(name, map_, vma_) \
diff --git a/mm/vma.h b/mm/vma.h
index 8ca6e7e8ae28..0bc7d521e976 100644
--- a/mm/vma.h
+++ b/mm/vma.h
@@ -543,7 +543,7 @@ static inline bool vma_wants_manual_pte_write_upgrade(struct vm_area_struct *vma
#ifdef CONFIG_MMU
static inline pgprot_t vma_pgprot_modify(pgprot_t oldprot, vma_flags_t vma_flags)
{
- const pgprot_t prot = vma_get_page_prot(vma_flags);
+ const pgprot_t prot = vma_flags_to_page_prot(vma_flags);
return pgprot_modify(oldprot, prot);
}
diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h
index 24955a1e318a..8621a7ae8980 100644
--- a/tools/testing/vma/include/dup.h
+++ b/tools/testing/vma/include/dup.h
@@ -1545,7 +1545,7 @@ static inline int get_sysctl_max_map_count(void)
#define pgtable_supports_soft_dirty() IS_ENABLED(CONFIG_MEM_SOFT_DIRTY)
#endif
-static inline pgprot_t vma_get_page_prot(vma_flags_t vma_flags)
+static inline pgprot_t vma_flags_to_page_prot(vma_flags_t vma_flags)
{
const vm_flags_t vm_flags = vma_flags_to_legacy(vma_flags);
--
2.55.0
^ permalink raw reply related
* [PATCH v2 06/13] mm/vma: convert vm_pgprot_modify() to use vma_flags_t and rename
From: Lorenzo Stoakes @ 2026-07-11 18:45 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Thomas Bogendoerfer, Benjamin LaHaise, Alexander Viro,
Christian Brauner, Jan Kara, Hugh Dickins, Baolin Wang, Jann Horn,
Pedro Falcato, Muchun Song, Oscar Salvador, Zi Yan, Nico Pache,
Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Usama Arif,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Lucas Stach,
Russell King, Christian Gmeiner, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Tomi Valkeinen, Sandy Huang, Heiko Stübner, Andy Yan,
Thierry Reding, Mikko Perttunen, Jonathan Hunter, Gerd Hoffmann,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Matthew Brost,
Thomas Hellström, Oleksandr Andrushchenko, Helge Deller,
Kees Cook, Jaroslav Kysela, Takashi Iwai, Boris Brezillon,
Steven Price, Liviu Dudau
Cc: Lorenzo Stoakes, linux-mm, linux-kernel, linux-mips, linux-aio,
linux-fsdevel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-sound
In-Reply-To: <20260711-b4-vma-flags-mm-v2-0-0fa2357d5431@kernel.org>
Update vm_pgprot_modify() to use the new VMA flags type vma_flags_t, and
rename to vma_pgprot_modify() accordingly.
This is part of the ongoing work to convert vm_flags_t to vma_flags_t, in
order to eliminate the arbitrary limit of the number of bits in a system
word on available VMA flags.
Update VMA userland tests accordingly, updating vma_set_page_prot() to no
longer inline vma_pgprot_modify(), rather we can simply define
vma_pgprot_modify() as a static inline function and the tests will pick it
up from vma.h.
No functional change intended.
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
---
mm/mmap.c | 8 ++++----
mm/vma.c | 2 +-
mm/vma.h | 6 ++++--
tools/testing/vma/include/dup.h | 12 +++++-------
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index ae9a5018e20e..2076c70e7700 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -80,13 +80,13 @@ core_param(ignore_rlimit_data, ignore_rlimit_data, bool, 0644);
/* Update vma->vm_page_prot to reflect vma->vm_flags. */
void vma_set_page_prot(struct vm_area_struct *vma)
{
- vm_flags_t vm_flags = vma->vm_flags;
+ vma_flags_t vma_flags = vma->flags;
pgprot_t vm_page_prot;
- vm_page_prot = vm_pgprot_modify(vma->vm_page_prot, vm_flags);
+ vm_page_prot = vma_pgprot_modify(vma->vm_page_prot, vma_flags);
if (vma_wants_writenotify(vma, vm_page_prot)) {
- vm_flags &= ~VM_SHARED;
- vm_page_prot = vm_pgprot_modify(vm_page_prot, vm_flags);
+ vma_flags_clear(&vma_flags, VMA_SHARED_BIT);
+ vm_page_prot = vma_pgprot_modify(vm_page_prot, vma_flags);
}
/* remove_protection_ptes reads vma->vm_page_prot without mmap_lock */
WRITE_ONCE(vma->vm_page_prot, vm_page_prot);
diff --git a/mm/vma.c b/mm/vma.c
index 1f443d979a7d..a74a0e467c63 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -2176,7 +2176,7 @@ bool vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot)
/* The open routine did something to the protections that pgprot_modify
* won't preserve? */
if (pgprot_val(vm_page_prot) !=
- pgprot_val(vm_pgprot_modify(vm_page_prot, vma->vm_flags)))
+ pgprot_val(vma_pgprot_modify(vm_page_prot, vma->flags)))
return false;
/*
diff --git a/mm/vma.h b/mm/vma.h
index 4eb85b4a6adc..8ca6e7e8ae28 100644
--- a/mm/vma.h
+++ b/mm/vma.h
@@ -541,9 +541,11 @@ static inline bool vma_wants_manual_pte_write_upgrade(struct vm_area_struct *vma
}
#ifdef CONFIG_MMU
-static inline pgprot_t vm_pgprot_modify(pgprot_t oldprot, vm_flags_t vm_flags)
+static inline pgprot_t vma_pgprot_modify(pgprot_t oldprot, vma_flags_t vma_flags)
{
- return pgprot_modify(oldprot, vm_get_page_prot(vm_flags));
+ const pgprot_t prot = vma_get_page_prot(vma_flags);
+
+ return pgprot_modify(oldprot, prot);
}
#endif
diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h
index 773e23303e26..24955a1e318a 100644
--- a/tools/testing/vma/include/dup.h
+++ b/tools/testing/vma/include/dup.h
@@ -1424,20 +1424,18 @@ struct vm_area_struct *vma_iter_next_range(struct vma_iterator *vmi)
}
bool vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot);
+static inline pgprot_t vma_pgprot_modify(pgprot_t oldprot, vma_flags_t vma_flags);
/* Update vma->vm_page_prot to reflect vma->vm_flags. */
static inline void vma_set_page_prot(struct vm_area_struct *vma)
{
- vm_flags_t vm_flags = vma->vm_flags;
+ vma_flags_t vma_flags = vma->flags;
pgprot_t vm_page_prot;
- /* testing: we inline vm_pgprot_modify() to avoid clash with vma.h. */
- vm_page_prot = pgprot_modify(vma->vm_page_prot, vm_get_page_prot(vm_flags));
-
+ vm_page_prot = vma_pgprot_modify(vma->vm_page_prot, vma_flags);
if (vma_wants_writenotify(vma, vm_page_prot)) {
- vm_flags &= ~VM_SHARED;
- /* testing: we inline vm_pgprot_modify() to avoid clash with vma.h. */
- vm_page_prot = pgprot_modify(vm_page_prot, vm_get_page_prot(vm_flags));
+ vma_flags_clear(&vma_flags, VMA_SHARED_BIT);
+ vm_page_prot = vma_pgprot_modify(vm_page_prot, vma_flags);
}
/* remove_protection_ptes reads vma->vm_page_prot without mmap_lock */
WRITE_ONCE(vma->vm_page_prot, vm_page_prot);
--
2.55.0
^ permalink raw reply related
* [PATCH v2 05/13] mm: prefer mm->def_vma_flags in mm logic
From: Lorenzo Stoakes @ 2026-07-11 18:45 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Thomas Bogendoerfer, Benjamin LaHaise, Alexander Viro,
Christian Brauner, Jan Kara, Hugh Dickins, Baolin Wang, Jann Horn,
Pedro Falcato, Muchun Song, Oscar Salvador, Zi Yan, Nico Pache,
Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Usama Arif,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Lucas Stach,
Russell King, Christian Gmeiner, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Tomi Valkeinen, Sandy Huang, Heiko Stübner, Andy Yan,
Thierry Reding, Mikko Perttunen, Jonathan Hunter, Gerd Hoffmann,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Matthew Brost,
Thomas Hellström, Oleksandr Andrushchenko, Helge Deller,
Kees Cook, Jaroslav Kysela, Takashi Iwai, Boris Brezillon,
Steven Price, Liviu Dudau
Cc: Lorenzo Stoakes, linux-mm, linux-kernel, linux-mips, linux-aio,
linux-fsdevel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-sound
In-Reply-To: <20260711-b4-vma-flags-mm-v2-0-0fa2357d5431@kernel.org>
Currently mm->def_flags (of type vm_flags_t) is union'd with
mm->def_vma_flags (of type vma_flags_t).
As part of the effort to convert vm_flags_t usage to vma_flags_t (in order
to no longer be arbitrarily limited to a system word size for VMA flags),
prefer mm->def_vma_flags to mm->def_flags throughout the mm logic.
We update dump_mm() to use the %*pb format which means we make no
assumption about the number of VMA flag bits on output when outputting
default VMA flags.
No functional change intended.
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
---
mm/debug.c | 5 +++--
mm/mlock.c | 13 +++++++------
mm/mmap.c | 11 ++++++-----
mm/vma.c | 2 +-
4 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/mm/debug.c b/mm/debug.c
index 497654b36f1a..9a0297b3988d 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -197,7 +197,7 @@ void dump_mm(const struct mm_struct *mm)
"numa_next_scan %lu numa_scan_offset %lu numa_scan_seq %d\n"
#endif
"tlb_flush_pending %d\n"
- "def_flags: %#lx(%pGv)\n",
+ "def_flags: %*pb(%pGv)\n",
mm, mm->task_size,
mm->mmap_base, mm->mmap_legacy_base,
@@ -226,7 +226,8 @@ void dump_mm(const struct mm_struct *mm)
mm->numa_next_scan, mm->numa_scan_offset, mm->numa_scan_seq,
#endif
atomic_read(&mm->tlb_flush_pending),
- mm->def_flags, &mm->def_flags
+ NUM_VMA_FLAG_BITS, mm->def_vma_flags.__vma_flags,
+ &mm->def_vma_flags
);
}
EXPORT_SYMBOL(dump_mm);
diff --git a/mm/mlock.c b/mm/mlock.c
index 97e49038d8d3..34ffa954006f 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -699,26 +699,27 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
/*
* Take the MCL_* flags passed into mlockall (or 0 if called from munlockall)
- * and translate into the appropriate modifications to mm->def_flags and/or the
- * flags for all current VMAs.
+ * and translate into the appropriate modifications to mm->def_vma_flags and/or
+ * the flags for all current VMAs.
*
* There are a couple of subtleties with this. If mlockall() is called multiple
* times with different flags, the values do not necessarily stack. If mlockall
* is called once including the MCL_FUTURE flag and then a second time without
- * it, VM_LOCKED and VM_LOCKONFAULT will be cleared from mm->def_flags.
+ * it, VM_LOCKED and VM_LOCKONFAULT will be cleared from mm->def_vma_flags.
*/
static int apply_mlockall_flags(int flags)
{
VMA_ITERATOR(vmi, current->mm, 0);
+ struct mm_struct *mm = current->mm;
struct vm_area_struct *vma, *prev = NULL;
vm_flags_t to_add = 0;
- current->mm->def_flags &= ~VM_LOCKED_MASK;
+ vma_flags_clear_mask(&mm->def_vma_flags, VMA_LOCKED_MASK);
if (flags & MCL_FUTURE) {
- current->mm->def_flags |= VM_LOCKED;
+ vma_flags_set(&mm->def_vma_flags, VMA_LOCKED_BIT);
if (flags & MCL_ONFAULT)
- current->mm->def_flags |= VM_LOCKONFAULT;
+ vma_flags_set(&mm->def_vma_flags, VMA_LOCKONFAULT_BIT);
if (!(flags & MCL_CURRENT))
goto out;
diff --git a/mm/mmap.c b/mm/mmap.c
index 39d33f3a55c2..ae9a5018e20e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -102,15 +102,16 @@ void vma_set_page_prot(struct vm_area_struct *vma)
*/
static int check_brk_limits(unsigned long addr, unsigned long len)
{
+ const struct mm_struct *mm = current->mm;
+ const bool is_def_locked =
+ vma_flags_test(&mm->def_vma_flags, VMA_LOCKED_BIT);
unsigned long mapped_addr;
mapped_addr = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
if (IS_ERR_VALUE(mapped_addr))
return mapped_addr;
- return mlock_future_ok(current->mm,
- current->mm->def_flags & VM_LOCKED, len)
- ? 0 : -EAGAIN;
+ return mlock_future_ok(mm, is_def_locked, len) ? 0 : -EAGAIN;
}
SYSCALL_DEFINE1(brk, unsigned long, brk)
@@ -197,7 +198,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
goto out;
mm->brk = brk;
- if (mm->def_flags & VM_LOCKED)
+ if (vma_flags_test(&mm->def_vma_flags, VMA_LOCKED_BIT))
populate = true;
success:
@@ -1247,7 +1248,7 @@ int vm_brk_flags(unsigned long addr, unsigned long request, bool is_exec)
vma = vma_prev(&vmi);
ret = do_brk_flags(&vmi, vma, addr, len, vma_flags);
- populate = ((mm->def_flags & VM_LOCKED) != 0);
+ populate = vma_flags_test(&mm->def_vma_flags, VMA_LOCKED_BIT);
mmap_write_unlock(mm);
userfaultfd_unmap_complete(mm, &uf);
if (populate && !ret)
diff --git a/mm/vma.c b/mm/vma.c
index 70b08c76ea2f..1f443d979a7d 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -3426,7 +3426,7 @@ struct vm_area_struct *__install_special_mapping(
if (unlikely(vma == NULL))
return ERR_PTR(-ENOMEM);
- vm_flags |= mm->def_flags | VM_DONTEXPAND;
+ vm_flags |= vma_flags_to_legacy(mm->def_vma_flags) | VM_DONTEXPAND;
if (pgtable_supports_soft_dirty())
vm_flags |= VM_SOFTDIRTY;
vm_flags_init(vma, vm_flags & ~VM_LOCKED_MASK);
--
2.55.0
^ permalink raw reply related
* [PATCH v2 04/13] mm: update generic_get_unmapped_area[_topdown]() to use vma_flags_t
From: Lorenzo Stoakes @ 2026-07-11 18:45 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Thomas Bogendoerfer, Benjamin LaHaise, Alexander Viro,
Christian Brauner, Jan Kara, Hugh Dickins, Baolin Wang, Jann Horn,
Pedro Falcato, Muchun Song, Oscar Salvador, Zi Yan, Nico Pache,
Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Usama Arif,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Lucas Stach,
Russell King, Christian Gmeiner, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Tomi Valkeinen, Sandy Huang, Heiko Stübner, Andy Yan,
Thierry Reding, Mikko Perttunen, Jonathan Hunter, Gerd Hoffmann,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Matthew Brost,
Thomas Hellström, Oleksandr Andrushchenko, Helge Deller,
Kees Cook, Jaroslav Kysela, Takashi Iwai, Boris Brezillon,
Steven Price, Liviu Dudau
Cc: Lorenzo Stoakes, linux-mm, linux-kernel, linux-mips, linux-aio,
linux-fsdevel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-sound
In-Reply-To: <20260711-b4-vma-flags-mm-v2-0-0fa2357d5431@kernel.org>
As part of the changes converting VMA flags from a system word size to a
bitmap, extend this change to generic_get_unmapped_area() and
generic_get_unmapped_area_topdown(), which also allows us to convert
stack_guard_placement() as well.
We retain arch_get_unmapped_area() and arch_get_unmapped_area_topdown()
as-is for now, using legacy_to_vma_flags() as necessary to do so.
No functional change intended.
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
---
arch/powerpc/mm/book3s64/slice.c | 6 ++++--
include/linux/sched/mm.h | 4 ++--
mm/mmap.c | 16 ++++++++--------
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c
index 28bec5bc7879..82127e31dca6 100644
--- a/arch/powerpc/mm/book3s64/slice.c
+++ b/arch/powerpc/mm/book3s64/slice.c
@@ -659,7 +659,8 @@ unsigned long arch_get_unmapped_area(struct file *filp,
unsigned int psize;
if (radix_enabled())
- return generic_get_unmapped_area(filp, addr, len, pgoff, flags, vm_flags);
+ return generic_get_unmapped_area(filp, addr, len, pgoff, flags,
+ legacy_to_vma_flags(vm_flags));
if (filp && is_file_hugepages(filp))
psize = file_to_psize(filp);
@@ -679,7 +680,8 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp,
unsigned int psize;
if (radix_enabled())
- return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags, vm_flags);
+ return generic_get_unmapped_area_topdown(filp, addr0, len,
+ pgoff, flags, legacy_to_vma_flags(vm_flags));
if (filp && is_file_hugepages(filp))
psize = file_to_psize(filp);
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index 10d723bee95c..10be8a54b416 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -200,11 +200,11 @@ unsigned long mm_get_unmapped_area_vmaflags(struct file *filp,
unsigned long
generic_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff,
- unsigned long flags, vm_flags_t vm_flags);
+ unsigned long flags, vma_flags_t vma_flags);
unsigned long
generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff,
- unsigned long flags, vm_flags_t vm_flags);
+ unsigned long flags, vma_flags_t vma_flags);
#else
static inline void arch_pick_mmap_layout(struct mm_struct *mm,
const struct rlimit *rlim_stack) {}
diff --git a/mm/mmap.c b/mm/mmap.c
index 4a88b2a233f7..39d33f3a55c2 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -657,9 +657,9 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg)
* Determine if the allocation needs to ensure that there is no
* existing mapping within it's guard gaps, for use as start_gap.
*/
-static inline unsigned long stack_guard_placement(vm_flags_t vm_flags)
+static inline unsigned long stack_guard_placement(vma_flags_t vma_flags)
{
- if (vm_flags & VM_SHADOW_STACK)
+ if (vma_flags_test_single_mask(&vma_flags, VMA_SHADOW_STACK))
return PAGE_SIZE;
return 0;
@@ -701,7 +701,7 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info)
unsigned long
generic_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff,
- unsigned long flags, vm_flags_t vm_flags)
+ unsigned long flags, vma_flags_t vma_flags)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma, *prev;
@@ -726,7 +726,7 @@ generic_get_unmapped_area(struct file *filp, unsigned long addr,
info.length = len;
info.low_limit = mm->mmap_base;
info.high_limit = mmap_end;
- info.start_gap = stack_guard_placement(vm_flags);
+ info.start_gap = stack_guard_placement(vma_flags);
if (filp && is_file_hugepages(filp))
info.align_mask = huge_page_mask_align(filp);
return vm_unmapped_area(&info);
@@ -739,7 +739,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long flags, vm_flags_t vm_flags)
{
return generic_get_unmapped_area(filp, addr, len, pgoff, flags,
- vm_flags);
+ legacy_to_vma_flags(vm_flags));
}
#endif
@@ -750,7 +750,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long
generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff,
- unsigned long flags, vm_flags_t vm_flags)
+ unsigned long flags, vma_flags_t vma_flags)
{
struct vm_area_struct *vma, *prev;
struct mm_struct *mm = current->mm;
@@ -778,7 +778,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
info.length = len;
info.low_limit = PAGE_SIZE;
info.high_limit = arch_get_mmap_base(addr, mm->mmap_base);
- info.start_gap = stack_guard_placement(vm_flags);
+ info.start_gap = stack_guard_placement(vma_flags);
if (filp && is_file_hugepages(filp))
info.align_mask = huge_page_mask_align(filp);
addr = vm_unmapped_area(&info);
@@ -807,7 +807,7 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
unsigned long flags, vm_flags_t vm_flags)
{
return generic_get_unmapped_area_topdown(filp, addr, len, pgoff, flags,
- vm_flags);
+ legacy_to_vma_flags(vm_flags));
}
#endif
--
2.55.0
^ permalink raw reply related
* [PATCH v2 03/13] mm: convert __get_unmapped_area() to use vma_flags_t
From: Lorenzo Stoakes @ 2026-07-11 18:45 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Thomas Bogendoerfer, Benjamin LaHaise, Alexander Viro,
Christian Brauner, Jan Kara, Hugh Dickins, Baolin Wang, Jann Horn,
Pedro Falcato, Muchun Song, Oscar Salvador, Zi Yan, Nico Pache,
Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Usama Arif,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Lucas Stach,
Russell King, Christian Gmeiner, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Tomi Valkeinen, Sandy Huang, Heiko Stübner, Andy Yan,
Thierry Reding, Mikko Perttunen, Jonathan Hunter, Gerd Hoffmann,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Matthew Brost,
Thomas Hellström, Oleksandr Andrushchenko, Helge Deller,
Kees Cook, Jaroslav Kysela, Takashi Iwai, Boris Brezillon,
Steven Price, Liviu Dudau
Cc: Lorenzo Stoakes, linux-mm, linux-kernel, linux-mips, linux-aio,
linux-fsdevel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-sound
In-Reply-To: <20260711-b4-vma-flags-mm-v2-0-0fa2357d5431@kernel.org>
Update __get_unmapped_area() to be parameterised by vma_flags_t rather than
vm_flags_t as part of the effort to move VMA flags from a system word to a
bitmap.
We cascade the changes up to arch_get_unmapped_area_topdown() and
arch_get_unmapped_area(), where, for now, we use vma_flags_to_legacy() in
order to propagate the VMA flags.
No functional change intended.
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
---
fs/hugetlbfs/inode.c | 3 ++-
include/linux/huge_mm.h | 10 +++++-----
include/linux/mm.h | 6 ++++--
include/linux/sched/mm.h | 9 +++------
mm/huge_memory.c | 21 ++++++++++++---------
mm/mmap.c | 27 ++++++++++++++-------------
6 files changed, 40 insertions(+), 36 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 9fddd1e0b813..43066f9ddf52 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -184,7 +184,8 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
if (addr)
addr0 = ALIGN(addr, huge_page_size(h));
- return mm_get_unmapped_area_vmflags(file, addr0, len, pgoff, flags, 0);
+ return mm_get_unmapped_area_vmaflags(file, addr0, len, pgoff, flags,
+ EMPTY_VMA_FLAGS);
}
/*
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index cae97c307280..9e43e138c0b7 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -391,9 +391,9 @@ static inline bool thp_disabled_by_hw(void)
unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags);
-unsigned long thp_get_unmapped_area_vmflags(struct file *filp, unsigned long addr,
+unsigned long thp_get_unmapped_area_vmaflags(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags,
- vm_flags_t vm_flags);
+ vma_flags_t vma_flags);
enum split_type {
SPLIT_TYPE_UNIFORM,
@@ -617,9 +617,9 @@ static inline unsigned long thp_vma_allowable_orders(struct vm_area_struct *vma,
#define thp_get_unmapped_area NULL
static inline unsigned long
-thp_get_unmapped_area_vmflags(struct file *filp, unsigned long addr,
- unsigned long len, unsigned long pgoff,
- unsigned long flags, vm_flags_t vm_flags)
+thp_get_unmapped_area_vmaflags(struct file *filp, unsigned long addr,
+ unsigned long len, unsigned long pgoff,
+ unsigned long flags, vma_flags_t vma_flags)
{
return 0;
}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index d20aa2f80472..5b3825fddf58 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4191,13 +4191,15 @@ unsigned long randomize_page(unsigned long start, unsigned long range);
unsigned long
__get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
- unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags);
+ unsigned long pgoff, unsigned long flags,
+ vma_flags_t vma_flags);
static inline unsigned long
get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
unsigned long pgoff, unsigned long flags)
{
- return __get_unmapped_area(file, addr, len, pgoff, flags, 0);
+ return __get_unmapped_area(file, addr, len, pgoff, flags,
+ EMPTY_VMA_FLAGS);
}
unsigned long do_mmap(struct file *file, unsigned long addr,
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index 95d0040df584..10d723bee95c 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -193,12 +193,9 @@ unsigned long mm_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff,
unsigned long flags);
-unsigned long mm_get_unmapped_area_vmflags(struct file *filp,
- unsigned long addr,
- unsigned long len,
- unsigned long pgoff,
- unsigned long flags,
- vm_flags_t vm_flags);
+unsigned long mm_get_unmapped_area_vmaflags(struct file *filp,
+ unsigned long addr, unsigned long len, unsigned long pgoff,
+ unsigned long flags, vma_flags_t vma_flags);
unsigned long
generic_get_unmapped_area(struct file *filp, unsigned long addr,
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 0dc6d630570f..40d6b4078e3d 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1196,7 +1196,7 @@ static inline bool is_transparent_hugepage(const struct folio *folio)
static unsigned long __thp_get_unmapped_area(struct file *filp,
unsigned long addr, unsigned long len,
loff_t off, unsigned long flags, unsigned long size,
- vm_flags_t vm_flags)
+ vma_flags_t vma_flags)
{
loff_t off_end = off + len;
loff_t off_align = round_up(off, size);
@@ -1212,8 +1212,9 @@ static unsigned long __thp_get_unmapped_area(struct file *filp,
if (len_pad < len || (off + len_pad) < off)
return 0;
- ret = mm_get_unmapped_area_vmflags(filp, addr, len_pad,
- off >> PAGE_SHIFT, flags, vm_flags);
+ ret = mm_get_unmapped_area_vmaflags(filp, addr, len_pad,
+ off >> PAGE_SHIFT, flags,
+ vma_flags);
/*
* The failure might be due to length padding. The caller will retry
@@ -1238,25 +1239,27 @@ static unsigned long __thp_get_unmapped_area(struct file *filp,
return ret;
}
-unsigned long thp_get_unmapped_area_vmflags(struct file *filp, unsigned long addr,
+unsigned long thp_get_unmapped_area_vmaflags(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags,
- vm_flags_t vm_flags)
+ vma_flags_t vma_flags)
{
unsigned long ret;
loff_t off = (loff_t)pgoff << PAGE_SHIFT;
- ret = __thp_get_unmapped_area(filp, addr, len, off, flags, PMD_SIZE, vm_flags);
+ ret = __thp_get_unmapped_area(filp, addr, len, off, flags, PMD_SIZE,
+ vma_flags);
if (ret)
return ret;
- return mm_get_unmapped_area_vmflags(filp, addr, len, pgoff, flags,
- vm_flags);
+ return mm_get_unmapped_area_vmaflags(filp, addr, len, pgoff, flags,
+ vma_flags);
}
unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
{
- return thp_get_unmapped_area_vmflags(filp, addr, len, pgoff, flags, 0);
+ return thp_get_unmapped_area_vmaflags(filp, addr, len, pgoff, flags,
+ EMPTY_VMA_FLAGS);
}
EXPORT_SYMBOL_GPL(thp_get_unmapped_area);
diff --git a/mm/mmap.c b/mm/mmap.c
index bcc3793e532d..4a88b2a233f7 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -411,8 +411,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
/* Obtain the address to map to. we verify (or select) it and ensure
* that it represents a valid section of the address space.
*/
- addr = __get_unmapped_area(file, addr, len, pgoff, flags,
- vma_flags_to_legacy(vma_flags));
+ addr = __get_unmapped_area(file, addr, len, pgoff, flags, vma_flags);
if (IS_ERR_VALUE(addr))
return addr;
@@ -812,19 +811,20 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
}
#endif
-unsigned long mm_get_unmapped_area_vmflags(struct file *filp, unsigned long addr,
- unsigned long len, unsigned long pgoff,
- unsigned long flags, vm_flags_t vm_flags)
+unsigned long mm_get_unmapped_area_vmaflags(struct file *filp, unsigned long addr,
+ unsigned long len, unsigned long pgoff, unsigned long flags,
+ vma_flags_t vma_flags)
{
if (mm_flags_test(MMF_TOPDOWN, current->mm))
return arch_get_unmapped_area_topdown(filp, addr, len, pgoff,
- flags, vm_flags);
- return arch_get_unmapped_area(filp, addr, len, pgoff, flags, vm_flags);
+ flags, vma_flags_to_legacy(vma_flags));
+ return arch_get_unmapped_area(filp, addr, len, pgoff, flags,
+ vma_flags_to_legacy(vma_flags));
}
unsigned long
__get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
- unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags)
+ unsigned long pgoff, unsigned long flags, vma_flags_t vma_flags)
{
unsigned long (*get_area)(struct file *, unsigned long,
unsigned long, unsigned long, unsigned long)
@@ -859,11 +859,11 @@ __get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
&& !addr /* no hint */
&& IS_ALIGNED(len, PMD_SIZE)) {
/* Ensures that larger anonymous mappings are THP aligned. */
- addr = thp_get_unmapped_area_vmflags(file, addr, len,
- pgoff, flags, vm_flags);
+ addr = thp_get_unmapped_area_vmaflags(file, addr, len,
+ pgoff, flags, vma_flags);
} else {
- addr = mm_get_unmapped_area_vmflags(file, addr, len,
- pgoff, flags, vm_flags);
+ addr = mm_get_unmapped_area_vmaflags(file, addr, len,
+ pgoff, flags, vma_flags);
}
if (IS_ERR_VALUE(addr))
return addr;
@@ -881,7 +881,8 @@ unsigned long
mm_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
unsigned long pgoff, unsigned long flags)
{
- return mm_get_unmapped_area_vmflags(file, addr, len, pgoff, flags, 0);
+ return mm_get_unmapped_area_vmaflags(file, addr, len, pgoff, flags,
+ EMPTY_VMA_FLAGS);
}
EXPORT_SYMBOL(mm_get_unmapped_area);
--
2.55.0
^ permalink raw reply related
* [PATCH v2 02/13] mm/vma: update do_mmap() to use vma_flags_t
From: Lorenzo Stoakes @ 2026-07-11 18:44 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Thomas Bogendoerfer, Benjamin LaHaise, Alexander Viro,
Christian Brauner, Jan Kara, Hugh Dickins, Baolin Wang, Jann Horn,
Pedro Falcato, Muchun Song, Oscar Salvador, Zi Yan, Nico Pache,
Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Usama Arif,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Lucas Stach,
Russell King, Christian Gmeiner, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Tomi Valkeinen, Sandy Huang, Heiko Stübner, Andy Yan,
Thierry Reding, Mikko Perttunen, Jonathan Hunter, Gerd Hoffmann,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Matthew Brost,
Thomas Hellström, Oleksandr Andrushchenko, Helge Deller,
Kees Cook, Jaroslav Kysela, Takashi Iwai, Boris Brezillon,
Steven Price, Liviu Dudau
Cc: Lorenzo Stoakes, linux-mm, linux-kernel, linux-mips, linux-aio,
linux-fsdevel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-sound
In-Reply-To: <20260711-b4-vma-flags-mm-v2-0-0fa2357d5431@kernel.org>
The core do_mmap() function accepts a vm_flags_t parameter which it then
manipulates before passing to mmap_region() to do the heavy lifting of the
memory mapping.
Update do_mmap() to instead accept a vma_flags_t parameter, and adjust all
the logic within do_mmap() to manipulate this instead.
This is as part of the ongoing effort to convert VMA flags from a system
word size to a bitmap type which allows us to unrestrict the number of VMA
flags, as well as gain control over how VMA flag manipulation occurs.
We do not cascade these changes to all functions which accept vm_flags_t,
but rather use vma_flags_to_legacy() where necessary, specifically
deferring converting calc_vm_prot_bits(), calc_vm_flag_bits() and
__get_unmapped_area() to vma_flags_t.
Also utilise the new vma_flags_can_grow() predicate which correctly handles
the case of architectures without upward growing stacks.
As part of this change, introduce VMA_SHADOW_STACK so we can correctly
handle the case of the shadow stack not being defined.
No functional change intended.
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
---
arch/mips/kernel/vdso.c | 4 +--
fs/aio.c | 2 +-
include/linux/memfd.h | 6 ++---
include/linux/mm.h | 6 +++--
ipc/shm.c | 3 ++-
mm/memfd.c | 15 +++++------
mm/mmap.c | 67 +++++++++++++++++++++++++++++--------------------
mm/nommu.c | 3 ++-
mm/util.c | 10 ++++----
mm/vma.c | 7 +++---
mm/vma.h | 2 +-
11 files changed, 69 insertions(+), 56 deletions(-)
diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index bd1fc17d3975..94873775fc0f 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -91,8 +91,8 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
/* Map delay slot emulation page */
base = do_mmap(NULL, STACK_TOP, PAGE_SIZE, PROT_READ | PROT_EXEC,
- MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, 0, 0, &unused,
- NULL);
+ MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED,
+ EMPTY_VMA_FLAGS, 0, &unused, NULL);
if (IS_ERR_VALUE(base)) {
ret = base;
goto out;
diff --git a/fs/aio.c b/fs/aio.c
index f57fa21a2503..3de586da197b 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -604,7 +604,7 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events)
ctx->mmap_base = do_mmap(ctx->aio_ring_file, 0, ctx->mmap_size,
PROT_READ | PROT_WRITE,
- MAP_SHARED, 0, 0, &unused, NULL);
+ MAP_SHARED, EMPTY_VMA_FLAGS, 0, &unused, NULL);
mmap_write_unlock(mm);
if (IS_ERR((void *)ctx->mmap_base)) {
ctx->mmap_size = 0;
diff --git a/include/linux/memfd.h b/include/linux/memfd.h
index b4fda09dab9f..c159e40e3f34 100644
--- a/include/linux/memfd.h
+++ b/include/linux/memfd.h
@@ -14,9 +14,9 @@ struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx);
* to sealing, or 0 otherwise.
*
* We also update VMA flags if appropriate by manipulating the VMA flags pointed
- * to by vm_flags_ptr.
+ * to by vma_flags_ptr.
*/
-int memfd_check_seals_mmap(struct file *file, vm_flags_t *vm_flags_ptr);
+int memfd_check_seals_mmap(struct file *file, vma_flags_t *vma_flags_ptr);
struct file *memfd_alloc_file(const char *name, unsigned int flags);
int memfd_get_seals(struct file *file);
int memfd_add_seals(struct file *file, unsigned int seals);
@@ -30,7 +30,7 @@ static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)
return ERR_PTR(-EINVAL);
}
static inline int memfd_check_seals_mmap(struct file *file,
- vm_flags_t *vm_flags_ptr)
+ vma_flags_t *vma_flags_ptr)
{
return 0;
}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7a7f559b3df0..d20aa2f80472 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -465,9 +465,11 @@ enum {
#if defined(CONFIG_X86_USER_SHADOW_STACK) || defined(CONFIG_ARM64_GCS) || \
defined(CONFIG_RISCV_USER_CFI)
#define VM_SHADOW_STACK INIT_VM_FLAG(SHADOW_STACK)
+#define VMA_SHADOW_STACK mk_vma_flags(VMA_SHADOW_STACK_BIT)
#define VMA_STARTGAP_FLAGS mk_vma_flags(VMA_GROWSDOWN_BIT, VMA_SHADOW_STACK_BIT)
#else
#define VM_SHADOW_STACK VM_NONE
+#define VMA_SHADOW_STACK EMPTY_VMA_FLAGS
#define VMA_STARTGAP_FLAGS mk_vma_flags(VMA_GROWSDOWN_BIT)
#endif
#if defined(CONFIG_PPC64)
@@ -4198,9 +4200,9 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
return __get_unmapped_area(file, addr, len, pgoff, flags, 0);
}
-extern unsigned long do_mmap(struct file *file, unsigned long addr,
+unsigned long do_mmap(struct file *file, unsigned long addr,
unsigned long len, unsigned long prot, unsigned long flags,
- vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate,
+ vma_flags_t vma_flags, unsigned long pgoff, unsigned long *populate,
struct list_head *uf);
extern int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm,
unsigned long start, size_t len, struct list_head *uf,
diff --git a/ipc/shm.c b/ipc/shm.c
index b3e8a58e177d..bb1a721a3e74 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -1661,7 +1661,8 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
goto invalid;
}
- addr = do_mmap(file, addr, size, prot, flags, 0, 0, &populate, NULL);
+ addr = do_mmap(file, addr, size, prot, flags, EMPTY_VMA_FLAGS, 0,
+ &populate, NULL);
*raddr = addr;
err = 0;
if (IS_ERR_VALUE(addr))
diff --git a/mm/memfd.c b/mm/memfd.c
index 6c72fe6caef7..c708d92533f4 100644
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -370,39 +370,36 @@ static inline bool is_write_sealed(unsigned int seals)
return seals & (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE);
}
-static int check_write_seal(vm_flags_t *vm_flags_ptr)
+static int check_write_seal(vma_flags_t *vma_flags_ptr)
{
- vm_flags_t vm_flags = *vm_flags_ptr;
- vm_flags_t mask = vm_flags & (VM_SHARED | VM_WRITE);
-
/* If a private mapping then writability is irrelevant. */
- if (!(mask & VM_SHARED))
+ if (!vma_flags_test(vma_flags_ptr, VMA_SHARED_BIT))
return 0;
/*
* New PROT_WRITE and MAP_SHARED mmaps are not allowed when
* write seals are active.
*/
- if (mask & VM_WRITE)
+ if (vma_flags_test(vma_flags_ptr, VMA_WRITE_BIT))
return -EPERM;
/*
* This is a read-only mapping, disallow mprotect() from making a
* write-sealed mapping writable in future.
*/
- *vm_flags_ptr &= ~VM_MAYWRITE;
+ vma_flags_clear(vma_flags_ptr, VMA_MAYWRITE_BIT);
return 0;
}
-int memfd_check_seals_mmap(struct file *file, vm_flags_t *vm_flags_ptr)
+int memfd_check_seals_mmap(struct file *file, vma_flags_t *vma_flags_ptr)
{
int err = 0;
unsigned int *seals_ptr = memfd_file_seals_ptr(file);
unsigned int seals = seals_ptr ? *seals_ptr : 0;
if (is_write_sealed(seals))
- err = check_write_seal(vm_flags_ptr);
+ err = check_write_seal(vma_flags_ptr);
return err;
}
diff --git a/mm/mmap.c b/mm/mmap.c
index 308a43eabd83..bcc3793e532d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -280,7 +280,7 @@ static inline bool file_mmap_ok(struct file *file, struct inode *inode,
* do_mmap() - Perform a userland memory mapping into the current process
* address space of length @len with protection bits @prot, mmap flags @flags
* (from which VMA flags will be inferred), and any additional VMA flags to
- * apply @vm_flags. If this is a file-backed mapping then the file is specified
+ * apply @vma_flags. If this is a file-backed mapping then the file is specified
* in @file and page offset into the file via @pgoff.
*
* This function does not perform security checks on the file and assumes, if
@@ -320,7 +320,8 @@ static inline bool file_mmap_ok(struct file *file, struct inode *inode,
* (2) for details.
* @flags: Flags specifying how the mapping should be performed, see mmap (2)
* for details.
- * @vm_flags: VMA flags which should be set by default, or 0 otherwise.
+ * @vma_flags: VMA flags which should be set by default, or EMPTY_VMA_FLAGS
+ * otherwise.
* @pgoff: Page offset into the @file if file-backed, should be 0 otherwise.
* @populate: A pointer to a value which will be set to 0 if no population of
* the range is required, or the number of bytes to populate if it is. Must be
@@ -335,7 +336,7 @@ static inline bool file_mmap_ok(struct file *file, struct inode *inode,
*/
unsigned long do_mmap(struct file *file, unsigned long addr,
unsigned long len, unsigned long prot,
- unsigned long flags, vm_flags_t vm_flags,
+ unsigned long flags, vma_flags_t vma_flags,
unsigned long pgoff, unsigned long *populate,
struct list_head *uf)
{
@@ -399,13 +400,19 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
* to. we assume access permissions have been handled by the open
* of the memory object, so we don't do any here.
*/
- vm_flags |= calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(file, flags) |
- mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
+ vma_flags_set_mask(&vma_flags,
+ legacy_to_vma_flags(calc_vm_prot_bits(prot, pkey)));
+ vma_flags_set_mask(&vma_flags,
+ legacy_to_vma_flags(calc_vm_flag_bits(file, flags)));
+ vma_flags_set_mask(&vma_flags, mm->def_vma_flags);
+ vma_flags_set(&vma_flags, VMA_MAYREAD_BIT, VMA_MAYWRITE_BIT,
+ VMA_MAYEXEC_BIT);
/* Obtain the address to map to. we verify (or select) it and ensure
* that it represents a valid section of the address space.
*/
- addr = __get_unmapped_area(file, addr, len, pgoff, flags, vm_flags);
+ addr = __get_unmapped_area(file, addr, len, pgoff, flags,
+ vma_flags_to_legacy(vma_flags));
if (IS_ERR_VALUE(addr))
return addr;
@@ -418,7 +425,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
if (!can_do_mlock())
return -EPERM;
- if (!mlock_future_ok(mm, vm_flags & VM_LOCKED, len))
+ if (!mlock_future_ok(mm, vma_flags_test(&vma_flags, VMA_LOCKED_BIT), len))
return -EAGAIN;
if (file) {
@@ -461,22 +468,23 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
if (IS_APPEND(inode) && (file->f_mode & FMODE_WRITE))
return -EACCES;
- vm_flags |= VM_SHARED | VM_MAYSHARE;
+ vma_flags_set(&vma_flags, VMA_SHARED_BIT, VMA_MAYSHARE_BIT);
if (!(file->f_mode & FMODE_WRITE))
- vm_flags &= ~(VM_MAYWRITE | VM_SHARED);
+ vma_flags_clear(&vma_flags, VMA_MAYWRITE_BIT,
+ VMA_SHARED_BIT);
fallthrough;
case MAP_PRIVATE:
if (!(file->f_mode & FMODE_READ))
return -EACCES;
if (path_noexec(&file->f_path)) {
- if (vm_flags & VM_EXEC)
+ if (vma_flags_test(&vma_flags, VMA_EXEC_BIT))
return -EPERM;
- vm_flags &= ~VM_MAYEXEC;
+ vma_flags_clear(&vma_flags, VMA_MAYEXEC_BIT);
}
if (!can_mmap_file(file))
return -ENODEV;
- if (vm_flags & (VM_GROWSDOWN|VM_GROWSUP))
+ if (vma_flags_can_grow(&vma_flags))
return -EINVAL;
break;
@@ -488,23 +496,27 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
* Check to see if we are violating any seals and update VMA
* flags if necessary to avoid future seal violations.
*/
- err = memfd_check_seals_mmap(file, &vm_flags);
+ err = memfd_check_seals_mmap(file, &vma_flags);
if (err)
return (unsigned long)err;
} else {
switch (flags & MAP_TYPE) {
case MAP_SHARED:
- if (vm_flags & (VM_GROWSDOWN|VM_GROWSUP))
+ if (vma_flags_can_grow(&vma_flags))
return -EINVAL;
/*
* Ignore pgoff.
*/
pgoff = 0;
- vm_flags |= VM_SHARED | VM_MAYSHARE;
+ vma_flags_set(&vma_flags, VMA_SHARED_BIT, VMA_MAYSHARE_BIT);
break;
- case MAP_DROPPABLE:
- if (VM_DROPPABLE == VM_NONE)
+ case MAP_DROPPABLE: {
+ vma_flags_t droppable = VMA_DROPPABLE;
+
+ if (vma_flags_empty(&droppable))
return -EOPNOTSUPP;
+ vma_flags_set_mask(&vma_flags, droppable);
+
/*
* A locked or stack area makes no sense to be droppable.
*
@@ -515,23 +527,24 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
*/
if (flags & (MAP_LOCKED | MAP_HUGETLB))
return -EINVAL;
- if (vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
+ if (vma_flags_can_grow(&vma_flags))
return -EINVAL;
- vm_flags |= VM_DROPPABLE;
-
/*
* If the pages can be dropped, then it doesn't make
* sense to reserve them.
*/
- vm_flags |= VM_NORESERVE;
+ vma_flags_set(&vma_flags, VMA_NORESERVE_BIT);
/*
* Likewise, they're volatile enough that they
* shouldn't survive forks or coredumps.
*/
- vm_flags |= VM_WIPEONFORK | VM_DONTDUMP;
+ vma_flags_set(&vma_flags, VMA_WIPEONFORK_BIT,
+ VMA_DONTDUMP_BIT);
+
fallthrough;
+ }
case MAP_PRIVATE:
/*
* Set pgoff according to addr for anon_vma.
@@ -550,16 +563,16 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
if (flags & MAP_NORESERVE) {
/* We honor MAP_NORESERVE if allowed to overcommit */
if (sysctl_overcommit_memory != OVERCOMMIT_NEVER)
- vm_flags |= VM_NORESERVE;
+ vma_flags_set(&vma_flags, VMA_NORESERVE_BIT);
/* hugetlb applies strict overcommit unless MAP_NORESERVE */
if (file && is_file_hugepages(file))
- vm_flags |= VM_NORESERVE;
+ vma_flags_set(&vma_flags, VMA_NORESERVE_BIT);
}
- addr = mmap_region(file, addr, len, vm_flags, pgoff, uf);
+ addr = mmap_region(file, addr, len, vma_flags, pgoff, uf);
if (!IS_ERR_VALUE(addr) &&
- ((vm_flags & VM_LOCKED) ||
+ (vma_flags_test(&vma_flags, VMA_LOCKED_BIT) ||
(flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE))
*populate = len;
return addr;
@@ -1191,7 +1204,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
}
ret = do_mmap(vma->vm_file, start, size,
- prot, flags, 0, pgoff, &populate, NULL);
+ prot, flags, EMPTY_VMA_FLAGS, pgoff, &populate, NULL);
out:
mmap_write_unlock(mm);
fput(file);
diff --git a/mm/nommu.c b/mm/nommu.c
index adc0b0ca906b..498e01ee40b0 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1014,11 +1014,12 @@ unsigned long do_mmap(struct file *file,
unsigned long len,
unsigned long prot,
unsigned long flags,
- vm_flags_t vm_flags,
+ vma_flags_t vma_flags,
unsigned long pgoff,
unsigned long *populate,
struct list_head *uf)
{
+ vm_flags_t vm_flags = vma_flags_to_legacy(vma_flags);
struct vm_area_struct *vma;
struct vm_region *region;
struct rb_node *rb;
diff --git a/mm/util.c b/mm/util.c
index 5090457542ca..bf0513d1d3d0 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -578,8 +578,8 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr,
if (!ret) {
if (mmap_write_lock_killable(mm))
return -EINTR;
- ret = do_mmap(file, addr, len, prot, flag, 0, pgoff, &populate,
- &uf);
+ ret = do_mmap(file, addr, len, prot, flag, EMPTY_VMA_FLAGS, pgoff,
+ &populate, &uf);
mmap_write_unlock(mm);
userfaultfd_unmap_complete(mm, &uf);
if (populate)
@@ -627,20 +627,20 @@ EXPORT_SYMBOL(vm_mmap);
unsigned long vm_mmap_shadow_stack(unsigned long addr, unsigned long len,
unsigned long flags)
{
+ vma_flags_t vma_flags = VMA_SHADOW_STACK;
struct mm_struct *mm = current->mm;
unsigned long ret, unused;
- vm_flags_t vm_flags = VM_SHADOW_STACK;
flags |= MAP_ANONYMOUS | MAP_PRIVATE;
if (addr)
flags |= MAP_FIXED_NOREPLACE;
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
- vm_flags |= VM_NOHUGEPAGE;
+ vma_flags_set(&vma_flags, VMA_NOHUGEPAGE_BIT);
mmap_write_lock(mm);
ret = do_mmap(NULL, addr, len, PROT_READ | PROT_WRITE, flags,
- vm_flags, 0, &unused, NULL);
+ vma_flags, 0, &unused, NULL);
mmap_write_unlock(mm);
return ret;
diff --git a/mm/vma.c b/mm/vma.c
index 9d556d33b24b..70b08c76ea2f 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -2883,7 +2883,7 @@ static unsigned long __mmap_region(struct file *file, unsigned long addr,
* file to be mapped, otherwise NULL.
* @addr: The page-aligned address at which to perform the mapping.
* @len: The page-aligned, non-zero, length of the mapping.
- * @vm_flags: The VMA flags which should be applied to the mapping.
+ * @vma_flags: The VMA flags which should be applied to the mapping.
* @pgoff: If @file is specified, the page offset into the file, if not then
* the virtual page offset in memory of the anonymous mapping.
* @uf: Optionally, a pointer to a list head used for tracking userfaultfd unmap
@@ -2893,12 +2893,11 @@ static unsigned long __mmap_region(struct file *file, unsigned long addr,
* been performed.
*/
unsigned long mmap_region(struct file *file, unsigned long addr,
- unsigned long len, vm_flags_t vm_flags,
+ unsigned long len, vma_flags_t vma_flags,
unsigned long pgoff, struct list_head *uf)
{
unsigned long ret;
bool writable_file_mapping = false;
- const vma_flags_t vma_flags = legacy_to_vma_flags(vm_flags);
mmap_assert_write_locked(current->mm);
@@ -2907,7 +2906,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
return -EACCES;
/* Allow architectures to sanity-check the vm_flags. */
- if (!arch_validate_flags(vm_flags))
+ if (!arch_validate_flags(vma_flags_to_legacy(vma_flags)))
return -EINVAL;
/* Map writable and ensure this isn't a sealed memfd. */
diff --git a/mm/vma.h b/mm/vma.h
index adb7a0ba1192..4eb85b4a6adc 100644
--- a/mm/vma.h
+++ b/mm/vma.h
@@ -517,7 +517,7 @@ int mm_take_all_locks(struct mm_struct *mm);
void mm_drop_all_locks(struct mm_struct *mm);
unsigned long mmap_region(struct file *file, unsigned long addr,
- unsigned long len, vm_flags_t vm_flags, unsigned long pgoff,
+ unsigned long len, vma_flags_t vma_flags, unsigned long pgoff,
struct list_head *uf);
int do_brk_flags(struct vma_iterator *vmi, struct vm_area_struct *brkvma,
--
2.55.0
^ permalink raw reply related
* [PATCH v2 01/13] mm: introduce vma_flags_can_grow() and vma_can_grow()
From: Lorenzo Stoakes @ 2026-07-11 18:44 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Thomas Bogendoerfer, Benjamin LaHaise, Alexander Viro,
Christian Brauner, Jan Kara, Hugh Dickins, Baolin Wang, Jann Horn,
Pedro Falcato, Muchun Song, Oscar Salvador, Zi Yan, Nico Pache,
Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Usama Arif,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Lucas Stach,
Russell King, Christian Gmeiner, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Tomi Valkeinen, Sandy Huang, Heiko Stübner, Andy Yan,
Thierry Reding, Mikko Perttunen, Jonathan Hunter, Gerd Hoffmann,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Matthew Brost,
Thomas Hellström, Oleksandr Andrushchenko, Helge Deller,
Kees Cook, Jaroslav Kysela, Takashi Iwai, Boris Brezillon,
Steven Price, Liviu Dudau
Cc: Lorenzo Stoakes, linux-mm, linux-kernel, linux-mips, linux-aio,
linux-fsdevel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-sound
In-Reply-To: <20260711-b4-vma-flags-mm-v2-0-0fa2357d5431@kernel.org>
These test whether the VMA has stack semantics, i.e. is able to grow
upwards or downwards depending on the architecture.
In order to account for arches which do not support upward-growing stacks,
introduce VMA_GROWSUP whose definition depends on the architecture
supporting it, and use vma_flags_test_single_mask() in vma_flags_can_grow()
to account for this.
No functional change intended.
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
---
include/linux/mm.h | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 32bb723ffbb9..7a7f559b3df0 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -474,6 +474,7 @@ enum {
#define VM_SAO INIT_VM_FLAG(SAO)
#elif defined(CONFIG_PARISC)
#define VM_GROWSUP INIT_VM_FLAG(GROWSUP)
+#define VMA_GROWSUP mk_vma_flags(VMA_GROWSUP_BIT)
#elif defined(CONFIG_SPARC64)
#define VM_SPARC_ADI INIT_VM_FLAG(SPARC_ADI)
#define VM_ARCH_CLEAR INIT_VM_FLAG(ARCH_CLEAR)
@@ -485,6 +486,7 @@ enum {
#endif
#ifndef VM_GROWSUP
#define VM_GROWSUP VM_NONE
+#define VMA_GROWSUP EMPTY_VMA_FLAGS
#endif
#ifdef CONFIG_ARM64_MTE
#define VM_MTE INIT_VM_FLAG(MTE)
@@ -1578,11 +1580,24 @@ static inline bool vma_is_initial_stack(const struct vm_area_struct *vma)
vma->vm_end >= vma->vm_mm->start_stack;
}
-static inline bool vma_is_temporary_stack(const struct vm_area_struct *vma)
+static inline bool vma_flags_can_grow(const vma_flags_t *flags)
{
- int maybe_stack = vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP);
+ if (vma_flags_test_single_mask(flags, VMA_GROWSUP))
+ return true;
+ if (vma_flags_test(flags, VMA_GROWSDOWN_BIT))
+ return true;
+
+ return false;
+}
- if (!maybe_stack)
+static inline bool vma_can_grow(const struct vm_area_struct *vma)
+{
+ return vma_flags_can_grow(&vma->flags);
+}
+
+static inline bool vma_is_temporary_stack(const struct vm_area_struct *vma)
+{
+ if (!vma_can_grow(vma))
return false;
if ((vma->vm_flags & VM_STACK_INCOMPLETE_SETUP) ==
--
2.55.0
^ permalink raw reply related
* [PATCH v2 00/13] mm: convert more vm_flags_t users to vma_flags_t
From: Lorenzo Stoakes @ 2026-07-11 18:44 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Thomas Bogendoerfer, Benjamin LaHaise, Alexander Viro,
Christian Brauner, Jan Kara, Hugh Dickins, Baolin Wang, Jann Horn,
Pedro Falcato, Muchun Song, Oscar Salvador, Zi Yan, Nico Pache,
Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Usama Arif,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Lucas Stach,
Russell King, Christian Gmeiner, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Tomi Valkeinen, Sandy Huang, Heiko Stübner, Andy Yan,
Thierry Reding, Mikko Perttunen, Jonathan Hunter, Gerd Hoffmann,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Matthew Brost,
Thomas Hellström, Oleksandr Andrushchenko, Helge Deller,
Kees Cook, Jaroslav Kysela, Takashi Iwai, Boris Brezillon,
Steven Price, Liviu Dudau
Cc: Lorenzo Stoakes, linux-mm, linux-kernel, linux-mips, linux-aio,
linux-fsdevel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-sound, Jani Nikula
This series makes further progress in converting usage of the deprecated
vm_flags_t type to its replacement, vma_flags_t.
It focuses on mm, though updates some users of mm APIs also.
It updates:
* The core do_mmap() code path for VMA mapping.
* Unmapped area logic.
* The usage of mm->def_vma_flags.
* VMA page protection bit logic.
* General usage of VMA flags in core mm code, mlock, mprotect, mremap.
REVIEWER/MERGER NOTE: This is dependent on [0], which must be merged before
this.
[0]:https://lore.kernel.org/linux-mm/20260710-b4-pre-scalable-cow-v2-0-2a5aa403d977@kernel.org/
Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
---
Changes in v2:
* Rebased on to mm-new that has the 33 patch rework dependency in it.
* Distributed tags, thanks everybody!
* Moved VMA_STACK_INCOMPLETE_SETUP and VMA_STACK_EARLY VMA userland test defines
from 1/13 to 9/13 as per Zi.
* Fixed whitespace in 3/13 as per Zi.
* Updated 5/13 to use %*pb formatter for VMA flags (to match mm flags formatter)
in dump_mm(), as per Lance.
* Updated 8/13 to update panthor_gem.c to vma_get_page_prot() as per Lance.
* Fixed up comment type in 11/13 as per Lance.
* Fixed bug of using VMA_GROWSUP_BIT rather than VMA_GROWSUP as per Lance
in 12/13.
* Added detail about when we are and are not required to open code
vma_write_lock() for VMA flag mutators in the commit message for 13/13 as
per Lance and Zi.
v1:
https://patch.msgid.link/cover.1782760670.git.ljs@kernel.org
To: Andrew Morton <akpm@linux-foundation.org>
To: David Hildenbrand <david@kernel.org>
To: "Liam R. Howlett" <liam@infradead.org>
To: Vlastimil Babka <vbabka@kernel.org>
To: Mike Rapoport <rppt@kernel.org>
To: Suren Baghdasaryan <surenb@google.com>
To: Michal Hocko <mhocko@suse.com>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Benjamin LaHaise <bcrl@kvack.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>
To: Christian Brauner <brauner@kernel.org>
To: Jan Kara <jack@suse.cz>
To: Hugh Dickins <hughd@google.com>
To: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Jann Horn <jannh@google.com>
To: Pedro Falcato <pfalcato@suse.de>
To: Muchun Song <muchun.song@linux.dev>
To: Oscar Salvador <osalvador@suse.de>
To: Zi Yan <ziy@nvidia.com>
To: Nico Pache <npache@redhat.com>
To: Ryan Roberts <ryan.roberts@arm.com>
To: Dev Jain <dev.jain@arm.com>
To: Barry Song <baohua@kernel.org>
To: Lance Yang <lance.yang@linux.dev>
To: Usama Arif <usama.arif@linux.dev>
To: Madhavan Srinivasan <maddy@linux.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
To: Nicholas Piggin <npiggin@gmail.com>
To: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Maxime Ripard <mripard@kernel.org>
To: Thomas Zimmermann <tzimmermann@suse.de>
To: David Airlie <airlied@gmail.com>
To: Simona Vetter <simona@ffwll.ch>
To: Lucas Stach <l.stach@pengutronix.de>
To: Russell King <linux+etnaviv@armlinux.org.uk>
To: Christian Gmeiner <christian.gmeiner@gmail.com>
To: Inki Dae <inki.dae@samsung.com>
To: Seung-Woo Kim <sw0312.kim@samsung.com>
To: Kyungmin Park <kyungmin.park@samsung.com>
To: Krzysztof Kozlowski <krzk@kernel.org>
To: Peter Griffin <peter.griffin@linaro.org>
To: Alim Akhtar <alim.akhtar@samsung.com>
To: Jani Nikula <jani.nikula@linux.intel.com>
To: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Tvrtko Ursulin <tursulin@ursulin.net>
To: Rob Clark <robin.clark@oss.qualcomm.com>
To: Dmitry Baryshkov <lumag@kernel.org>
To: Abhinav Kumar <abhinav.kumar@linux.dev>
To: Jessica Zhang <jesszhan0024@gmail.com>
To: Sean Paul <sean@poorly.run>
To: Marijn Suijten <marijn.suijten@somainline.org>
To: Lyude Paul <lyude@redhat.com>
To: Danilo Krummrich <dakr@kernel.org>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Sandy Huang <hjc@rock-chips.com>
To: Heiko Stübner <heiko@sntech.de>
To: Andy Yan <andy.yan@rock-chips.com>
To: Thierry Reding <thierry.reding@kernel.org>
To: Mikko Perttunen <mperttunen@nvidia.com>
To: Jonathan Hunter <jonathanh@nvidia.com>
To: Gerd Hoffmann <kraxel@redhat.com>
To: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Gurchetan Singh <gurchetansingh@chromium.org>
To: Chia-I Wu <olvaffe@gmail.com>
To: Zack Rusin <zack.rusin@broadcom.com>
To: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
To: Matthew Brost <matthew.brost@intel.com>
To: Thomas Hellström <thomas.hellstrom@linux.intel.com>
To: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
To: Helge Deller <deller@gmx.de>
To: Kees Cook <kees@kernel.org>
To: Jaroslav Kysela <perex@perex.cz>
To: Takashi Iwai <tiwai@suse.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
To: Steven Price <steven.price@arm.com>
To: Liviu Dudau <liviu.dudau@arm.com>
Cc: ljs@kernel.org
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: linux-aio@kvack.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: dri-devel@lists.freedesktop.org
Cc: etnaviv@lists.freedesktop.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: intel-gfx@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-tegra@vger.kernel.org
Cc: virtualization@lists.linux.dev
Cc: intel-xe@lists.freedesktop.org
Cc: xen-devel@lists.xenproject.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-sound@vger.kernel.org
---
Lorenzo Stoakes (13):
mm: introduce vma_flags_can_grow() and vma_can_grow()
mm/vma: update do_mmap() to use vma_flags_t
mm: convert __get_unmapped_area() to use vma_flags_t
mm: update generic_get_unmapped_area[_topdown]() to use vma_flags_t
mm: prefer mm->def_vma_flags in mm logic
mm/vma: convert vm_pgprot_modify() to use vma_flags_t and rename
mm/vma: rename vma_get_page_prot to vma_flags_to_page_prot
mm: introduce vma_get_page_prot() and use it
mm/vma: update create_init_stack_vma() to use vma_flags_t
mm/vma: convert miscellaneous uses of VMA flags in core mm
mm/mlock: convert mlock code to use vma_flags_t
mm/mprotect: convert mprotect code to use vma_flags_t
mm/mremap: convert mremap code to use vma_flags_t
arch/mips/kernel/vdso.c | 4 +-
arch/powerpc/mm/book3s64/slice.c | 6 +-
drivers/gpu/drm/drm_gem.c | 2 +-
drivers/gpu/drm/drm_gem_dma_helper.c | 2 +-
drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +-
drivers/gpu/drm/exynos/exynos_drm_gem.c | 6 +-
drivers/gpu/drm/i915/gem/i915_gem_mman.c | 12 +-
drivers/gpu/drm/msm/msm_gem.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +-
drivers/gpu/drm/omapdrm/omap_fbdev.c | 2 +-
drivers/gpu/drm/omapdrm/omap_gem.c | 6 +-
drivers/gpu/drm/panthor/panthor_gem.c | 2 +-
drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 2 +-
drivers/gpu/drm/tegra/gem.c | 2 +-
drivers/gpu/drm/virtio/virtgpu_vram.c | 2 +-
drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 2 +-
drivers/gpu/drm/xe/xe_device.c | 2 +-
drivers/gpu/drm/xe/xe_mmio_gem.c | 2 +-
drivers/gpu/drm/xen/xen_drm_front_gem.c | 2 +-
drivers/video/fbdev/core/fb_io_fops.c | 2 +-
fs/aio.c | 2 +-
fs/hugetlbfs/inode.c | 3 +-
include/linux/huge_mm.h | 10 +-
include/linux/memfd.h | 6 +-
include/linux/mm.h | 52 +++++++--
include/linux/sched/mm.h | 13 +--
ipc/shm.c | 3 +-
mm/debug.c | 5 +-
mm/huge_memory.c | 21 ++--
mm/memfd.c | 15 +--
mm/mlock.c | 99 +++++++++--------
mm/mmap.c | 164 +++++++++++++++-------------
mm/mprotect.c | 16 +--
mm/mremap.c | 38 ++++---
mm/nommu.c | 3 +-
mm/util.c | 10 +-
mm/vma.c | 26 +++--
mm/vma.h | 8 +-
mm/vma_exec.c | 20 ++--
sound/core/memalloc.c | 2 +-
tools/testing/vma/include/dup.h | 23 ++--
42 files changed, 341 insertions(+), 264 deletions(-)
---
base-commit: 61cccb8363fcc282d4ae0555b8739dd227f5ad0b
change-id: 20260711-b4-vma-flags-mm-bd05385df9fc
Cheers,
--
Lorenzo Stoakes <ljs@kernel.org>
^ permalink raw reply
* Re: [PATCH 13/13] mm/mremap: convert mremap code to use vma_flags_t
From: Lorenzo Stoakes @ 2026-07-11 17:09 UTC (permalink / raw)
To: Zi Yan
Cc: Lance Yang, akpm, tsbogend, maddy, mpe, maarten.lankhorst,
mripard, tzimmermann, airlied, simona, l.stach, inki.dae,
sw0312.kim, kyungmin.park, krzk, peter.griffin, jani.nikula,
joonas.lahtinen, rodrigo.vivi, tursulin, robin.clark, lumag,
lyude, dakr, tomi.valkeinen, hjc, heiko, andy.yan, thierry.reding,
mperttunen, jonathanh, kraxel, dmitry.osipenko, zack.rusin,
matthew.brost, thomas.hellstrom, oleksandr_andrushchenko, deller,
bcrl, viro, brauner, muchun.song, osalvador, david, baolin.wang,
liam, npache, ryan.roberts, dev.jain, baohua, hughd, vbabka, rppt,
surenb, mhocko, jannh, pfalcato, kees, perex, tiwai, linux-mips,
linux-kernel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-aio, linux-fsdevel, linux-mm, linux-sound
In-Reply-To: <DJTOP760MDDG.2KUSKD8WVVKJ5@nvidia.com>
On Wed, Jul 08, 2026 at 10:28:00PM -0400, Zi Yan wrote:
> On Thu Jul 2, 2026 at 12:07 PM EDT, Lorenzo Stoakes wrote:
> > On Thu, Jul 02, 2026 at 09:49:47PM +0800, Lance Yang wrote:
> >>
> >> On Mon, Jun 29, 2026 at 08:25:36PM +0100, Lorenzo Stoakes wrote:
> >> >Replace use of the legacy vm_flags_t flags with vma_flags_t values
> >> >throughout the mremap logic.
> >> >
> >> >Additionally update comments to reflect the changes to be consistent.
> >> >
> >> >No functional change intended.
> >> >
> >> >Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
> >> >---
> >>
> >> The vm_flags_set() cases below spell out vma_start_write(), but the
> >> vm_flags_clear() cases don't?
> >
> > Yep as I said elsewhere, implicitly taking the lock is terrible and me doing
> > this is completely on purpose to get rid of that :)
> >
> > But I haven't been clear enough clearly, so I should put the argument as to why
> > that's ok in the commit message.
> >
> > Will do so on respin.
>
> How about also add a comment to vma_clear*() telling us a lock is not
> needed and why like you explained a lock is needed for vma_set*()?
> This asymmetry could confuse people.
Well you do absolutely have to hold the lock once the VMA is initialised when
using any VMA flags API that manipulates flags (apart from the explicitly atomic
case).
The argument here is that the VMA was _already locked_ at the point of clearing
:)
>
> This patch looks good to me.
>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
Thanks!
>
> --
> Best Regards,
> Yan, Zi
>
Cheers, Lorenzo
^ permalink raw reply
* Re: [PATCH 12/13] mm/mprotect: convert mprotect code to use vma_flags_t
From: Lorenzo Stoakes @ 2026-07-11 17:04 UTC (permalink / raw)
To: Zi Yan
Cc: Lance Yang, akpm, tsbogend, maddy, mpe, maarten.lankhorst,
mripard, tzimmermann, airlied, simona, l.stach, inki.dae,
sw0312.kim, kyungmin.park, krzk, peter.griffin, jani.nikula,
joonas.lahtinen, rodrigo.vivi, tursulin, robin.clark, lumag,
lyude, dakr, tomi.valkeinen, hjc, heiko, andy.yan, thierry.reding,
mperttunen, jonathanh, kraxel, dmitry.osipenko, zack.rusin,
matthew.brost, thomas.hellstrom, oleksandr_andrushchenko, deller,
bcrl, viro, brauner, muchun.song, osalvador, david, baolin.wang,
liam, npache, ryan.roberts, dev.jain, baohua, hughd, vbabka, rppt,
surenb, mhocko, jannh, pfalcato, kees, perex, tiwai, linux-mips,
linux-kernel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-aio, linux-fsdevel, linux-mm, linux-sound
In-Reply-To: <DJTOG7IBZKEE.87TLWNXOCHR8@nvidia.com>
On Wed, Jul 08, 2026 at 10:16:15PM -0400, Zi Yan wrote:
> On Thu Jul 2, 2026 at 11:53 AM EDT, Lorenzo Stoakes wrote:
> > On Thu, Jul 02, 2026 at 12:09:17AM +0800, Lance Yang wrote:
> >>
> >> On Mon, Jun 29, 2026 at 08:25:35PM +0100, Lorenzo Stoakes wrote:
> >> >Replace use of the legacy vm_flags_t flags with vma_flags_t values
> >> >throughout the mprotect logic.
> >> >
> >> >Note that we retain the legacy vm_flags_t bit shifting code in
> >> >do_mprotect_key(), deferring a vma_flags_t approach to this for the time
> >> >being.
> >> >
> >> >Additionally update comments to reflect the changes to be consistent.
> >> >
> >> >No functional change intended.
> >> >
> >> >Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
> >> >---
> >> > mm/mprotect.c | 16 ++++++++--------
> >> > 1 file changed, 8 insertions(+), 8 deletions(-)
> >> >
> >> >diff --git a/mm/mprotect.c b/mm/mprotect.c
> >> >index 9cbf932b028c..c9504b2a2525 100644
> >> >--- a/mm/mprotect.c
> >> >+++ b/mm/mprotect.c
> >> >@@ -40,7 +40,7 @@
> >> >
> >> > static bool maybe_change_pte_writable(struct vm_area_struct *vma, pte_t pte)
> >> > {
> >> >- if (WARN_ON_ONCE(!(vma->vm_flags & VM_WRITE)))
> >> >+ if (WARN_ON_ONCE(!vma_test(vma, VMA_WRITE_BIT)))
> >> > return false;
> >> >
> >> > /* Don't touch entries that are not even readable. */
> >> >@@ -97,7 +97,7 @@ static bool can_change_shared_pte_writable(struct vm_area_struct *vma,
> >> > bool can_change_pte_writable(struct vm_area_struct *vma, unsigned long addr,
> >> > pte_t pte)
> >> > {
> >> >- if (!(vma->vm_flags & VM_SHARED))
> >> >+ if (!vma_test(vma, VMA_SHARED_BIT))
> >> > return can_change_private_pte_writable(vma, addr, pte);
> >> >
> >> > return can_change_shared_pte_writable(vma, pte);
> >> >@@ -194,7 +194,7 @@ static __always_inline void set_write_prot_commit_flush_ptes(struct vm_area_stru
> >> > {
> >> > bool set_write;
> >> >
> >> >- if (vma->vm_flags & VM_SHARED) {
> >> >+ if (vma_test(vma, VMA_SHARED_BIT)) {
> >> > set_write = can_change_shared_pte_writable(vma, ptent);
> >> > prot_commit_flush_ptes(vma, addr, ptep, oldpte, ptent, nr_ptes,
> >> > /* idx = */ 0, set_write, tlb);
> >> >@@ -811,8 +811,8 @@ mprotect_fixup(struct vma_iterator *vmi, struct mmu_gather *tlb,
> >> > vm_unacct_memory(nrpages);
> >> >
> >> > /*
> >> >- * Private VM_LOCKED VMA becoming writable: trigger COW to avoid major
> >> >- * fault on access.
> >> >+ * Private VMA_LOCKED_BIT VMA becoming writable: trigger COW to avoid
> >> >+ * major fault on access.
> >> > */
> >> > if (vma_flags_test(&new_vma_flags, VMA_WRITE_BIT) &&
> >> > vma_flags_test(&old_vma_flags, VMA_LOCKED_BIT) &&
> >> >@@ -886,7 +886,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
> >> > goto out;
> >> > start = vma->vm_start;
> >> > error = -EINVAL;
> >> >- if (!(vma->vm_flags & VM_GROWSDOWN))
> >> >+ if (!vma_test(vma, VMA_GROWSDOWN_BIT))
> >> > goto out;
> >> > } else {
> >> > if (vma->vm_start > start)
> >> >@@ -894,7 +894,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
> >> > if (unlikely(grows & PROT_GROWSUP)) {
> >> > end = vma->vm_end;
> >> > error = -EINVAL;
> >> >- if (!(vma->vm_flags & VM_GROWSUP))
> >> >+ if (!vma_test(vma, VMA_GROWSUP_BIT))
> >>
> >> IIUC, should this be
> >>
> >> if (!vma_test_single_mask(vma, VMA_GROWSUP))
> >>
> >> instead?
> >>
> >> #elif defined(CONFIG_PARISC)
> >> #define VM_GROWSUP INIT_VM_FLAG(GROWSUP)
> >> ...
> >> #ifndef VM_GROWSUP
> >> #define VM_GROWSUP VM_NONE
> >> ...
> >>
> >> VM_GROWSUP is only defined as GROWSUP on parisc and becomes VM_NONE
> >> elsewhere. But VMA_GROWSUP_BIT is the raw ARCH_1 bit, which is also used
> >> for other arch-specific VMA flags:
> >>
> >> DECLARE_VMA_BIT_ALIAS(SAO, ARCH_1), /* Strong Access Ordering (powerpc) */
> >> DECLARE_VMA_BIT_ALIAS(GROWSUP, ARCH_1), /* parisc */
> >> DECLARE_VMA_BIT_ALIAS(SPARC_ADI, ARCH_1), /* sparc64 */
> >> DECLARE_VMA_BIT_ALIAS(ARM64_BTI, ARCH_1), /* arm64 */
> >> DECLARE_VMA_BIT_ALIAS(ARCH_CLEAR, ARCH_1), /* sparc64, arm64 */
> >> DECLARE_VMA_BIT_ALIAS(MAPPED_COPY, ARCH_1), /* !CONFIG_MMU */
> >>
> >> Other vma_test() changes look fine to me: just fixed INIT_VM_FLAG()
> >> masks matching their VMA_*_BIT :)
> >
> > Thanks you're right, will fix!
> >
> > Again I swear I ran claude on all of this so it's failing me here :)
> >
>
> Is it better to add something like below to avoid misuse these mutually
> exclusive bit aliases?
>
> An example for VMA_GROWSUP_BIT:
>
> #if defined(CONFIG_PARISC)
> DECLARE_VMA_BIT_ALIAS(GROWSUP, ARCH_1), /* parisc */
> #else
> /* make VMA_GROWSUP_BIT a build bug on */
> #endif
Nah we can't...
>
> Hmm, these VMA_*_BIT are enum items, so the above might not be possible.
...because of this but also this is the canonical definition and we want to use
it for the VMA_xxx form.
> An alternative is to only define them for the corresponding config and
> you will get build errors when trying to use them directly and the
> config is not enabled. Otherwise, misuses like "vma_test(vma,
> VMA_GROWSUP_BIT)" is harder to uncover.
Yeah good idea, I may add a new DECLARE_INTERNAL_VMA_BIT() that gives you
__VMA_xxx_BIT, so nobody makes the obvious mistake and we force uses of safe
VMA_xxx form. Hmm :)
>
>
> --
> Best Regards,
> Yan, Zi
>
Thanks, Lorenzo
^ permalink raw reply
* Re: [PATCH 11/13] mm/mlock: convert mlock code to use vma_flags_t
From: Lorenzo Stoakes @ 2026-07-11 16:52 UTC (permalink / raw)
To: Zi Yan
Cc: Andrew Morton, Thomas Bogendoerfer, Madhavan Srinivasan,
Michael Ellerman, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Lucas Stach,
Inki Dae, Seung-Woo Kim, Kyungmin Park, Krzysztof Kozlowski,
Peter Griffin, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, Rob Clark, Dmitry Baryshkov, Lyude Paul,
Danilo Krummrich, Tomi Valkeinen, Sandy Huang, Heiko Stübner,
Andy Yan, Thierry Reding, Mikko Perttunen, Jonathan Hunter,
Gerd Hoffmann, Dmitry Osipenko, Zack Rusin, Matthew Brost,
Thomas Hellstrom, Oleksandr Andrushchenko, Helge Deller,
Benjamin LaHaise, Alexander Viro, Christian Brauner, Muchun Song,
Oscar Salvador, David Hildenbrand, Baolin Wang, Liam R . Howlett,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Lance Yang,
Hugh Dickins, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan,
Michal Hocko, Jann Horn, Pedro Falcato, Kees Cook,
Jaroslav Kysela, Takashi Iwai, linux-mips, linux-kernel,
linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-aio, linux-fsdevel, linux-mm, linux-sound
In-Reply-To: <DJTO4SXFAKEV.1GVVCX3LZ6R0M@nvidia.com>
On Wed, Jul 08, 2026 at 10:01:22PM -0400, Zi Yan wrote:
> On Mon Jun 29, 2026 at 3:25 PM EDT, Lorenzo Stoakes wrote:
> > Replace use of the legacy vm_flags_t flags with vma_flags_t values
> > throughout the mlock logic.
> >
> > Additionally update comments to reflect the changes to be consistent.
> >
> > No functional change intended.
> >
> > Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
> > ---
> > mm/mlock.c | 86 +++++++++++++++++++++++++++++-------------------------
> > 1 file changed, 46 insertions(+), 40 deletions(-)
> >
>
> LGTM. What confused me when I was reading the code is VMA_LOCKED_MASK
> and VMA_LOCKED_BIT, since both share the same prefix VMA_LOCKED. Before
> looking at the definition of VMA_LOCKED_MASK, I was wondering when to
> use _BIT or _MASK. But it is just a naming thing.
Yeah, indeed, not great naming there. Was a pre-existing though, and previously
was VM_LOCKED_MASK (also not great :)
The whole VMA_LOCKED_BIT and VMA_LOCK_ON_FAULT_BIT thing is a bit weird anyway,
since you set both and then just use the latter to know not to fault in in
GUP... anyway, can revisit that one later...! :)
>
> Anyway,
>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
Thanks!
>
>
> --
> Best Regards,
> Yan, Zi
>
Cheers, Lorenzo
^ permalink raw reply
* Re: [PATCH 10/13] mm/vma: convert miscellaneous uses of VMA flags in core mm
From: Lorenzo Stoakes @ 2026-07-11 16:44 UTC (permalink / raw)
To: Zi Yan
Cc: Lance Yang, akpm, tsbogend, maddy, mpe, maarten.lankhorst,
mripard, tzimmermann, airlied, simona, l.stach, inki.dae,
sw0312.kim, kyungmin.park, krzk, peter.griffin, jani.nikula,
joonas.lahtinen, rodrigo.vivi, tursulin, robin.clark, lumag,
lyude, dakr, tomi.valkeinen, hjc, heiko, andy.yan, thierry.reding,
mperttunen, jonathanh, kraxel, dmitry.osipenko, zack.rusin,
matthew.brost, thomas.hellstrom, oleksandr_andrushchenko, deller,
bcrl, viro, brauner, muchun.song, osalvador, david, baolin.wang,
liam, npache, ryan.roberts, dev.jain, baohua, hughd, vbabka, rppt,
surenb, mhocko, jannh, pfalcato, kees, perex, tiwai, linux-mips,
linux-kernel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-aio, linux-fsdevel, linux-mm, linux-sound
In-Reply-To: <alJqjo_MZCFWj3Wt@lucifer>
On Sat, Jul 11, 2026 at 05:23:39PM +0100, Lorenzo Stoakes wrote:
> On Wed, Jul 08, 2026 at 09:52:19PM -0400, Zi Yan wrote:
> > On Thu Jul 2, 2026 at 11:46 AM EDT, Lorenzo Stoakes wrote:
> > > On Thu, Jul 02, 2026 at 09:12:33PM +0800, Lance Yang wrote:
> > >>
> > >> On Mon, Jun 29, 2026 at 08:25:33PM +0100, Lorenzo Stoakes wrote:
> > >> >Update various uses of legacy flags in vma.c and mmap.c to the new
> > >> >vma_flags_t type, updating comments alongside them to be consistent.
> > >> >
> > >> >Also update __install_special_mapping() to rearrange things slightly to
> > >> >accommodate the changes.
> > >> >
> > >> >Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
> > >> >---
> > >> [...]
> > >> >diff --git a/mm/vma.c b/mm/vma.c
> > >> >index b81c05e67a61..ab2ef0f04420 100644
> > >> >--- a/mm/vma.c
> > >> >+++ b/mm/vma.c
> > >> >@@ -3417,23 +3417,27 @@ struct vm_area_struct *__install_special_mapping(
> > >> > vm_flags_t vm_flags, void *priv,
> > >> > const struct vm_operations_struct *ops)
> > >> > {
> > >> >- int ret;
> > >> >+ vma_flags_t vma_flags = legacy_to_vma_flags(vm_flags);
> > >> > struct vm_area_struct *vma;
> > >> >+ int ret;
> > >> >
> > >> > vma = vm_area_alloc(mm);
> > >> >- if (unlikely(vma == NULL))
> > >> >+ if (unlikely(!vma))
> > >> > return ERR_PTR(-ENOMEM);
> > >> >
> > >> >- vma_set_range(vma, addr, addr + len, 0);
> > >> >- vm_flags |= vma_flags_to_legacy(mm->def_vma_flags) | VM_DONTEXPAND;
> > >> >+ vma_flags_set_mask(&vma_flags, mm->def_vma_flags);
> > >> >+ vma_flags_set(&vma_flags, VMA_DONTEXPAND_BIT);
> > >> > if (pgtable_supports_soft_dirty())
> > >> >- vm_flags |= VM_SOFTDIRTY;
> > >> >- vm_flags_init(vma, vm_flags & ~VM_LOCKED_MASK);
> > >> >+ vma_flags_set(&vma_flags, VMA_SOFTDIRTY_BIT);
> > >> >+ vma_flags_clear_mask(&vma_flags, VMA_LOCKED_MASK);
> > >> >+ vma->flags = vma_flags;
> > >>
> > >> Maybe worth a vma_flags_init() helper here to mirror vm_flags_init()?
> > >> With this open-coded, we lose the soft-dirty WARN_ON_ONCE sanity check.
> > >>
> > >> Might be nicer to keep that check in one place ;)
> > >
> > > I really hate all the VMA flag accessors, they conflate things horribly - we
> > > should be explicitly taking VMA write locks when we need to (and often killable
> > > ones actually) not assuming that a VMA flags accessor does (they should at most
> > > assert).
> > >
> > > This case is even more terribly egregious - you are setting flags at an
> > > arbitrary time, why are we asserting something about softdirty?
> > >
> > > You may update them as part of initialisation, maybe not. It's far from a
> > > guarantee and feels like a lazy place to put it.
> > >
> > > BUT obviously it's an oversight not to open code that here, so I'll update the
> > > patch to do that!
> >
> > What do you want to open code here? softdirty WARN_ON_ONCE()?
>
> As you can tell I said this reflexively without checking the code :)
>
> >
> > vma_flags gets VMA_SOFTDIRTY_BIT just above vma->flags, why do we need a
> > check after that?
>
> And yeah it's completely unnecessary, indeed.
>
> >
> > BTW, if you think the check is needed, patch 9 will need to be updated,
> > since the same pattern appears in create_init_stack_vma().
>
> I'll check to see if it's valid there.
Exactly the same case as here, unnecessary :)
Cheers, LOrenzo
^ permalink raw reply
* Re: [PATCH 10/13] mm/vma: convert miscellaneous uses of VMA flags in core mm
From: Lorenzo Stoakes @ 2026-07-11 16:23 UTC (permalink / raw)
To: Zi Yan
Cc: Lance Yang, akpm, tsbogend, maddy, mpe, maarten.lankhorst,
mripard, tzimmermann, airlied, simona, l.stach, inki.dae,
sw0312.kim, kyungmin.park, krzk, peter.griffin, jani.nikula,
joonas.lahtinen, rodrigo.vivi, tursulin, robin.clark, lumag,
lyude, dakr, tomi.valkeinen, hjc, heiko, andy.yan, thierry.reding,
mperttunen, jonathanh, kraxel, dmitry.osipenko, zack.rusin,
matthew.brost, thomas.hellstrom, oleksandr_andrushchenko, deller,
bcrl, viro, brauner, muchun.song, osalvador, david, baolin.wang,
liam, npache, ryan.roberts, dev.jain, baohua, hughd, vbabka, rppt,
surenb, mhocko, jannh, pfalcato, kees, perex, tiwai, linux-mips,
linux-kernel, linuxppc-dev, dri-devel, etnaviv, linux-arm-kernel,
linux-samsung-soc, intel-gfx, linux-arm-msm, freedreno, nouveau,
linux-rockchip, linux-tegra, virtualization, intel-xe, xen-devel,
linux-fbdev, linux-aio, linux-fsdevel, linux-mm, linux-sound
In-Reply-To: <DJTNXVOWGWJ4.3MDNLPMY0Y3RF@nvidia.com>
On Wed, Jul 08, 2026 at 09:52:19PM -0400, Zi Yan wrote:
> On Thu Jul 2, 2026 at 11:46 AM EDT, Lorenzo Stoakes wrote:
> > On Thu, Jul 02, 2026 at 09:12:33PM +0800, Lance Yang wrote:
> >>
> >> On Mon, Jun 29, 2026 at 08:25:33PM +0100, Lorenzo Stoakes wrote:
> >> >Update various uses of legacy flags in vma.c and mmap.c to the new
> >> >vma_flags_t type, updating comments alongside them to be consistent.
> >> >
> >> >Also update __install_special_mapping() to rearrange things slightly to
> >> >accommodate the changes.
> >> >
> >> >Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
> >> >---
> >> [...]
> >> >diff --git a/mm/vma.c b/mm/vma.c
> >> >index b81c05e67a61..ab2ef0f04420 100644
> >> >--- a/mm/vma.c
> >> >+++ b/mm/vma.c
> >> >@@ -3417,23 +3417,27 @@ struct vm_area_struct *__install_special_mapping(
> >> > vm_flags_t vm_flags, void *priv,
> >> > const struct vm_operations_struct *ops)
> >> > {
> >> >- int ret;
> >> >+ vma_flags_t vma_flags = legacy_to_vma_flags(vm_flags);
> >> > struct vm_area_struct *vma;
> >> >+ int ret;
> >> >
> >> > vma = vm_area_alloc(mm);
> >> >- if (unlikely(vma == NULL))
> >> >+ if (unlikely(!vma))
> >> > return ERR_PTR(-ENOMEM);
> >> >
> >> >- vma_set_range(vma, addr, addr + len, 0);
> >> >- vm_flags |= vma_flags_to_legacy(mm->def_vma_flags) | VM_DONTEXPAND;
> >> >+ vma_flags_set_mask(&vma_flags, mm->def_vma_flags);
> >> >+ vma_flags_set(&vma_flags, VMA_DONTEXPAND_BIT);
> >> > if (pgtable_supports_soft_dirty())
> >> >- vm_flags |= VM_SOFTDIRTY;
> >> >- vm_flags_init(vma, vm_flags & ~VM_LOCKED_MASK);
> >> >+ vma_flags_set(&vma_flags, VMA_SOFTDIRTY_BIT);
> >> >+ vma_flags_clear_mask(&vma_flags, VMA_LOCKED_MASK);
> >> >+ vma->flags = vma_flags;
> >>
> >> Maybe worth a vma_flags_init() helper here to mirror vm_flags_init()?
> >> With this open-coded, we lose the soft-dirty WARN_ON_ONCE sanity check.
> >>
> >> Might be nicer to keep that check in one place ;)
> >
> > I really hate all the VMA flag accessors, they conflate things horribly - we
> > should be explicitly taking VMA write locks when we need to (and often killable
> > ones actually) not assuming that a VMA flags accessor does (they should at most
> > assert).
> >
> > This case is even more terribly egregious - you are setting flags at an
> > arbitrary time, why are we asserting something about softdirty?
> >
> > You may update them as part of initialisation, maybe not. It's far from a
> > guarantee and feels like a lazy place to put it.
> >
> > BUT obviously it's an oversight not to open code that here, so I'll update the
> > patch to do that!
>
> What do you want to open code here? softdirty WARN_ON_ONCE()?
As you can tell I said this reflexively without checking the code :)
>
> vma_flags gets VMA_SOFTDIRTY_BIT just above vma->flags, why do we need a
> check after that?
And yeah it's completely unnecessary, indeed.
>
> BTW, if you think the check is needed, patch 9 will need to be updated,
> since the same pattern appears in create_init_stack_vma().
I'll check to see if it's valid there.
For me it just feels like the most silly place to put that check, a VMA flags
update should update VMA flags not start randomly asserting silly things :)
>
> >
> > I want VMA flags to be a clean stateless thing, other than the flags
> > themselves. Implicit, unrelated, asserts or lock acquisitions in general should
> > be done separately IMO.
> >
>
> Anyway,
>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
Thanks!
>
> --
> Best Regards,
> Yan, Zi
>
Cheers, Lorenzo
^ permalink raw reply
* Re: [PATCH] virtio_net: validate device stats reply records before use
From: Michael S. Tsirkin @ 2026-07-11 15:52 UTC (permalink / raw)
To: Michael Bommarito
Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, Andrew Lunn,
Jakub Kicinski, Paolo Abeni, virtualization, netdev, linux-kernel,
stable
In-Reply-To: <CAJJ9bXwUtQ3pHqZ=AMuwaNLs16pmujiMdeBQtB5kFc6JjM-Pug@mail.gmail.com>
On Sat, Jul 11, 2026 at 11:29:56AM -0400, Michael Bommarito wrote:
> On Sat, Jul 11, 2026 at 11:20 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> > Why does it "matter most", or at all, there?
> > Host can always deny guest service. In fact, this is how cloud vendors
> > charge their clients, by denying service to whoever did not pay them.
> ...
> > I'm all for making things easier to debug even when the device is buggy.
> > But I'm not inclined to add tons of hard to maintain code to
> > that end, and I would be worried broken hosts will come to
> > rely on drivers working around them.
>
> I am always confused by the CoCo threat model to be honest,
Confidential computing? It's vague at points, given the term covers a
lot of different hardware. But one thing is clear - it's about
confidentiality. DoS by host is empathically outside the threat model.
On any virtualization platform I know without exception,
host can just exit the VM, done, service denied.
> since it
> seems like some people care a lot about maximalist reliance on the
> contract and other people are more practical about how many other
> vectors exist anyway.
I don't really know what "vectors" or "the contract" are here.
Making a guest recover from a misbehaving device has as much a chance
to reduce security as increase it. So the only benefit is
robustness for users/developers, not security. And that
has to be weighted against the maintainance cost of the change.
This one is too costly, I judge.
> No hard feelings if you want to NACK, but at
> least it's documented publicly now for people to consider.
>
> Thanks,
> Mike
^ permalink raw reply
* Re: [PATCH] virtio_net: validate device stats reply records before use
From: Michael Bommarito @ 2026-07-11 15:29 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, Andrew Lunn,
Jakub Kicinski, Paolo Abeni, virtualization, netdev, linux-kernel,
stable
In-Reply-To: <20260711111503-mutt-send-email-mst@kernel.org>
On Sat, Jul 11, 2026 at 11:20 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> Why does it "matter most", or at all, there?
> Host can always deny guest service. In fact, this is how cloud vendors
> charge their clients, by denying service to whoever did not pay them.
...
> I'm all for making things easier to debug even when the device is buggy.
> But I'm not inclined to add tons of hard to maintain code to
> that end, and I would be worried broken hosts will come to
> rely on drivers working around them.
I am always confused by the CoCo threat model to be honest, since it
seems like some people care a lot about maximalist reliance on the
contract and other people are more practical about how many other
vectors exist anyway. No hard feelings if you want to NACK, but at
least it's documented publicly now for people to consider.
Thanks,
Mike
^ permalink raw reply
* Re: [PATCH] virtio_net: validate device stats reply records before use
From: Michael S. Tsirkin @ 2026-07-11 15:20 UTC (permalink / raw)
To: Michael Bommarito
Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, Andrew Lunn,
Jakub Kicinski, Paolo Abeni, virtualization, netdev, linux-kernel,
stable
In-Reply-To: <20260711150754.2918392-1-michael.bommarito@gmail.com>
On Sat, Jul 11, 2026 at 11:07:54AM -0400, Michael Bommarito wrote:
> __virtnet_get_hw_stats() walks the device statistics reply buffer with
> "for (p = reply; p - reply < res_size; p += le16_to_cpu(hdr->size))",
> using each record's device-supplied hdr->size as the stride without
> checking that a full struct virtio_net_stats_reply_hdr remains, that
> hdr->size is nonzero and matches the expected size for hdr->type, or that
> the record fits within res_size. A backend that returns hdr->size == 0
> spins the loop forever; a short or oversized size drives out-of-bounds
> reads in virtnet_fill_stats().
>
> Impact: a malicious or compromised virtio-net backend hangs the CPU
> running the guest's device-statistics query in an infinite loop
> (hdr->size == 0), or drives an out-of-bounds read of the reply buffer.
> This matters most for a confidential guest, where the host is outside the
> trust boundary.
Why does it "matter most", or at all, there?
Host can always deny guest service. In fact, this is how cloud vendors
charge their clients, by denying service to whoever did not pay them.
> Validate each record before use: require a full header in the remaining
> bytes, a nonzero hdr->size that is at least the header size and matches the
> size expected for hdr->type, and that the record fits within res_size; stop
> the walk otherwise. Add virtnet_stats_reply_size() for the per-type size.
I'm all for making things easier to debug even when the device is buggy.
But I'm not inclined to add tons of hard to maintain code to
that end, and I would be worried broken hosts will come to
rely on drivers working around them.
>
> Fixes: 941168f8b40e ("virtio_net: support device stats")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
> ---
> drivers/net/virtio_net.c | 42 ++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 3e2a5876c6c8c..9cbe40d218cc4 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -3532,6 +3532,7 @@ static int virtnet_tx_resize(struct virtnet_info *vi, struct send_queue *sq,
> return err;
> }
>
> +
> /*
> * Send command via the control virtqueue and check status. Commands
> * supported by the hypervisor, as indicated by feature bits, should
> @@ -3546,6 +3547,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd
> bool ok;
> int ret;
>
> +
> /* Caller should know better */
> BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ));
>
we don't need this.
> @@ -4927,6 +4929,32 @@ static void virtnet_fill_stats(struct virtnet_info *vi, u32 qid,
> }
> }
>
> +static int virtnet_stats_reply_size(u8 type)
> +{
> + switch (type) {
> + case VIRTIO_NET_STATS_TYPE_REPLY_CVQ:
> + return sizeof(struct virtio_net_stats_cvq);
> + case VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC:
> + return sizeof(struct virtio_net_stats_rx_basic);
> + case VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM:
> + return sizeof(struct virtio_net_stats_rx_csum);
> + case VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO:
> + return sizeof(struct virtio_net_stats_rx_gso);
> + case VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED:
> + return sizeof(struct virtio_net_stats_rx_speed);
> + case VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC:
> + return sizeof(struct virtio_net_stats_tx_basic);
> + case VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM:
> + return sizeof(struct virtio_net_stats_tx_csum);
> + case VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO:
> + return sizeof(struct virtio_net_stats_tx_gso);
> + case VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED:
> + return sizeof(struct virtio_net_stats_tx_speed);
> + default:
> + return sizeof(struct virtio_net_stats_reply_hdr);
> + }
> +}
> +
> static int __virtnet_get_hw_stats(struct virtnet_info *vi,
> struct virtnet_stats_ctx *ctx,
> struct virtio_net_ctrl_queue_stats *req,
> @@ -4936,7 +4964,7 @@ static int __virtnet_get_hw_stats(struct virtnet_info *vi,
> struct scatterlist sgs_in, sgs_out;
> void *p;
> u32 qid;
> - int ok;
> + int hdr_size, ok, remaining;
>
> sg_init_one(&sgs_out, req, req_size);
> sg_init_one(&sgs_in, reply, res_size);
> @@ -4948,8 +4976,17 @@ static int __virtnet_get_hw_stats(struct virtnet_info *vi,
> if (!ok)
> return ok;
>
> - for (p = reply; p - reply < res_size; p += le16_to_cpu(hdr->size)) {
> + for (p = reply; p - reply < res_size; p += hdr_size) {
> + remaining = res_size - (p - reply);
> + if (remaining < sizeof(*hdr))
> + return -EINVAL;
> +
> hdr = p;
> + hdr_size = le16_to_cpu(hdr->size);
> + if (hdr_size < virtnet_stats_reply_size(hdr->type) ||
> + hdr_size > remaining)
> + return -EINVAL;
> +
> qid = le16_to_cpu(hdr->vq_index);
> virtnet_fill_stats(vi, qid, ctx, p, false, hdr->type);
> }
That's a lot of fragile code for unclear benefit.
> @@ -7305,3 +7342,4 @@ module_exit(virtio_net_driver_exit);
> MODULE_DEVICE_TABLE(virtio, id_table);
> MODULE_DESCRIPTION("Virtio network driver");
> MODULE_LICENSE("GPL");
> +
> --
> 2.53.0
^ permalink raw reply
* [PATCH] virtio_net: validate device stats reply records before use
From: Michael Bommarito @ 2026-07-11 15:07 UTC (permalink / raw)
To: Michael S . Tsirkin, Jason Wang, Xuan Zhuo, Eugenio Pérez
Cc: Andrew Lunn, Jakub Kicinski, Paolo Abeni, virtualization, netdev,
linux-kernel, stable
__virtnet_get_hw_stats() walks the device statistics reply buffer with
"for (p = reply; p - reply < res_size; p += le16_to_cpu(hdr->size))",
using each record's device-supplied hdr->size as the stride without
checking that a full struct virtio_net_stats_reply_hdr remains, that
hdr->size is nonzero and matches the expected size for hdr->type, or that
the record fits within res_size. A backend that returns hdr->size == 0
spins the loop forever; a short or oversized size drives out-of-bounds
reads in virtnet_fill_stats().
Impact: a malicious or compromised virtio-net backend hangs the CPU
running the guest's device-statistics query in an infinite loop
(hdr->size == 0), or drives an out-of-bounds read of the reply buffer.
This matters most for a confidential guest, where the host is outside the
trust boundary.
Validate each record before use: require a full header in the remaining
bytes, a nonzero hdr->size that is at least the header size and matches the
size expected for hdr->type, and that the record fits within res_size; stop
the walk otherwise. Add virtnet_stats_reply_size() for the per-type size.
Fixes: 941168f8b40e ("virtio_net: support device stats")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
---
drivers/net/virtio_net.c | 42 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 3e2a5876c6c8c..9cbe40d218cc4 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -3532,6 +3532,7 @@ static int virtnet_tx_resize(struct virtnet_info *vi, struct send_queue *sq,
return err;
}
+
/*
* Send command via the control virtqueue and check status. Commands
* supported by the hypervisor, as indicated by feature bits, should
@@ -3546,6 +3547,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd
bool ok;
int ret;
+
/* Caller should know better */
BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ));
@@ -4927,6 +4929,32 @@ static void virtnet_fill_stats(struct virtnet_info *vi, u32 qid,
}
}
+static int virtnet_stats_reply_size(u8 type)
+{
+ switch (type) {
+ case VIRTIO_NET_STATS_TYPE_REPLY_CVQ:
+ return sizeof(struct virtio_net_stats_cvq);
+ case VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC:
+ return sizeof(struct virtio_net_stats_rx_basic);
+ case VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM:
+ return sizeof(struct virtio_net_stats_rx_csum);
+ case VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO:
+ return sizeof(struct virtio_net_stats_rx_gso);
+ case VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED:
+ return sizeof(struct virtio_net_stats_rx_speed);
+ case VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC:
+ return sizeof(struct virtio_net_stats_tx_basic);
+ case VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM:
+ return sizeof(struct virtio_net_stats_tx_csum);
+ case VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO:
+ return sizeof(struct virtio_net_stats_tx_gso);
+ case VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED:
+ return sizeof(struct virtio_net_stats_tx_speed);
+ default:
+ return sizeof(struct virtio_net_stats_reply_hdr);
+ }
+}
+
static int __virtnet_get_hw_stats(struct virtnet_info *vi,
struct virtnet_stats_ctx *ctx,
struct virtio_net_ctrl_queue_stats *req,
@@ -4936,7 +4964,7 @@ static int __virtnet_get_hw_stats(struct virtnet_info *vi,
struct scatterlist sgs_in, sgs_out;
void *p;
u32 qid;
- int ok;
+ int hdr_size, ok, remaining;
sg_init_one(&sgs_out, req, req_size);
sg_init_one(&sgs_in, reply, res_size);
@@ -4948,8 +4976,17 @@ static int __virtnet_get_hw_stats(struct virtnet_info *vi,
if (!ok)
return ok;
- for (p = reply; p - reply < res_size; p += le16_to_cpu(hdr->size)) {
+ for (p = reply; p - reply < res_size; p += hdr_size) {
+ remaining = res_size - (p - reply);
+ if (remaining < sizeof(*hdr))
+ return -EINVAL;
+
hdr = p;
+ hdr_size = le16_to_cpu(hdr->size);
+ if (hdr_size < virtnet_stats_reply_size(hdr->type) ||
+ hdr_size > remaining)
+ return -EINVAL;
+
qid = le16_to_cpu(hdr->vq_index);
virtnet_fill_stats(vi, qid, ctx, p, false, hdr->type);
}
@@ -7305,3 +7342,4 @@ module_exit(virtio_net_driver_exit);
MODULE_DEVICE_TABLE(virtio, id_table);
MODULE_DESCRIPTION("Virtio network driver");
MODULE_LICENSE("GPL");
+
--
2.53.0
^ permalink raw reply related
* Re: [PATCH v4 0/8] media: add virtio-media driver
From: Michael S. Tsirkin @ 2026-07-11 9:02 UTC (permalink / raw)
To: Brian Daniels
Cc: Mauro Carvalho Chehab, acourbot, adelva, aesteve, changyeon,
daniel.almeida, eperezma, gnurou, gurchetansingh, hverkuil,
jasowang, linux-kernel, linux-media, nicolas.dufresne,
virtualization, xuanzhuo
In-Reply-To: <CAD4i_GTPO2vEoCtDM1p1APapWv5TYqP_Hhn41kOCodTYJB5Yiw@mail.gmail.com>
On Fri, Jul 10, 2026 at 04:44:14PM -0400, Brian Daniels wrote:
> Hi Michael,
>
> Would you prefer more time to review these changes, or should I go
> ahead and upload a v5 based on the existing comments?
>
> Thanks,
> Brian
Pls send v5. Thanks!
> On Thu, Jun 25, 2026 at 4:21 PM Brian Daniels <briandaniels@google.com> wrote:
> >
> > > > From: Alexandre Courbot <gnurou@gmail.com>
> > > >
> > > > Add the first version of the virtio-media driver.
> > > >
> > > > This driver acts roughly as a V4L2 relay between user-space and the
> > > > virtio virtual device on the host, so it is relatively simple, yet
> > > > unconventional. It doesn't use VB2 or other frameworks typically used in
> > > > a V4L2 driver, and most of its complexity resides in correctly and
> > > > efficiently building the virtio descriptor chain to pass to the host,
> > > > avoiding copies whenever possible. This is done by
> > > > scatterlist_builder.[ch].
> > > >
> > > > This version supports MMAP buffers, while USERPTR buffers can also be
> > > > enabled through a driver option. DMABUF support is still pending.
> > > >
> > > > NOTE: This depends on the VIRTIO ID being added in this patch:
> > > > https://lore.kernel.org/all/20260310-virtio-media-id-v1-1-be211bcf682b@redhat.com
> >
> > I saw some CI build failures come back, but that should be resolved if the
> > patch above is merged. If you'd rather me add it to this patch series let me
> > know.
> >
> > > > Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
> > > > Co-developed-by: Brian Daniels <briandaniels@google.com>
> > > > Signed-off-by: Brian Daniels <briandaniels@google.com>
> > >
> > > Thanks for the patches!
> > > Sent some comments on individual patches.
> >
> > Thanks for the feedback!
> >
> > I've started to prepare v5 based on the comments so far, I'll hold off on
> > sending it until we've resolved the other open threads.
> >
> > > > ---
> > > > Guest Setup
> > > >
> > > > Tests were ran on a Debian 12 guest running with crosvm. The guest image
> > > > was created with:
> > > >
> > > > $ virt-builder debian-12 --root-password password:""
> > > >
> > > > Build crosvm and launch the guest starting at the "Crosvm" section on
> > > > this page: https://github.com/chromeos/virtio-media/blob/main/TRY_IT_OUT.md#crosvm
> > > >
> > > > NOTE: Before running v4l2-compliance in the guest, you need to install
> > > > v4l-utils and ffmpeg:
> > > >
> > > > $ apt update && apt install v4l-utils ffmpeg
> > > >
> > > > ---
> > > > Compliance Testing
> > > >
> > > > This was tested using v4l2-compliance. Since virtio-media serves as
> > > > a proxy to host devices for the guest VMs, we expect the guest
> > > > compliance test to essentially match the host compliance test for the
> > > > same device.
> > > >
> > > > NOTE: v4l2-compliance changes its test behavior depending on the driver
> > > > name. In the guest, the driver name for virtio-media proxied-devices is
> > > > always "virtio-media", even if the actual host device has a driver name
> > > > of e.g. "uvcvideo". To ensure the test is consistent between the host
> > > > and the guest, I created a patch for the v4l2-compliance tool that
> > > > allows you to override the driver name. All test results that follow use
> > > > this patch:
> > > > https://lore.kernel.org/r/20260528163448.4031965-1-briandaniels@google.com/
> > > >
> > > > All tests used a Logitech USB Webcam C925e.
> > > >
> > > > As tested on the host:
> > > >
> > > > $ v4l2-compliance -d1 -s
> > > >
> > > > v4l2-compliance 1.33.0-5471, 64 bits, 64-bit time_t
> > > > v4l2-compliance SHA: 9f2d3ea879ff 2026-05-28 14:45:11
> > > >
> > > > Compliance test for uvcvideo device /dev/video1:
> > > >
> > > > Driver Info:
> > > > Driver name : uvcvideo
> > > > Card type : Logitech Webcam C925e
> > > > Bus info : usb-0000:04:00.1-3
> > > > Driver version : 6.18.14
> > > > Capabilities : 0x84a00001
> > > > Video Capture
> > > > Metadata Capture
> > > > Streaming
> > > > Extended Pix Format
> > > > Device Capabilities
> > > > Device Caps : 0x04200001
> > > > Video Capture
> > > > Streaming
> > > > Extended Pix Format
> > > > Media Driver Info:
> > > > Driver name : uvcvideo
> > > > Model : Logitech Webcam C925e
> > > > Serial : 686F371F
> > > > Bus info : usb-0000:04:00.1-3
> > > > Media version : 6.18.14
> > > > Hardware revision: 0x00000016 (22)
> > > > Driver version : 6.18.14
> > > > Interface Info:
> > > > ID : 0x03000002
> > > > Type : V4L Video
> > > > Entity Info:
> > > > ID : 0x00000001 (1)
> > > > Name : Logitech Webcam C925e
> > > > Function : V4L2 I/O
> > > > Flags : default
> > > > Pad 0x01000007 : 0: Sink
> > > > Link 0x0200001f: from remote pad 0x100000a of entity 'Processing 3' (Video Pixel Formatter): Data, Enabled, Immutable
> > > >
> > > > Required ioctls:
> > > > test MC information (see 'Media Driver Info' above): OK
> > > > test VIDIOC_QUERYCAP: OK
> > > > test invalid ioctls: OK
> > > >
> > > > Allow for multiple opens:
> > > > test second /dev/video1 open: OK
> > > > test VIDIOC_QUERYCAP: OK
> > > > test VIDIOC_G/S_PRIORITY: OK
> > > > test for unlimited opens: OK
> > > >
> > > > Debug ioctls:
> > > > test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
> > > > test VIDIOC_LOG_STATUS: OK (Not Supported)
> > > >
> > > > Input ioctls:
> > > > test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
> > > > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > > > test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
> > > > test VIDIOC_ENUMAUDIO: OK (Not Supported)
> > > > test VIDIOC_G/S/ENUMINPUT: OK
> > > > test VIDIOC_G/S_AUDIO: OK (Not Supported)
> > > > Inputs: 1 Audio Inputs: 0 Tuners: 0
> > > >
> > > > Output ioctls:
> > > > test VIDIOC_G/S_MODULATOR: OK (Not Supported)
> > > > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > > > test VIDIOC_ENUMAUDOUT: OK (Not Supported)
> > > > test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
> > > > test VIDIOC_G/S_AUDOUT: OK (Not Supported)
> > > > Outputs: 0 Audio Outputs: 0 Modulators: 0
> > > >
> > > > Input/Output configuration ioctls:
> > > > test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
> > > > test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
> > > > test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
> > > > test VIDIOC_G/S_EDID: OK (Not Supported)
> > > >
> > > > Control ioctls (Input 0):
> > > > test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
> > > > test VIDIOC_QUERYCTRL: OK
> > > > test VIDIOC_G/S_CTRL: OK
> > > > fail: v4l2-test-controls.cpp(983): ret != EINVAL (got 13)
> > > > test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
> > > > test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
> > > > test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> > > > Standard Controls: 19 Private Controls: 0
> > > >
> > > > Format ioctls (Input 0):
> > > > test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
> > > > test VIDIOC_G/S_PARM: OK
> > > > test VIDIOC_G_FBUF: OK (Not Supported)
> > > > test VIDIOC_G_FMT: OK
> > > > test VIDIOC_TRY_FMT: OK
> > > > test VIDIOC_S_FMT: OK
> > > > test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
> > > > test Cropping: OK (Not Supported)
> > > > test Composing: OK (Not Supported)
> > > > test Scaling: OK (Not Supported)
> > > >
> > > > Codec ioctls (Input 0):
> > > > test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
> > > > test VIDIOC_G_ENC_INDEX: OK (Not Supported)
> > > > test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
> > > >
> > > > Buffer ioctls (Input 0):
> > > > test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> > > > test CREATE_BUFS maximum buffers: OK
> > > > test VIDIOC_REMOVE_BUFS: OK
> > > > test VIDIOC_EXPBUF: OK
> > > > test Requests: OK (Not Supported)
> > > > test blocking wait: OK
> > > >
> > > > Test input 0:
> > > >
> > > > Streaming ioctls:
> > > > test read/write: OK (Not Supported)
> > > >
> > > > Video Capture: Frame #000
> > > > Video Capture: Frame #001
> > > > Video Capture: Frame #002
> > > > Video Capture: Frame #003
> > > > Video Capture: Frame #004
> > > > Video Capture: Frame #005
> > > > Video Capture: Frame #006
> > > > Video Capture: Frame #007
> > > > Video Capture: Frame #008
> > > > Video Capture: Frame #009
> > > > Video Capture: Frame #010
> > > > Video Capture: Frame #011
> > > > Video Capture: Frame #012
> > > > Video Capture: Frame #013
> > > > Video Capture: Frame #014
> > > > Video Capture: Frame #015
> > > > Video Capture: Frame #016
> > > > Video Capture: Frame #017
> > > > Video Capture: Frame #018
> > > > Video Capture: Frame #019
> > > > Video Capture: Frame #020
> > > > Video Capture: Frame #021
> > > > Video Capture: Frame #022
> > > > Video Capture: Frame #023
> > > > Video Capture: Frame #024
> > > > Video Capture: Frame #025
> > > > Video Capture: Frame #026
> > > > Video Capture: Frame #027
> > > > Video Capture: Frame #028
> > > > Video Capture: Frame #029
> > > > Video Capture: Frame #030
> > > > Video Capture: Frame #031
> > > > Video Capture: Frame #032
> > > > Video Capture: Frame #033
> > > > Video Capture: Frame #034
> > > > Video Capture: Frame #035
> > > > Video Capture: Frame #036
> > > > Video Capture: Frame #037
> > > > Video Capture: Frame #038
> > > > Video Capture: Frame #039
> > > > Video Capture: Frame #040
> > > > Video Capture: Frame #041
> > > > Video Capture: Frame #042
> > > > Video Capture: Frame #043
> > > > Video Capture: Frame #044
> > > > Video Capture: Frame #045
> > > > Video Capture: Frame #046
> > > > Video Capture: Frame #047
> > > > Video Capture: Frame #048
> > > > Video Capture: Frame #049
> > > > Video Capture: Frame #050
> > > > Video Capture: Frame #051
> > > > Video Capture: Frame #052
> > > > Video Capture: Frame #053
> > > > Video Capture: Frame #054
> > > > Video Capture: Frame #055
> > > > Video Capture: Frame #056
> > > > Video Capture: Frame #057
> > > > Video Capture: Frame #058
> > > > Video Capture: Frame #059
> > > >
> > > > test MMAP (no poll, REQBUFS): OK
> > > >
> > > > Video Capture: Frame #000 (select)
> > > > Video Capture: Frame #001 (select)
> > > > Video Capture: Frame #002 (select)
> > > > Video Capture: Frame #003 (select)
> > > > Video Capture: Frame #004 (select)
> > > > Video Capture: Frame #005 (select)
> > > > Video Capture: Frame #006 (select)
> > > > Video Capture: Frame #007 (select)
> > > > Video Capture: Frame #008 (select)
> > > > Video Capture: Frame #009 (select)
> > > > Video Capture: Frame #010 (select)
> > > > Video Capture: Frame #011 (select)
> > > > Video Capture: Frame #012 (select)
> > > > Video Capture: Frame #013 (select)
> > > > Video Capture: Frame #014 (select)
> > > > Video Capture: Frame #015 (select)
> > > > Video Capture: Frame #016 (select)
> > > > Video Capture: Frame #017 (select)
> > > > Video Capture: Frame #018 (select)
> > > > Video Capture: Frame #019 (select)
> > > > Video Capture: Frame #020 (select)
> > > > Video Capture: Frame #021 (select)
> > > > Video Capture: Frame #022 (select)
> > > > Video Capture: Frame #023 (select)
> > > > Video Capture: Frame #024 (select)
> > > > Video Capture: Frame #025 (select)
> > > > Video Capture: Frame #026 (select)
> > > > Video Capture: Frame #027 (select)
> > > > Video Capture: Frame #028 (select)
> > > > Video Capture: Frame #029 (select)
> > > > Video Capture: Frame #030 (select)
> > > > Video Capture: Frame #031 (select)
> > > > Video Capture: Frame #032 (select)
> > > > Video Capture: Frame #033 (select)
> > > > Video Capture: Frame #034 (select)
> > > > Video Capture: Frame #035 (select)
> > > > Video Capture: Frame #036 (select)
> > > > Video Capture: Frame #037 (select)
> > > > Video Capture: Frame #038 (select)
> > > > Video Capture: Frame #039 (select)
> > > > Video Capture: Frame #040 (select)
> > > > Video Capture: Frame #041 (select)
> > > > Video Capture: Frame #042 (select)
> > > > Video Capture: Frame #043 (select)
> > > > Video Capture: Frame #044 (select)
> > > > Video Capture: Frame #045 (select)
> > > > Video Capture: Frame #046 (select)
> > > > Video Capture: Frame #047 (select)
> > > > Video Capture: Frame #048 (select)
> > > > Video Capture: Frame #049 (select)
> > > > Video Capture: Frame #050 (select)
> > > > Video Capture: Frame #051 (select)
> > > > Video Capture: Frame #052 (select)
> > > > Video Capture: Frame #053 (select)
> > > > Video Capture: Frame #054 (select)
> > > > Video Capture: Frame #055 (select)
> > > > Video Capture: Frame #056 (select)
> > > > Video Capture: Frame #057 (select)
> > > > Video Capture: Frame #058 (select)
> > > > Video Capture: Frame #059 (select)
> > > >
> > > > test MMAP (select, REQBUFS): OK
> > > >
> > > > Video Capture: Frame #000 (epoll)
> > > > Video Capture: Frame #001 (epoll)
> > > > Video Capture: Frame #002 (epoll)
> > > > Video Capture: Frame #003 (epoll)
> > > > Video Capture: Frame #004 (epoll)
> > > > Video Capture: Frame #005 (epoll)
> > > > Video Capture: Frame #006 (epoll)
> > > > Video Capture: Frame #007 (epoll)
> > > > Video Capture: Frame #008 (epoll)
> > > > Video Capture: Frame #009 (epoll)
> > > > Video Capture: Frame #010 (epoll)
> > > > Video Capture: Frame #011 (epoll)
> > > > Video Capture: Frame #012 (epoll)
> > > > Video Capture: Frame #013 (epoll)
> > > > Video Capture: Frame #014 (epoll)
> > > > Video Capture: Frame #015 (epoll)
> > > > Video Capture: Frame #016 (epoll)
> > > > Video Capture: Frame #017 (epoll)
> > > > Video Capture: Frame #018 (epoll)
> > > > Video Capture: Frame #019 (epoll)
> > > > Video Capture: Frame #020 (epoll)
> > > > Video Capture: Frame #021 (epoll)
> > > > Video Capture: Frame #022 (epoll)
> > > > Video Capture: Frame #023 (epoll)
> > > > Video Capture: Frame #024 (epoll)
> > > > Video Capture: Frame #025 (epoll)
> > > > Video Capture: Frame #026 (epoll)
> > > > Video Capture: Frame #027 (epoll)
> > > > Video Capture: Frame #028 (epoll)
> > > > Video Capture: Frame #029 (epoll)
> > > > Video Capture: Frame #030 (epoll)
> > > > Video Capture: Frame #031 (epoll)
> > > > Video Capture: Frame #032 (epoll)
> > > > Video Capture: Frame #033 (epoll)
> > > > Video Capture: Frame #034 (epoll)
> > > > Video Capture: Frame #035 (epoll)
> > > > Video Capture: Frame #036 (epoll)
> > > > Video Capture: Frame #037 (epoll)
> > > > Video Capture: Frame #038 (epoll)
> > > > Video Capture: Frame #039 (epoll)
> > > > Video Capture: Frame #040 (epoll)
> > > > Video Capture: Frame #041 (epoll)
> > > > Video Capture: Frame #042 (epoll)
> > > > Video Capture: Frame #043 (epoll)
> > > > Video Capture: Frame #044 (epoll)
> > > > Video Capture: Frame #045 (epoll)
> > > > Video Capture: Frame #046 (epoll)
> > > > Video Capture: Frame #047 (epoll)
> > > > Video Capture: Frame #048 (epoll)
> > > > Video Capture: Frame #049 (epoll)
> > > > Video Capture: Frame #050 (epoll)
> > > > Video Capture: Frame #051 (epoll)
> > > > Video Capture: Frame #052 (epoll)
> > > > Video Capture: Frame #053 (epoll)
> > > > Video Capture: Frame #054 (epoll)
> > > > Video Capture: Frame #055 (epoll)
> > > > Video Capture: Frame #056 (epoll)
> > > > Video Capture: Frame #057 (epoll)
> > > > Video Capture: Frame #058 (epoll)
> > > > Video Capture: Frame #059 (epoll)
> > > >
> > > > test MMAP (epoll, REQBUFS): OK
> > > >
> > > > Video Capture: Frame #000
> > > > Video Capture: Frame #001
> > > > Video Capture: Frame #002
> > > > Video Capture: Frame #003
> > > > Video Capture: Frame #004
> > > > Video Capture: Frame #005
> > > > Video Capture: Frame #006
> > > > Video Capture: Frame #007
> > > > Video Capture: Frame #008
> > > > Video Capture: Frame #009
> > > > Video Capture: Frame #010
> > > > Video Capture: Frame #011
> > > > Video Capture: Frame #012
> > > > Video Capture: Frame #013
> > > > Video Capture: Frame #014
> > > > Video Capture: Frame #015
> > > > Video Capture: Frame #016
> > > > Video Capture: Frame #017
> > > > Video Capture: Frame #018
> > > > Video Capture: Frame #019
> > > > Video Capture: Frame #020
> > > > Video Capture: Frame #021
> > > > Video Capture: Frame #022
> > > > Video Capture: Frame #023
> > > > Video Capture: Frame #024
> > > > Video Capture: Frame #025
> > > > Video Capture: Frame #026
> > > > Video Capture: Frame #027
> > > > Video Capture: Frame #028
> > > > Video Capture: Frame #029
> > > > Video Capture: Frame #030
> > > > Video Capture: Frame #031
> > > > Video Capture: Frame #032
> > > > Video Capture: Frame #033
> > > > Video Capture: Frame #034
> > > > Video Capture: Frame #035
> > > > Video Capture: Frame #036
> > > > Video Capture: Frame #037
> > > > Video Capture: Frame #038
> > > > Video Capture: Frame #039
> > > > Video Capture: Frame #040
> > > > Video Capture: Frame #041
> > > > Video Capture: Frame #042
> > > > Video Capture: Frame #043
> > > > Video Capture: Frame #044
> > > > Video Capture: Frame #045
> > > > Video Capture: Frame #046
> > > > Video Capture: Frame #047
> > > > Video Capture: Frame #048
> > > > Video Capture: Frame #049
> > > > Video Capture: Frame #050
> > > > Video Capture: Frame #051
> > > > Video Capture: Frame #052
> > > > Video Capture: Frame #053
> > > > Video Capture: Frame #054
> > > > Video Capture: Frame #055
> > > > Video Capture: Frame #056
> > > > Video Capture: Frame #057
> > > > Video Capture: Frame #058
> > > > Video Capture: Frame #059
> > > >
> > > > test MMAP (no poll, CREATE_BUFS): OK
> > > >
> > > > Video Capture: Frame #000 (select)
> > > > Video Capture: Frame #001 (select)
> > > > Video Capture: Frame #002 (select)
> > > > Video Capture: Frame #003 (select)
> > > > Video Capture: Frame #004 (select)
> > > > Video Capture: Frame #005 (select)
> > > > Video Capture: Frame #006 (select)
> > > > Video Capture: Frame #007 (select)
> > > > Video Capture: Frame #008 (select)
> > > > Video Capture: Frame #009 (select)
> > > > Video Capture: Frame #010 (select)
> > > > Video Capture: Frame #011 (select)
> > > > Video Capture: Frame #012 (select)
> > > > Video Capture: Frame #013 (select)
> > > > Video Capture: Frame #014 (select)
> > > > Video Capture: Frame #015 (select)
> > > > Video Capture: Frame #016 (select)
> > > > Video Capture: Frame #017 (select)
> > > > Video Capture: Frame #018 (select)
> > > > Video Capture: Frame #019 (select)
> > > > Video Capture: Frame #020 (select)
> > > > Video Capture: Frame #021 (select)
> > > > Video Capture: Frame #022 (select)
> > > > Video Capture: Frame #023 (select)
> > > > Video Capture: Frame #024 (select)
> > > > Video Capture: Frame #025 (select)
> > > > Video Capture: Frame #026 (select)
> > > > Video Capture: Frame #027 (select)
> > > > Video Capture: Frame #028 (select)
> > > > Video Capture: Frame #029 (select)
> > > > Video Capture: Frame #030 (select)
> > > > Video Capture: Frame #031 (select)
> > > > Video Capture: Frame #032 (select)
> > > > Video Capture: Frame #033 (select)
> > > > Video Capture: Frame #034 (select)
> > > > Video Capture: Frame #035 (select)
> > > > Video Capture: Frame #036 (select)
> > > > Video Capture: Frame #037 (select)
> > > > Video Capture: Frame #038 (select)
> > > > Video Capture: Frame #039 (select)
> > > > Video Capture: Frame #040 (select)
> > > > Video Capture: Frame #041 (select)
> > > > Video Capture: Frame #042 (select)
> > > > Video Capture: Frame #043 (select)
> > > > Video Capture: Frame #044 (select)
> > > > Video Capture: Frame #045 (select)
> > > > Video Capture: Frame #046 (select)
> > > > Video Capture: Frame #047 (select)
> > > > Video Capture: Frame #048 (select)
> > > > Video Capture: Frame #049 (select)
> > > > Video Capture: Frame #050 (select)
> > > > Video Capture: Frame #051 (select)
> > > > Video Capture: Frame #052 (select)
> > > > Video Capture: Frame #053 (select)
> > > > Video Capture: Frame #054 (select)
> > > > Video Capture: Frame #055 (select)
> > > > Video Capture: Frame #056 (select)
> > > > Video Capture: Frame #057 (select)
> > > > Video Capture: Frame #058 (select)
> > > > Video Capture: Frame #059 (select)
> > > >
> > > > test MMAP (select, CREATE_BUFS): OK
> > > >
> > > > Video Capture: Frame #000 (epoll)
> > > > Video Capture: Frame #001 (epoll)
> > > > Video Capture: Frame #002 (epoll)
> > > > Video Capture: Frame #003 (epoll)
> > > > Video Capture: Frame #004 (epoll)
> > > > Video Capture: Frame #005 (epoll)
> > > > Video Capture: Frame #006 (epoll)
> > > > Video Capture: Frame #007 (epoll)
> > > > Video Capture: Frame #008 (epoll)
> > > > Video Capture: Frame #009 (epoll)
> > > > Video Capture: Frame #010 (epoll)
> > > > Video Capture: Frame #011 (epoll)
> > > > Video Capture: Frame #012 (epoll)
> > > > Video Capture: Frame #013 (epoll)
> > > > Video Capture: Frame #014 (epoll)
> > > > Video Capture: Frame #015 (epoll)
> > > > Video Capture: Frame #016 (epoll)
> > > > Video Capture: Frame #017 (epoll)
> > > > Video Capture: Frame #018 (epoll)
> > > > Video Capture: Frame #019 (epoll)
> > > > Video Capture: Frame #020 (epoll)
> > > > Video Capture: Frame #021 (epoll)
> > > > Video Capture: Frame #022 (epoll)
> > > > Video Capture: Frame #023 (epoll)
> > > > Video Capture: Frame #024 (epoll)
> > > > Video Capture: Frame #025 (epoll)
> > > > Video Capture: Frame #026 (epoll)
> > > > Video Capture: Frame #027 (epoll)
> > > > Video Capture: Frame #028 (epoll)
> > > > Video Capture: Frame #029 (epoll)
> > > > Video Capture: Frame #030 (epoll)
> > > > Video Capture: Frame #031 (epoll)
> > > > Video Capture: Frame #032 (epoll)
> > > > Video Capture: Frame #033 (epoll)
> > > > Video Capture: Frame #034 (epoll)
> > > > Video Capture: Frame #035 (epoll)
> > > > Video Capture: Frame #036 (epoll)
> > > > Video Capture: Frame #037 (epoll)
> > > > Video Capture: Frame #038 (epoll)
> > > > Video Capture: Frame #039 (epoll)
> > > > Video Capture: Frame #040 (epoll)
> > > > Video Capture: Frame #041 (epoll)
> > > > Video Capture: Frame #042 (epoll)
> > > > Video Capture: Frame #043 (epoll)
> > > > Video Capture: Frame #044 (epoll)
> > > > Video Capture: Frame #045 (epoll)
> > > > Video Capture: Frame #046 (epoll)
> > > > Video Capture: Frame #047 (epoll)
> > > > Video Capture: Frame #048 (epoll)
> > > > Video Capture: Frame #049 (epoll)
> > > > Video Capture: Frame #050 (epoll)
> > > > Video Capture: Frame #051 (epoll)
> > > > Video Capture: Frame #052 (epoll)
> > > > Video Capture: Frame #053 (epoll)
> > > > Video Capture: Frame #054 (epoll)
> > > > Video Capture: Frame #055 (epoll)
> > > > Video Capture: Frame #056 (epoll)
> > > > Video Capture: Frame #057 (epoll)
> > > > Video Capture: Frame #058 (epoll)
> > > > Video Capture: Frame #059 (epoll)
> > > >
> > > > test MMAP (epoll, CREATE_BUFS): OK
> > > >
> > > > Video Capture: Frame #000
> > > > Video Capture: Frame #001
> > > > Video Capture: Frame #002
> > > > Video Capture: Frame #003
> > > > Video Capture: Frame #004
> > > > Video Capture: Frame #005
> > > > Video Capture: Frame #006
> > > > Video Capture: Frame #007
> > > > Video Capture: Frame #008
> > > > Video Capture: Frame #009
> > > > Video Capture: Frame #010
> > > > Video Capture: Frame #011
> > > > Video Capture: Frame #012
> > > > Video Capture: Frame #013
> > > > Video Capture: Frame #014
> > > > Video Capture: Frame #015
> > > > Video Capture: Frame #016
> > > > Video Capture: Frame #017
> > > > Video Capture: Frame #018
> > > > Video Capture: Frame #019
> > > > Video Capture: Frame #020
> > > > Video Capture: Frame #021
> > > > Video Capture: Frame #022
> > > > Video Capture: Frame #023
> > > > Video Capture: Frame #024
> > > > Video Capture: Frame #025
> > > > Video Capture: Frame #026
> > > > Video Capture: Frame #027
> > > > Video Capture: Frame #028
> > > > Video Capture: Frame #029
> > > > Video Capture: Frame #030
> > > > Video Capture: Frame #031
> > > > Video Capture: Frame #032
> > > > Video Capture: Frame #033
> > > > Video Capture: Frame #034
> > > > Video Capture: Frame #035
> > > > Video Capture: Frame #036
> > > > Video Capture: Frame #037
> > > > Video Capture: Frame #038
> > > > Video Capture: Frame #039
> > > > Video Capture: Frame #040
> > > > Video Capture: Frame #041
> > > > Video Capture: Frame #042
> > > > Video Capture: Frame #043
> > > > Video Capture: Frame #044
> > > > Video Capture: Frame #045
> > > > Video Capture: Frame #046
> > > > Video Capture: Frame #047
> > > > Video Capture: Frame #048
> > > > Video Capture: Frame #049
> > > > Video Capture: Frame #050
> > > > Video Capture: Frame #051
> > > > Video Capture: Frame #052
> > > > Video Capture: Frame #053
> > > > Video Capture: Frame #054
> > > > Video Capture: Frame #055
> > > > Video Capture: Frame #056
> > > > Video Capture: Frame #057
> > > > Video Capture: Frame #058
> > > > Video Capture: Frame #059
> > > >
> > > > test USERPTR (no poll): OK
> > > >
> > > > Video Capture: Frame #000 (select)
> > > > Video Capture: Frame #001 (select)
> > > > Video Capture: Frame #002 (select)
> > > > Video Capture: Frame #003 (select)
> > > > Video Capture: Frame #004 (select)
> > > > Video Capture: Frame #005 (select)
> > > > Video Capture: Frame #006 (select)
> > > > Video Capture: Frame #007 (select)
> > > > Video Capture: Frame #008 (select)
> > > > Video Capture: Frame #009 (select)
> > > > Video Capture: Frame #010 (select)
> > > > Video Capture: Frame #011 (select)
> > > > Video Capture: Frame #012 (select)
> > > > Video Capture: Frame #013 (select)
> > > > Video Capture: Frame #014 (select)
> > > > Video Capture: Frame #015 (select)
> > > > Video Capture: Frame #016 (select)
> > > > Video Capture: Frame #017 (select)
> > > > Video Capture: Frame #018 (select)
> > > > Video Capture: Frame #019 (select)
> > > > Video Capture: Frame #020 (select)
> > > > Video Capture: Frame #021 (select)
> > > > Video Capture: Frame #022 (select)
> > > > Video Capture: Frame #023 (select)
> > > > Video Capture: Frame #024 (select)
> > > > Video Capture: Frame #025 (select)
> > > > Video Capture: Frame #026 (select)
> > > > Video Capture: Frame #027 (select)
> > > > Video Capture: Frame #028 (select)
> > > > Video Capture: Frame #029 (select)
> > > > Video Capture: Frame #030 (select)
> > > > Video Capture: Frame #031 (select)
> > > > Video Capture: Frame #032 (select)
> > > > Video Capture: Frame #033 (select)
> > > > Video Capture: Frame #034 (select)
> > > > Video Capture: Frame #035 (select)
> > > > Video Capture: Frame #036 (select)
> > > > Video Capture: Frame #037 (select)
> > > > Video Capture: Frame #038 (select)
> > > > Video Capture: Frame #039 (select)
> > > > Video Capture: Frame #040 (select)
> > > > Video Capture: Frame #041 (select)
> > > > Video Capture: Frame #042 (select)
> > > > Video Capture: Frame #043 (select)
> > > > Video Capture: Frame #044 (select)
> > > > Video Capture: Frame #045 (select)
> > > > Video Capture: Frame #046 (select)
> > > > Video Capture: Frame #047 (select)
> > > > Video Capture: Frame #048 (select)
> > > > Video Capture: Frame #049 (select)
> > > > Video Capture: Frame #050 (select)
> > > > Video Capture: Frame #051 (select)
> > > > Video Capture: Frame #052 (select)
> > > > Video Capture: Frame #053 (select)
> > > > Video Capture: Frame #054 (select)
> > > > Video Capture: Frame #055 (select)
> > > > Video Capture: Frame #056 (select)
> > > > Video Capture: Frame #057 (select)
> > > > Video Capture: Frame #058 (select)
> > > > Video Capture: Frame #059 (select)
> > > >
> > > > test USERPTR (select): OK
> > > > test DMABUF: Cannot test, specify --expbuf-device
> > > >
> > > > Total for uvcvideo device /dev/video1: 58, Succeeded: 57, Failed: 1, Warnings: 0
> > > >
> > > > As tested on the guest:
> > > >
> > > > $ v4l2-compliance -d0 -s --driver-name uvcvideo
> > > >
> > > > v4l2-compliance 1.33.0-5457, 64 bits, 64-bit time_t
> > > > v4l2-compliance SHA: e7e240f546f3 2026-05-28 17:06:12
> > > >
> > > > Compliance test for uvcvideo device (overridden from virtio-media) /dev/video0:
> > > >
> > > > Driver Info:
> > > > Driver name : uvcvideo
> > > > Card type : Logitech Webcam C925e
> > > > Bus info : platform:virtio-media
> > > > Driver version : 7.1.0
> > > > Capabilities : 0x84200001
> > > > Video Capture
> > > > Streaming
> > > > Extended Pix Format
> > > > Device Capabilities
> > > > Device Caps : 0x04200001
> > > > Video Capture
> > > > Streaming
> > > > Extended Pix Format
> > > >
> > > > Required ioctls:
> > > > test VIDIOC_QUERYCAP: OK
> > > > test invalid ioctls: OK
> > > >
> > > > Allow for multiple opens:
> > > > test second /dev/video0 open: OK
> > > > test VIDIOC_QUERYCAP: OK
> > > > test VIDIOC_G/S_PRIORITY: OK
> > > > test for unlimited opens: OK
> > > >
> > > > Debug ioctls:
> > > > test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
> > > > test VIDIOC_LOG_STATUS: OK (Not Supported)
> > > >
> > > > Input ioctls:
> > > > test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
> > > > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > > > test VIDIOC_S_HW_FREQ_SEEK: OK
> > > > test VIDIOC_ENUMAUDIO: OK (Not Supported)
> > > > test VIDIOC_G/S/ENUMINPUT: OK
> > > > test VIDIOC_G/S_AUDIO: OK (Not Supported)
> > > > Inputs: 1 Audio Inputs: 0 Tuners: 0
> > > >
> > > > Output ioctls:
> > > > test VIDIOC_G/S_MODULATOR: OK (Not Supported)
> > > > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > > > test VIDIOC_ENUMAUDOUT: OK (Not Supported)
> > > > test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
> > > > test VIDIOC_G/S_AUDOUT: OK (Not Supported)
> > > > Outputs: 0 Audio Outputs: 0 Modulators: 0
> > > >
> > > > Input/Output configuration ioctls:
> > > > test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
> > > > test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
> > > > test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
> > > > test VIDIOC_G/S_EDID: OK (Not Supported)
> > > >
> > > > Control ioctls (Input 0):
> > > > test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
> > > > test VIDIOC_QUERYCTRL: OK
> > > > test VIDIOC_G/S_CTRL: OK
> > > > fail: v4l2-test-controls.cpp(981): ret (got 22)
> > > > test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
> > > > test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
> > > > test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> > > > Standard Controls: 19 Private Controls: 0
> > > >
> > > > Format ioctls (Input 0):
> > > > test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
> > > > test VIDIOC_G/S_PARM: OK
> > > > test VIDIOC_G_FBUF: OK (Not Supported)
> > > > test VIDIOC_G_FMT: OK
> > > > test VIDIOC_TRY_FMT: OK
> > > > test VIDIOC_S_FMT: OK
> > > > test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
> > > > test Cropping: OK (Not Supported)
> > > > test Composing: OK (Not Supported)
> > > > test Scaling: OK (Not Supported)
> > > >
> > > > Codec ioctls (Input 0):
> > > > test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
> > > > test VIDIOC_G_ENC_INDEX: OK (Not Supported)
> > > > test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
> > > >
> > > > Buffer ioctls (Input 0):
> > > > test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> > > > test CREATE_BUFS maximum buffers: OK
> > > > test VIDIOC_REMOVE_BUFS: OK
> > > > test VIDIOC_EXPBUF: OK (Not Supported)
> > > > test Requests: OK (Not Supported)
> > > > test blocking wait: OK
> > > >
> > > > Test input 0:
> > > >
> > > > Streaming ioctls:
> > > > test read/write: OK (Not Supported)
> > > >
> > > > Video Capture: Frame #000
> > > > Video Capture: Frame #001
> > > > Video Capture: Frame #002
> > > > Video Capture: Frame #003
> > > > Video Capture: Frame #004
> > > > Video Capture: Frame #005
> > > > Video Capture: Frame #006
> > > > Video Capture: Frame #007
> > > > Video Capture: Frame #008
> > > > Video Capture: Frame #009
> > > > Video Capture: Frame #010
> > > > Video Capture: Frame #011
> > > > Video Capture: Frame #012
> > > > Video Capture: Frame #013
> > > > Video Capture: Frame #014
> > > > Video Capture: Frame #015
> > > > Video Capture: Frame #016
> > > > Video Capture: Frame #017
> > > > Video Capture: Frame #018
> > > > Video Capture: Frame #019
> > > > Video Capture: Frame #020
> > > > Video Capture: Frame #021
> > > > Video Capture: Frame #022
> > > > Video Capture: Frame #023
> > > > Video Capture: Frame #024
> > > > Video Capture: Frame #025
> > > > Video Capture: Frame #026
> > > > Video Capture: Frame #027
> > > > Video Capture: Frame #028
> > > > Video Capture: Frame #029
> > > > Video Capture: Frame #030
> > > > Video Capture: Frame #031
> > > > Video Capture: Frame #032
> > > > Video Capture: Frame #033
> > > > Video Capture: Frame #034
> > > > Video Capture: Frame #035
> > > > Video Capture: Frame #036
> > > > Video Capture: Frame #037
> > > > Video Capture: Frame #038
> > > > Video Capture: Frame #039
> > > > Video Capture: Frame #040
> > > > Video Capture: Frame #041
> > > > Video Capture: Frame #042
> > > > Video Capture: Frame #043
> > > > Video Capture: Frame #044
> > > > Video Capture: Frame #045
> > > > Video Capture: Frame #046
> > > > Video Capture: Frame #047
> > > > Video Capture: Frame #048
> > > > Video Capture: Frame #049
> > > > Video Capture: Frame #050
> > > > Video Capture: Frame #051
> > > > Video Capture: Frame #052
> > > > Video Capture: Frame #053
> > > > Video Capture: Frame #054
> > > > Video Capture: Frame #055
> > > > Video Capture: Frame #056
> > > > Video Capture: Frame #057
> > > > Video Capture: Frame #058
> > > > Video Capture: Frame #059
> > > >
> > > > test MMAP (no poll, REQBUFS): OK
> > > >
> > > > Video Capture: Frame #000 (select)
> > > > Video Capture: Frame #001 (select)
> > > > Video Capture: Frame #002 (select)
> > > > Video Capture: Frame #003 (select)
> > > > Video Capture: Frame #004 (select)
> > > > Video Capture: Frame #005 (select)
> > > > Video Capture: Frame #006 (select)
> > > > Video Capture: Frame #007 (select)
> > > > Video Capture: Frame #008 (select)
> > > > Video Capture: Frame #009 (select)
> > > > Video Capture: Frame #010 (select)
> > > > Video Capture: Frame #011 (select)
> > > > Video Capture: Frame #012 (select)
> > > > Video Capture: Frame #013 (select)
> > > > Video Capture: Frame #014 (select)
> > > > Video Capture: Frame #015 (select)
> > > > Video Capture: Frame #016 (select)
> > > > Video Capture: Frame #017 (select)
> > > > Video Capture: Frame #018 (select)
> > > > Video Capture: Frame #019 (select)
> > > > Video Capture: Frame #020 (select)
> > > > Video Capture: Frame #021 (select)
> > > > Video Capture: Frame #022 (select)
> > > > Video Capture: Frame #023 (select)
> > > > Video Capture: Frame #024 (select)
> > > > Video Capture: Frame #025 (select)
> > > > Video Capture: Frame #026 (select)
> > > > Video Capture: Frame #027 (select)
> > > > Video Capture: Frame #028 (select)
> > > > Video Capture: Frame #029 (select)
> > > > Video Capture: Frame #030 (select)
> > > > Video Capture: Frame #031 (select)
> > > > Video Capture: Frame #032 (select)
> > > > Video Capture: Frame #033 (select)
> > > > Video Capture: Frame #034 (select)
> > > > Video Capture: Frame #035 (select)
> > > > Video Capture: Frame #036 (select)
> > > > Video Capture: Frame #037 (select)
> > > > Video Capture: Frame #038 (select)
> > > > Video Capture: Frame #039 (select)
> > > > Video Capture: Frame #040 (select)
> > > > Video Capture: Frame #041 (select)
> > > > Video Capture: Frame #042 (select)
> > > > Video Capture: Frame #043 (select)
> > > > Video Capture: Frame #044 (select)
> > > > Video Capture: Frame #045 (select)
> > > > Video Capture: Frame #046 (select)
> > > > Video Capture: Frame #047 (select)
> > > > Video Capture: Frame #048 (select)
> > > > Video Capture: Frame #049 (select)
> > > > Video Capture: Frame #050 (select)
> > > > Video Capture: Frame #051 (select)
> > > > Video Capture: Frame #052 (select)
> > > > Video Capture: Frame #053 (select)
> > > > Video Capture: Frame #054 (select)
> > > > Video Capture: Frame #055 (select)
> > > > Video Capture: Frame #056 (select)
> > > > Video Capture: Frame #057 (select)
> > > > Video Capture: Frame #058 (select)
> > > > Video Capture: Frame #059 (select)
> > > >
> > > > test MMAP (select, REQBUFS): OK
> > > >
> > > > Video Capture: Frame #000 (epoll)
> > > > Video Capture: Frame #001 (epoll)
> > > > Video Capture: Frame #002 (epoll)
> > > > Video Capture: Frame #003 (epoll)
> > > > Video Capture: Frame #004 (epoll)
> > > > Video Capture: Frame #005 (epoll)
> > > > Video Capture: Frame #006 (epoll)
> > > > Video Capture: Frame #007 (epoll)
> > > > Video Capture: Frame #008 (epoll)
> > > > Video Capture: Frame #009 (epoll)
> > > > Video Capture: Frame #010 (epoll)
> > > > Video Capture: Frame #011 (epoll)
> > > > Video Capture: Frame #012 (epoll)
> > > > Video Capture: Frame #013 (epoll)
> > > > Video Capture: Frame #014 (epoll)
> > > > Video Capture: Frame #015 (epoll)
> > > > Video Capture: Frame #016 (epoll)
> > > > Video Capture: Frame #017 (epoll)
> > > > Video Capture: Frame #018 (epoll)
> > > > Video Capture: Frame #019 (epoll)
> > > > Video Capture: Frame #020 (epoll)
> > > > Video Capture: Frame #021 (epoll)
> > > > Video Capture: Frame #022 (epoll)
> > > > Video Capture: Frame #023 (epoll)
> > > > Video Capture: Frame #024 (epoll)
> > > > Video Capture: Frame #025 (epoll)
> > > > Video Capture: Frame #026 (epoll)
> > > > Video Capture: Frame #027 (epoll)
> > > > Video Capture: Frame #028 (epoll)
> > > > Video Capture: Frame #029 (epoll)
> > > > Video Capture: Frame #030 (epoll)
> > > > Video Capture: Frame #031 (epoll)
> > > > Video Capture: Frame #032 (epoll)
> > > > Video Capture: Frame #033 (epoll)
> > > > Video Capture: Frame #034 (epoll)
> > > > Video Capture: Frame #035 (epoll)
> > > > Video Capture: Frame #036 (epoll)
> > > > Video Capture: Frame #037 (epoll)
> > > > Video Capture: Frame #038 (epoll)
> > > > Video Capture: Frame #039 (epoll)
> > > > Video Capture: Frame #040 (epoll)
> > > > Video Capture: Frame #041 (epoll)
> > > > Video Capture: Frame #042 (epoll)
> > > > Video Capture: Frame #043 (epoll)
> > > > Video Capture: Frame #044 (epoll)
> > > > Video Capture: Frame #045 (epoll)
> > > > Video Capture: Frame #046 (epoll)
> > > > Video Capture: Frame #047 (epoll)
> > > > Video Capture: Frame #048 (epoll)
> > > > Video Capture: Frame #049 (epoll)
> > > > Video Capture: Frame #050 (epoll)
> > > > Video Capture: Frame #051 (epoll)
> > > > Video Capture: Frame #052 (epoll)
> > > > Video Capture: Frame #053 (epoll)
> > > > Video Capture: Frame #054 (epoll)
> > > > Video Capture: Frame #055 (epoll)
> > > > Video Capture: Frame #056 (epoll)
> > > > Video Capture: Frame #057 (epoll)
> > > > Video Capture: Frame #058 (epoll)
> > > > Video Capture: Frame #059 (epoll)
> > > >
> > > > test MMAP (epoll, REQBUFS): OK
> > > >
> > > > Video Capture: Frame #000
> > > > Video Capture: Frame #001
> > > > Video Capture: Frame #002
> > > > Video Capture: Frame #003
> > > > Video Capture: Frame #004
> > > > Video Capture: Frame #005
> > > > Video Capture: Frame #006
> > > > Video Capture: Frame #007
> > > > Video Capture: Frame #008
> > > > Video Capture: Frame #009
> > > > Video Capture: Frame #010
> > > > Video Capture: Frame #011
> > > > Video Capture: Frame #012
> > > > Video Capture: Frame #013
> > > > Video Capture: Frame #014
> > > > Video Capture: Frame #015
> > > > Video Capture: Frame #016
> > > > Video Capture: Frame #017
> > > > Video Capture: Frame #018
> > > > Video Capture: Frame #019
> > > > Video Capture: Frame #020
> > > > Video Capture: Frame #021
> > > > Video Capture: Frame #022
> > > > Video Capture: Frame #023
> > > > Video Capture: Frame #024
> > > > Video Capture: Frame #025
> > > > Video Capture: Frame #026
> > > > Video Capture: Frame #027
> > > > Video Capture: Frame #028
> > > > Video Capture: Frame #029
> > > > Video Capture: Frame #030
> > > > Video Capture: Frame #031
> > > > Video Capture: Frame #032
> > > > Video Capture: Frame #033
> > > > Video Capture: Frame #034
> > > > Video Capture: Frame #035
> > > > Video Capture: Frame #036
> > > > Video Capture: Frame #037
> > > > Video Capture: Frame #038
> > > > Video Capture: Frame #039
> > > > Video Capture: Frame #040
> > > > Video Capture: Frame #041
> > > > Video Capture: Frame #042
> > > > Video Capture: Frame #043
> > > > Video Capture: Frame #044
> > > > Video Capture: Frame #045
> > > > Video Capture: Frame #046
> > > > Video Capture: Frame #047
> > > > Video Capture: Frame #048
> > > > Video Capture: Frame #049
> > > > Video Capture: Frame #050
> > > > Video Capture: Frame #051
> > > > Video Capture: Frame #052
> > > > Video Capture: Frame #053
> > > > Video Capture: Frame #054
> > > > Video Capture: Frame #055
> > > > Video Capture: Frame #056
> > > > Video Capture: Frame #057
> > > > Video Capture: Frame #058
> > > > Video Capture: Frame #059
> > > >
> > > > test MMAP (no poll, CREATE_BUFS): OK
> > > >
> > > > Video Capture: Frame #000 (select)
> > > > Video Capture: Frame #001 (select)
> > > > Video Capture: Frame #002 (select)
> > > > Video Capture: Frame #003 (select)
> > > > Video Capture: Frame #004 (select)
> > > > Video Capture: Frame #005 (select)
> > > > Video Capture: Frame #006 (select)
> > > > Video Capture: Frame #007 (select)
> > > > Video Capture: Frame #008 (select)
> > > > Video Capture: Frame #009 (select)
> > > > Video Capture: Frame #010 (select)
> > > > Video Capture: Frame #011 (select)
> > > > Video Capture: Frame #012 (select)
> > > > Video Capture: Frame #013 (select)
> > > > Video Capture: Frame #014 (select)
> > > > Video Capture: Frame #015 (select)
> > > > Video Capture: Frame #016 (select)
> > > > Video Capture: Frame #017 (select)
> > > > Video Capture: Frame #018 (select)
> > > > Video Capture: Frame #019 (select)
> > > > Video Capture: Frame #020 (select)
> > > > Video Capture: Frame #021 (select)
> > > > Video Capture: Frame #022 (select)
> > > > Video Capture: Frame #023 (select)
> > > > Video Capture: Frame #024 (select)
> > > > Video Capture: Frame #025 (select)
> > > > Video Capture: Frame #026 (select)
> > > > Video Capture: Frame #027 (select)
> > > > Video Capture: Frame #028 (select)
> > > > Video Capture: Frame #029 (select)
> > > > Video Capture: Frame #030 (select)
> > > > Video Capture: Frame #031 (select)
> > > > Video Capture: Frame #032 (select)
> > > > Video Capture: Frame #033 (select)
> > > > Video Capture: Frame #034 (select)
> > > > Video Capture: Frame #035 (select)
> > > > Video Capture: Frame #036 (select)
> > > > Video Capture: Frame #037 (select)
> > > > Video Capture: Frame #038 (select)
> > > > Video Capture: Frame #039 (select)
> > > > Video Capture: Frame #040 (select)
> > > > Video Capture: Frame #041 (select)
> > > > Video Capture: Frame #042 (select)
> > > > Video Capture: Frame #043 (select)
> > > > Video Capture: Frame #044 (select)
> > > > Video Capture: Frame #045 (select)
> > > > Video Capture: Frame #046 (select)
> > > > Video Capture: Frame #047 (select)
> > > > Video Capture: Frame #048 (select)
> > > > Video Capture: Frame #049 (select)
> > > > Video Capture: Frame #050 (select)
> > > > Video Capture: Frame #051 (select)
> > > > Video Capture: Frame #052 (select)
> > > > Video Capture: Frame #053 (select)
> > > > Video Capture: Frame #054 (select)
> > > > Video Capture: Frame #055 (select)
> > > > Video Capture: Frame #056 (select)
> > > > Video Capture: Frame #057 (select)
> > > > Video Capture: Frame #058 (select)
> > > > Video Capture: Frame #059 (select)
> > > >
> > > > test MMAP (select, CREATE_BUFS): OK
> > > >
> > > > Video Capture: Frame #000 (epoll)
> > > > Video Capture: Frame #001 (epoll)
> > > > Video Capture: Frame #002 (epoll)
> > > > Video Capture: Frame #003 (epoll)
> > > > Video Capture: Frame #004 (epoll)
> > > > Video Capture: Frame #005 (epoll)
> > > > Video Capture: Frame #006 (epoll)
> > > > Video Capture: Frame #007 (epoll)
> > > > Video Capture: Frame #008 (epoll)
> > > > Video Capture: Frame #009 (epoll)
> > > > Video Capture: Frame #010 (epoll)
> > > > Video Capture: Frame #011 (epoll)
> > > > Video Capture: Frame #012 (epoll)
> > > > Video Capture: Frame #013 (epoll)
> > > > Video Capture: Frame #014 (epoll)
> > > > Video Capture: Frame #015 (epoll)
> > > > Video Capture: Frame #016 (epoll)
> > > > Video Capture: Frame #017 (epoll)
> > > > Video Capture: Frame #018 (epoll)
> > > > Video Capture: Frame #019 (epoll)
> > > > Video Capture: Frame #020 (epoll)
> > > > Video Capture: Frame #021 (epoll)
> > > > Video Capture: Frame #022 (epoll)
> > > > Video Capture: Frame #023 (epoll)
> > > > Video Capture: Frame #024 (epoll)
> > > > Video Capture: Frame #025 (epoll)
> > > > Video Capture: Frame #026 (epoll)
> > > > Video Capture: Frame #027 (epoll)
> > > > Video Capture: Frame #028 (epoll)
> > > > Video Capture: Frame #029 (epoll)
> > > > Video Capture: Frame #030 (epoll)
> > > > Video Capture: Frame #031 (epoll)
> > > > Video Capture: Frame #032 (epoll)
> > > > Video Capture: Frame #033 (epoll)
> > > > Video Capture: Frame #034 (epoll)
> > > > Video Capture: Frame #035 (epoll)
> > > > Video Capture: Frame #036 (epoll)
> > > > Video Capture: Frame #037 (epoll)
> > > > Video Capture: Frame #038 (epoll)
> > > > Video Capture: Frame #039 (epoll)
> > > > Video Capture: Frame #040 (epoll)
> > > > Video Capture: Frame #041 (epoll)
> > > > Video Capture: Frame #042 (epoll)
> > > > Video Capture: Frame #043 (epoll)
> > > > Video Capture: Frame #044 (epoll)
> > > > Video Capture: Frame #045 (epoll)
> > > > Video Capture: Frame #046 (epoll)
> > > > Video Capture: Frame #047 (epoll)
> > > > Video Capture: Frame #048 (epoll)
> > > > Video Capture: Frame #049 (epoll)
> > > > Video Capture: Frame #050 (epoll)
> > > > Video Capture: Frame #051 (epoll)
> > > > Video Capture: Frame #052 (epoll)
> > > > Video Capture: Frame #053 (epoll)
> > > > Video Capture: Frame #054 (epoll)
> > > > Video Capture: Frame #055 (epoll)
> > > > Video Capture: Frame #056 (epoll)
> > > > Video Capture: Frame #057 (epoll)
> > > > Video Capture: Frame #058 (epoll)
> > > > Video Capture: Frame #059 (epoll)
> > > >
> > > > test MMAP (epoll, CREATE_BUFS): OK
> > > > test USERPTR (no poll): OK (Not Supported)
> > > > test USERPTR (select): OK (Not Supported)
> > > > test DMABUF (no poll): OK (Not Supported)
> > > > test DMABUF (select): OK (Not Supported)
> > > >
> > > > Total for uvcvideo device /dev/video0: 59, Succeeded: 58, Failed: 1, Warnings: 0
> > > >
> > > > ---
> > > > Changes in v4:
> > > > - Rebased on top of v7.1-rc1
> > > > - Replace usages of filep->private_data with file_to_v4l2_fh()
> > > > throughout the driver
> > > > - Link to v3: https://lore.kernel.org/r/20250412-virtio-media-v3-1-97dc94c18398@gmail.com
> > > >
> > > > Changes in v3:
> > > > - Rebased on top of v6.15-rc1 and removes obsolete control callbacks.
> > > > - Link to v2: https://lore.kernel.org/r/20250201-virtio-media-v2-1-ac840681452d@gmail.com
> > > >
> > > > Changes in v2:
> > > > - Fixed kernel test robot and media CI warnings (ignored a few false
> > > > positives).
> > > > - Changed in-driver email address to personal one since my Google one
> > > > will soon become invalid.
> > > > - Link to v1: https://lore.kernel.org/r/20250123-virtio-media-v1-1-81e2549b86b9@gmail.com
> > > >
> > > > Brian Daniels (8):
> > > > media: virtio: Add protocol
> > > > media: virtio: Add virtio-media driver structs and function
> > > > declarations
> > > > media: virtio: Add virtio-media session related structures
> > > > media: virtio: Add scatterlist_builder
> > > > media: virtio: Add virtio_media_ioctls
> > > > media: virtio: Add virtio_media_driver
> > > > media: virtio: Add virtio-media to the build system
> > > > media: virtio: Add MAINTAINERS entry
> > > >
> > > > MAINTAINERS | 6 +
> > > > drivers/media/Kconfig | 13 +
> > > > drivers/media/Makefile | 2 +
> > > > drivers/media/virtio/Makefile | 8 +
> > > > drivers/media/virtio/protocol.h | 287 +++++
> > > > drivers/media/virtio/scatterlist_builder.c | 574 +++++++++
> > > > drivers/media/virtio/scatterlist_builder.h | 112 ++
> > > > drivers/media/virtio/session.h | 130 ++
> > > > drivers/media/virtio/virtio_media.h | 95 ++
> > > > drivers/media/virtio/virtio_media_driver.c | 959 ++++++++++++++
> > > > drivers/media/virtio/virtio_media_ioctls.c | 1338 ++++++++++++++++++++
> > > > 11 files changed, 3524 insertions(+)
> > > > create mode 100644 drivers/media/virtio/Makefile
> > > > create mode 100644 drivers/media/virtio/protocol.h
> > > > create mode 100644 drivers/media/virtio/scatterlist_builder.c
> > > > create mode 100644 drivers/media/virtio/scatterlist_builder.h
> > > > create mode 100644 drivers/media/virtio/session.h
> > > > create mode 100644 drivers/media/virtio/virtio_media.h
> > > > create mode 100644 drivers/media/virtio/virtio_media_driver.c
> > > > create mode 100644 drivers/media/virtio/virtio_media_ioctls.c
> > > >
> > > >
> > > > base-commit: 06cb687a5132fcffe624c0070576ab852ac6b568
> >
> >
^ permalink raw reply
* Re: [PATCH v4 0/8] media: add virtio-media driver
From: Brian Daniels @ 2026-07-10 20:44 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Mauro Carvalho Chehab, acourbot, adelva, aesteve, changyeon,
daniel.almeida, eperezma, gnurou, gurchetansingh, hverkuil,
jasowang, linux-kernel, linux-media, nicolas.dufresne,
virtualization, xuanzhuo
In-Reply-To: <20260625202130.2983760-1-briandaniels@google.com>
Hi Michael,
Would you prefer more time to review these changes, or should I go
ahead and upload a v5 based on the existing comments?
Thanks,
Brian
On Thu, Jun 25, 2026 at 4:21 PM Brian Daniels <briandaniels@google.com> wrote:
>
> > > From: Alexandre Courbot <gnurou@gmail.com>
> > >
> > > Add the first version of the virtio-media driver.
> > >
> > > This driver acts roughly as a V4L2 relay between user-space and the
> > > virtio virtual device on the host, so it is relatively simple, yet
> > > unconventional. It doesn't use VB2 or other frameworks typically used in
> > > a V4L2 driver, and most of its complexity resides in correctly and
> > > efficiently building the virtio descriptor chain to pass to the host,
> > > avoiding copies whenever possible. This is done by
> > > scatterlist_builder.[ch].
> > >
> > > This version supports MMAP buffers, while USERPTR buffers can also be
> > > enabled through a driver option. DMABUF support is still pending.
> > >
> > > NOTE: This depends on the VIRTIO ID being added in this patch:
> > > https://lore.kernel.org/all/20260310-virtio-media-id-v1-1-be211bcf682b@redhat.com
>
> I saw some CI build failures come back, but that should be resolved if the
> patch above is merged. If you'd rather me add it to this patch series let me
> know.
>
> > > Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
> > > Co-developed-by: Brian Daniels <briandaniels@google.com>
> > > Signed-off-by: Brian Daniels <briandaniels@google.com>
> >
> > Thanks for the patches!
> > Sent some comments on individual patches.
>
> Thanks for the feedback!
>
> I've started to prepare v5 based on the comments so far, I'll hold off on
> sending it until we've resolved the other open threads.
>
> > > ---
> > > Guest Setup
> > >
> > > Tests were ran on a Debian 12 guest running with crosvm. The guest image
> > > was created with:
> > >
> > > $ virt-builder debian-12 --root-password password:""
> > >
> > > Build crosvm and launch the guest starting at the "Crosvm" section on
> > > this page: https://github.com/chromeos/virtio-media/blob/main/TRY_IT_OUT.md#crosvm
> > >
> > > NOTE: Before running v4l2-compliance in the guest, you need to install
> > > v4l-utils and ffmpeg:
> > >
> > > $ apt update && apt install v4l-utils ffmpeg
> > >
> > > ---
> > > Compliance Testing
> > >
> > > This was tested using v4l2-compliance. Since virtio-media serves as
> > > a proxy to host devices for the guest VMs, we expect the guest
> > > compliance test to essentially match the host compliance test for the
> > > same device.
> > >
> > > NOTE: v4l2-compliance changes its test behavior depending on the driver
> > > name. In the guest, the driver name for virtio-media proxied-devices is
> > > always "virtio-media", even if the actual host device has a driver name
> > > of e.g. "uvcvideo". To ensure the test is consistent between the host
> > > and the guest, I created a patch for the v4l2-compliance tool that
> > > allows you to override the driver name. All test results that follow use
> > > this patch:
> > > https://lore.kernel.org/r/20260528163448.4031965-1-briandaniels@google.com/
> > >
> > > All tests used a Logitech USB Webcam C925e.
> > >
> > > As tested on the host:
> > >
> > > $ v4l2-compliance -d1 -s
> > >
> > > v4l2-compliance 1.33.0-5471, 64 bits, 64-bit time_t
> > > v4l2-compliance SHA: 9f2d3ea879ff 2026-05-28 14:45:11
> > >
> > > Compliance test for uvcvideo device /dev/video1:
> > >
> > > Driver Info:
> > > Driver name : uvcvideo
> > > Card type : Logitech Webcam C925e
> > > Bus info : usb-0000:04:00.1-3
> > > Driver version : 6.18.14
> > > Capabilities : 0x84a00001
> > > Video Capture
> > > Metadata Capture
> > > Streaming
> > > Extended Pix Format
> > > Device Capabilities
> > > Device Caps : 0x04200001
> > > Video Capture
> > > Streaming
> > > Extended Pix Format
> > > Media Driver Info:
> > > Driver name : uvcvideo
> > > Model : Logitech Webcam C925e
> > > Serial : 686F371F
> > > Bus info : usb-0000:04:00.1-3
> > > Media version : 6.18.14
> > > Hardware revision: 0x00000016 (22)
> > > Driver version : 6.18.14
> > > Interface Info:
> > > ID : 0x03000002
> > > Type : V4L Video
> > > Entity Info:
> > > ID : 0x00000001 (1)
> > > Name : Logitech Webcam C925e
> > > Function : V4L2 I/O
> > > Flags : default
> > > Pad 0x01000007 : 0: Sink
> > > Link 0x0200001f: from remote pad 0x100000a of entity 'Processing 3' (Video Pixel Formatter): Data, Enabled, Immutable
> > >
> > > Required ioctls:
> > > test MC information (see 'Media Driver Info' above): OK
> > > test VIDIOC_QUERYCAP: OK
> > > test invalid ioctls: OK
> > >
> > > Allow for multiple opens:
> > > test second /dev/video1 open: OK
> > > test VIDIOC_QUERYCAP: OK
> > > test VIDIOC_G/S_PRIORITY: OK
> > > test for unlimited opens: OK
> > >
> > > Debug ioctls:
> > > test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
> > > test VIDIOC_LOG_STATUS: OK (Not Supported)
> > >
> > > Input ioctls:
> > > test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
> > > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > > test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
> > > test VIDIOC_ENUMAUDIO: OK (Not Supported)
> > > test VIDIOC_G/S/ENUMINPUT: OK
> > > test VIDIOC_G/S_AUDIO: OK (Not Supported)
> > > Inputs: 1 Audio Inputs: 0 Tuners: 0
> > >
> > > Output ioctls:
> > > test VIDIOC_G/S_MODULATOR: OK (Not Supported)
> > > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > > test VIDIOC_ENUMAUDOUT: OK (Not Supported)
> > > test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
> > > test VIDIOC_G/S_AUDOUT: OK (Not Supported)
> > > Outputs: 0 Audio Outputs: 0 Modulators: 0
> > >
> > > Input/Output configuration ioctls:
> > > test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
> > > test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
> > > test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
> > > test VIDIOC_G/S_EDID: OK (Not Supported)
> > >
> > > Control ioctls (Input 0):
> > > test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
> > > test VIDIOC_QUERYCTRL: OK
> > > test VIDIOC_G/S_CTRL: OK
> > > fail: v4l2-test-controls.cpp(983): ret != EINVAL (got 13)
> > > test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
> > > test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
> > > test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> > > Standard Controls: 19 Private Controls: 0
> > >
> > > Format ioctls (Input 0):
> > > test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
> > > test VIDIOC_G/S_PARM: OK
> > > test VIDIOC_G_FBUF: OK (Not Supported)
> > > test VIDIOC_G_FMT: OK
> > > test VIDIOC_TRY_FMT: OK
> > > test VIDIOC_S_FMT: OK
> > > test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
> > > test Cropping: OK (Not Supported)
> > > test Composing: OK (Not Supported)
> > > test Scaling: OK (Not Supported)
> > >
> > > Codec ioctls (Input 0):
> > > test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
> > > test VIDIOC_G_ENC_INDEX: OK (Not Supported)
> > > test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
> > >
> > > Buffer ioctls (Input 0):
> > > test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> > > test CREATE_BUFS maximum buffers: OK
> > > test VIDIOC_REMOVE_BUFS: OK
> > > test VIDIOC_EXPBUF: OK
> > > test Requests: OK (Not Supported)
> > > test blocking wait: OK
> > >
> > > Test input 0:
> > >
> > > Streaming ioctls:
> > > test read/write: OK (Not Supported)
> > >
> > > Video Capture: Frame #000
> > > Video Capture: Frame #001
> > > Video Capture: Frame #002
> > > Video Capture: Frame #003
> > > Video Capture: Frame #004
> > > Video Capture: Frame #005
> > > Video Capture: Frame #006
> > > Video Capture: Frame #007
> > > Video Capture: Frame #008
> > > Video Capture: Frame #009
> > > Video Capture: Frame #010
> > > Video Capture: Frame #011
> > > Video Capture: Frame #012
> > > Video Capture: Frame #013
> > > Video Capture: Frame #014
> > > Video Capture: Frame #015
> > > Video Capture: Frame #016
> > > Video Capture: Frame #017
> > > Video Capture: Frame #018
> > > Video Capture: Frame #019
> > > Video Capture: Frame #020
> > > Video Capture: Frame #021
> > > Video Capture: Frame #022
> > > Video Capture: Frame #023
> > > Video Capture: Frame #024
> > > Video Capture: Frame #025
> > > Video Capture: Frame #026
> > > Video Capture: Frame #027
> > > Video Capture: Frame #028
> > > Video Capture: Frame #029
> > > Video Capture: Frame #030
> > > Video Capture: Frame #031
> > > Video Capture: Frame #032
> > > Video Capture: Frame #033
> > > Video Capture: Frame #034
> > > Video Capture: Frame #035
> > > Video Capture: Frame #036
> > > Video Capture: Frame #037
> > > Video Capture: Frame #038
> > > Video Capture: Frame #039
> > > Video Capture: Frame #040
> > > Video Capture: Frame #041
> > > Video Capture: Frame #042
> > > Video Capture: Frame #043
> > > Video Capture: Frame #044
> > > Video Capture: Frame #045
> > > Video Capture: Frame #046
> > > Video Capture: Frame #047
> > > Video Capture: Frame #048
> > > Video Capture: Frame #049
> > > Video Capture: Frame #050
> > > Video Capture: Frame #051
> > > Video Capture: Frame #052
> > > Video Capture: Frame #053
> > > Video Capture: Frame #054
> > > Video Capture: Frame #055
> > > Video Capture: Frame #056
> > > Video Capture: Frame #057
> > > Video Capture: Frame #058
> > > Video Capture: Frame #059
> > >
> > > test MMAP (no poll, REQBUFS): OK
> > >
> > > Video Capture: Frame #000 (select)
> > > Video Capture: Frame #001 (select)
> > > Video Capture: Frame #002 (select)
> > > Video Capture: Frame #003 (select)
> > > Video Capture: Frame #004 (select)
> > > Video Capture: Frame #005 (select)
> > > Video Capture: Frame #006 (select)
> > > Video Capture: Frame #007 (select)
> > > Video Capture: Frame #008 (select)
> > > Video Capture: Frame #009 (select)
> > > Video Capture: Frame #010 (select)
> > > Video Capture: Frame #011 (select)
> > > Video Capture: Frame #012 (select)
> > > Video Capture: Frame #013 (select)
> > > Video Capture: Frame #014 (select)
> > > Video Capture: Frame #015 (select)
> > > Video Capture: Frame #016 (select)
> > > Video Capture: Frame #017 (select)
> > > Video Capture: Frame #018 (select)
> > > Video Capture: Frame #019 (select)
> > > Video Capture: Frame #020 (select)
> > > Video Capture: Frame #021 (select)
> > > Video Capture: Frame #022 (select)
> > > Video Capture: Frame #023 (select)
> > > Video Capture: Frame #024 (select)
> > > Video Capture: Frame #025 (select)
> > > Video Capture: Frame #026 (select)
> > > Video Capture: Frame #027 (select)
> > > Video Capture: Frame #028 (select)
> > > Video Capture: Frame #029 (select)
> > > Video Capture: Frame #030 (select)
> > > Video Capture: Frame #031 (select)
> > > Video Capture: Frame #032 (select)
> > > Video Capture: Frame #033 (select)
> > > Video Capture: Frame #034 (select)
> > > Video Capture: Frame #035 (select)
> > > Video Capture: Frame #036 (select)
> > > Video Capture: Frame #037 (select)
> > > Video Capture: Frame #038 (select)
> > > Video Capture: Frame #039 (select)
> > > Video Capture: Frame #040 (select)
> > > Video Capture: Frame #041 (select)
> > > Video Capture: Frame #042 (select)
> > > Video Capture: Frame #043 (select)
> > > Video Capture: Frame #044 (select)
> > > Video Capture: Frame #045 (select)
> > > Video Capture: Frame #046 (select)
> > > Video Capture: Frame #047 (select)
> > > Video Capture: Frame #048 (select)
> > > Video Capture: Frame #049 (select)
> > > Video Capture: Frame #050 (select)
> > > Video Capture: Frame #051 (select)
> > > Video Capture: Frame #052 (select)
> > > Video Capture: Frame #053 (select)
> > > Video Capture: Frame #054 (select)
> > > Video Capture: Frame #055 (select)
> > > Video Capture: Frame #056 (select)
> > > Video Capture: Frame #057 (select)
> > > Video Capture: Frame #058 (select)
> > > Video Capture: Frame #059 (select)
> > >
> > > test MMAP (select, REQBUFS): OK
> > >
> > > Video Capture: Frame #000 (epoll)
> > > Video Capture: Frame #001 (epoll)
> > > Video Capture: Frame #002 (epoll)
> > > Video Capture: Frame #003 (epoll)
> > > Video Capture: Frame #004 (epoll)
> > > Video Capture: Frame #005 (epoll)
> > > Video Capture: Frame #006 (epoll)
> > > Video Capture: Frame #007 (epoll)
> > > Video Capture: Frame #008 (epoll)
> > > Video Capture: Frame #009 (epoll)
> > > Video Capture: Frame #010 (epoll)
> > > Video Capture: Frame #011 (epoll)
> > > Video Capture: Frame #012 (epoll)
> > > Video Capture: Frame #013 (epoll)
> > > Video Capture: Frame #014 (epoll)
> > > Video Capture: Frame #015 (epoll)
> > > Video Capture: Frame #016 (epoll)
> > > Video Capture: Frame #017 (epoll)
> > > Video Capture: Frame #018 (epoll)
> > > Video Capture: Frame #019 (epoll)
> > > Video Capture: Frame #020 (epoll)
> > > Video Capture: Frame #021 (epoll)
> > > Video Capture: Frame #022 (epoll)
> > > Video Capture: Frame #023 (epoll)
> > > Video Capture: Frame #024 (epoll)
> > > Video Capture: Frame #025 (epoll)
> > > Video Capture: Frame #026 (epoll)
> > > Video Capture: Frame #027 (epoll)
> > > Video Capture: Frame #028 (epoll)
> > > Video Capture: Frame #029 (epoll)
> > > Video Capture: Frame #030 (epoll)
> > > Video Capture: Frame #031 (epoll)
> > > Video Capture: Frame #032 (epoll)
> > > Video Capture: Frame #033 (epoll)
> > > Video Capture: Frame #034 (epoll)
> > > Video Capture: Frame #035 (epoll)
> > > Video Capture: Frame #036 (epoll)
> > > Video Capture: Frame #037 (epoll)
> > > Video Capture: Frame #038 (epoll)
> > > Video Capture: Frame #039 (epoll)
> > > Video Capture: Frame #040 (epoll)
> > > Video Capture: Frame #041 (epoll)
> > > Video Capture: Frame #042 (epoll)
> > > Video Capture: Frame #043 (epoll)
> > > Video Capture: Frame #044 (epoll)
> > > Video Capture: Frame #045 (epoll)
> > > Video Capture: Frame #046 (epoll)
> > > Video Capture: Frame #047 (epoll)
> > > Video Capture: Frame #048 (epoll)
> > > Video Capture: Frame #049 (epoll)
> > > Video Capture: Frame #050 (epoll)
> > > Video Capture: Frame #051 (epoll)
> > > Video Capture: Frame #052 (epoll)
> > > Video Capture: Frame #053 (epoll)
> > > Video Capture: Frame #054 (epoll)
> > > Video Capture: Frame #055 (epoll)
> > > Video Capture: Frame #056 (epoll)
> > > Video Capture: Frame #057 (epoll)
> > > Video Capture: Frame #058 (epoll)
> > > Video Capture: Frame #059 (epoll)
> > >
> > > test MMAP (epoll, REQBUFS): OK
> > >
> > > Video Capture: Frame #000
> > > Video Capture: Frame #001
> > > Video Capture: Frame #002
> > > Video Capture: Frame #003
> > > Video Capture: Frame #004
> > > Video Capture: Frame #005
> > > Video Capture: Frame #006
> > > Video Capture: Frame #007
> > > Video Capture: Frame #008
> > > Video Capture: Frame #009
> > > Video Capture: Frame #010
> > > Video Capture: Frame #011
> > > Video Capture: Frame #012
> > > Video Capture: Frame #013
> > > Video Capture: Frame #014
> > > Video Capture: Frame #015
> > > Video Capture: Frame #016
> > > Video Capture: Frame #017
> > > Video Capture: Frame #018
> > > Video Capture: Frame #019
> > > Video Capture: Frame #020
> > > Video Capture: Frame #021
> > > Video Capture: Frame #022
> > > Video Capture: Frame #023
> > > Video Capture: Frame #024
> > > Video Capture: Frame #025
> > > Video Capture: Frame #026
> > > Video Capture: Frame #027
> > > Video Capture: Frame #028
> > > Video Capture: Frame #029
> > > Video Capture: Frame #030
> > > Video Capture: Frame #031
> > > Video Capture: Frame #032
> > > Video Capture: Frame #033
> > > Video Capture: Frame #034
> > > Video Capture: Frame #035
> > > Video Capture: Frame #036
> > > Video Capture: Frame #037
> > > Video Capture: Frame #038
> > > Video Capture: Frame #039
> > > Video Capture: Frame #040
> > > Video Capture: Frame #041
> > > Video Capture: Frame #042
> > > Video Capture: Frame #043
> > > Video Capture: Frame #044
> > > Video Capture: Frame #045
> > > Video Capture: Frame #046
> > > Video Capture: Frame #047
> > > Video Capture: Frame #048
> > > Video Capture: Frame #049
> > > Video Capture: Frame #050
> > > Video Capture: Frame #051
> > > Video Capture: Frame #052
> > > Video Capture: Frame #053
> > > Video Capture: Frame #054
> > > Video Capture: Frame #055
> > > Video Capture: Frame #056
> > > Video Capture: Frame #057
> > > Video Capture: Frame #058
> > > Video Capture: Frame #059
> > >
> > > test MMAP (no poll, CREATE_BUFS): OK
> > >
> > > Video Capture: Frame #000 (select)
> > > Video Capture: Frame #001 (select)
> > > Video Capture: Frame #002 (select)
> > > Video Capture: Frame #003 (select)
> > > Video Capture: Frame #004 (select)
> > > Video Capture: Frame #005 (select)
> > > Video Capture: Frame #006 (select)
> > > Video Capture: Frame #007 (select)
> > > Video Capture: Frame #008 (select)
> > > Video Capture: Frame #009 (select)
> > > Video Capture: Frame #010 (select)
> > > Video Capture: Frame #011 (select)
> > > Video Capture: Frame #012 (select)
> > > Video Capture: Frame #013 (select)
> > > Video Capture: Frame #014 (select)
> > > Video Capture: Frame #015 (select)
> > > Video Capture: Frame #016 (select)
> > > Video Capture: Frame #017 (select)
> > > Video Capture: Frame #018 (select)
> > > Video Capture: Frame #019 (select)
> > > Video Capture: Frame #020 (select)
> > > Video Capture: Frame #021 (select)
> > > Video Capture: Frame #022 (select)
> > > Video Capture: Frame #023 (select)
> > > Video Capture: Frame #024 (select)
> > > Video Capture: Frame #025 (select)
> > > Video Capture: Frame #026 (select)
> > > Video Capture: Frame #027 (select)
> > > Video Capture: Frame #028 (select)
> > > Video Capture: Frame #029 (select)
> > > Video Capture: Frame #030 (select)
> > > Video Capture: Frame #031 (select)
> > > Video Capture: Frame #032 (select)
> > > Video Capture: Frame #033 (select)
> > > Video Capture: Frame #034 (select)
> > > Video Capture: Frame #035 (select)
> > > Video Capture: Frame #036 (select)
> > > Video Capture: Frame #037 (select)
> > > Video Capture: Frame #038 (select)
> > > Video Capture: Frame #039 (select)
> > > Video Capture: Frame #040 (select)
> > > Video Capture: Frame #041 (select)
> > > Video Capture: Frame #042 (select)
> > > Video Capture: Frame #043 (select)
> > > Video Capture: Frame #044 (select)
> > > Video Capture: Frame #045 (select)
> > > Video Capture: Frame #046 (select)
> > > Video Capture: Frame #047 (select)
> > > Video Capture: Frame #048 (select)
> > > Video Capture: Frame #049 (select)
> > > Video Capture: Frame #050 (select)
> > > Video Capture: Frame #051 (select)
> > > Video Capture: Frame #052 (select)
> > > Video Capture: Frame #053 (select)
> > > Video Capture: Frame #054 (select)
> > > Video Capture: Frame #055 (select)
> > > Video Capture: Frame #056 (select)
> > > Video Capture: Frame #057 (select)
> > > Video Capture: Frame #058 (select)
> > > Video Capture: Frame #059 (select)
> > >
> > > test MMAP (select, CREATE_BUFS): OK
> > >
> > > Video Capture: Frame #000 (epoll)
> > > Video Capture: Frame #001 (epoll)
> > > Video Capture: Frame #002 (epoll)
> > > Video Capture: Frame #003 (epoll)
> > > Video Capture: Frame #004 (epoll)
> > > Video Capture: Frame #005 (epoll)
> > > Video Capture: Frame #006 (epoll)
> > > Video Capture: Frame #007 (epoll)
> > > Video Capture: Frame #008 (epoll)
> > > Video Capture: Frame #009 (epoll)
> > > Video Capture: Frame #010 (epoll)
> > > Video Capture: Frame #011 (epoll)
> > > Video Capture: Frame #012 (epoll)
> > > Video Capture: Frame #013 (epoll)
> > > Video Capture: Frame #014 (epoll)
> > > Video Capture: Frame #015 (epoll)
> > > Video Capture: Frame #016 (epoll)
> > > Video Capture: Frame #017 (epoll)
> > > Video Capture: Frame #018 (epoll)
> > > Video Capture: Frame #019 (epoll)
> > > Video Capture: Frame #020 (epoll)
> > > Video Capture: Frame #021 (epoll)
> > > Video Capture: Frame #022 (epoll)
> > > Video Capture: Frame #023 (epoll)
> > > Video Capture: Frame #024 (epoll)
> > > Video Capture: Frame #025 (epoll)
> > > Video Capture: Frame #026 (epoll)
> > > Video Capture: Frame #027 (epoll)
> > > Video Capture: Frame #028 (epoll)
> > > Video Capture: Frame #029 (epoll)
> > > Video Capture: Frame #030 (epoll)
> > > Video Capture: Frame #031 (epoll)
> > > Video Capture: Frame #032 (epoll)
> > > Video Capture: Frame #033 (epoll)
> > > Video Capture: Frame #034 (epoll)
> > > Video Capture: Frame #035 (epoll)
> > > Video Capture: Frame #036 (epoll)
> > > Video Capture: Frame #037 (epoll)
> > > Video Capture: Frame #038 (epoll)
> > > Video Capture: Frame #039 (epoll)
> > > Video Capture: Frame #040 (epoll)
> > > Video Capture: Frame #041 (epoll)
> > > Video Capture: Frame #042 (epoll)
> > > Video Capture: Frame #043 (epoll)
> > > Video Capture: Frame #044 (epoll)
> > > Video Capture: Frame #045 (epoll)
> > > Video Capture: Frame #046 (epoll)
> > > Video Capture: Frame #047 (epoll)
> > > Video Capture: Frame #048 (epoll)
> > > Video Capture: Frame #049 (epoll)
> > > Video Capture: Frame #050 (epoll)
> > > Video Capture: Frame #051 (epoll)
> > > Video Capture: Frame #052 (epoll)
> > > Video Capture: Frame #053 (epoll)
> > > Video Capture: Frame #054 (epoll)
> > > Video Capture: Frame #055 (epoll)
> > > Video Capture: Frame #056 (epoll)
> > > Video Capture: Frame #057 (epoll)
> > > Video Capture: Frame #058 (epoll)
> > > Video Capture: Frame #059 (epoll)
> > >
> > > test MMAP (epoll, CREATE_BUFS): OK
> > >
> > > Video Capture: Frame #000
> > > Video Capture: Frame #001
> > > Video Capture: Frame #002
> > > Video Capture: Frame #003
> > > Video Capture: Frame #004
> > > Video Capture: Frame #005
> > > Video Capture: Frame #006
> > > Video Capture: Frame #007
> > > Video Capture: Frame #008
> > > Video Capture: Frame #009
> > > Video Capture: Frame #010
> > > Video Capture: Frame #011
> > > Video Capture: Frame #012
> > > Video Capture: Frame #013
> > > Video Capture: Frame #014
> > > Video Capture: Frame #015
> > > Video Capture: Frame #016
> > > Video Capture: Frame #017
> > > Video Capture: Frame #018
> > > Video Capture: Frame #019
> > > Video Capture: Frame #020
> > > Video Capture: Frame #021
> > > Video Capture: Frame #022
> > > Video Capture: Frame #023
> > > Video Capture: Frame #024
> > > Video Capture: Frame #025
> > > Video Capture: Frame #026
> > > Video Capture: Frame #027
> > > Video Capture: Frame #028
> > > Video Capture: Frame #029
> > > Video Capture: Frame #030
> > > Video Capture: Frame #031
> > > Video Capture: Frame #032
> > > Video Capture: Frame #033
> > > Video Capture: Frame #034
> > > Video Capture: Frame #035
> > > Video Capture: Frame #036
> > > Video Capture: Frame #037
> > > Video Capture: Frame #038
> > > Video Capture: Frame #039
> > > Video Capture: Frame #040
> > > Video Capture: Frame #041
> > > Video Capture: Frame #042
> > > Video Capture: Frame #043
> > > Video Capture: Frame #044
> > > Video Capture: Frame #045
> > > Video Capture: Frame #046
> > > Video Capture: Frame #047
> > > Video Capture: Frame #048
> > > Video Capture: Frame #049
> > > Video Capture: Frame #050
> > > Video Capture: Frame #051
> > > Video Capture: Frame #052
> > > Video Capture: Frame #053
> > > Video Capture: Frame #054
> > > Video Capture: Frame #055
> > > Video Capture: Frame #056
> > > Video Capture: Frame #057
> > > Video Capture: Frame #058
> > > Video Capture: Frame #059
> > >
> > > test USERPTR (no poll): OK
> > >
> > > Video Capture: Frame #000 (select)
> > > Video Capture: Frame #001 (select)
> > > Video Capture: Frame #002 (select)
> > > Video Capture: Frame #003 (select)
> > > Video Capture: Frame #004 (select)
> > > Video Capture: Frame #005 (select)
> > > Video Capture: Frame #006 (select)
> > > Video Capture: Frame #007 (select)
> > > Video Capture: Frame #008 (select)
> > > Video Capture: Frame #009 (select)
> > > Video Capture: Frame #010 (select)
> > > Video Capture: Frame #011 (select)
> > > Video Capture: Frame #012 (select)
> > > Video Capture: Frame #013 (select)
> > > Video Capture: Frame #014 (select)
> > > Video Capture: Frame #015 (select)
> > > Video Capture: Frame #016 (select)
> > > Video Capture: Frame #017 (select)
> > > Video Capture: Frame #018 (select)
> > > Video Capture: Frame #019 (select)
> > > Video Capture: Frame #020 (select)
> > > Video Capture: Frame #021 (select)
> > > Video Capture: Frame #022 (select)
> > > Video Capture: Frame #023 (select)
> > > Video Capture: Frame #024 (select)
> > > Video Capture: Frame #025 (select)
> > > Video Capture: Frame #026 (select)
> > > Video Capture: Frame #027 (select)
> > > Video Capture: Frame #028 (select)
> > > Video Capture: Frame #029 (select)
> > > Video Capture: Frame #030 (select)
> > > Video Capture: Frame #031 (select)
> > > Video Capture: Frame #032 (select)
> > > Video Capture: Frame #033 (select)
> > > Video Capture: Frame #034 (select)
> > > Video Capture: Frame #035 (select)
> > > Video Capture: Frame #036 (select)
> > > Video Capture: Frame #037 (select)
> > > Video Capture: Frame #038 (select)
> > > Video Capture: Frame #039 (select)
> > > Video Capture: Frame #040 (select)
> > > Video Capture: Frame #041 (select)
> > > Video Capture: Frame #042 (select)
> > > Video Capture: Frame #043 (select)
> > > Video Capture: Frame #044 (select)
> > > Video Capture: Frame #045 (select)
> > > Video Capture: Frame #046 (select)
> > > Video Capture: Frame #047 (select)
> > > Video Capture: Frame #048 (select)
> > > Video Capture: Frame #049 (select)
> > > Video Capture: Frame #050 (select)
> > > Video Capture: Frame #051 (select)
> > > Video Capture: Frame #052 (select)
> > > Video Capture: Frame #053 (select)
> > > Video Capture: Frame #054 (select)
> > > Video Capture: Frame #055 (select)
> > > Video Capture: Frame #056 (select)
> > > Video Capture: Frame #057 (select)
> > > Video Capture: Frame #058 (select)
> > > Video Capture: Frame #059 (select)
> > >
> > > test USERPTR (select): OK
> > > test DMABUF: Cannot test, specify --expbuf-device
> > >
> > > Total for uvcvideo device /dev/video1: 58, Succeeded: 57, Failed: 1, Warnings: 0
> > >
> > > As tested on the guest:
> > >
> > > $ v4l2-compliance -d0 -s --driver-name uvcvideo
> > >
> > > v4l2-compliance 1.33.0-5457, 64 bits, 64-bit time_t
> > > v4l2-compliance SHA: e7e240f546f3 2026-05-28 17:06:12
> > >
> > > Compliance test for uvcvideo device (overridden from virtio-media) /dev/video0:
> > >
> > > Driver Info:
> > > Driver name : uvcvideo
> > > Card type : Logitech Webcam C925e
> > > Bus info : platform:virtio-media
> > > Driver version : 7.1.0
> > > Capabilities : 0x84200001
> > > Video Capture
> > > Streaming
> > > Extended Pix Format
> > > Device Capabilities
> > > Device Caps : 0x04200001
> > > Video Capture
> > > Streaming
> > > Extended Pix Format
> > >
> > > Required ioctls:
> > > test VIDIOC_QUERYCAP: OK
> > > test invalid ioctls: OK
> > >
> > > Allow for multiple opens:
> > > test second /dev/video0 open: OK
> > > test VIDIOC_QUERYCAP: OK
> > > test VIDIOC_G/S_PRIORITY: OK
> > > test for unlimited opens: OK
> > >
> > > Debug ioctls:
> > > test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
> > > test VIDIOC_LOG_STATUS: OK (Not Supported)
> > >
> > > Input ioctls:
> > > test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
> > > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > > test VIDIOC_S_HW_FREQ_SEEK: OK
> > > test VIDIOC_ENUMAUDIO: OK (Not Supported)
> > > test VIDIOC_G/S/ENUMINPUT: OK
> > > test VIDIOC_G/S_AUDIO: OK (Not Supported)
> > > Inputs: 1 Audio Inputs: 0 Tuners: 0
> > >
> > > Output ioctls:
> > > test VIDIOC_G/S_MODULATOR: OK (Not Supported)
> > > test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> > > test VIDIOC_ENUMAUDOUT: OK (Not Supported)
> > > test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
> > > test VIDIOC_G/S_AUDOUT: OK (Not Supported)
> > > Outputs: 0 Audio Outputs: 0 Modulators: 0
> > >
> > > Input/Output configuration ioctls:
> > > test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
> > > test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
> > > test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
> > > test VIDIOC_G/S_EDID: OK (Not Supported)
> > >
> > > Control ioctls (Input 0):
> > > test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
> > > test VIDIOC_QUERYCTRL: OK
> > > test VIDIOC_G/S_CTRL: OK
> > > fail: v4l2-test-controls.cpp(981): ret (got 22)
> > > test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
> > > test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
> > > test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> > > Standard Controls: 19 Private Controls: 0
> > >
> > > Format ioctls (Input 0):
> > > test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
> > > test VIDIOC_G/S_PARM: OK
> > > test VIDIOC_G_FBUF: OK (Not Supported)
> > > test VIDIOC_G_FMT: OK
> > > test VIDIOC_TRY_FMT: OK
> > > test VIDIOC_S_FMT: OK
> > > test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
> > > test Cropping: OK (Not Supported)
> > > test Composing: OK (Not Supported)
> > > test Scaling: OK (Not Supported)
> > >
> > > Codec ioctls (Input 0):
> > > test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
> > > test VIDIOC_G_ENC_INDEX: OK (Not Supported)
> > > test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
> > >
> > > Buffer ioctls (Input 0):
> > > test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> > > test CREATE_BUFS maximum buffers: OK
> > > test VIDIOC_REMOVE_BUFS: OK
> > > test VIDIOC_EXPBUF: OK (Not Supported)
> > > test Requests: OK (Not Supported)
> > > test blocking wait: OK
> > >
> > > Test input 0:
> > >
> > > Streaming ioctls:
> > > test read/write: OK (Not Supported)
> > >
> > > Video Capture: Frame #000
> > > Video Capture: Frame #001
> > > Video Capture: Frame #002
> > > Video Capture: Frame #003
> > > Video Capture: Frame #004
> > > Video Capture: Frame #005
> > > Video Capture: Frame #006
> > > Video Capture: Frame #007
> > > Video Capture: Frame #008
> > > Video Capture: Frame #009
> > > Video Capture: Frame #010
> > > Video Capture: Frame #011
> > > Video Capture: Frame #012
> > > Video Capture: Frame #013
> > > Video Capture: Frame #014
> > > Video Capture: Frame #015
> > > Video Capture: Frame #016
> > > Video Capture: Frame #017
> > > Video Capture: Frame #018
> > > Video Capture: Frame #019
> > > Video Capture: Frame #020
> > > Video Capture: Frame #021
> > > Video Capture: Frame #022
> > > Video Capture: Frame #023
> > > Video Capture: Frame #024
> > > Video Capture: Frame #025
> > > Video Capture: Frame #026
> > > Video Capture: Frame #027
> > > Video Capture: Frame #028
> > > Video Capture: Frame #029
> > > Video Capture: Frame #030
> > > Video Capture: Frame #031
> > > Video Capture: Frame #032
> > > Video Capture: Frame #033
> > > Video Capture: Frame #034
> > > Video Capture: Frame #035
> > > Video Capture: Frame #036
> > > Video Capture: Frame #037
> > > Video Capture: Frame #038
> > > Video Capture: Frame #039
> > > Video Capture: Frame #040
> > > Video Capture: Frame #041
> > > Video Capture: Frame #042
> > > Video Capture: Frame #043
> > > Video Capture: Frame #044
> > > Video Capture: Frame #045
> > > Video Capture: Frame #046
> > > Video Capture: Frame #047
> > > Video Capture: Frame #048
> > > Video Capture: Frame #049
> > > Video Capture: Frame #050
> > > Video Capture: Frame #051
> > > Video Capture: Frame #052
> > > Video Capture: Frame #053
> > > Video Capture: Frame #054
> > > Video Capture: Frame #055
> > > Video Capture: Frame #056
> > > Video Capture: Frame #057
> > > Video Capture: Frame #058
> > > Video Capture: Frame #059
> > >
> > > test MMAP (no poll, REQBUFS): OK
> > >
> > > Video Capture: Frame #000 (select)
> > > Video Capture: Frame #001 (select)
> > > Video Capture: Frame #002 (select)
> > > Video Capture: Frame #003 (select)
> > > Video Capture: Frame #004 (select)
> > > Video Capture: Frame #005 (select)
> > > Video Capture: Frame #006 (select)
> > > Video Capture: Frame #007 (select)
> > > Video Capture: Frame #008 (select)
> > > Video Capture: Frame #009 (select)
> > > Video Capture: Frame #010 (select)
> > > Video Capture: Frame #011 (select)
> > > Video Capture: Frame #012 (select)
> > > Video Capture: Frame #013 (select)
> > > Video Capture: Frame #014 (select)
> > > Video Capture: Frame #015 (select)
> > > Video Capture: Frame #016 (select)
> > > Video Capture: Frame #017 (select)
> > > Video Capture: Frame #018 (select)
> > > Video Capture: Frame #019 (select)
> > > Video Capture: Frame #020 (select)
> > > Video Capture: Frame #021 (select)
> > > Video Capture: Frame #022 (select)
> > > Video Capture: Frame #023 (select)
> > > Video Capture: Frame #024 (select)
> > > Video Capture: Frame #025 (select)
> > > Video Capture: Frame #026 (select)
> > > Video Capture: Frame #027 (select)
> > > Video Capture: Frame #028 (select)
> > > Video Capture: Frame #029 (select)
> > > Video Capture: Frame #030 (select)
> > > Video Capture: Frame #031 (select)
> > > Video Capture: Frame #032 (select)
> > > Video Capture: Frame #033 (select)
> > > Video Capture: Frame #034 (select)
> > > Video Capture: Frame #035 (select)
> > > Video Capture: Frame #036 (select)
> > > Video Capture: Frame #037 (select)
> > > Video Capture: Frame #038 (select)
> > > Video Capture: Frame #039 (select)
> > > Video Capture: Frame #040 (select)
> > > Video Capture: Frame #041 (select)
> > > Video Capture: Frame #042 (select)
> > > Video Capture: Frame #043 (select)
> > > Video Capture: Frame #044 (select)
> > > Video Capture: Frame #045 (select)
> > > Video Capture: Frame #046 (select)
> > > Video Capture: Frame #047 (select)
> > > Video Capture: Frame #048 (select)
> > > Video Capture: Frame #049 (select)
> > > Video Capture: Frame #050 (select)
> > > Video Capture: Frame #051 (select)
> > > Video Capture: Frame #052 (select)
> > > Video Capture: Frame #053 (select)
> > > Video Capture: Frame #054 (select)
> > > Video Capture: Frame #055 (select)
> > > Video Capture: Frame #056 (select)
> > > Video Capture: Frame #057 (select)
> > > Video Capture: Frame #058 (select)
> > > Video Capture: Frame #059 (select)
> > >
> > > test MMAP (select, REQBUFS): OK
> > >
> > > Video Capture: Frame #000 (epoll)
> > > Video Capture: Frame #001 (epoll)
> > > Video Capture: Frame #002 (epoll)
> > > Video Capture: Frame #003 (epoll)
> > > Video Capture: Frame #004 (epoll)
> > > Video Capture: Frame #005 (epoll)
> > > Video Capture: Frame #006 (epoll)
> > > Video Capture: Frame #007 (epoll)
> > > Video Capture: Frame #008 (epoll)
> > > Video Capture: Frame #009 (epoll)
> > > Video Capture: Frame #010 (epoll)
> > > Video Capture: Frame #011 (epoll)
> > > Video Capture: Frame #012 (epoll)
> > > Video Capture: Frame #013 (epoll)
> > > Video Capture: Frame #014 (epoll)
> > > Video Capture: Frame #015 (epoll)
> > > Video Capture: Frame #016 (epoll)
> > > Video Capture: Frame #017 (epoll)
> > > Video Capture: Frame #018 (epoll)
> > > Video Capture: Frame #019 (epoll)
> > > Video Capture: Frame #020 (epoll)
> > > Video Capture: Frame #021 (epoll)
> > > Video Capture: Frame #022 (epoll)
> > > Video Capture: Frame #023 (epoll)
> > > Video Capture: Frame #024 (epoll)
> > > Video Capture: Frame #025 (epoll)
> > > Video Capture: Frame #026 (epoll)
> > > Video Capture: Frame #027 (epoll)
> > > Video Capture: Frame #028 (epoll)
> > > Video Capture: Frame #029 (epoll)
> > > Video Capture: Frame #030 (epoll)
> > > Video Capture: Frame #031 (epoll)
> > > Video Capture: Frame #032 (epoll)
> > > Video Capture: Frame #033 (epoll)
> > > Video Capture: Frame #034 (epoll)
> > > Video Capture: Frame #035 (epoll)
> > > Video Capture: Frame #036 (epoll)
> > > Video Capture: Frame #037 (epoll)
> > > Video Capture: Frame #038 (epoll)
> > > Video Capture: Frame #039 (epoll)
> > > Video Capture: Frame #040 (epoll)
> > > Video Capture: Frame #041 (epoll)
> > > Video Capture: Frame #042 (epoll)
> > > Video Capture: Frame #043 (epoll)
> > > Video Capture: Frame #044 (epoll)
> > > Video Capture: Frame #045 (epoll)
> > > Video Capture: Frame #046 (epoll)
> > > Video Capture: Frame #047 (epoll)
> > > Video Capture: Frame #048 (epoll)
> > > Video Capture: Frame #049 (epoll)
> > > Video Capture: Frame #050 (epoll)
> > > Video Capture: Frame #051 (epoll)
> > > Video Capture: Frame #052 (epoll)
> > > Video Capture: Frame #053 (epoll)
> > > Video Capture: Frame #054 (epoll)
> > > Video Capture: Frame #055 (epoll)
> > > Video Capture: Frame #056 (epoll)
> > > Video Capture: Frame #057 (epoll)
> > > Video Capture: Frame #058 (epoll)
> > > Video Capture: Frame #059 (epoll)
> > >
> > > test MMAP (epoll, REQBUFS): OK
> > >
> > > Video Capture: Frame #000
> > > Video Capture: Frame #001
> > > Video Capture: Frame #002
> > > Video Capture: Frame #003
> > > Video Capture: Frame #004
> > > Video Capture: Frame #005
> > > Video Capture: Frame #006
> > > Video Capture: Frame #007
> > > Video Capture: Frame #008
> > > Video Capture: Frame #009
> > > Video Capture: Frame #010
> > > Video Capture: Frame #011
> > > Video Capture: Frame #012
> > > Video Capture: Frame #013
> > > Video Capture: Frame #014
> > > Video Capture: Frame #015
> > > Video Capture: Frame #016
> > > Video Capture: Frame #017
> > > Video Capture: Frame #018
> > > Video Capture: Frame #019
> > > Video Capture: Frame #020
> > > Video Capture: Frame #021
> > > Video Capture: Frame #022
> > > Video Capture: Frame #023
> > > Video Capture: Frame #024
> > > Video Capture: Frame #025
> > > Video Capture: Frame #026
> > > Video Capture: Frame #027
> > > Video Capture: Frame #028
> > > Video Capture: Frame #029
> > > Video Capture: Frame #030
> > > Video Capture: Frame #031
> > > Video Capture: Frame #032
> > > Video Capture: Frame #033
> > > Video Capture: Frame #034
> > > Video Capture: Frame #035
> > > Video Capture: Frame #036
> > > Video Capture: Frame #037
> > > Video Capture: Frame #038
> > > Video Capture: Frame #039
> > > Video Capture: Frame #040
> > > Video Capture: Frame #041
> > > Video Capture: Frame #042
> > > Video Capture: Frame #043
> > > Video Capture: Frame #044
> > > Video Capture: Frame #045
> > > Video Capture: Frame #046
> > > Video Capture: Frame #047
> > > Video Capture: Frame #048
> > > Video Capture: Frame #049
> > > Video Capture: Frame #050
> > > Video Capture: Frame #051
> > > Video Capture: Frame #052
> > > Video Capture: Frame #053
> > > Video Capture: Frame #054
> > > Video Capture: Frame #055
> > > Video Capture: Frame #056
> > > Video Capture: Frame #057
> > > Video Capture: Frame #058
> > > Video Capture: Frame #059
> > >
> > > test MMAP (no poll, CREATE_BUFS): OK
> > >
> > > Video Capture: Frame #000 (select)
> > > Video Capture: Frame #001 (select)
> > > Video Capture: Frame #002 (select)
> > > Video Capture: Frame #003 (select)
> > > Video Capture: Frame #004 (select)
> > > Video Capture: Frame #005 (select)
> > > Video Capture: Frame #006 (select)
> > > Video Capture: Frame #007 (select)
> > > Video Capture: Frame #008 (select)
> > > Video Capture: Frame #009 (select)
> > > Video Capture: Frame #010 (select)
> > > Video Capture: Frame #011 (select)
> > > Video Capture: Frame #012 (select)
> > > Video Capture: Frame #013 (select)
> > > Video Capture: Frame #014 (select)
> > > Video Capture: Frame #015 (select)
> > > Video Capture: Frame #016 (select)
> > > Video Capture: Frame #017 (select)
> > > Video Capture: Frame #018 (select)
> > > Video Capture: Frame #019 (select)
> > > Video Capture: Frame #020 (select)
> > > Video Capture: Frame #021 (select)
> > > Video Capture: Frame #022 (select)
> > > Video Capture: Frame #023 (select)
> > > Video Capture: Frame #024 (select)
> > > Video Capture: Frame #025 (select)
> > > Video Capture: Frame #026 (select)
> > > Video Capture: Frame #027 (select)
> > > Video Capture: Frame #028 (select)
> > > Video Capture: Frame #029 (select)
> > > Video Capture: Frame #030 (select)
> > > Video Capture: Frame #031 (select)
> > > Video Capture: Frame #032 (select)
> > > Video Capture: Frame #033 (select)
> > > Video Capture: Frame #034 (select)
> > > Video Capture: Frame #035 (select)
> > > Video Capture: Frame #036 (select)
> > > Video Capture: Frame #037 (select)
> > > Video Capture: Frame #038 (select)
> > > Video Capture: Frame #039 (select)
> > > Video Capture: Frame #040 (select)
> > > Video Capture: Frame #041 (select)
> > > Video Capture: Frame #042 (select)
> > > Video Capture: Frame #043 (select)
> > > Video Capture: Frame #044 (select)
> > > Video Capture: Frame #045 (select)
> > > Video Capture: Frame #046 (select)
> > > Video Capture: Frame #047 (select)
> > > Video Capture: Frame #048 (select)
> > > Video Capture: Frame #049 (select)
> > > Video Capture: Frame #050 (select)
> > > Video Capture: Frame #051 (select)
> > > Video Capture: Frame #052 (select)
> > > Video Capture: Frame #053 (select)
> > > Video Capture: Frame #054 (select)
> > > Video Capture: Frame #055 (select)
> > > Video Capture: Frame #056 (select)
> > > Video Capture: Frame #057 (select)
> > > Video Capture: Frame #058 (select)
> > > Video Capture: Frame #059 (select)
> > >
> > > test MMAP (select, CREATE_BUFS): OK
> > >
> > > Video Capture: Frame #000 (epoll)
> > > Video Capture: Frame #001 (epoll)
> > > Video Capture: Frame #002 (epoll)
> > > Video Capture: Frame #003 (epoll)
> > > Video Capture: Frame #004 (epoll)
> > > Video Capture: Frame #005 (epoll)
> > > Video Capture: Frame #006 (epoll)
> > > Video Capture: Frame #007 (epoll)
> > > Video Capture: Frame #008 (epoll)
> > > Video Capture: Frame #009 (epoll)
> > > Video Capture: Frame #010 (epoll)
> > > Video Capture: Frame #011 (epoll)
> > > Video Capture: Frame #012 (epoll)
> > > Video Capture: Frame #013 (epoll)
> > > Video Capture: Frame #014 (epoll)
> > > Video Capture: Frame #015 (epoll)
> > > Video Capture: Frame #016 (epoll)
> > > Video Capture: Frame #017 (epoll)
> > > Video Capture: Frame #018 (epoll)
> > > Video Capture: Frame #019 (epoll)
> > > Video Capture: Frame #020 (epoll)
> > > Video Capture: Frame #021 (epoll)
> > > Video Capture: Frame #022 (epoll)
> > > Video Capture: Frame #023 (epoll)
> > > Video Capture: Frame #024 (epoll)
> > > Video Capture: Frame #025 (epoll)
> > > Video Capture: Frame #026 (epoll)
> > > Video Capture: Frame #027 (epoll)
> > > Video Capture: Frame #028 (epoll)
> > > Video Capture: Frame #029 (epoll)
> > > Video Capture: Frame #030 (epoll)
> > > Video Capture: Frame #031 (epoll)
> > > Video Capture: Frame #032 (epoll)
> > > Video Capture: Frame #033 (epoll)
> > > Video Capture: Frame #034 (epoll)
> > > Video Capture: Frame #035 (epoll)
> > > Video Capture: Frame #036 (epoll)
> > > Video Capture: Frame #037 (epoll)
> > > Video Capture: Frame #038 (epoll)
> > > Video Capture: Frame #039 (epoll)
> > > Video Capture: Frame #040 (epoll)
> > > Video Capture: Frame #041 (epoll)
> > > Video Capture: Frame #042 (epoll)
> > > Video Capture: Frame #043 (epoll)
> > > Video Capture: Frame #044 (epoll)
> > > Video Capture: Frame #045 (epoll)
> > > Video Capture: Frame #046 (epoll)
> > > Video Capture: Frame #047 (epoll)
> > > Video Capture: Frame #048 (epoll)
> > > Video Capture: Frame #049 (epoll)
> > > Video Capture: Frame #050 (epoll)
> > > Video Capture: Frame #051 (epoll)
> > > Video Capture: Frame #052 (epoll)
> > > Video Capture: Frame #053 (epoll)
> > > Video Capture: Frame #054 (epoll)
> > > Video Capture: Frame #055 (epoll)
> > > Video Capture: Frame #056 (epoll)
> > > Video Capture: Frame #057 (epoll)
> > > Video Capture: Frame #058 (epoll)
> > > Video Capture: Frame #059 (epoll)
> > >
> > > test MMAP (epoll, CREATE_BUFS): OK
> > > test USERPTR (no poll): OK (Not Supported)
> > > test USERPTR (select): OK (Not Supported)
> > > test DMABUF (no poll): OK (Not Supported)
> > > test DMABUF (select): OK (Not Supported)
> > >
> > > Total for uvcvideo device /dev/video0: 59, Succeeded: 58, Failed: 1, Warnings: 0
> > >
> > > ---
> > > Changes in v4:
> > > - Rebased on top of v7.1-rc1
> > > - Replace usages of filep->private_data with file_to_v4l2_fh()
> > > throughout the driver
> > > - Link to v3: https://lore.kernel.org/r/20250412-virtio-media-v3-1-97dc94c18398@gmail.com
> > >
> > > Changes in v3:
> > > - Rebased on top of v6.15-rc1 and removes obsolete control callbacks.
> > > - Link to v2: https://lore.kernel.org/r/20250201-virtio-media-v2-1-ac840681452d@gmail.com
> > >
> > > Changes in v2:
> > > - Fixed kernel test robot and media CI warnings (ignored a few false
> > > positives).
> > > - Changed in-driver email address to personal one since my Google one
> > > will soon become invalid.
> > > - Link to v1: https://lore.kernel.org/r/20250123-virtio-media-v1-1-81e2549b86b9@gmail.com
> > >
> > > Brian Daniels (8):
> > > media: virtio: Add protocol
> > > media: virtio: Add virtio-media driver structs and function
> > > declarations
> > > media: virtio: Add virtio-media session related structures
> > > media: virtio: Add scatterlist_builder
> > > media: virtio: Add virtio_media_ioctls
> > > media: virtio: Add virtio_media_driver
> > > media: virtio: Add virtio-media to the build system
> > > media: virtio: Add MAINTAINERS entry
> > >
> > > MAINTAINERS | 6 +
> > > drivers/media/Kconfig | 13 +
> > > drivers/media/Makefile | 2 +
> > > drivers/media/virtio/Makefile | 8 +
> > > drivers/media/virtio/protocol.h | 287 +++++
> > > drivers/media/virtio/scatterlist_builder.c | 574 +++++++++
> > > drivers/media/virtio/scatterlist_builder.h | 112 ++
> > > drivers/media/virtio/session.h | 130 ++
> > > drivers/media/virtio/virtio_media.h | 95 ++
> > > drivers/media/virtio/virtio_media_driver.c | 959 ++++++++++++++
> > > drivers/media/virtio/virtio_media_ioctls.c | 1338 ++++++++++++++++++++
> > > 11 files changed, 3524 insertions(+)
> > > create mode 100644 drivers/media/virtio/Makefile
> > > create mode 100644 drivers/media/virtio/protocol.h
> > > create mode 100644 drivers/media/virtio/scatterlist_builder.c
> > > create mode 100644 drivers/media/virtio/scatterlist_builder.h
> > > create mode 100644 drivers/media/virtio/session.h
> > > create mode 100644 drivers/media/virtio/virtio_media.h
> > > create mode 100644 drivers/media/virtio/virtio_media_driver.c
> > > create mode 100644 drivers/media/virtio/virtio_media_ioctls.c
> > >
> > >
> > > base-commit: 06cb687a5132fcffe624c0070576ab852ac6b568
>
>
^ permalink raw reply
* Re: [PATCH v2] drm/qxl: remove dependency on DRM simple helpers
From: Thomas Zimmermann @ 2026-07-10 13:11 UTC (permalink / raw)
To: Diogo Silva, Dave Airlie, Gerd Hoffmann, Maarten Lankhorst,
Maxime Ripard, David Airlie, Simona Vetter
Cc: virtualization, spice-devel, dri-devel, linux-kernel
In-Reply-To: <18186cbc-a60c-4a1a-95f5-46e392faa997@suse.de>
Merged into drm-misc-next
Am 08.07.26 um 14:33 schrieb Thomas Zimmermann:
>
>
> Am 07.07.26 um 18:14 schrieb Diogo Silva:
>> Simple KMS helper are deprecated since they only add an intermediate
>> layer between drivers and the atomic modesetting.
>> This patch removes the drm_simple_encoder_init() helper usage in the
>> qxl display driver by open coding it and using the encoder atomic
>> helpers directly. This is a step to eventually get rid of this simple
>> KMS helper, once all drivers that use it have been converted.
>>
>> Signed-off-by: Diogo Silva <diogompaissilva@gmail.com>
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
>> ---
>> Changes in v2:
>> - fix type error
>> - Link to v1:
>> https://lore.kernel.org/r/20260707-qxl-simple-v1-1-524f6316b5d5@gmail.com
>> ---
>> drivers/gpu/drm/qxl/qxl_display.c | 12 ++++++++----
>> 1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/qxl/qxl_display.c
>> b/drivers/gpu/drm/qxl/qxl_display.c
>> index a026bd35ef485..7f4178800afd7 100644
>> --- a/drivers/gpu/drm/qxl/qxl_display.c
>> +++ b/drivers/gpu/drm/qxl/qxl_display.c
>> @@ -31,12 +31,12 @@
>> #include <drm/drm_atomic.h>
>> #include <drm/drm_atomic_helper.h>
>> #include <drm/drm_edid.h>
>> +#include <drm/drm_encoder.h>
>> #include <drm/drm_framebuffer.h>
>> #include <drm/drm_gem_framebuffer_helper.h>
>> #include <drm/drm_plane_helper.h>
>> #include <drm/drm_print.h>
>> #include <drm/drm_probe_helper.h>
>> -#include <drm/drm_simple_kms_helper.h>
>> #include <drm/drm_gem_atomic_helper.h>
>> #include <drm/drm_vblank.h>
>> #include <drm/drm_vblank_helper.h>
>> @@ -1095,6 +1095,10 @@ static const struct drm_connector_helper_funcs
>> qxl_connector_helper_funcs = {
>> .best_encoder = qxl_best_encoder,
>> };
>> +static const struct drm_encoder_funcs qxl_encoder_funcs = {
>> + .destroy = drm_encoder_cleanup,
>> +};
>> +
>> static enum drm_connector_status qxl_conn_detect(
>> struct drm_connector *connector,
>> bool force)
>> @@ -1169,10 +1173,10 @@ static int qdev_output_init(struct drm_device
>> *dev, int num_output)
>> drm_connector_init(dev, &qxl_output->base,
>> &qxl_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL);
>> - ret = drm_simple_encoder_init(dev, &qxl_output->enc,
>> - DRM_MODE_ENCODER_VIRTUAL);
>> + ret = drm_encoder_init(dev, &qxl_output->enc, &qxl_encoder_funcs,
>> + DRM_MODE_ENCODER_VIRTUAL, NULL);
>> if (ret) {
>> - drm_err(dev, "drm_simple_encoder_init() failed, error %d\n",
>> + drm_err(dev, "drm_encoder_init() failed, error %d\n",
>> ret);
>> goto err_drm_connector_cleanup;
>> }
>>
>> ---
>> base-commit: ee2867b79f9bac3a6fc3221139b09598ce79099c
>> change-id: 20260707-qxl-simple-c01aa1a5c4eb
>>
>> Best regards,
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)
^ permalink raw reply
* Re: [PATCH v3] vdpa/mlx5: Fix buffer length in create_direct_keys()
From: Dragos Tatulea @ 2026-07-10 11:37 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Michael S . Tsirkin, Jason Wang, virtualization, linux-kernel
In-Reply-To: <21e944c6-2039-4e34-a2f9-711ea4769294@nvidia.com>
On 10.07.26 10:23, Dragos Tatulea wrote:
>
>
> On 10.07.26 09:18, Christian Borntraeger wrote:
>> Am 07.07.26 um 09:17 schrieb Christian Borntraeger:
>>> Am 06.07.26 um 16:15 schrieb Christian Borntraeger:
>>>> We have seen in our CI the following KASAN message:
>>>> BUG: KASAN: slab-out-of-bounds in cmd_exec+0x550/0xca0 [mlx5_core]
>>>> Read of size 272 at addr 0000000176795020 by task qemu-system-s39/82764
>>>> [...]
>>>> [<000011388ab3a7a0>] cmd_exec+0x550/0xca0 [mlx5_core]
>>>> [<000011388ab3b61c>] mlx5_cmd_exec_cb+0x25c/0x4f0 [mlx5_core]
>>>> [<000011388b21e82e>] mlx5_vdpa_exec_async_cmds+0x22e/0x5e0 [mlx5_vdpa]
>>>> [<000011388b21fd44>] create_direct_keys+0x954/0xef0 [mlx5_vdpa]
>>>> [...]
>>>> The buggy address is located 4128 bytes inside of
>>>> allocated 4384-byte region [0000000176794000, 0000000176795120)
>>>>
>>>> So in essence we read 16 bytes beyond 4384-byte allocation.
>>>> create_direct_keys calculates the pointer and length for in and out
>>>> buffers.
>>>> The size calculation for in includes the entire structure
>>>> size (out + in + mtt[]) but the pointer passed to cmd_exec points only
>>>> to the 'in' field, skipping the 'out' field.
>>>>
>>>> This causes mlx5_copy_to_msg() to read beyond the allocated buffer
>>>> by sizeof(out) bytes when copying command data.
>>>>
>>>> Properly calculate the input size to match the pointer and allocation size.
>>>>
>>>> Fixes: 0071b138d44a ("vdpa/mlx5: Create direct MKEYs in parallel")
>>>> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
>>>
>>>
>>> Dragos,
>>>
>>> With this fix our nighly CI did not result in a kasan message. As I only have
>>> limited test coverage a full regression on your side might still be the right
>>> thing to do.
>>
>> Any feedback?
>>
> Sorry, got carried away with other stuff. Yes, I will check it on our side.
>
> Until then:
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
>
I was able to reproduce the issue with KASAN during our live migration tests.
With this patch the issue is gone. Thanks for the fix!
Tested-by: Dragos Tatulea <dtatulea@nvidia.com>
Thanks,
Dragos
^ permalink raw reply
* Re: [PATCH v3] vdpa/mlx5: Fix buffer length in create_direct_keys()
From: Dragos Tatulea @ 2026-07-10 8:23 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Michael S . Tsirkin, Jason Wang, virtualization, linux-kernel
In-Reply-To: <9f799ce2-f84c-4224-b91d-464dc767eb00@linux.ibm.com>
On 10.07.26 09:18, Christian Borntraeger wrote:
> Am 07.07.26 um 09:17 schrieb Christian Borntraeger:
>> Am 06.07.26 um 16:15 schrieb Christian Borntraeger:
>>> We have seen in our CI the following KASAN message:
>>> BUG: KASAN: slab-out-of-bounds in cmd_exec+0x550/0xca0 [mlx5_core]
>>> Read of size 272 at addr 0000000176795020 by task qemu-system-s39/82764
>>> [...]
>>> [<000011388ab3a7a0>] cmd_exec+0x550/0xca0 [mlx5_core]
>>> [<000011388ab3b61c>] mlx5_cmd_exec_cb+0x25c/0x4f0 [mlx5_core]
>>> [<000011388b21e82e>] mlx5_vdpa_exec_async_cmds+0x22e/0x5e0 [mlx5_vdpa]
>>> [<000011388b21fd44>] create_direct_keys+0x954/0xef0 [mlx5_vdpa]
>>> [...]
>>> The buggy address is located 4128 bytes inside of
>>> allocated 4384-byte region [0000000176794000, 0000000176795120)
>>>
>>> So in essence we read 16 bytes beyond 4384-byte allocation.
>>> create_direct_keys calculates the pointer and length for in and out
>>> buffers.
>>> The size calculation for in includes the entire structure
>>> size (out + in + mtt[]) but the pointer passed to cmd_exec points only
>>> to the 'in' field, skipping the 'out' field.
>>>
>>> This causes mlx5_copy_to_msg() to read beyond the allocated buffer
>>> by sizeof(out) bytes when copying command data.
>>>
>>> Properly calculate the input size to match the pointer and allocation size.
>>>
>>> Fixes: 0071b138d44a ("vdpa/mlx5: Create direct MKEYs in parallel")
>>> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
>>
>>
>> Dragos,
>>
>> With this fix our nighly CI did not result in a kasan message. As I only have
>> limited test coverage a full regression on your side might still be the right
>> thing to do.
>
> Any feedback?
>
Sorry, got carried away with other stuff. Yes, I will check it on our side.
Until then:
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Thanks,
Dragos
^ permalink raw reply
* Re: [PATCH net-next 1/3] net: busy-poll: introduce sk_tx_busy_loop()
From: Menglong Dong @ 2026-07-10 7:39 UTC (permalink / raw)
To: Maciej Fijalkowski
Cc: menglong8.dong, Jakub Kicinski, jasowang, mst, xuanzhuo, eperezma,
andrew+netdev, davem, edumazet, pabeni, magnus.karlsson, sdf,
horms, ast, daniel, hawk, john.fastabend, bjorn, kerneljasonxing,
netdev, virtualization, linux-kernel, bpf
In-Reply-To: <ajJrckiXEUztBQDz@boxer>
On 2026/6/17 17:40 Maciej Fijalkowski <maciej.fijalkowski@intel.com> write:
> On Sun, Jun 14, 2026 at 06:12:46PM +0800, Menglong Dong wrote:
> > On 2026/6/14 02:21, Jakub Kicinski wrote:
> > > On Thu, 11 Jun 2026 15:12:40 +0800 menglong8.dong@gmail.com wrote:
> > > > For now, we use sk_busy_loop() for both rx and tx path. The sk_busy_loop()
> > > > will call napi_busy_loop() for the specified napi_id. However, some
> > > > nic drivers have tx napi, such as virtio-net. In this case, sk_busy_loop()
> > > > doesn't work, as it can only schedule the NAPI for the rx queue.
> > > >
> > > > Therefore, introduce sk_tx_busy_loop() for the nic drivers that support tx
> > > > napi, which will schedule the tx napi if available.
> > >
> > > First, I thought the only difference with Tx NAPI is that it can't be
> > > busy polled. So if you want to poll an instance don't register it as
> > > a Tx one instead of adding all this "tx polling" stuff in the core?
> >
> > I see. Register the tx NAPI with netif_napi_add_config() allow us
> > busy poll it. But we still have two NAPI instance: rx NAPI and tx NAPI.
> > sk_busy_loop() can only busy poll on one of them.
> >
> > Before AF_XDP, we don't have the need to send packet via tx NAPI, which
> > means that we don't need to busy poll it.
> >
> > I analyst some nic drivers on the implement of AF_XDP. Some of them
> > will check xsk tx ring of current queue and send the data in it in the
> > rx NAPI, such as mlx5. Some of them will allocate a extra "rxtx" NAPI
> > for the AF_XDP zero-copy queue, which will poll both the data receiving
> > and sending.
> >
> > In the case about, they will do the data sending and receiving for the
> > AF_XDP in a single NAPI instance.
> >
> > However, some driver receiving the data in rx NAPI and send data in
> > tx NAPI for AF_XDP. In this case, we can't use sk_busy_loop() for both
> > rx path and tx path, as we need to wake different NAPI instance.
> >
> > >
> > > Second, can this problem happen for any other NIC or is it purely
> > > an artifact of virtio's delayed Tx completion handling?
> >
> > According to my analysis, only virtio-net and ICSSG driver have
> > split NAPI for AF_XDP. I don't have a ICSSG nic, but the codex tell
> > me that it does have the same problem.
> >
> > I'm not sure if it is a good idea to introduce the sk_tx_busy_loop().
> > Maybe we can modify the driver instead by using the same NAPI
> > for both data sending and receiving, just like others do. The
> > advantage of introduce sk_tx_busy_loop() is that we can split the
> > data sending and receiving, which maybe more efficient.
>
> Would be good if you back your changes by any performance numbers. I
> believe that drivers do tx processing via rx napi as before AF_XDP it was
> only about cleaning up writebacks, AF_XDP added more weight via actual tx
> descriptors submission.
>
> Maybe you can vibe-code virtio-net to work only with rx napi and see what
> are the results.
According to my testing, there is no obvious performance improvement
with tx napi. I'm going to implement the xsk tx queue consume in rx napi
instead for virtio-net.
Thanks!
Menglong Dong
>
> Side note/question - Do you have a tx-only use case for AF_XDP ? I am
> planning (for a long time actually) to implement asymmetric AF_XDP
> sockets. Currently for ZC scenarios xsk socket occupies both rx and tx
> queues even when you do rx or tx only.
>
> >
> > >
> > > Third, this series does not apply.
> >
> > Ah, I'll rebase this series if a V2 is acceptable.
> >
> > Thanks!
> > Menglong Dong
> >
> > >
> > >
> >
> >
> >
> >
>
^ permalink raw reply
* Re: [PATCH v3] vdpa/mlx5: Fix buffer length in create_direct_keys()
From: Christian Borntraeger @ 2026-07-10 7:18 UTC (permalink / raw)
To: Dragos Tatulea
Cc: Michael S . Tsirkin, Jason Wang, virtualization, linux-kernel
In-Reply-To: <3508dbb8-d110-42dc-aa25-4b3e73057422@linux.ibm.com>
Am 07.07.26 um 09:17 schrieb Christian Borntraeger:
> Am 06.07.26 um 16:15 schrieb Christian Borntraeger:
>> We have seen in our CI the following KASAN message:
>> BUG: KASAN: slab-out-of-bounds in cmd_exec+0x550/0xca0 [mlx5_core]
>> Read of size 272 at addr 0000000176795020 by task qemu-system-s39/82764
>> [...]
>> [<000011388ab3a7a0>] cmd_exec+0x550/0xca0 [mlx5_core]
>> [<000011388ab3b61c>] mlx5_cmd_exec_cb+0x25c/0x4f0 [mlx5_core]
>> [<000011388b21e82e>] mlx5_vdpa_exec_async_cmds+0x22e/0x5e0 [mlx5_vdpa]
>> [<000011388b21fd44>] create_direct_keys+0x954/0xef0 [mlx5_vdpa]
>> [...]
>> The buggy address is located 4128 bytes inside of
>> allocated 4384-byte region [0000000176794000, 0000000176795120)
>>
>> So in essence we read 16 bytes beyond 4384-byte allocation.
>> create_direct_keys calculates the pointer and length for in and out
>> buffers.
>> The size calculation for in includes the entire structure
>> size (out + in + mtt[]) but the pointer passed to cmd_exec points only
>> to the 'in' field, skipping the 'out' field.
>>
>> This causes mlx5_copy_to_msg() to read beyond the allocated buffer
>> by sizeof(out) bytes when copying command data.
>>
>> Properly calculate the input size to match the pointer and allocation size.
>>
>> Fixes: 0071b138d44a ("vdpa/mlx5: Create direct MKEYs in parallel")
>> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
>
>
> Dragos,
>
> With this fix our nighly CI did not result in a kasan message. As I only have
> limited test coverage a full regression on your side might still be the right
> thing to do.
Any feedback?
^ permalink raw reply
* Re: [PATCH v2] virtio-pmem: allocate flush bio from a driver-private bio_set
From: Christoph Hellwig @ 2026-07-10 5:45 UTC (permalink / raw)
To: Joseph Qi
Cc: Pankaj Gupta, Christoph Hellwig, Baokun Li, virtualization,
linux-kernel
In-Reply-To: <20260709124455.1547912-1-joseph.qi@linux.alibaba.com>
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox