Skip to content

Commit 05de778

Browse files
committed
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
pc,pci,virtio: bugfixes, improvements vhost-user-rng support. Fixes all over the place. Signed-off-by: Michael S. Tsirkin <[email protected]> # gpg: Signature made Wed 07 Jul 2021 14:29:30 BST # gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469 # gpg: issuer "[email protected]" # gpg: Good signature from "Michael S. Tsirkin <[email protected]>" [full] # gpg: aka "Michael S. Tsirkin <[email protected]>" [full] # Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67 # Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469 * remotes/mst/tags/for_upstream: MAINTAINERS: Add maintainer for vhost-user RNG implementation docs: add slot when adding new PCIe root port acpi/ged: fix reset cause tests: acpi: pc: update expected DSDT blobs acpi: pc: revert back to v5.2 PCI slot enumeration tests: acpi: prepare for changing DSDT tables migration: failover: reset partially_hotplugged virtio-pci: Changed return values for "notify", "device" and "isr" read. virtio-pci: Added check for virtio device in PCI config cbs. virtio-pci: Added check for virtio device presence in mm callbacks. hw/pci-host/q35: Ignore write of reserved PCIEXBAR LENGTH field virtio: Clarify MR transaction optimization virtio: disable ioeventfd for record/replay Signed-off-by: Peter Maydell <[email protected]>
2 parents 53c0123 + e3e0146 commit 05de778

22 files changed

+115
-8
lines changed

MAINTAINERS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,15 @@ F: include/sysemu/rng*.h
19521952
F: backends/rng*.c
19531953
F: tests/qtest/virtio-rng-test.c
19541954

1955+
vhost-user-rng
1956+
M: Mathieu Poirier <[email protected]>
1957+
S: Supported
1958+
F: docs/tools/vhost-user-rng.rst
1959+
F: hw/virtio/vhost-user-rng.c
1960+
F: hw/virtio/vhost-user-rng-pci.c
1961+
F: include/hw/virtio/vhost-user-rng.h
1962+
F: tools/vhost-user-rng/*
1963+
19551964
virtio-crypto
19561965
M: Gonglei <[email protected]>
19571966
S: Supported

docs/pcie_pci_bridge.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ A detailed command line would be:
7070

7171
[qemu-bin + storage options] \
7272
-m 2G \
73-
-device pcie-root-port,bus=pcie.0,id=rp1 \
74-
-device pcie-root-port,bus=pcie.0,id=rp2 \
75-
-device pcie-root-port,bus=pcie.0,id=rp3,bus-reserve=1 \
73+
-device pcie-root-port,bus=pcie.0,id=rp1,slot=1 \
74+
-device pcie-root-port,bus=pcie.0,id=rp2,slot=2 \
75+
-device pcie-root-port,bus=pcie.0,id=rp3,slot=3,bus-reserve=1 \
7676
-device pcie-pci-bridge,id=br1,bus=rp1 \
7777
-device pcie-pci-bridge,id=br2,bus=rp2 \
7878
-device e1000,bus=br1,addr=8

hw/acpi/generic_event_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void ged_regs_write(void *opaque, hwaddr addr, uint64_t data,
207207
return;
208208
case ACPI_GED_REG_RESET:
209209
if (data == ACPI_GED_RESET_VALUE) {
210-
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
210+
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
211211
}
212212
return;
213213
}

hw/block/dataplane/virtio-blk.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
198198
goto fail_guest_notifiers;
199199
}
200200

201+
/*
202+
* Batch all the host notifiers in a single transaction to avoid
203+
* quadratic time complexity in address_space_update_ioeventfds().
204+
*/
201205
memory_region_transaction_begin();
202206

203207
/* Set up virtqueue notify */
@@ -211,6 +215,10 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
211215
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
212216
}
213217

218+
/*
219+
* The transaction expects the ioeventfds to be open when it
220+
* commits. Do it now, before the cleanup loop.
221+
*/
214222
memory_region_transaction_commit();
215223

216224
while (j--) {
@@ -330,12 +338,20 @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev)
330338

331339
aio_context_release(s->ctx);
332340

