* [PATCH v2 0/2] virtio-pci: add check for vdev in virtio_pci_isr_read
@ 2021-03-15 11:59 Yuri Benditovich
2021-03-15 11:59 ` [PATCH v2 1/2] " Yuri Benditovich
2021-03-15 11:59 ` [PATCH v2 2/2] virtio-pci: remove explicit initialization of val Yuri Benditovich
0 siblings, 2 replies; 4+ messages in thread
From: Yuri Benditovich @ 2021-03-15 11:59 UTC (permalink / raw)
To: qemu-devel, mst; +Cc: yan
This commit completes the solution of segfault in hot unplug flow
(by commit ccec7e9603f446fe75c6c563ba335c00cfda6a06).
Added missing check for vdev in virtio_pci_isr_read.
v1->v2:
Added crash stack
Updated commit comment
Cosmetic change in additional procedure in this file per request
of Philippe Mathieu-Daude
Yuri Benditovich (2):
virtio-pci: add check for vdev in virtio_pci_isr_read
virtio-pci: remove explicit initialization of val
hw/virtio/virtio-pci.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] virtio-pci: add check for vdev in virtio_pci_isr_read
2021-03-15 11:59 [PATCH v2 0/2] virtio-pci: add check for vdev in virtio_pci_isr_read Yuri Benditovich
@ 2021-03-15 11:59 ` Yuri Benditovich
2021-03-23 19:51 ` Yuri Benditovich
2021-03-15 11:59 ` [PATCH v2 2/2] virtio-pci: remove explicit initialization of val Yuri Benditovich
1 sibling, 1 reply; 4+ messages in thread
From: Yuri Benditovich @ 2021-03-15 11:59 UTC (permalink / raw)
To: qemu-devel, mst; +Cc: yan
https://bugzilla.redhat.com/show_bug.cgi?id=1743098
This commit completes the solution of segfault in hot unplug flow
(by commit ccec7e9603f446fe75c6c563ba335c00cfda6a06).
Added missing check for vdev in virtio_pci_isr_read.
Typical stack of crash:
virtio_pci_isr_read ../hw/virtio/virtio-pci.c:1365 with proxy-vdev = 0
memory_region_read_accessor at ../softmmu/memory.c:442
access_with_adjusted_size at ../softmmu/memory.c:552
memory_region_dispatch_read1 at ../softmmu/memory.c:1420
memory_region_dispatch_read at ../softmmu/memory.c:1449
flatview_read_continue at ../softmmu/physmem.c:2822
flatview_read at ../softmmu/physmem.c:2862
address_space_read_full at ../softmmu/physmem.c:2875
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
---
hw/virtio/virtio-pci.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 883045a223..4a3dcee771 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1364,9 +1364,14 @@ static uint64_t virtio_pci_isr_read(void *opaque, hwaddr addr,
{
VirtIOPCIProxy *proxy = opaque;
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
- uint64_t val = qatomic_xchg(&vdev->isr, 0);
- pci_irq_deassert(&proxy->pci_dev);
+ uint64_t val;
+
+ if (vdev == NULL) {
+ return 0;
+ }
+ val = qatomic_xchg(&vdev->isr, 0);
+ pci_irq_deassert(&proxy->pci_dev);
return val;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] virtio-pci: remove explicit initialization of val
2021-03-15 11:59 [PATCH v2 0/2] virtio-pci: add check for vdev in virtio_pci_isr_read Yuri Benditovich
2021-03-15 11:59 ` [PATCH v2 1/2] " Yuri Benditovich
@ 2021-03-15 11:59 ` Yuri Benditovich
1 sibling, 0 replies; 4+ messages in thread
From: Yuri Benditovich @ 2021-03-15 11:59 UTC (permalink / raw)
To: qemu-devel, mst; +Cc: yan
The value is assigned later in this procedure.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
---
hw/virtio/virtio-pci.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 4a3dcee771..c1b67cf6fc 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1385,10 +1385,10 @@ static uint64_t virtio_pci_device_read(void *opaque, hwaddr addr,
{
VirtIOPCIProxy *proxy = opaque;
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
- uint64_t val = 0;
+ uint64_t val;
if (vdev == NULL) {
- return val;
+ return 0;
}
switch (size) {
@@ -1401,6 +1401,9 @@ static uint64_t virtio_pci_device_read(void *opaque, hwaddr addr,
case 4:
val = virtio_config_modern_readl(vdev, addr);
break;
+ default:
+ val = 0;
+ break;
}
return val;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] virtio-pci: add check for vdev in virtio_pci_isr_read
2021-03-15 11:59 ` [PATCH v2 1/2] " Yuri Benditovich
@ 2021-03-23 19:51 ` Yuri Benditovich
0 siblings, 0 replies; 4+ messages in thread
From: Yuri Benditovich @ 2021-03-23 19:51 UTC (permalink / raw)
To: qemu-devel, Michael S . Tsirkin; +Cc: Yan Vugenfirer
Ping
On Mon, Mar 15, 2021 at 1:59 PM Yuri Benditovich
<yuri.benditovich@daynix.com> wrote:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1743098
> This commit completes the solution of segfault in hot unplug flow
> (by commit ccec7e9603f446fe75c6c563ba335c00cfda6a06).
> Added missing check for vdev in virtio_pci_isr_read.
> Typical stack of crash:
> virtio_pci_isr_read ../hw/virtio/virtio-pci.c:1365 with proxy-vdev = 0
> memory_region_read_accessor at ../softmmu/memory.c:442
> access_with_adjusted_size at ../softmmu/memory.c:552
> memory_region_dispatch_read1 at ../softmmu/memory.c:1420
> memory_region_dispatch_read at ../softmmu/memory.c:1449
> flatview_read_continue at ../softmmu/physmem.c:2822
> flatview_read at ../softmmu/physmem.c:2862
> address_space_read_full at ../softmmu/physmem.c:2875
>
> Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
> ---
> hw/virtio/virtio-pci.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index 883045a223..4a3dcee771 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1364,9 +1364,14 @@ static uint64_t virtio_pci_isr_read(void *opaque, hwaddr addr,
> {
> VirtIOPCIProxy *proxy = opaque;
> VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
> - uint64_t val = qatomic_xchg(&vdev->isr, 0);
> - pci_irq_deassert(&proxy->pci_dev);
> + uint64_t val;
> +
> + if (vdev == NULL) {
> + return 0;
> + }
>
> + val = qatomic_xchg(&vdev->isr, 0);
> + pci_irq_deassert(&proxy->pci_dev);
> return val;
> }
>
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-23 19:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 11:59 [PATCH v2 0/2] virtio-pci: add check for vdev in virtio_pci_isr_read Yuri Benditovich
2021-03-15 11:59 ` [PATCH v2 1/2] " Yuri Benditovich
2021-03-23 19:51 ` Yuri Benditovich
2021-03-15 11:59 ` [PATCH v2 2/2] virtio-pci: remove explicit initialization of val Yuri Benditovich
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).