- hw/virtio/virtio-crypto: Protect from DMA re-entrancy bugs(CVE-2024-3446) - hw/char/virtio-serial-bus: Protect from DMA re-entrancy bugs(CVE-2024-3446) - hw/display/virtio-gpu: Protect from DMA re-entrancy bugs(CVE-2024-3446) - hw/virtio: Introduce virtio_bh_new_guarded() helper - hw: replace most qemu_bh_new calls with qemu_bh_new_guarded - checkpatch: add qemu_bh_new/aio_bh_new checks - async: avoid use-after-free on re-entrancy guard - async: Add an optional reentrancy guard to the BH API - hw/sd/sdhci: Do not update TRNMOD when Command Inhibit (DAT) is set(CVE-2024-3447) - rtl8139: Remove unused variable - tulip: Remove unused variable - virtio-mem: Fix the bitmap index of the section offset - virtio-mem: Fix the iterator variable in a vmem->rdl_list loop - system/memory: use ldn_he_p/stn_he_p - block: Fix crash when loading snapshot on inactive node - smmu: Clear SMMUPciBus pointer cache when system reset - block/mirror: Fix NULL s->job in active writes - amd_iommu: Fix APIC address check - virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_reques - libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick cherry-pick from 66e411885a23c96ff73742d06b793fec3ceaebb7 - ivshmem-test.c: enable test_ivshmem_server for ppc64 arch - ivshmem.c: change endianness to LITTLE_ENDIAN - hw/ppc/mac.h: Remove MAX_CPUS macro - configure: remove dead variables - virtio-gpu: do not byteswap padding - hw/intc: clean-up error reporting for failed ITS cmd - qemu-iotests: Discard stderr when probing devices - linux-user: un-parent OBJECT(cpu) when closing thread - hw/net/rocker: Avoid undefined shifts with more than 31 ports - contrib/vhost-user-blk: Clean up deallocation of VuVirtqElement - scsi-disk: fix overflow when block size is not a multiple of BDRV_SECTOR_SIZE Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com> (cherry picked from commit bf54b48c2963c869dfdc89977c57be4bd9e772aa)
428 lines
18 KiB
Diff
428 lines
18 KiB
Diff
From 458b3f30a4e5d7b6361e6040061c9e30b4d75d1d Mon Sep 17 00:00:00 2001
|
|
From: Alexander Bulekov <alxndr@bu.edu>
|
|
Date: Thu, 27 Apr 2023 17:10:09 -0400
|
|
Subject: [PATCH] hw: replace most qemu_bh_new calls with qemu_bh_new_guarded
|
|
|
|
This protects devices from bh->mmio reentrancy issues.
|
|
|
|
Thanks: Thomas Huth <thuth@redhat.com> for diagnosing OS X test failure.
|
|
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
|
|
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
|
|
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Reviewed-by: Paul Durrant <paul@xen.org>
|
|
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
|
Message-Id: <20230427211013.2994127-5-alxndr@bu.edu>
|
|
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
Signed-off-by: liuxiangdong <liuxiangdong5@huawei.com>
|
|
---
|
|
hw/9pfs/xen-9p-backend.c | 5 ++++-
|
|
hw/block/dataplane/virtio-blk.c | 3 ++-
|
|
hw/block/dataplane/xen-block.c | 5 +++--
|
|
hw/char/virtio-serial-bus.c | 3 ++-
|
|
hw/display/qxl.c | 9 ++++++---
|
|
hw/display/virtio-gpu.c | 6 ++++--
|
|
hw/ide/ahci.c | 3 ++-
|
|
hw/ide/ahci_internal.h | 1 +
|
|
hw/ide/core.c | 4 +++-
|
|
hw/misc/imx_rngc.c | 6 ++++--
|
|
hw/misc/macio/mac_dbdma.c | 2 +-
|
|
hw/net/virtio-net.c | 3 ++-
|
|
hw/scsi/mptsas.c | 3 ++-
|
|
hw/scsi/scsi-bus.c | 3 ++-
|
|
hw/scsi/vmw_pvscsi.c | 3 ++-
|
|
hw/usb/dev-uas.c | 3 ++-
|
|
hw/usb/hcd-dwc2.c | 3 ++-
|
|
hw/usb/hcd-ehci.c | 3 ++-
|
|
hw/usb/hcd-uhci.c | 2 +-
|
|
hw/usb/host-libusb.c | 6 ++++--
|
|
hw/usb/redirect.c | 6 ++++--
|
|
hw/usb/xen-usb.c | 3 ++-
|
|
hw/virtio/virtio-balloon.c | 5 +++--
|
|
hw/virtio/virtio-crypto.c | 3 ++-
|
|
24 files changed, 62 insertions(+), 31 deletions(-)
|
|
|
|
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
|
|
index 65c4979c3c..09f7c13588 100644
|
|
--- a/hw/9pfs/xen-9p-backend.c
|
|
+++ b/hw/9pfs/xen-9p-backend.c
|
|
@@ -60,6 +60,7 @@ typedef struct Xen9pfsDev {
|
|
|
|
int num_rings;
|
|
Xen9pfsRing *rings;
|
|
+ MemReentrancyGuard mem_reentrancy_guard;
|
|
} Xen9pfsDev;
|
|
|
|
static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev);
|
|
@@ -441,7 +442,9 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xendev)
|
|
xen_9pdev->rings[i].ring.out = xen_9pdev->rings[i].data +
|
|
XEN_FLEX_RING_SIZE(ring_order);
|
|
|
|
- xen_9pdev->rings[i].bh = qemu_bh_new(xen_9pfs_bh, &xen_9pdev->rings[i]);
|
|
+ xen_9pdev->rings[i].bh = qemu_bh_new_guarded(xen_9pfs_bh,
|
|
+ &xen_9pdev->rings[i],
|
|
+ &xen_9pdev->mem_reentrancy_guard);
|
|
xen_9pdev->rings[i].out_cons = 0;
|
|
xen_9pdev->rings[i].out_size = 0;
|
|
xen_9pdev->rings[i].inprogress = false;
|
|
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
|
|
index ee5a5352dc..5f0de7da1e 100644
|
|
--- a/hw/block/dataplane/virtio-blk.c
|
|
+++ b/hw/block/dataplane/virtio-blk.c
|
|
@@ -127,7 +127,8 @@ bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf,
|
|
} else {
|
|
s->ctx = qemu_get_aio_context();
|
|
}
|
|
- s->bh = aio_bh_new(s->ctx, notify_guest_bh, s);
|
|
+ s->bh = aio_bh_new_guarded(s->ctx, notify_guest_bh, s,
|
|
+ &DEVICE(vdev)->mem_reentrancy_guard);
|
|
s->batch_notify_vqs = bitmap_new(conf->num_queues);
|
|
|
|
*dataplane = s;
|
|
diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
|
|
index 860787580a..07855feea6 100644
|
|
--- a/hw/block/dataplane/xen-block.c
|
|
+++ b/hw/block/dataplane/xen-block.c
|
|
@@ -631,8 +631,9 @@ XenBlockDataPlane *xen_block_dataplane_create(XenDevice *xendev,
|
|
} else {
|
|
dataplane->ctx = qemu_get_aio_context();
|
|
}
|
|
- dataplane->bh = aio_bh_new(dataplane->ctx, xen_block_dataplane_bh,
|
|
- dataplane);
|
|
+ dataplane->bh = aio_bh_new_guarded(dataplane->ctx, xen_block_dataplane_bh,
|
|
+ dataplane,
|
|
+ &DEVICE(xendev)->mem_reentrancy_guard);
|
|
|
|
return dataplane;
|
|
}
|
|
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
|
|
index edb7a44ee9..14716b66cc 100644
|
|
--- a/hw/char/virtio-serial-bus.c
|
|
+++ b/hw/char/virtio-serial-bus.c
|
|
@@ -990,7 +990,8 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp)
|
|
return;
|
|
}
|
|
|
|
- port->bh = qemu_bh_new(flush_queued_data_bh, port);
|
|
+ port->bh = qemu_bh_new_guarded(flush_queued_data_bh, port,
|
|
+ &dev->mem_reentrancy_guard);
|
|
port->elem = NULL;
|
|
}
|
|
|
|
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
|
|
index bcd9e8716a..0f663b9912 100644
|
|
--- a/hw/display/qxl.c
|
|
+++ b/hw/display/qxl.c
|
|
@@ -2206,11 +2206,14 @@ static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
|
|
|
|
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
|
|
|
|
- qxl->update_irq = qemu_bh_new(qxl_update_irq_bh, qxl);
|
|
+ qxl->update_irq = qemu_bh_new_guarded(qxl_update_irq_bh, qxl,
|
|
+ &DEVICE(qxl)->mem_reentrancy_guard);
|
|
qxl_reset_state(qxl);
|
|
|
|
- qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);
|
|
- qxl->ssd.cursor_bh = qemu_bh_new(qemu_spice_cursor_refresh_bh, &qxl->ssd);
|
|
+ qxl->update_area_bh = qemu_bh_new_guarded(qxl_render_update_area_bh, qxl,
|
|
+ &DEVICE(qxl)->mem_reentrancy_guard);
|
|
+ qxl->ssd.cursor_bh = qemu_bh_new_guarded(qemu_spice_cursor_refresh_bh, &qxl->ssd,
|
|
+ &DEVICE(qxl)->mem_reentrancy_guard);
|
|
}
|
|
|
|
static void qxl_realize_primary(PCIDevice *dev, Error **errp)
|
|
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
|
|
index 9ccc0575e3..897042c3dc 100644
|
|
--- a/hw/display/virtio-gpu.c
|
|
+++ b/hw/display/virtio-gpu.c
|
|
@@ -1335,8 +1335,10 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
|
|
|
|
g->ctrl_vq = virtio_get_queue(vdev, 0);
|
|
g->cursor_vq = virtio_get_queue(vdev, 1);
|
|
- g->ctrl_bh = qemu_bh_new(virtio_gpu_ctrl_bh, g);
|
|
- g->cursor_bh = qemu_bh_new(virtio_gpu_cursor_bh, g);
|
|
+ g->ctrl_bh = qemu_bh_new_guarded(virtio_gpu_ctrl_bh, g,
|
|
+ &qdev->mem_reentrancy_guard);
|
|
+ g->cursor_bh = qemu_bh_new_guarded(virtio_gpu_cursor_bh, g,
|
|
+ &qdev->mem_reentrancy_guard);
|
|
QTAILQ_INIT(&g->reslist);
|
|
QTAILQ_INIT(&g->cmdq);
|
|
QTAILQ_INIT(&g->fenceq);
|
|
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
|
|
index 1e482738de..36d050aafc 100644
|
|
--- a/hw/ide/ahci.c
|
|
+++ b/hw/ide/ahci.c
|
|
@@ -1510,7 +1510,8 @@ static void ahci_cmd_done(const IDEDMA *dma)
|
|
ahci_write_fis_d2h(ad);
|
|
|
|
if (ad->port_regs.cmd_issue && !ad->check_bh) {
|
|
- ad->check_bh = qemu_bh_new(ahci_check_cmd_bh, ad);
|
|
+ ad->check_bh = qemu_bh_new_guarded(ahci_check_cmd_bh, ad,
|
|
+ &ad->mem_reentrancy_guard);
|
|
qemu_bh_schedule(ad->check_bh);
|
|
}
|
|
}
|
|
diff --git a/hw/ide/ahci_internal.h b/hw/ide/ahci_internal.h
|
|
index 109de9e2d1..a7768dd69e 100644
|
|
--- a/hw/ide/ahci_internal.h
|
|
+++ b/hw/ide/ahci_internal.h
|
|
@@ -321,6 +321,7 @@ struct AHCIDevice {
|
|
bool init_d2h_sent;
|
|
AHCICmdHdr *cur_cmd;
|
|
NCQTransferState ncq_tfs[AHCI_MAX_CMDS];
|
|
+ MemReentrancyGuard mem_reentrancy_guard;
|
|
};
|
|
|
|
struct AHCIPCIState {
|
|
diff --git a/hw/ide/core.c b/hw/ide/core.c
|
|
index 0d925c5ca5..14283a84a5 100644
|
|
--- a/hw/ide/core.c
|
|
+++ b/hw/ide/core.c
|
|
@@ -510,6 +510,7 @@ BlockAIOCB *ide_issue_trim(
|
|
BlockCompletionFunc *cb, void *cb_opaque, void *opaque)
|
|
{
|
|
IDEState *s = opaque;
|
|
+ IDEDevice *dev = s->unit ? s->bus->slave : s->bus->master;
|
|
TrimAIOCB *iocb;
|
|
|
|
/* Paired with a decrement in ide_trim_bh_cb() */
|
|
@@ -517,7 +518,8 @@ BlockAIOCB *ide_issue_trim(
|
|
|
|
iocb = blk_aio_get(&trim_aiocb_info, s->blk, cb, cb_opaque);
|
|
iocb->s = s;
|
|
- iocb->bh = qemu_bh_new(ide_trim_bh_cb, iocb);
|
|
+ iocb->bh = qemu_bh_new_guarded(ide_trim_bh_cb, iocb,
|
|
+ &DEVICE(dev)->mem_reentrancy_guard);
|
|
iocb->ret = 0;
|
|
iocb->qiov = qiov;
|
|
iocb->i = -1;
|
|
diff --git a/hw/misc/imx_rngc.c b/hw/misc/imx_rngc.c
|
|
index 632c03779c..082c6980ad 100644
|
|
--- a/hw/misc/imx_rngc.c
|
|
+++ b/hw/misc/imx_rngc.c
|
|
@@ -228,8 +228,10 @@ static void imx_rngc_realize(DeviceState *dev, Error **errp)
|
|
sysbus_init_mmio(sbd, &s->iomem);
|
|
|
|
sysbus_init_irq(sbd, &s->irq);
|
|
- s->self_test_bh = qemu_bh_new(imx_rngc_self_test, s);
|
|
- s->seed_bh = qemu_bh_new(imx_rngc_seed, s);
|
|
+ s->self_test_bh = qemu_bh_new_guarded(imx_rngc_self_test, s,
|
|
+ &dev->mem_reentrancy_guard);
|
|
+ s->seed_bh = qemu_bh_new_guarded(imx_rngc_seed, s,
|
|
+ &dev->mem_reentrancy_guard);
|
|
}
|
|
|
|
static void imx_rngc_reset(DeviceState *dev)
|
|
diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c
|
|
index efcc02609f..cc7e02203d 100644
|
|
--- a/hw/misc/macio/mac_dbdma.c
|
|
+++ b/hw/misc/macio/mac_dbdma.c
|
|
@@ -914,7 +914,7 @@ static void mac_dbdma_realize(DeviceState *dev, Error **errp)
|
|
{
|
|
DBDMAState *s = MAC_DBDMA(dev);
|
|
|
|
- s->bh = qemu_bh_new(DBDMA_run_bh, s);
|
|
+ s->bh = qemu_bh_new_guarded(DBDMA_run_bh, s, &dev->mem_reentrancy_guard);
|
|
}
|
|
|
|
static void mac_dbdma_class_init(ObjectClass *oc, void *data)
|
|
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
|
|
index cdf1313053..f3fb9393b3 100644
|
|
--- a/hw/net/virtio-net.c
|
|
+++ b/hw/net/virtio-net.c
|
|
@@ -2812,7 +2812,8 @@ static void virtio_net_add_queue(VirtIONet *n, int index)
|
|
n->vqs[index].tx_vq =
|
|
virtio_add_queue(vdev, n->net_conf.tx_queue_size,
|
|
virtio_net_handle_tx_bh);
|
|
- n->vqs[index].tx_bh = qemu_bh_new(virtio_net_tx_bh, &n->vqs[index]);
|
|
+ n->vqs[index].tx_bh = qemu_bh_new_guarded(virtio_net_tx_bh, &n->vqs[index],
|
|
+ &DEVICE(vdev)->mem_reentrancy_guard);
|
|
}
|
|
|
|
n->vqs[index].tx_waiting = 0;
|
|
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
|
|
index 5181b0c0b0..8487138cb6 100644
|
|
--- a/hw/scsi/mptsas.c
|
|
+++ b/hw/scsi/mptsas.c
|
|
@@ -1321,7 +1321,8 @@ static void mptsas_scsi_realize(PCIDevice *dev, Error **errp)
|
|
}
|
|
s->max_devices = MPTSAS_NUM_PORTS;
|
|
|
|
- s->request_bh = qemu_bh_new(mptsas_fetch_requests, s);
|
|
+ s->request_bh = qemu_bh_new_guarded(mptsas_fetch_requests, s,
|
|
+ &DEVICE(dev)->mem_reentrancy_guard);
|
|
|
|
scsi_bus_init(&s->bus, sizeof(s->bus), &dev->qdev, &mptsas_scsi_info);
|
|
}
|
|
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
|
|
index 2b613ad2b3..89c4693cc2 100644
|
|
--- a/hw/scsi/scsi-bus.c
|
|
+++ b/hw/scsi/scsi-bus.c
|
|
@@ -199,7 +199,8 @@ static void scsi_dma_restart_cb(void *opaque, bool running, RunState state)
|
|
AioContext *ctx = blk_get_aio_context(s->conf.blk);
|
|
/* The reference is dropped in scsi_dma_restart_bh.*/
|
|
object_ref(OBJECT(s));
|
|
- s->bh = aio_bh_new(ctx, scsi_dma_restart_bh, s);
|
|
+ s->bh = aio_bh_new_guarded(ctx, scsi_dma_restart_bh, s,
|
|
+ &DEVICE(s)->mem_reentrancy_guard);
|
|
qemu_bh_schedule(s->bh);
|
|
}
|
|
}
|
|
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
|
|
index 4d9969f3b1..d5c6293a21 100644
|
|
--- a/hw/scsi/vmw_pvscsi.c
|
|
+++ b/hw/scsi/vmw_pvscsi.c
|
|
@@ -1184,7 +1184,8 @@ pvscsi_realizefn(PCIDevice *pci_dev, Error **errp)
|
|
pcie_endpoint_cap_init(pci_dev, PVSCSI_EXP_EP_OFFSET);
|
|
}
|
|
|
|
- s->completion_worker = qemu_bh_new(pvscsi_process_completion_queue, s);
|
|
+ s->completion_worker = qemu_bh_new_guarded(pvscsi_process_completion_queue, s,
|
|
+ &DEVICE(pci_dev)->mem_reentrancy_guard);
|
|
|
|
scsi_bus_init(&s->bus, sizeof(s->bus), DEVICE(pci_dev), &pvscsi_scsi_info);
|
|
/* override default SCSI bus hotplug-handler, with pvscsi's one */
|
|
diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
|
|
index c9f295e7e4..67bcfac626 100644
|
|
--- a/hw/usb/dev-uas.c
|
|
+++ b/hw/usb/dev-uas.c
|
|
@@ -936,7 +936,8 @@ static void usb_uas_realize(USBDevice *dev, Error **errp)
|
|
|
|
QTAILQ_INIT(&uas->results);
|
|
QTAILQ_INIT(&uas->requests);
|
|
- uas->status_bh = qemu_bh_new(usb_uas_send_status_bh, uas);
|
|
+ uas->status_bh = qemu_bh_new_guarded(usb_uas_send_status_bh, uas,
|
|
+ &d->mem_reentrancy_guard);
|
|
|
|
dev->flags |= (1 << USB_DEV_FLAG_IS_SCSI_STORAGE);
|
|
scsi_bus_init(&uas->bus, sizeof(uas->bus), DEVICE(dev), &usb_uas_scsi_info);
|
|
diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
|
|
index 8755e9cbb0..a0c4e782b2 100644
|
|
--- a/hw/usb/hcd-dwc2.c
|
|
+++ b/hw/usb/hcd-dwc2.c
|
|
@@ -1364,7 +1364,8 @@ static void dwc2_realize(DeviceState *dev, Error **errp)
|
|
s->fi = USB_FRMINTVL - 1;
|
|
s->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_frame_boundary, s);
|
|
s->frame_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_work_timer, s);
|
|
- s->async_bh = qemu_bh_new(dwc2_work_bh, s);
|
|
+ s->async_bh = qemu_bh_new_guarded(dwc2_work_bh, s,
|
|
+ &dev->mem_reentrancy_guard);
|
|
|
|
sysbus_init_irq(sbd, &s->irq);
|
|
}
|
|
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
|
|
index f9aa567f5d..3fbb06e248 100644
|
|
--- a/hw/usb/hcd-ehci.c
|
|
+++ b/hw/usb/hcd-ehci.c
|
|
@@ -2535,7 +2535,8 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
|
|
}
|
|
|
|
s->frame_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ehci_work_timer, s);
|
|
- s->async_bh = qemu_bh_new(ehci_work_bh, s);
|
|
+ s->async_bh = qemu_bh_new_guarded(ehci_work_bh, s,
|
|
+ &dev->mem_reentrancy_guard);
|
|
s->device = dev;
|
|
|
|
s->vmstate = qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s);
|
|
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
|
|
index 693c68f445..00a8de2fba 100644
|
|
--- a/hw/usb/hcd-uhci.c
|
|
+++ b/hw/usb/hcd-uhci.c
|
|
@@ -1236,7 +1236,7 @@ void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
|
|
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
|
|
}
|
|
}
|
|
- s->bh = qemu_bh_new(uhci_bh, s);
|
|
+ s->bh = qemu_bh_new_guarded(uhci_bh, s, &DEVICE(dev)->mem_reentrancy_guard);
|
|
s->frame_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, uhci_frame_timer, s);
|
|
s->num_ports_vmstate = NB_PORTS;
|
|
s->frame_time = NANOSECONDS_PER_SECOND / uhci_frame_timer_freq;
|
|
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
|
|
index 3394b04f50..13e83a3050 100644
|
|
--- a/hw/usb/host-libusb.c
|
|
+++ b/hw/usb/host-libusb.c
|
|
@@ -1178,7 +1178,8 @@ static void usb_host_nodev_bh(void *opaque)
|
|
static void usb_host_nodev(USBHostDevice *s)
|
|
{
|
|
if (!s->bh_nodev) {
|
|
- s->bh_nodev = qemu_bh_new(usb_host_nodev_bh, s);
|
|
+ s->bh_nodev = qemu_bh_new_guarded(usb_host_nodev_bh, s,
|
|
+ &DEVICE(s)->mem_reentrancy_guard);
|
|
}
|
|
qemu_bh_schedule(s->bh_nodev);
|
|
}
|
|
@@ -1776,7 +1777,8 @@ static int usb_host_post_load(void *opaque, int version_id)
|
|
USBHostDevice *dev = opaque;
|
|
|
|
if (!dev->bh_postld) {
|
|
- dev->bh_postld = qemu_bh_new(usb_host_post_load_bh, dev);
|
|
+ dev->bh_postld = qemu_bh_new_guarded(usb_host_post_load_bh, dev,
|
|
+ &DEVICE(dev)->mem_reentrancy_guard);
|
|
}
|
|
qemu_bh_schedule(dev->bh_postld);
|
|
dev->bh_postld_pending = true;
|
|
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
|
|
index 5f0ef9cb3b..59cd3cd7c4 100644
|
|
--- a/hw/usb/redirect.c
|
|
+++ b/hw/usb/redirect.c
|
|
@@ -1437,8 +1437,10 @@ static void usbredir_realize(USBDevice *udev, Error **errp)
|
|
}
|
|
}
|
|
|
|
- dev->chardev_close_bh = qemu_bh_new(usbredir_chardev_close_bh, dev);
|
|
- dev->device_reject_bh = qemu_bh_new(usbredir_device_reject_bh, dev);
|
|
+ dev->chardev_close_bh = qemu_bh_new_guarded(usbredir_chardev_close_bh, dev,
|
|
+ &DEVICE(dev)->mem_reentrancy_guard);
|
|
+ dev->device_reject_bh = qemu_bh_new_guarded(usbredir_device_reject_bh, dev,
|
|
+ &DEVICE(dev)->mem_reentrancy_guard);
|
|
dev->attach_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, usbredir_do_attach, dev);
|
|
|
|
packet_id_queue_init(&dev->cancelled, dev, "cancelled");
|
|
diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c
|
|
index 0f7369e7ed..dec91294ad 100644
|
|
--- a/hw/usb/xen-usb.c
|
|
+++ b/hw/usb/xen-usb.c
|
|
@@ -1021,7 +1021,8 @@ static void usbback_alloc(struct XenLegacyDevice *xendev)
|
|
|
|
QTAILQ_INIT(&usbif->req_free_q);
|
|
QSIMPLEQ_INIT(&usbif->hotplug_q);
|
|
- usbif->bh = qemu_bh_new(usbback_bh, usbif);
|
|
+ usbif->bh = qemu_bh_new_guarded(usbback_bh, usbif,
|
|
+ &DEVICE(xendev)->mem_reentrancy_guard);
|
|
}
|
|
|
|
static int usbback_free(struct XenLegacyDevice *xendev)
|
|
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
|
|
index 9a4f491b54..f503572e27 100644
|
|
--- a/hw/virtio/virtio-balloon.c
|
|
+++ b/hw/virtio/virtio-balloon.c
|
|
@@ -917,8 +917,9 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
|
|
precopy_add_notifier(&s->free_page_hint_notify);
|
|
|
|
object_ref(OBJECT(s->iothread));
|
|
- s->free_page_bh = aio_bh_new(iothread_get_aio_context(s->iothread),
|
|
- virtio_ballloon_get_free_page_hints, s);
|
|
+ s->free_page_bh = aio_bh_new_guarded(iothread_get_aio_context(s->iothread),
|
|
+ virtio_ballloon_get_free_page_hints, s,
|
|
+ &dev->mem_reentrancy_guard);
|
|
}
|
|
|
|
if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_REPORTING)) {
|
|
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
|
|
index 8c2047f4e0..bcca4fb72a 100644
|
|
--- a/hw/virtio/virtio-crypto.c
|
|
+++ b/hw/virtio/virtio-crypto.c
|
|
@@ -829,7 +829,8 @@ static void virtio_crypto_device_realize(DeviceState *dev, Error **errp)
|
|
vcrypto->vqs[i].dataq =
|
|
virtio_add_queue(vdev, 1024, virtio_crypto_handle_dataq_bh);
|
|
vcrypto->vqs[i].dataq_bh =
|
|
- qemu_bh_new(virtio_crypto_dataq_bh, &vcrypto->vqs[i]);
|
|
+ qemu_bh_new_guarded(virtio_crypto_dataq_bh, &vcrypto->vqs[i],
|
|
+ &dev->mem_reentrancy_guard);
|
|
vcrypto->vqs[i].vcrypto = vcrypto;
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|