mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
Hi,
"Host Memory Backends" and "Memory devices" queue ("mem"): - Support memory devices with multiple memslots - Support memory devices that dynamically consume memslots - Support memory devices that can automatically decide on the number of memslots to use - virtio-mem support for exposing memory dynamically via multiple memslots - Some required cleanups/refactorings -----BEGIN PGP SIGNATURE----- iQJFBAABCAAvFiEEG9nKrXNcTDpGDfzKTd4Q9wD/g1oFAmUn+XMRHGRhdmlkQHJl ZGhhdC5jb20ACgkQTd4Q9wD/g1qDHA//T01suTa+uzrcoJHoMWN11S47WnAmbuTo vVakucLBPMJAa9xZeCy3OavXaVGpHkw+t6g3OFknof0LfQ5/j9iE3Q1PxURN7g5j SJ2WJXCoceM6T4TMhPvVvgEaYjFmESqZB5FZgedMT0QRyhAxMuF9pCkWhk1O3OAV JqQKqLFiGcv60AEuBYGZGzgiOUv8EJ5gKwRF4VOdyHIxqZDw1aZXzlcd4TzFZBQ7 rwW/3ef+sFmUJdmfrSrqcIlQSRrqZ2w95xATDzLTIEEUT3SWqh/E95EZWIz1M0oQ NgWgFiLCR1KOj7bWFhLXT7IfyLh0mEysD+P/hY6QwQ4RewWG7EW5UK+JFswssdcZ rEj5XpHZzev/wx7hM4bWsoQ+VIvrH7j3uYGyWkcgYRbdDEkWDv2rsT23lwGYNhht oBsrdEBELRw6v4C8doq/+sCmHmuxUMqTGwbArCQVnB1XnLxOEkuqlnfq5MORkzNF fxbIRx+LRluOllC0HVaDQd8qxRq1+UC5WIpAcDcrouy4HGgi1onWKrXpgjIAbVyH M6cENkK7rnRk96gpeXdmrf0h9HqRciAOY8oUsFsvLyKBOCPBWDrLyOQEY5UoSdtD m4QpEVgywCy2z1uU/UObeT/UxJy/9EL/Zb+DHoEK06iEhwONoUJjEBYMJD38RMkk mwPTB4UAk9g= =s69t -----END PGP SIGNATURE----- Merge tag 'mem-2023-10-12' of https://github.com/davidhildenbrand/qemu into staging Hi, "Host Memory Backends" and "Memory devices" queue ("mem"): - Support memory devices with multiple memslots - Support memory devices that dynamically consume memslots - Support memory devices that can automatically decide on the number of memslots to use - virtio-mem support for exposing memory dynamically via multiple memslots - Some required cleanups/refactorings # -----BEGIN PGP SIGNATURE----- # # iQJFBAABCAAvFiEEG9nKrXNcTDpGDfzKTd4Q9wD/g1oFAmUn+XMRHGRhdmlkQHJl # ZGhhdC5jb20ACgkQTd4Q9wD/g1qDHA//T01suTa+uzrcoJHoMWN11S47WnAmbuTo # vVakucLBPMJAa9xZeCy3OavXaVGpHkw+t6g3OFknof0LfQ5/j9iE3Q1PxURN7g5j # SJ2WJXCoceM6T4TMhPvVvgEaYjFmESqZB5FZgedMT0QRyhAxMuF9pCkWhk1O3OAV # JqQKqLFiGcv60AEuBYGZGzgiOUv8EJ5gKwRF4VOdyHIxqZDw1aZXzlcd4TzFZBQ7 # rwW/3ef+sFmUJdmfrSrqcIlQSRrqZ2w95xATDzLTIEEUT3SWqh/E95EZWIz1M0oQ # NgWgFiLCR1KOj7bWFhLXT7IfyLh0mEysD+P/hY6QwQ4RewWG7EW5UK+JFswssdcZ # rEj5XpHZzev/wx7hM4bWsoQ+VIvrH7j3uYGyWkcgYRbdDEkWDv2rsT23lwGYNhht # oBsrdEBELRw6v4C8doq/+sCmHmuxUMqTGwbArCQVnB1XnLxOEkuqlnfq5MORkzNF # fxbIRx+LRluOllC0HVaDQd8qxRq1+UC5WIpAcDcrouy4HGgi1onWKrXpgjIAbVyH # M6cENkK7rnRk96gpeXdmrf0h9HqRciAOY8oUsFsvLyKBOCPBWDrLyOQEY5UoSdtD # m4QpEVgywCy2z1uU/UObeT/UxJy/9EL/Zb+DHoEK06iEhwONoUJjEBYMJD38RMkk # mwPTB4UAk9g= # =s69t # -----END PGP SIGNATURE----- # gpg: Signature made Thu 12 Oct 2023 09:49:39 EDT # gpg: using RSA key 1BD9CAAD735C4C3A460DFCCA4DDE10F700FF835A # gpg: issuer "david@redhat.com" # gpg: Good signature from "David Hildenbrand <david@redhat.com>" [unknown] # gpg: aka "David Hildenbrand <davidhildenbrand@gmail.com>" [full] # gpg: aka "David Hildenbrand <hildenbr@in.tum.de>" [unknown] # gpg: WARNING: The key's User ID is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 1BD9 CAAD 735C 4C3A 460D FCCA 4DDE 10F7 00FF 835A * tag 'mem-2023-10-12' of https://github.com/davidhildenbrand/qemu: virtio-mem: Mark memslot alias memory regions unmergeable memory,vhost: Allow for marking memory device memory regions unmergeable virtio-mem: Expose device memory dynamically via multiple memslots if enabled virtio-mem: Update state to match bitmap as soon as it's been migrated virtio-mem: Pass non-const VirtIOMEM via virtio_mem_range_cb memory: Clarify mapping requirements for RamDiscardManager memory-device,vhost: Support automatic decision on the number of memslots vhost: Add vhost_get_max_memslots() kvm: Add stub for kvm_get_max_memslots() memory-device,vhost: Support memory devices that dynamically consume memslots memory-device: Track required and actually used memslots in DeviceMemoryState stubs: Rename qmp_memory_device.c to memory_device.c memory-device: Support memory devices with multiple memslots vhost: Return number of free memslots kvm: Return number of free memslots softmmu/physmem: Fixup qemu_ram_block_from_host() documentation vhost: Remove vhost_backend_can_merge() callback vhost: Rework memslot filtering and fix "used_memslot" tracking Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
commit
bc2b89b385
23 changed files with 839 additions and 113 deletions
|
@ -224,6 +224,7 @@ struct FlatRange {
|
|||
bool romd_mode;
|
||||
bool readonly;
|
||||
bool nonvolatile;
|
||||
bool unmergeable;
|
||||
};
|
||||
|
||||
#define FOR_EACH_FLAT_RANGE(var, view) \
|
||||
|
@ -240,6 +241,7 @@ section_from_flat_range(FlatRange *fr, FlatView *fv)
|
|||
.offset_within_address_space = int128_get64(fr->addr.start),
|
||||
.readonly = fr->readonly,
|
||||
.nonvolatile = fr->nonvolatile,
|
||||
.unmergeable = fr->unmergeable,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -250,7 +252,8 @@ static bool flatrange_equal(FlatRange *a, FlatRange *b)
|
|||
&& a->offset_in_region == b->offset_in_region
|
||||
&& a->romd_mode == b->romd_mode
|
||||
&& a->readonly == b->readonly
|
||||
&& a->nonvolatile == b->nonvolatile;
|
||||
&& a->nonvolatile == b->nonvolatile
|
||||
&& a->unmergeable == b->unmergeable;
|
||||
}
|
||||
|
||||
static FlatView *flatview_new(MemoryRegion *mr_root)
|
||||
|
@ -323,7 +326,8 @@ static bool can_merge(FlatRange *r1, FlatRange *r2)
|
|||
&& r1->dirty_log_mask == r2->dirty_log_mask
|
||||
&& r1->romd_mode == r2->romd_mode
|
||||
&& r1->readonly == r2->readonly
|
||||
&& r1->nonvolatile == r2->nonvolatile;
|
||||
&& r1->nonvolatile == r2->nonvolatile
|
||||
&& !r1->unmergeable && !r2->unmergeable;
|
||||
}
|
||||
|
||||
/* Attempt to simplify a view by merging adjacent ranges */
|
||||
|
@ -599,7 +603,8 @@ static void render_memory_region(FlatView *view,
|
|||
Int128 base,
|
||||
AddrRange clip,
|
||||
bool readonly,
|
||||
bool nonvolatile)
|
||||
bool nonvolatile,
|
||||
bool unmergeable)
|
||||
{
|
||||
MemoryRegion *subregion;
|
||||
unsigned i;
|
||||
|
@ -616,6 +621,7 @@ static void render_memory_region(FlatView *view,
|
|||
int128_addto(&base, int128_make64(mr->addr));
|
||||
readonly |= mr->readonly;
|
||||
nonvolatile |= mr->nonvolatile;
|
||||
unmergeable |= mr->unmergeable;
|
||||
|
||||
tmp = addrrange_make(base, mr->size);
|
||||
|
||||
|
@ -629,14 +635,14 @@ static void render_memory_region(FlatView *view,
|
|||
int128_subfrom(&base, int128_make64(mr->alias->addr));
|
||||
int128_subfrom(&base, int128_make64(mr->alias_offset));
|
||||
render_memory_region(view, mr->alias, base, clip,
|
||||
readonly, nonvolatile);
|
||||
readonly, nonvolatile, unmergeable);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Render subregions in priority order. */
|
||||
QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) {
|
||||
render_memory_region(view, subregion, base, clip,
|
||||
readonly, nonvolatile);
|
||||
readonly, nonvolatile, unmergeable);
|
||||
}
|
||||
|
||||
if (!mr->terminates) {
|
||||
|
@ -652,6 +658,7 @@ static void render_memory_region(FlatView *view,
|
|||
fr.romd_mode = mr->romd_mode;
|
||||
fr.readonly = readonly;
|
||||
fr.nonvolatile = nonvolatile;
|
||||
fr.unmergeable = unmergeable;
|
||||
|
||||
/* Render the region itself into any gaps left by the current view. */
|
||||
for (i = 0; i < view->nr && int128_nz(remain); ++i) {
|
||||
|
@ -753,7 +760,7 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)
|
|||
if (mr) {
|
||||
render_memory_region(view, mr, int128_zero(),
|
||||
addrrange_make(int128_zero(), int128_2_64()),
|
||||
false, false);
|
||||
false, false, false);
|
||||
}
|
||||
flatview_simplify(view);
|
||||
|
||||
|
@ -2085,7 +2092,7 @@ int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr)
|
|||
|
||||
RamDiscardManager *memory_region_get_ram_discard_manager(MemoryRegion *mr)
|
||||
{
|
||||
if (!memory_region_is_mapped(mr) || !memory_region_is_ram(mr)) {
|
||||
if (!memory_region_is_ram(mr)) {
|
||||
return NULL;
|
||||
}
|
||||
return mr->rdm;
|
||||
|
@ -2094,7 +2101,7 @@ RamDiscardManager *memory_region_get_ram_discard_manager(MemoryRegion *mr)
|
|||
void memory_region_set_ram_discard_manager(MemoryRegion *mr,
|
||||
RamDiscardManager *rdm)
|
||||
{
|
||||
g_assert(memory_region_is_ram(mr) && !memory_region_is_mapped(mr));
|
||||
g_assert(memory_region_is_ram(mr));
|
||||
g_assert(!rdm || !mr->rdm);
|
||||
mr->rdm = rdm;
|
||||
}
|
||||
|
@ -2755,6 +2762,18 @@ void memory_region_set_alias_offset(MemoryRegion *mr, hwaddr offset)
|
|||
memory_region_transaction_commit();
|
||||
}
|
||||
|
||||
void memory_region_set_unmergeable(MemoryRegion *mr, bool unmergeable)
|
||||
{
|
||||
if (unmergeable == mr->unmergeable) {
|
||||
return;
|
||||
}
|
||||
|
||||
memory_region_transaction_begin();
|
||||
mr->unmergeable = unmergeable;
|
||||
memory_region_update_pending |= mr->enabled;
|
||||
memory_region_transaction_commit();
|
||||
}
|
||||
|
||||
uint64_t memory_region_get_alignment(const MemoryRegion *mr)
|
||||
{
|
||||
return mr->align;
|
||||
|
|
|
@ -2221,23 +2221,6 @@ ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
|
|||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translates a host ptr back to a RAMBlock, a ram_addr and an offset
|
||||
* in that RAMBlock.
|
||||
*
|
||||
* ptr: Host pointer to look up
|
||||
* round_offset: If true round the result offset down to a page boundary
|
||||
* *ram_addr: set to result ram_addr
|
||||
* *offset: set to result offset within the RAMBlock
|
||||
*
|
||||
* Returns: RAMBlock (or NULL if not found)
|
||||
*
|
||||
* By the time this function returns, the returned pointer is not protected
|
||||
* by RCU anymore. If the caller is not within an RCU critical section and
|
||||
* does not hold the iothread lock, it must have other means of protecting the
|
||||
* pointer, such as a reference to the region that includes the incoming
|
||||
* ram_addr_t.
|
||||
*/
|
||||
RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
|
||||
ram_addr_t *offset)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue