* [Qemu-devel] [PATCH] vga: set owner for mmio regions
@ 2018-06-26 6:09 Gerd Hoffmann
2018-06-26 7:20 ` Thomas Huth
2018-06-26 11:39 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2018-06-26 6:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Thomas Huth, Gerd Hoffmann, Michael S. Tsirkin
This makes sure the regions are properly cleaned when unplugging -device
seconday-vga.
Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/display/vga_int.h | 1 +
hw/display/vga-pci.c | 11 ++++++-----
hw/display/virtio-vga.c | 2 +-
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index 313cff84fc..f8fcf62a56 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -193,6 +193,7 @@ extern const MemoryRegionOps vga_mem_ops;
/* vga-pci.c */
void pci_std_vga_mmio_region_init(VGACommonState *s,
+ Object *owner,
MemoryRegion *parent,
MemoryRegion *subs,
bool qext);
diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index 700ac58c69..1ea559762a 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -192,22 +192,23 @@ static const MemoryRegionOps pci_vga_qext_ops = {
};
void pci_std_vga_mmio_region_init(VGACommonState *s,
+ Object *owner,
MemoryRegion *parent,
MemoryRegion *subs,
bool qext)
{
- memory_region_init_io(&subs[0], NULL, &pci_vga_ioport_ops, s,
+ memory_region_init_io(&subs[0], owner, &pci_vga_ioport_ops, s,
"vga ioports remapped", PCI_VGA_IOPORT_SIZE);
memory_region_add_subregion(parent, PCI_VGA_IOPORT_OFFSET,
&subs[0]);
- memory_region_init_io(&subs[1], NULL, &pci_vga_bochs_ops, s,
+ memory_region_init_io(&subs[1], owner, &pci_vga_bochs_ops, s,
"bochs dispi interface", PCI_VGA_BOCHS_SIZE);
memory_region_add_subregion(parent, PCI_VGA_BOCHS_OFFSET,
&subs[1]);
if (qext) {
- memory_region_init_io(&subs[2], NULL, &pci_vga_qext_ops, s,
+ memory_region_init_io(&subs[2], owner, &pci_vga_qext_ops, s,
"qemu extended regs", PCI_VGA_QEXT_SIZE);
memory_region_add_subregion(parent, PCI_VGA_QEXT_OFFSET,
&subs[2]);
@@ -239,7 +240,7 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
qext = true;
pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
}
- pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
+ pci_std_vga_mmio_region_init(s, OBJECT(dev), &d->mmio, d->mrs, qext);
pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
}
@@ -275,7 +276,7 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
qext = true;
pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
}
- pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
+ pci_std_vga_mmio_region_init(s, OBJECT(dev), &d->mmio, d->mrs, qext);
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index baa74ba82c..97db6c3372 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -152,7 +152,7 @@ static void virtio_vga_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
}
/* add stdvga mmio regions */
- pci_std_vga_mmio_region_init(vga, &vpci_dev->modern_bar,
+ pci_std_vga_mmio_region_init(vga, OBJECT(vvga), &vpci_dev->modern_bar,
vvga->vga_mrs, true);
vga->con = g->scanout[0].con;
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vga: set owner for mmio regions
2018-06-26 6:09 [Qemu-devel] [PATCH] vga: set owner for mmio regions Gerd Hoffmann
@ 2018-06-26 7:20 ` Thomas Huth
2018-06-26 11:39 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2018-06-26 7:20 UTC (permalink / raw)
To: Gerd Hoffmann, qemu-devel; +Cc: Michael S. Tsirkin
On 26.06.2018 08:09, Gerd Hoffmann wrote:
> This makes sure the regions are properly cleaned when unplugging -device
> seconday-vga.
>
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/display/vga_int.h | 1 +
> hw/display/vga-pci.c | 11 ++++++-----
> hw/display/virtio-vga.c | 2 +-
> 3 files changed, 8 insertions(+), 6 deletions(-)
Thanks, this fixes the issue indeed! Without this patch:
$ valgrind mips-softmmu/qemu-system-mips -accel qtest -monitor stdio
[...]
(qemu) device_add secondary-vga
Unsupported bus. Bus doesn't have property 'acpi-pcihp-bsel' set
(qemu) dump-guest-memory /dev/null 0 4096
==8407== Invalid read of size 8
==8407== at 0x6B0DA5: object_dynamic_cast (object.c:613)
==8407== by 0x6B0DA5: object_resolve_abs_path (object.c:1721)
==8407== by 0x6B0E00: object_resolve_partial_path (object.c:1745)
==8407== by 0x6B0E62: object_resolve_partial_path (object.c:1755)
[...]
With this patch applied, the problem is gone.
Tested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vga: set owner for mmio regions
2018-06-26 6:09 [Qemu-devel] [PATCH] vga: set owner for mmio regions Gerd Hoffmann
2018-06-26 7:20 ` Thomas Huth
@ 2018-06-26 11:39 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-26 11:39 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel, Thomas Huth, Michael S. Tsirkin
On 06/26/2018 03:09 AM, Gerd Hoffmann wrote:
> This makes sure the regions are properly cleaned when unplugging -device
> seconday-vga.
>
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/display/vga_int.h | 1 +
> hw/display/vga-pci.c | 11 ++++++-----
> hw/display/virtio-vga.c | 2 +-
> 3 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
> index 313cff84fc..f8fcf62a56 100644
> --- a/hw/display/vga_int.h
> +++ b/hw/display/vga_int.h
> @@ -193,6 +193,7 @@ extern const MemoryRegionOps vga_mem_ops;
>
> /* vga-pci.c */
> void pci_std_vga_mmio_region_init(VGACommonState *s,
> + Object *owner,
> MemoryRegion *parent,
> MemoryRegion *subs,
> bool qext);
> diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
> index 700ac58c69..1ea559762a 100644
> --- a/hw/display/vga-pci.c
> +++ b/hw/display/vga-pci.c
> @@ -192,22 +192,23 @@ static const MemoryRegionOps pci_vga_qext_ops = {
> };
>
> void pci_std_vga_mmio_region_init(VGACommonState *s,
> + Object *owner,
> MemoryRegion *parent,
> MemoryRegion *subs,
> bool qext)
> {
> - memory_region_init_io(&subs[0], NULL, &pci_vga_ioport_ops, s,
> + memory_region_init_io(&subs[0], owner, &pci_vga_ioport_ops, s,
> "vga ioports remapped", PCI_VGA_IOPORT_SIZE);
> memory_region_add_subregion(parent, PCI_VGA_IOPORT_OFFSET,
> &subs[0]);
>
> - memory_region_init_io(&subs[1], NULL, &pci_vga_bochs_ops, s,
> + memory_region_init_io(&subs[1], owner, &pci_vga_bochs_ops, s,
> "bochs dispi interface", PCI_VGA_BOCHS_SIZE);
> memory_region_add_subregion(parent, PCI_VGA_BOCHS_OFFSET,
> &subs[1]);
>
> if (qext) {
> - memory_region_init_io(&subs[2], NULL, &pci_vga_qext_ops, s,
> + memory_region_init_io(&subs[2], owner, &pci_vga_qext_ops, s,
> "qemu extended regs", PCI_VGA_QEXT_SIZE);
> memory_region_add_subregion(parent, PCI_VGA_QEXT_OFFSET,
> &subs[2]);
> @@ -239,7 +240,7 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
> qext = true;
> pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
> }
> - pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
> + pci_std_vga_mmio_region_init(s, OBJECT(dev), &d->mmio, d->mrs, qext);
>
> pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
> }
> @@ -275,7 +276,7 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
> qext = true;
> pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
> }
> - pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
> + pci_std_vga_mmio_region_init(s, OBJECT(dev), &d->mmio, d->mrs, qext);
>
> pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
> pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
> diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
> index baa74ba82c..97db6c3372 100644
> --- a/hw/display/virtio-vga.c
> +++ b/hw/display/virtio-vga.c
> @@ -152,7 +152,7 @@ static void virtio_vga_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
> }
>
> /* add stdvga mmio regions */
> - pci_std_vga_mmio_region_init(vga, &vpci_dev->modern_bar,
> + pci_std_vga_mmio_region_init(vga, OBJECT(vvga), &vpci_dev->modern_bar,
> vvga->vga_mrs, true);
>
> vga->con = g->scanout[0].con;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-26 11:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-26 6:09 [Qemu-devel] [PATCH] vga: set owner for mmio regions Gerd Hoffmann
2018-06-26 7:20 ` Thomas Huth
2018-06-26 11:39 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).