Showing with 1,182 additions and 529 deletions.
  1. +1 −1 .gitlab-ci.d/buildtest.yml
  2. +1 −1 VERSION
  3. +1 −1 accel/tcg/cputlb.c
  4. +1 −1 block.c
  5. +9 −1 block/block-backend.c
  6. +3 −3 block/crypto.c
  7. +5 −1 block/export/export.c
  8. +0 −1 block/export/vduse-blk.c
  9. +27 −0 block/graph-lock.c
  10. +6 −4 block/monitor/block-hmp-cmds.c
  11. +3 −3 block/parallels.c
  12. +3 −3 block/qcow.c
  13. +7 −7 block/qcow2.c
  14. +3 −3 block/qed.c
  15. +3 −3 block/vdi.c
  16. +3 −3 block/vhdx.c
  17. +9 −9 block/vmdk.c
  18. +3 −3 block/vpc.c
  19. +16 −6 blockdev.c
  20. +1 −0 configure
  21. +6 −2 docs/about/deprecated.rst
  22. +1 −1 docs/about/emulation.rst
  23. +1 −1 fpu/softfloat.c
  24. +6 −0 hw/9pfs/trace-events
  25. +22 −13 hw/9pfs/xen-9p-backend.c
  26. +10 −0 hw/acpi/pcihp.c
  27. +22 −20 hw/arm/aspeed.c
  28. +8 −27 hw/arm/boot.c
  29. +34 −30 hw/arm/raspi.c
  30. +9 −0 hw/core/machine.c
  31. +2 −5 hw/intc/allwinner-a10-pic.c
  32. +15 −7 hw/net/allwinner-sun8i-emac.c
  33. +5 −6 hw/net/e1000.c
  34. +15 −36 hw/net/e1000e_core.c
  35. +20 −8 hw/net/e1000x_common.c
  36. +3 −2 hw/net/e1000x_common.h
  37. +55 −65 hw/net/igb_core.c
  38. +5 −0 hw/net/igb_regs.h
  39. +11 −7 hw/net/msf2-emac.c
  40. +5 −9 hw/net/net_rx_pkt.c
  41. +6 −4 hw/net/net_rx_pkt.h
  42. +3 −0 hw/net/rtl8139.c
  43. +5 −3 hw/net/virtio-net.c
  44. +6 −1 hw/net/vmxnet3.c
  45. +1 −1 hw/pci-bridge/pci_expander_bridge.c
  46. +2 −0 hw/pci/pci.c
  47. +7 −4 hw/pci/pcie_aer.c
  48. +8 −2 hw/s390x/pv.c
  49. +1 −1 hw/s390x/s390-virtio-ccw.c
  50. +17 −6 hw/scsi/lsi53c895a.c
  51. +9 −5 hw/scsi/scsi-generic.c
  52. +26 −5 hw/sd/allwinner-sdhost.c
  53. +1 −1 hw/timer/imx_epit.c
  54. +2 −0 hw/usb/hcd-ohci.c
  55. +4 −1 hw/virtio/vhost-shadow-virtqueue.c
  56. +3 −0 hw/virtio/vhost-shadow-virtqueue.h
  57. +11 −9 hw/virtio/virtio-crypto.c
  58. +5 −6 hw/virtio/virtio-qmp.c
  59. +7 −2 include/block/block-global-state.h
  60. +49 −0 include/hw/arm/boot.h
  61. +2 −0 include/hw/pci/pci.h
  62. +3 −3 include/hw/s390x/pv.h
  63. +10 −0 include/io/channel.h
  64. +3 −3 include/net/eth.h
  65. +4 −1 include/sysemu/block-backend-global-state.h
  66. +27 −6 io/channel.c
  67. +4 −1 linux-user/mips/cpu_loop.c
  68. +68 −31 linux-user/syscall.c
  69. +6 −0 meson.build
  70. +2 −0 meson_options.txt
  71. +16 −14 migration/migration.c
  72. +1 −2 nbd/server.c
  73. +8 −10 net/eth.c
  74. +14 −0 os-posix.c
  75. +45 −13 qemu-options.hx
  76. +4 −0 scripts/meson-buildoptions.sh
  77. +1 −1 target/arm/gdbstub64.c
  78. +13 −2 target/arm/helper.c
  79. +11 −1 target/arm/internals.h
  80. +2 −0 target/arm/kvm.c
  81. +4 −14 target/arm/kvm64.c
  82. +8 −0 target/arm/kvm_arm.h
  83. +53 −37 target/arm/ptw.c
  84. +3 −3 target/arm/tcg/pauth_helper.c
  85. +6 −0 target/arm/tcg/sve_helper.c
  86. +2 −2 target/arm/tcg/translate.c
  87. +7 −0 target/arm/translate-a32.h
  88. +2 −2 target/i386/cpu.c
  89. +8 −0 target/i386/ops_sse.h
  90. +13 −2 target/i386/tcg/decode-new.c.inc
  91. +1 −1 target/i386/tcg/emit.c.inc
  92. +1 −1 target/ppc/translate/vmx-impl.c.inc
  93. +9 −2 target/riscv/csr.c
  94. +6 −0 target/riscv/insn_trans/trans_privileged.c.inc
  95. +1 −1 target/s390x/tcg/insn-data.h.inc
  96. +58 −23 target/s390x/tcg/translate.c
  97. +1 −1 tcg/i386/tcg-target.c.inc
  98. +1 −1 tests/docker/dockerfiles/debian-xtensa-cross.docker
  99. +33 −0 tests/qtest/fuzz-lsi53c895a-test.c
  100. +4 −1 tests/unit/meson.build
  101. +130 −0 tests/unit/test-nested-aio-poll.c
  102. +2 −2 ui/console.c
  103. +1 −1 ui/vnc.c
  104. +11 −0 util/aio-posix.c
  105. +21 −0 util/async-teardown.c
  106. +14 −0 util/async.c
  107. +5 −3 util/vfio-helpers.c
