All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] system/memory: Make ram device region directly accessible
@ 2026-07-27  3:26 Gavin Shan
  2026-07-27  3:26 ` [PATCH v4 1/3] system/memory: Use memmove() for directly accessible regions Gavin Shan
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Gavin Shan @ 2026-07-27  3:26 UTC (permalink / raw)
  To: qemu-arm
  Cc: qemu-devel, peterx, mst, philmd, peter.maydell, richard.henderson,
	alex, berrange, philmd, david, clg, pbonzini, phrdina, jugraham,
	liugang24219, dinghui, shan.gavin

All ram device regions was turned to be indirectly accessible by commit
4a2e242bbb ("memory: Don't use memcpy for ram_device regions"). This leads
to a frozen guest where a NVidia GH100 GPU is passed from host. The memory
in its PCI BAR#4 can be allocated as DMA target buffer. qemu has to take
DMA bounce buffer in address_space_map() to cover the DMA request. However,
the bounce buffer size is 4096 bytes only and it's exhaused very quickly
when the guest has significant disk activities on compiling 'cuda-samples'.
The full log and problem description can be found from PATCH[2/3]'s commit
log.

Fix the issue handled in commit 4a2e242bbb by replacing memmove() with newly
added qemu_ram_move() where the aligned and small-sized accesses are handled
by qatomics, and fall back to memmove() otherwise, for the directly accessible
regions. With this, we can revert 4a2e242bbb to make ram device region directly
accessible again and bypass the bounce buffer in address_space_map() where the
guest hang happens.

PATCH[1] replaces memcpy() with memomve() for directly accessible regions
PATCH[2] uses qemu_ram_move() for directly accessible regions
PATCH[3] makes ram device region directly accessible again

Changelog
=========
v3 -> v4:
  * https://lore.kernel.org/qemu-arm/20260616052552.389021-1-gshan@redhat.com/
  * New PATCH[1/3] to replace memcpy() with memmove() (Peterx)
  * Unified qemu_ram_move() for all architectures     (Peterx/Michael)
v2 -> v3:
  * https://lore.kernel.org/qemu-arm/20260615100200.266968-1-gshan@redhat.com/
  * Documentation for qemu_ram_{copy, move}           (Peter/Michael)
  * Support qemu_ram_move() for overlapped src/dest   (Richard)
  * Use {memcpy, memmove} if step is 16-bytes or more (Michael)
  * Code improvements                                 (Richard/Michael)
v1 -> v2:
  * https://lore.kernel.org/qemu-arm/20260612110307.1264798-1-gshan@redhat.com/
  * Rename address_space_{memcpy, memmove}() to qemu_ram_{copy, move}()
    and move them to physmem.c and memory.h   (Philippe)
  * Use memcpy() and memmove() in qemu_ram_{copy, move}() for the variable
    length case                               (Miachel)
  * Handle unaligned access in qemu_ram_{copy, move}() for all archs
    except i386 and x86_64                    (Richard/Michael)
RFCv1 -> v1:
  * https://lists.nongnu.org/archive/html/qemu-arm/2026-06/msg00307.html
  * Reworked solution based on suggestions from Peter Xu, Peter Maydell
    and Michael S. Tsirkin

Gavin Shan (3):
  system/memory: Use memmove() for directly accessible regions
  system/memory: Use qemu_ram_move() for directly accessible regions
  system/memory: Make ram device region directly accessible

 hw/remote/vfio-user-obj.c |  4 ++--
 include/system/memory.h   | 28 ++++++++++++++++----------
 system/memory.c           | 41 +--------------------------------------
 system/physmem.c          | 39 +++++++++++++++++++++++++++++++++++--
 system/trace-events       |  2 --
 5 files changed, 58 insertions(+), 56 deletions(-)

-- 
2.55.0



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

end of thread, other threads:[~2026-07-28  3:10 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27  3:26 [PATCH v4 0/3] system/memory: Make ram device region directly accessible Gavin Shan
2026-07-27  3:26 ` [PATCH v4 1/3] system/memory: Use memmove() for directly accessible regions Gavin Shan
2026-07-27 10:51   ` Peter Maydell
2026-07-27 14:03   ` Peter Xu
2026-07-27  3:26 ` [PATCH v4 2/3] system/memory: Use qemu_ram_move() " Gavin Shan
2026-07-27 12:51   ` Peter Maydell
2026-07-27 13:52     ` Philippe Mathieu-Daudé
2026-07-28  3:09       ` Gavin Shan
2026-07-27 14:02     ` Peter Xu
2026-07-28  3:02       ` Gavin Shan
2026-07-28  3:00     ` Gavin Shan
2026-07-27  3:26 ` [PATCH v4 3/3] system/memory: Make ram device region directly accessible Gavin Shan
2026-07-27 12:07   ` Peter Maydell

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.