Skip to content

Commit 30bd1db

Browse files
committed
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* -smp cleanpus (Yanan) * Hyper-V enlightenment functionality (Vitaly) * virtio-mem support in dump, tpm and QMP (David) * NetBSD GCC 7.4 compiler support (Nia) # gpg: Signature made Sun 03 Oct 2021 03:41:30 AM EDT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "[email protected]" # gpg: Good signature from "Paolo Bonzini <[email protected]>" [full] # gpg: aka "Paolo Bonzini <[email protected]>" [full] * remotes/bonzini/tags/for-upstream: softmmu/memory_mapping: optimize for RamDiscardManager sections softmmu/memory_mapping: factor out adding physical memory ranges softmmu/memory_mapping: never merge ranges accross memory regions tpm: mark correct memory region range dirty when clearing RAM monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device qapi: Include qom-path in MEMORY_DEVICE_SIZE_CHANGE qapi events virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event configure: Loosen GCC requirement from 7.5.0 to 7.4.0 Signed-off-by: Richard Henderson <[email protected]>
2 parents f50ecf5 + cb83ba8 commit 30bd1db

File tree

6 files changed

+66
-33
lines changed

6 files changed

+66
-33
lines changed

configure

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,16 +2094,16 @@ cat > $TMPC << EOF
20942094
# endif
20952095
# endif
20962096
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
2097-
# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 5)
2098-
# error You need at least GCC v7.5.0 to compile QEMU
2097+
# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
2098+
# error You need at least GCC v7.4.0 to compile QEMU
20992099
# endif
21002100
#else
21012101
# error You either need GCC or Clang to compiler QEMU
21022102
#endif
21032103
int main (void) { return 0; }
21042104
EOF
21052105
if ! compile_prog "" "" ; then
2106-
error_exit "You need at least GCC v7.5 or Clang v6.0 (or XCode Clang v10.0)"
2106+
error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
21072107
fi
21082108

21092109
# Accumulate -Wfoo and -Wno-bar separately.

hw/tpm/tpm_ppi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ void tpm_ppi_reset(TPMPPI *tpmppi)
3030
guest_phys_blocks_init(&guest_phys_blocks);
3131
guest_phys_blocks_append(&guest_phys_blocks);
3232
QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) {
33+
hwaddr mr_offs = block->host_addr -
34+
(uint8_t *)memory_region_get_ram_ptr(block->mr);
35+
3336
trace_tpm_ppi_memset(block->host_addr,
3437
block->target_end - block->target_start);
3538
memset(block->host_addr, 0,
3639
block->target_end - block->target_start);
37-
memory_region_set_dirty(block->mr, 0,
40+
memory_region_set_dirty(block->mr, mr_offs,
3841
block->target_end - block->target_start);
3942
}
4043
guest_phys_blocks_free(&guest_phys_blocks);

hw/virtio/virtio-mem-pci.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,12 @@ static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *data)
8787
VirtIOMEMPCI *pci_mem = container_of(notifier, VirtIOMEMPCI,
8888
size_change_notifier);
8989
DeviceState *dev = DEVICE(pci_mem);
90+
char *qom_path = object_get_canonical_path(OBJECT(dev));
9091
const uint64_t * const size_p = data;
91-
const char *id = NULL;
9292

93-
if (dev->id) {
94-
id = g_strdup(dev->id);
95-
}
96-
97-
qapi_event_send_memory_device_size_change(!!id, id, *size_p);
93+
qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p,
94+
qom_path);
95+
g_free(qom_path);
9896
}
9997

10098
static void virtio_mem_pci_class_init(ObjectClass *klass, void *data)

monitor/monitor.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@ static unsigned int qapi_event_throttle_hash(const void *key)
474474
hash += g_str_hash(qdict_get_str(evstate->data, "node-name"));
475475
}
476476

477+
if (evstate->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) {
478+
hash += g_str_hash(qdict_get_str(evstate->data, "qom-path"));
479+
}
480+
477481
return hash;
478482
}
479483

@@ -496,6 +500,11 @@ static gboolean qapi_event_throttle_equal(const void *a, const void *b)
496500
qdict_get_str(evb->data, "node-name"));
497501
}
498502

503+
if (eva->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) {
504+
return !strcmp(qdict_get_str(eva->data, "qom-path"),
505+
qdict_get_str(evb->data, "qom-path"));
506+
}
507+
499508
return TRUE;
500509
}
501510