341+
/*
342+
* Batch all the host notifiers in a single transaction to avoid
343+
* quadratic time complexity in address_space_update_ioeventfds().
344+
*/
333345
memory_region_transaction_begin();
334346

335347
for (i = 0; i < nvqs; i++) {
336348
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
337349
}
338350

351+
/*
352+
* The transaction expects the ioeventfds to be open when it
353+
* commits. Do it now, before the cleanup loop.
354+
*/
339355
memory_region_transaction_commit();
340356

341357
for (i = 0; i < nvqs; i++) {

hw/i386/acpi-build.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,15 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
435435
aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
436436

437437
if (bsel) {
438-
aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
438+
/*
439+
* Can't declare _SUN here for every device as it changes 'slot'
440+
* enumeration order in linux kernel, so use another variable for it
441+
*/
442+
aml_append(dev, aml_name_decl("ASUN", aml_int(slot)));
439443
method = aml_method("_DSM", 4, AML_SERIALIZED);
440444
aml_append(method, aml_return(
441445
aml_call6("PDSM", aml_arg(0), aml_arg(1), aml_arg(2),
442-
aml_arg(3), aml_name("BSEL"), aml_name("_SUN"))
446+
aml_arg(3), aml_name("BSEL"), aml_name("ASUN"))
443447
));
444448
aml_append(dev, method);
445449
}
@@ -466,6 +470,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
466470
aml_append(method, aml_return(aml_int(s3d)));
467471
aml_append(dev, method);
468472
} else if (hotplug_enabled_dev) {
473+
aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
469474
/* add _EJ0 to make slot hotpluggable */
470475
method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
471476
aml_append(method,

hw/net/virtio-net.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3234,6 +3234,7 @@ static bool failover_replug_primary(VirtIONet *n, DeviceState *dev,
32343234
}
32353235
hotplug_handler_plug(hotplug_ctrl, dev, &err);
32363236
}
3237+
pdev->partially_hotplugged = false;
32373238

32383239
out:
32393240
error_propagate(errp, err);

hw/pci-host/q35.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*/
3030

3131
#include "qemu/osdep.h"
32+
#include "qemu/log.h"
3233
#include "hw/i386/pc.h"
3334
#include "hw/pci-host/q35.h"
3435
#include "hw/qdev-properties.h"
@@ -318,6 +319,8 @@ static void mch_update_pciexbar(MCHPCIState *mch)
318319
addr_mask |= MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK;
319320
break;
320321
case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_RVD:
322+
qemu_log_mask(LOG_GUEST_ERROR, "Q35: Reserved PCIEXBAR LENGTH\n");
323+
return;
321324
default:
322325
abort();
323326
}

hw/s390x/virtio-ccw.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "trace.h"
3232
#include "hw/s390x/css-bridge.h"
3333
#include "hw/s390x/s390-virtio-ccw.h"
34+
#include "sysemu/replay.h"
3435

3536
#define NR_CLASSIC_INDICATOR_BITS 64
3637

@@ -770,6 +771,11 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp)
770771
dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD;
771772
}
772773

774+
/* fd-based ioevents can't be synchronized in record/replay */
775+
if (replay_mode != REPLAY_MODE_NONE) {
776+
dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD;
777+
}
778+
773779
if (k->realize) {
774780
k->realize(dev, &err);
775781
if (err) {

hw/scsi/virtio-scsi-dataplane.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
152152
goto fail_guest_notifiers;
153153
}
154154

155+
/*
156+
* Batch all the host notifiers in a single transaction to avoid
157+
* quadratic time complexity in address_space_update_ioeventfds().
158+
*/
155159
memory_region_transaction_begin();
156160

157161
rc = virtio_scsi_set_host_notifier(s, vs->ctrl_vq, 0);
@@ -198,6 +202,10 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
198202
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
199203
}
200204

205+
/*
206+
* The transaction expects the ioeventfds to be open when it
207+
* commits. Do it now, before the cleanup loop.
208+
*/
201209
memory_region_transaction_commit();
202210