2 changes: 1 addition & 1 deletion .gitlab-ci.d/buildtest.yml
Expand Up @@ -103,7 +103,7 @@ crash-test-debian:
script:
- cd build
- make check-venv
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-i386
- tests/venv/bin/python3 scripts/device-crash-test ./qemu-system-i386

build-system-fedora:
extends:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
8.0.0
8.0.2
2 changes: 1 addition & 1 deletion accel/tcg/cputlb.c
Expand Up @@ -1830,7 +1830,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
} else /* if (prot & PAGE_READ) */ {
tlb_addr = tlbe->addr_read;
if (!tlb_hit(tlb_addr, addr)) {
if (!VICTIM_TLB_HIT(addr_write, addr)) {
if (!VICTIM_TLB_HIT(addr_read, addr)) {
tlb_fill(env_cpu(env), addr, size,
MMU_DATA_LOAD, mmu_idx, retaddr);
index = tlb_index(env, mmu_idx, addr);
Expand Down
2 changes: 1 addition & 1 deletion block.c
Expand Up @@ -680,7 +680,7 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver *drv,

ret = 0;
out:
blk_unref(blk);
blk_co_unref(blk);
return ret;
}

Expand Down
10 changes: 9 additions & 1 deletion block/block-backend.c
Expand Up @@ -2018,7 +2018,15 @@ void blk_activate(BlockBackend *blk, Error **errp)
return;
}

bdrv_activate(bs, errp);
/*
* Migration code can call this function in coroutine context, so leave
* coroutine context if necessary.
*/
if (qemu_in_coroutine()) {
bdrv_co_activate(bs, errp);
} else {
bdrv_activate(bs, errp);
}
}

bool coroutine_fn blk_co_is_inserted(BlockBackend *blk)
Expand Down
6 changes: 3 additions & 3 deletions block/crypto.c
Expand Up @@ -355,7 +355,7 @@ block_crypto_co_create_generic(BlockDriverState *bs, int64_t size,
ret = 0;
cleanup:
qcrypto_block_free(crypto);
blk_unref(blk);
blk_co_unref(blk);
return ret;
}

Expand Down Expand Up @@ -661,7 +661,7 @@ block_crypto_co_create_luks(BlockdevCreateOptions *create_options, Error **errp)

ret = 0;
fail:
bdrv_unref(bs);
bdrv_co_unref(bs);
return ret;
}

Expand Down Expand Up @@ -730,7 +730,7 @@ block_crypto_co_create_opts_luks(BlockDriver *drv, const char *filename,
bdrv_co_delete_file_noerr(bs);
}

bdrv_unref(bs);
bdrv_co_unref(bs);
qapi_free_QCryptoBlockCreateOptions(create_opts);
qobject_unref(cryptoopts);
return ret;
Expand Down
6 changes: 5 additions & 1 deletion block/export/export.c
Expand Up @@ -192,7 +192,10 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
return exp;