qapi/machine.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,11 @@
13361336
# action).
13371337
#
13381338
# @id: device's ID
1339+
#
13391340
# @size: the new size of memory that the device provides
13401341
#
1342+
# @qom-path: path to the device object in the QOM tree (since 6.2)
1343+
#
13411344
# Note: this event is rate-limited.
13421345
#
13431346
# Since: 5.1
@@ -1350,7 +1353,7 @@
13501353
#
13511354
##
13521355
{ 'event': 'MEMORY_DEVICE_SIZE_CHANGE',
1353-
'data': { '*id': 'str', 'size': 'size' } }
1356+
'data': { '*id': 'str', 'size': 'size', 'qom-path' : 'str'} }
13541357

13551358

13561359
##

softmmu/memory_mapping.c

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -193,29 +193,14 @@ typedef struct GuestPhysListener {
193193
MemoryListener listener;
194194
} GuestPhysListener;
195195

196-
static void guest_phys_blocks_region_add(MemoryListener *listener,
196+
static void guest_phys_block_add_section(GuestPhysListener *g,
197197
MemoryRegionSection *section)
198198
{
199-
GuestPhysListener *g;
200-
uint64_t section_size;
201-
hwaddr target_start, target_end;
202-
uint8_t *host_addr;
203-
GuestPhysBlock *predecessor;
204-
205-
/* we only care about RAM */
206-
if (!memory_region_is_ram(section->mr) ||
207-
memory_region_is_ram_device(section->mr) ||
208-
memory_region_is_nonvolatile(section->mr)) {
209-
return;
210-
}
211-
212-
g = container_of(listener, GuestPhysListener, listener);
213-
section_size = int128_get64(section->size);
214-
target_start = section->offset_within_address_space;
215-
target_end = target_start + section_size;
216-
host_addr = memory_region_get_ram_ptr(section->mr) +
217-
section->offset_within_region;
218-
predecessor = NULL;
199+
const hwaddr target_start = section->offset_within_address_space;
200+
const hwaddr target_end = target_start + int128_get64(section->size);
201+
uint8_t *host_addr = memory_region_get_ram_ptr(section->mr) +
202+
section->offset_within_region;
203+
GuestPhysBlock *predecessor = NULL;
219204

220205
/* find continuity in guest physical address space */
221206
if (!QTAILQ_EMPTY(&g->list->head)) {
@@ -229,7 +214,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
229214

230215
/* we want continuity in both guest-physical and host-virtual memory */
231216
if (predecessor->target_end < target_start ||
232-
predecessor->host_addr + predecessor_size != host_addr) {
217+
predecessor->host_addr + predecessor_size != host_addr ||
218+
predecessor->mr != section->mr) {
233219
predecessor = NULL;
234220
}
235221
}
@@ -260,6 +246,40 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
260246
#endif
261247
}
262248

249+
static int guest_phys_ram_populate_cb(MemoryRegionSection *section,
250+
void *opaque)
251+
{
252+
GuestPhysListener *g = opaque;
253+
254+
guest_phys_block_add_section(g, section);
255+
return 0;
256+
}
257+
258+
static void guest_phys_blocks_region_add(MemoryListener *listener,
259+
MemoryRegionSection *section)
260+
{
261+
GuestPhysListener *g = container_of(listener, GuestPhysListener, listener);
262+
263+
/* we only care about RAM */
264+
if (!memory_region_is_ram(section->mr) ||
265+
memory_region_is_ram_device(section->mr) ||
266+
memory_region_is_nonvolatile(section->mr)) {
267+
return;
268+
}
269+
270+
/* for special sparse regions, only add populated parts */
271+
if (memory_region_has_ram_discard_manager(section->mr)) {
272+
RamDiscardManager *rdm;
273+
274+
rdm = memory_region_get_ram_discard_manager(section->mr);
275+
ram_discard_manager_replay_populated(rdm, section,
276+
guest_phys_ram_populate_cb, g);
277+
return;
278+
}
279+
280+
guest_phys_block_add_section(g, section);
281+
}
282+
263283
void guest_phys_blocks_append(GuestPhysBlockList *list)
264284
{
265285
GuestPhysListener g = { 0 };

0 commit comments

Comments
 (0)