533f5d6679
Let's allow for marking memory regions unmergeable, to teach flatview code and vhost to not merge adjacent aliases to the same memory region into a larger memory section; instead, we want separate aliases to stay separate such that we can atomically map/unmap aliases without affecting other aliases. This is desired for virtio-mem mapping device memory located on a RAM memory region via multiple aliases into a memory region container, resulting in separate memslots that can get (un)mapped atomically. As an example with virtio-mem, the layout would look something like this: [...] 0000000240000000-00000020bfffffff (prio 0, i/o): device-memory 0000000240000000-000000043fffffff (prio 0, i/o): virtio-mem 0000000240000000-000000027fffffff (prio 0, ram): alias memslot-0 @mem2 0000000000000000-000000003fffffff 0000000280000000-00000002bfffffff (prio 0, ram): alias memslot-1 @mem2 0000000040000000-000000007fffffff 00000002c0000000-00000002ffffffff (prio 0, ram): alias memslot-2 @mem2 0000000080000000-00000000bfffffff [...] Without unmergable memory regions, all three memslots would get merged into a single memory section. For example, when mapping another alias (e.g., virtio-mem-memslot-3) or when unmapping any of the mapped aliases, memory listeners will first get notified about the removal of the big memory section to then get notified about re-adding of the new (differently merged) memory section(s). In an ideal world, memory listeners would be able to deal with that atomically, like KVM nowadays does. However, (a) supporting this for other memory listeners (vhost-user, vfio) is fairly hard: temporary removal can result in all kinds of issues on concurrent access to guest memory; and (b) this handling is undesired, because temporarily removing+readding can consume quite some time on bigger memslots and is not efficient (e.g., vfio unpinning and repinning pages ...). Let's allow for marking a memory region unmergeable, such that we can atomically (un)map aliases to the same memory region, similar to (un)mapping individual DIMMs. Similarly, teach vhost code to not redo what flatview core stopped doing: don't merge such sections. Merging in vhost code is really only relevant for handling random holes in boot memory where; without this merging, the vhost-user backend wouldn't be able to mmap() some boot memory backed on hugetlb. We'll use this for virtio-mem next. Message-ID: <20230926185738.277351-18-david@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> |
||
---|---|---|
.. | ||
user | ||
address-spaces.h | ||
confidential-guest-support.h | ||
cpu_ldst.h | ||
cpu-all.h | ||
cpu-common.h | ||
cpu-defs.h | ||
cputlb.h | ||
exec-all.h | ||
gdbstub.h | ||
helper-gen-common.h | ||
helper-gen.h | ||
helper-gen.h.inc | ||
helper-head.h | ||
helper-info.c.inc | ||
helper-proto-common.h | ||
helper-proto.h | ||
helper-proto.h.inc | ||
hwaddr.h | ||
ioport.h | ||
log.h | ||
memattrs.h | ||
memop.h | ||
memopidx.h | ||
memory_ldst_cached.h.inc | ||
memory_ldst_phys.h.inc | ||
memory_ldst.h.inc | ||
memory-internal.h | ||
memory.h | ||
page-vary.h | ||
plugin-gen.h | ||
poison.h | ||
ram_addr.h | ||
ramblock.h | ||
ramlist.h | ||
replay-core.h | ||
target_long.h | ||
target_page.h | ||
tb-flush.h | ||
tlb-common.h | ||
translate-all.h | ||
translation-block.h | ||
translator.h | ||
tswap.h |