All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH RFC hci-8.1 0/4] mm: keep DMA-pinned MADV_DOEXEC memory working across exec
@ 2026-10-09 14:00 Andrey Drobyshev
  2026-10-09 14:00 ` [Devel] [PATCH RFC PATCH hci-8.1 1/4] mm: support moving anonymous page tables between address spaces Andrey Drobyshev
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Andrey Drobyshev @ 2026-10-09 14:00 UTC (permalink / raw)
  To: Konstantin Khorenko; +Cc: devel

QEMU live update (qemu-update, cpr-exec) keeps guest RAM across exec with
MADV_DOEXEC.  vma_dup() duplicates such VMAs the same way fork does: the
pages get shared and write-protected in both mms.

That's fine for ordinary guest RAM, but not for a VM with a VFIO device.
VFIO holds long-term pins on all guest pages, so after exec the first
guest write to a pinned page can't reuse it and copies it instead.  The
guest and the new QEMU use the copy, while the IOMMU keeps pointing the
device at the old pinned page, and device DMA silently diverges.  After
qemu-update a passed-through GPU fails.

This series moves preserved anonymous VMAs into the new mm instead of
copying them.  Page table entries, physical pages and anon-exclusive state
move as is, so nothing gets copied on write, and the device and the guest
keep seeing the same memory.  Exec is refused while other tasks still share
the old mm, since moving its memory away would break them.

Tested with qemu-update with a whole GPU passed through (RTX 6000 Ada):
the GPU keeps working after qemu-update.

https://virtuozzo.atlassian.net/browse/VSTOR-103860

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
Andrey Drobyshev (4):
      mm: support moving anonymous page tables between address spaces
      exec: protect preserved memory against surviving shared-mm tasks
      mm: move MADV_DOEXEC memory instead of copying it
      selftests/mm: test memory preservation across exec

 fs/exec.c                                 | 102 +++-
 include/linux/binfmts.h                   |   2 +
 include/linux/huge_mm.h                   |   3 +-
 include/linux/mm.h                        |   4 -
 include/linux/mm_types.h                  |   5 +-
 include/linux/rmap.h                      |   7 +-
 kernel/fork.c                             |  34 ++
 mm/huge_memory.c                          |  28 +-
 mm/internal.h                             |   4 +
 mm/madvise.c                              |   2 +-
 mm/memory.c                               |  81 +---
 mm/mlock.c                                |   2 +-
 mm/mmap.c                                 |  64 ++-
 mm/mremap.c                               | 140 +++++-
 tools/testing/selftests/mm/Makefile       |   1 +
 tools/testing/selftests/mm/doexec.c       | 774 ++++++++++++++++++++++++++++++
 tools/testing/selftests/mm/run_vmtests.sh |   1 +
 17 files changed, 1112 insertions(+), 142 deletions(-)
---
base-commit: f5d1fdcfffe101fe2bafa7df09d95d2e811c5c5e
change-id: 20261007-vfio_v1-c812d56db752

Best regards,
--  
Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-10-09 15:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-09 14:00 [Devel] [PATCH RFC hci-8.1 0/4] mm: keep DMA-pinned MADV_DOEXEC memory working across exec Andrey Drobyshev
2026-10-09 14:00 ` [Devel] [PATCH RFC PATCH hci-8.1 1/4] mm: support moving anonymous page tables between address spaces Andrey Drobyshev
2026-10-09 15:02   ` no-reply
2026-10-09 14:00 ` [Devel] [PATCH RFC PATCH hci-8.1 2/4] exec: protect preserved memory against surviving shared-mm tasks Andrey Drobyshev
2026-10-09 14:57   ` no-reply
2026-10-09 14:00 ` [Devel] [PATCH RFC PATCH hci-8.1 3/4] mm: move MADV_DOEXEC memory instead of copying it Andrey Drobyshev
2026-10-09 15:08   ` no-reply
2026-10-09 14:00 ` [Devel] [PATCH RFC PATCH hci-8.1 4/4] selftests/mm: test memory preservation across exec Andrey Drobyshev
2026-10-09 15:07   ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.