From 75b98cb9f6456ccf194211beffcbf93b0a995fa4 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Wed, 29 Sep 2021 18:24:43 +0200 Subject: virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event Apparently, we don't have to duplicate the string. Fixes: 722a3c783ef4 ("virtio-pci: Send qapi events when the virtio-mem size changes") Cc: qemu-stable@nongnu.org Signed-off-by: David Hildenbrand Reviewed-by: Markus Armbruster Message-Id: <20210929162445.64060-2-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/virtio/virtio-mem-pci.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'hw') diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c index fa5395c..7e384b7 100644 --- a/hw/virtio/virtio-mem-pci.c +++ b/hw/virtio/virtio-mem-pci.c @@ -88,13 +88,8 @@ static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *data) size_change_notifier); DeviceState *dev = DEVICE(pci_mem); const uint64_t * const size_p = data; - const char *id = NULL; - if (dev->id) { - id = g_strdup(dev->id); - } - - qapi_event_send_memory_device_size_change(!!id, id, *size_p); + qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p); } static void virtio_mem_pci_class_init(ObjectClass *klass, void *data) -- cgit v1.1 From d89dd28f0e29c9eae997b0cd645208454a2f3374 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Wed, 29 Sep 2021 18:24:44 +0200 Subject: qapi: Include qom-path in MEMORY_DEVICE_SIZE_CHANGE qapi events As we might not always have a device id, it is impossible to always match MEMORY_DEVICE_SIZE_CHANGE events to an actual device. Let's include the qom-path in the event, which allows for reliable mapping of events to devices. Fixes: 722a3c783ef4 ("virtio-pci: Send qapi events when the virtio-mem size changes") Suggested-by: Markus Armbruster Reviewed-by: Markus Armbruster Signed-off-by: David Hildenbrand Message-Id: <20210929162445.64060-3-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/virtio/virtio-mem-pci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c index 7e384b7..be2383b 100644 --- a/hw/virtio/virtio-mem-pci.c +++ b/hw/virtio/virtio-mem-pci.c @@ -87,9 +87,12 @@ static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *data) VirtIOMEMPCI *pci_mem = container_of(notifier, VirtIOMEMPCI, size_change_notifier); DeviceState *dev = DEVICE(pci_mem); + char *qom_path = object_get_canonical_path(OBJECT(dev)); const uint64_t * const size_p = data; - qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p); + qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p, + qom_path); + g_free(qom_path); } static void virtio_mem_pci_class_init(ObjectClass *klass, void *data) -- cgit v1.1 From 45e576c74533c70b38ba00f0c298dcdbc1635163 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Tue, 27 Jul 2021 10:25:42 +0200 Subject: tpm: mark correct memory region range dirty when clearing RAM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We might not start at the beginning of the memory region. Let's calculate the offset into the memory region via the difference in the host addresses. Acked-by: Stefan Berger Fixes: ffab1be70692 ("tpm: clear RAM when "memory overwrite" requested") Cc: Marc-André Lureau Cc: Paolo Bonzini Cc: "Michael S. Tsirkin" Cc: Eduardo Habkost Cc: Alex Williamson Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Claudio Fontana Cc: Thomas Huth Cc: "Alex Bennée" Cc: Peter Xu Cc: Laurent Vivier Cc: Stefan Berger Signed-off-by: David Hildenbrand Reviewed-by: Peter Xu Message-Id: <20210727082545.17934-2-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/tpm/tpm_ppi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c index 362edcc..274e9aa 100644 --- a/hw/tpm/tpm_ppi.c +++ b/hw/tpm/tpm_ppi.c @@ -30,11 +30,14 @@ void tpm_ppi_reset(TPMPPI *tpmppi) guest_phys_blocks_init(&guest_phys_blocks); guest_phys_blocks_append(&guest_phys_blocks); QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) { + hwaddr mr_offs = block->host_addr - + (uint8_t *)memory_region_get_ram_ptr(block->mr); + trace_tpm_ppi_memset(block->host_addr, block->target_end - block->target_start); memset(block->host_addr, 0, block->target_end - block->target_start); - memory_region_set_dirty(block->mr, 0, + memory_region_set_dirty(block->mr, mr_offs, block->target_end - block->target_start); } guest_phys_blocks_free(&guest_phys_blocks); -- cgit v1.1