fail:
blk_unref(blk);
if (blk) {
blk_set_dev_ops(blk, NULL, NULL);
blk_unref(blk);
}
aio_context_release(ctx);
if (exp) {
g_free(exp->id);
Expand All @@ -219,6 +222,7 @@ static void blk_exp_delete_bh(void *opaque)
assert(exp->refcount == 0);
QLIST_REMOVE(exp, next);
exp->drv->delete(exp);
blk_set_dev_ops(exp->blk, NULL, NULL);
blk_unref(exp->blk);
qapi_event_send_block_export_deleted(exp->id);
g_free(exp->id);
Expand Down
1 change: 0 additions & 1 deletion block/export/vduse-blk.c
Expand Up @@ -346,7 +346,6 @@ static void vduse_blk_exp_delete(BlockExport *exp)

blk_remove_aio_context_notifier(exp->blk, blk_aio_attached, blk_aio_detach,
vblk_exp);
blk_set_dev_ops(exp->blk, NULL, NULL);
ret = vduse_dev_destroy(vblk_exp->dev);
if (ret != -EBUSY) {
unlink(vblk_exp->recon_file);
Expand Down
27 changes: 27 additions & 0 deletions block/graph-lock.c
Expand Up @@ -30,8 +30,10 @@ BdrvGraphLock graph_lock;
/* Protects the list of aiocontext and orphaned_reader_count */
static QemuMutex aio_context_list_lock;

#if 0
/* Written and read with atomic operations. */
static int has_writer;
#endif

/*
* A reader coroutine could move from an AioContext to another.
Expand Down Expand Up @@ -88,6 +90,7 @@ void unregister_aiocontext(AioContext *ctx)
g_free(ctx->bdrv_graph);
}

#if 0
static uint32_t reader_count(void)
{
BdrvGraphRWlock *brdv_graph;
Expand All @@ -105,10 +108,17 @@ static uint32_t reader_count(void)
assert((int32_t)rd >= 0);
return rd;
}
#endif

void bdrv_graph_wrlock(void)
{
GLOBAL_STATE_CODE();
/*
* TODO Some callers hold an AioContext lock when this is called, which
* causes deadlocks. Reenable once the AioContext locking is cleaned up (or
* AioContext locks are gone).
*/
#if 0
assert(!qatomic_read(&has_writer));

/* Make sure that constantly arriving new I/O doesn't cause starvation */
Expand Down Expand Up @@ -139,11 +149,13 @@ void bdrv_graph_wrlock(void)
} while (reader_count() >= 1);

bdrv_drain_all_end();
#endif
}

void bdrv_graph_wrunlock(void)
{
GLOBAL_STATE_CODE();
#if 0
QEMU_LOCK_GUARD(&aio_context_list_lock);
assert(qatomic_read(&has_writer));

Expand All @@ -155,10 +167,13 @@ void bdrv_graph_wrunlock(void)

/* Wake up all coroutine that are waiting to read the graph */
qemu_co_enter_all(&reader_queue, &aio_context_list_lock);
#endif
}

void coroutine_fn bdrv_graph_co_rdlock(void)
{
/* TODO Reenable when wrlock is reenabled */
#if 0
BdrvGraphRWlock *bdrv_graph;
bdrv_graph = qemu_get_current_aio_context()->bdrv_graph;

Expand Down Expand Up @@ -223,10 +238,12 @@ void coroutine_fn bdrv_graph_co_rdlock(void)
qemu_co_queue_wait(&reader_queue, &aio_context_list_lock);
}
}
#endif
}

void coroutine_fn bdrv_graph_co_rdunlock(void)
{
#if 0
BdrvGraphRWlock *bdrv_graph;
bdrv_graph = qemu_get_current_aio_context()->bdrv_graph;

Expand All @@ -249,6 +266,7 @@ void coroutine_fn bdrv_graph_co_rdunlock(void)
if (qatomic_read(&has_writer)) {
aio_wait_kick();
}
#endif
}

void bdrv_graph_rdlock_main_loop(void)
Expand All @@ -265,11 +283,20 @@ void bdrv_graph_rdunlock_main_loop(void)

void assert_bdrv_graph_readable(void)
{
/* reader_count() is slow due to aio_context_list_lock lock contention */
/* TODO Reenable when wrlock is reenabled */
#if 0
#ifdef CONFIG_DEBUG_GRAPH_LOCK
assert(qemu_in_main_thread() || reader_count());
#endif
#endif
}

void assert_bdrv_graph_writable(void)
{
assert(qemu_in_main_thread());
/* TODO Reenable when wrlock is reenabled */
#if 0
assert(qatomic_read(&has_writer));
#endif
}
10 changes: 6 additions & 4 deletions block/monitor/block-hmp-cmds.c
Expand Up @@ -214,15 +214,17 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
error_report("Device '%s' not found", device);
return;
}
if (!blk_is_available(blk)) {
error_report("Device '%s' has no medium", device);
return;
}