203211
for (i = 0; i < vq_init_count; i++) {
@@ -238,12 +246,20 @@ void virtio_scsi_dataplane_stop(VirtIODevice *vdev)
238246

239247
blk_drain_all(); /* ensure there are no in-flight requests */
240248

249+
/*
250+
* Batch all the host notifiers in a single transaction to avoid
251+
* quadratic time complexity in address_space_update_ioeventfds().
252+
*/
241253
memory_region_transaction_begin();
242254

243255
for (i = 0; i < vs->conf.num_queues + 2; i++) {
244256
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
245257
}
246258

259+
/*
260+
* The transaction expects the ioeventfds to be open when it
261+
* commits. Do it now, before the cleanup loop.
262+
*/
247263
memory_region_transaction_commit();
248264

249265
for (i = 0; i < vs->conf.num_queues + 2; i++) {

hw/virtio/virtio-mmio.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "qemu/host-utils.h"
3030
#include "qemu/module.h"
3131
#include "sysemu/kvm.h"
32+
#include "sysemu/replay.h"
3233
#include "hw/virtio/virtio-mmio.h"
3334
#include "qemu/error-report.h"
3435
#include "qemu/log.h"
@@ -740,6 +741,11 @@ static void virtio_mmio_realizefn(DeviceState *d, Error **errp)
740741
proxy->flags &= ~VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD;
741742
}
742743

744+
/* fd-based ioevents can't be synchronized in record/replay */
745+
if (replay_mode != REPLAY_MODE_NONE) {
746+
proxy->flags &= ~VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD;
747+
}
748+
743749
if (proxy->legacy) {
744750
memory_region_init_io(&proxy->iomem, OBJECT(d),
745751
&virtio_legacy_mem_ops, proxy,

hw/virtio/virtio-pci.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "qemu/range.h"
3838
#include "hw/virtio/virtio-bus.h"
3939
#include "qapi/visitor.h"
40+
#include "sysemu/replay.h"
4041

4142
#define VIRTIO_PCI_REGION_SIZE(dev) VIRTIO_PCI_CONFIG_OFF(msix_present(dev))
4243

@@ -423,6 +424,11 @@ static uint64_t virtio_pci_config_read(void *opaque, hwaddr addr,
423424
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
424425
uint32_t config = VIRTIO_PCI_CONFIG_SIZE(&proxy->pci_dev);
425426
uint64_t val = 0;
427+
428+
if (vdev == NULL) {
429+
return UINT64_MAX;
430+
}
431+
426432
if (addr < config) {
427433
return virtio_ioport_read(proxy, addr);
428434
}
@@ -454,6 +460,11 @@ static void virtio_pci_config_write(void *opaque, hwaddr addr,
454460
VirtIOPCIProxy *proxy = opaque;
455461
uint32_t config = VIRTIO_PCI_CONFIG_SIZE(&proxy->pci_dev);
456462
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
463+
464+
if (vdev == NULL) {
465+
return;
466+
}
467+
457468
if (addr < config) {
458469
virtio_ioport_write(proxy, addr, val);
459470
return;
@@ -1146,6 +1157,10 @@ static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr,
11461157
uint32_t val = 0;
11471158
int i;
11481159

1160+
if (vdev == NULL) {
1161+
return UINT64_MAX;
1162+
}
1163+
11491164
switch (addr) {
11501165
case VIRTIO_PCI_COMMON_DFSELECT:
11511166
val = proxy->dfselect;
@@ -1229,6 +1244,10 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,
12291244
VirtIOPCIProxy *proxy = opaque;
12301245
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
12311246

1247+
if (vdev == NULL) {
1248+
return;
1249+
}
1250+
12321251
switch (addr) {
12331252
case VIRTIO_PCI_COMMON_DFSELECT:
12341253
proxy->dfselect = val;
@@ -1330,6 +1349,11 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,
13301349
static uint64_t virtio_pci_notify_read(void *opaque, hwaddr addr,
13311350
unsigned size)
13321351
{
1352+
VirtIOPCIProxy *proxy = opaque;
1353+
if (virtio_bus_get_device(&proxy->bus) == NULL) {
1354+
return UINT64_MAX;
1355+
}
1356+
13331357
return 0;
13341358
}
13351359

@@ -1367,7 +1391,7 @@ static uint64_t virtio_pci_isr_read(void *opaque, hwaddr addr,
13671391
uint64_t val;
13681392

13691393
if (vdev == NULL) {
1370-
return 0;
1394+
return UINT64_MAX;
13711395
}
13721396

13731397
val = qatomic_xchg(&vdev->isr, 0);
@@ -1388,7 +1412,7 @@ static uint64_t virtio_pci_device_read(void *opaque, hwaddr addr,
13881412
uint64_t val;
13891413

13901414
if (vdev == NULL) {
1391-
return 0;
1415+
return UINT64_MAX;
13921416
}
13931417

13941418
switch (size) {
@@ -1760,6 +1784,11 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
17601784
proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD;
17611785
}
17621786

1787+
/* fd-based ioevents can't be synchronized in record/replay */
1788+
if (replay_mode != REPLAY_MODE_NONE) {
1789+
proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD;
1790+
}
1791+
17631792
/*
17641793
* virtio pci bar layout used by default.
17651794
* subclasses can re-arrange things if needed.

hw/virtio/virtio.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,6 +3728,10 @@ static int virtio_device_start_ioeventfd_impl(VirtIODevice *vdev)
37283728
VirtioBusState *qbus = VIRTIO_BUS(qdev_get_parent_bus(DEVICE(vdev)));
37293729
int i, n, r, err;
37303730

3731+
/*
3732+
* Batch all the host notifiers in a single transaction to avoid
3733+
* quadratic time complexity in address_space_update_ioeventfds().
3734+
*/
37313735
memory_region_transaction_begin();
37323736
for (n = 0; n < VIRTIO_QUEUE_MAX; n++) {
37333737
VirtQueue *vq = &vdev->vq[n];
@@ -3766,6 +3770,10 @@ static int virtio_device_start_ioeventfd_impl(VirtIODevice *vdev)
37663770
r = virtio_bus_set_host_notifier(qbus, n, false);
37673771
assert(r >= 0);
37683772
}
3773+
/*
3774+
* The transaction expects the ioeventfds to be open when it
3775+
* commits. Do it now, before the cleanup loop.
3776+
*/
37693777
memory_region_transaction_commit();
37703778

37713779
while (--i >= 0) {
@@ -3790,6 +3798,10 @@ static void virtio_device_stop_ioeventfd_impl(VirtIODevice *vdev)
37903798
VirtioBusState *qbus = VIRTIO_BUS(qdev_get_parent_bus(DEVICE(vdev)));
37913799
int n, r;
37923800

3801+
/*
3802+
* Batch all the host notifiers in a single transaction to avoid
3803+
* quadratic time complexity in address_space_update_ioeventfds().
3804+
*/
37933805
memory_region_transaction_begin();
37943806
for (n = 0; n < VIRTIO_QUEUE_MAX; n++) {
37953807
VirtQueue *vq = &vdev->vq[n];
@@ -3801,6 +3813,10 @@ static void virtio_device_stop_ioeventfd_impl(VirtIODevice *vdev)
38013813
r = virtio_bus_set_host_notifier(qbus, n, false);
38023814
assert(r >= 0);
38033815
}
3816+
/*
3817+
* The transaction expects the ioeventfds to be open when it
3818+
* commits. Do it now, before the cleanup loop.
3819+
*/
38043820
memory_region_transaction_commit();
38053821

38063822
for (n = 0; n < VIRTIO_QUEUE_MAX; n++) {

tests/data/acpi/pc/DSDT

0 Bytes
Binary file not shown.

tests/data/acpi/pc/DSDT.acpihmat

0 Bytes
Binary file not shown.

tests/data/acpi/pc/DSDT.bridge

0 Bytes
Binary file not shown.

tests/data/acpi/pc/DSDT.cphp

0 Bytes
Binary file not shown.

tests/data/acpi/pc/DSDT.dimmpxm

0 Bytes
Binary file not shown.

tests/data/acpi/pc/DSDT.hpbridge

0 Bytes
Binary file not shown.

tests/data/acpi/pc/DSDT.ipmikcs

0 Bytes
Binary file not shown.

tests/data/acpi/pc/DSDT.memhp

0 Bytes
Binary file not shown.

tests/data/acpi/pc/DSDT.nohpet

0 Bytes
Binary file not shown.

tests/data/acpi/pc/DSDT.numamem

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)