bs = bdrv_skip_implicit_filters(blk_bs(blk));
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);

if (!blk_is_available(blk)) {
error_report("Device '%s' has no medium", device);
aio_context_release(aio_context);
return;
}

ret = bdrv_commit(bs);

aio_context_release(aio_context);
Expand Down
6 changes: 3 additions & 3 deletions block/parallels.c
Expand Up @@ -613,8 +613,8 @@ static int coroutine_fn parallels_co_create(BlockdevCreateOptions* opts,

ret = 0;
out:
blk_unref(blk);
bdrv_unref(bs);
blk_co_unref(blk);
bdrv_co_unref(bs);
return ret;

exit:
Expand Down Expand Up @@ -691,7 +691,7 @@ parallels_co_create_opts(BlockDriver *drv, const char *filename,

done:
qobject_unref(qdict);
bdrv_unref(bs);
bdrv_co_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
}
Expand Down
6 changes: 3 additions & 3 deletions block/qcow.c
Expand Up @@ -915,8 +915,8 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
g_free(tmp);
ret = 0;
exit:
blk_unref(qcow_blk);
bdrv_unref(bs);
blk_co_unref(qcow_blk);
bdrv_co_unref(bs);
qcrypto_block_free(crypto);
return ret;
}
Expand Down Expand Up @@ -1015,7 +1015,7 @@ qcow_co_create_opts(BlockDriver *drv, const char *filename,
fail:
g_free(backing_fmt);
qobject_unref(qdict);
bdrv_unref(bs);
bdrv_co_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
}
Expand Down
14 changes: 7 additions & 7 deletions block/qcow2.c
Expand Up @@ -3705,7 +3705,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
goto out;
}

blk_unref(blk);
blk_co_unref(blk);
blk = NULL;

/*
Expand Down Expand Up @@ -3785,7 +3785,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
}
}

blk_unref(blk);
blk_co_unref(blk);
blk = NULL;

/* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning.
Expand All @@ -3810,9 +3810,9 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)

ret = 0;
out:
blk_unref(blk);
bdrv_unref(bs);
bdrv_unref(data_bs);
blk_co_unref(blk);
bdrv_co_unref(bs);
bdrv_co_unref(data_bs);
return ret;
}

Expand Down Expand Up @@ -3943,8 +3943,8 @@ qcow2_co_create_opts(BlockDriver *drv, const char *filename, QemuOpts *opts,
}

qobject_unref(qdict);
bdrv_unref(bs);
bdrv_unref(data_bs);
bdrv_co_unref(bs);
bdrv_co_unref(data_bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
}
Expand Down
6 changes: 3 additions & 3 deletions block/qed.c
Expand Up @@ -748,8 +748,8 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts,
ret = 0; /* success */
out:
g_free(l1_table);
blk_unref(blk);
bdrv_unref(bs);
blk_co_unref(blk);
bdrv_co_unref(bs);
return ret;
}

Expand Down Expand Up @@ -819,7 +819,7 @@ bdrv_qed_co_create_opts(BlockDriver *drv, const char *filename,

fail:
qobject_unref(qdict);
bdrv_unref(bs);
bdrv_co_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
}
Expand Down
6 changes: 3 additions & 3 deletions block/vdi.c
Expand Up @@ -886,8 +886,8 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,

ret = 0;
exit:
blk_unref(blk);
bdrv_unref(bs_file);
blk_co_unref(blk);
bdrv_co_unref(bs_file);
g_free(bmap);
return ret;
}
Expand Down Expand Up @@ -975,7 +975,7 @@ vdi_co_create_opts(BlockDriver *drv, const char *filename,
done:
qobject_unref(qdict);
qapi_free_BlockdevCreateOptions(create_options);
bdrv_unref(bs_file);
bdrv_co_unref(bs_file);
return ret;
}

Expand Down
6 changes: 3 additions & 3 deletions block/vhdx.c
Expand Up @@ -2053,8 +2053,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,

ret = 0;
delete_and_exit:
blk_unref(blk);
bdrv_unref(bs);
blk_co_unref(blk);
bdrv_co_unref(bs);
g_free(creator);
return ret;
}
Expand Down Expand Up @@ -2144,7 +2144,7 @@ vhdx_co_create_opts(BlockDriver *drv, const char *filename,

fail:
qobject_unref(qdict);
bdrv_unref(bs);
bdrv_co_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
}
Expand Down