Skip to content

Commit

Permalink
Merge tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst…
Browse files Browse the repository at this point in the history
…/qemu into staging

pc,virtio: fixes

Several bugfixes, they all look very safe to me. Revert
seed support since we aren't any closer to a proper fix.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

# -----BEGIN PGP SIGNATURE-----
#
# iQFDBAABCAAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmL9E54PHG1zdEByZWRo
# YXQuY29tAAoJECgfDbjSjVRp9JkH/RRNaEsspgJZtp5IhdEfr9VU/kfBNBFBUST3
# 1wgclpSNWjafZdYY9443xos6+qTA0j8DQ7sGWp3U761By3/lVvp5u4QNzdd+ov6Z
# Y5M8KG0oeStqaa3Ge8Xa3cwfYPJ2W8nveAMwZgV123Jk+4/BRY14uutb0pywdPc2
# wtjkJapL8HOLFhOkUbbJJcVtN/6Kdhbz8vP7zkYPGPgn7OX0IDIdHVfGyZg0C+gs
# d4nQQDc4xowsOAb0sSuyLi+CrTcMtdHZ6GeN1HloCiSuSVH8U8ED79kf22cU/Y0q
# JOK/L5jAiGspvQ2b6C8k5LEZJ3Pm/sLyEdyusjUhxxF/uE+JrbQ=
# =he3H
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 17 Aug 2022 11:13:18 AM CDT
# gpg:                using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg:                issuer "mst@redhat.com"
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [undefined]
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>" [undefined]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# 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

* tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu:
  virtio-pci: don't touch pci on virtio reset
  tests: acpi: silence applesmc warning about invalid key
  hw/cxl: Correctly handle variable sized mailbox input payloads.
  hw/cxl: Fix Get LSA input payload size which should be 8 bytes.
  hw/cxl: Add stub write function for RO MemoryRegionOps entries.
  x86: disable rng seeding via setup_data
  hw/virtio: fix vhost_user_read tracepoint
  hw/virtio: handle un-configured shutdown in virtio-pci
  hw/virtio: gracefully handle unset vhost_dev vdev
  virtio-scsi: fix race in virtio_scsi_dataplane_start()

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Aug 17, 2022
2 parents c7208a6 + 019d253 commit 73f065d
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 21 deletions.
5 changes: 5 additions & 0 deletions hw/block/dataplane/virtio-blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)

memory_region_transaction_commit();

/*
* These fields are visible to the IOThread so we rely on implicit barriers
* in aio_context_acquire() on the write side and aio_notify_accept() on
* the read side.
*/
s->starting = false;
vblk->dataplane_started = true;
trace_virtio_blk_data_plane_start(s);
Expand Down
12 changes: 9 additions & 3 deletions hw/cxl/cxl-device-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,15 @@ static uint64_t mdev_reg_read(void *opaque, hwaddr offset, unsigned size)
return retval;
}

static void ro_reg_write(void *opaque, hwaddr offset, uint64_t value,
unsigned size)
{
/* Many register sets are read only */
}

static const MemoryRegionOps mdev_ops = {
.read = mdev_reg_read,
.write = NULL, /* memory device register is read only */
.write = ro_reg_write,
.endianness = DEVICE_LITTLE_ENDIAN,
.valid = {
.min_access_size = 1,
Expand Down Expand Up @@ -173,7 +179,7 @@ static const MemoryRegionOps mailbox_ops = {

static const MemoryRegionOps dev_ops = {
.read = dev_reg_read,
.write = NULL, /* status register is read only */
.write = ro_reg_write,
.endianness = DEVICE_LITTLE_ENDIAN,
.valid = {
.min_access_size = 1,
Expand All @@ -188,7 +194,7 @@ static const MemoryRegionOps dev_ops = {

static const MemoryRegionOps caps_ops = {
.read = caps_reg_read,
.write = NULL, /* caps registers are read only */
.write = ro_reg_write,
.endianness = DEVICE_LITTLE_ENDIAN,
.valid = {
.min_access_size = 1,
Expand Down
4 changes: 2 additions & 2 deletions hw/cxl/cxl-mailbox-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ static struct cxl_cmd cxl_cmd_set[256][256] = {
cmd_identify_memory_device, 0, 0 },
[CCLS][GET_PARTITION_INFO] = { "CCLS_GET_PARTITION_INFO",
cmd_ccls_get_partition_info, 0, 0 },
[CCLS][GET_LSA] = { "CCLS_GET_LSA", cmd_ccls_get_lsa, 0, 0 },
[CCLS][GET_LSA] = { "CCLS_GET_LSA", cmd_ccls_get_lsa, 8, 0 },
[CCLS][SET_LSA] = { "CCLS_SET_LSA", cmd_ccls_set_lsa,
~0, IMMEDIATE_CONFIG_CHANGE | IMMEDIATE_DATA_CHANGE },
};
Expand All @@ -425,7 +425,7 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate)
cxl_cmd = &cxl_cmd_set[set][cmd];
h = cxl_cmd->handler;
if (h) {
if (len == cxl_cmd->in) {
if (len == cxl_cmd->in || cxl_cmd->in == ~0) {
cxl_cmd->payload = cxl_dstate->mbox_reg_state +
A_CXL_DEV_CMD_PAYLOAD;
ret = (*h)(cxl_cmd, cxl_dstate, &len);
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/microvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)
rom_set_fw(fw_cfg);

if (machine->kernel_filename != NULL) {
x86_load_linux(x86ms, fw_cfg, 0, true, false);
x86_load_linux(x86ms, fw_cfg, 0, true, true);
}

if (mms->option_roms) {
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/pc_piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ static void pc_i440fx_7_1_machine_options(MachineClass *m)
m->alias = "pc";
m->is_default = true;
pcmc->default_cpu_version = 1;
pcmc->legacy_no_rng_seed = true;
}

DEFINE_I440FX_MACHINE(v7_1, "pc-i440fx-7.1", NULL,
Expand All @@ -450,7 +451,6 @@ static void pc_i440fx_7_0_machine_options(MachineClass *m)
pc_i440fx_7_1_machine_options(m);
m->alias = NULL;
m->is_default = false;
pcmc->legacy_no_rng_seed = true;
pcmc->enforce_amd_1tb_hole = false;
compat_props_add(m->compat_props, hw_compat_7_0, hw_compat_7_0_len);
compat_props_add(m->compat_props, pc_compat_7_0, pc_compat_7_0_len);
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/pc_q35.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ static void pc_q35_7_1_machine_options(MachineClass *m)
pc_q35_machine_options(m);
m->alias = "q35";
pcmc->default_cpu_version = 1;
pcmc->legacy_no_rng_seed = true;
}

DEFINE_Q35_MACHINE(v7_1, "pc-q35-7.1", NULL,
Expand All @@ -386,7 +387,6 @@ static void pc_q35_7_0_machine_options(MachineClass *m)
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_q35_7_1_machine_options(m);
m->alias = NULL;
pcmc->legacy_no_rng_seed = true;
pcmc->enforce_amd_1tb_hole = false;
compat_props_add(m->compat_props, hw_compat_7_0, hw_compat_7_0_len);
compat_props_add(m->compat_props, pc_compat_7_0, pc_compat_7_0_len);
Expand Down
11 changes: 8 additions & 3 deletions hw/scsi/virtio-scsi-dataplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,21 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)

memory_region_transaction_commit();

/*
* These fields are visible to the IOThread so we rely on implicit barriers
* in aio_context_acquire() on the write side and aio_notify_accept() on
* the read side.
*/
s->dataplane_starting = false;
s->dataplane_started = true;

aio_context_acquire(s->ctx);
virtio_queue_aio_attach_host_notifier(vs->ctrl_vq, s->ctx);
virtio_queue_aio_attach_host_notifier_no_poll(vs->event_vq, s->ctx);

for (i = 0; i < vs->conf.num_queues; i++) {
virtio_queue_aio_attach_host_notifier(vs->cmd_vqs[i], s->ctx);
}

s->dataplane_starting = false;
s->dataplane_started = true;
aio_context_release(s->ctx);
return 0;

Expand Down
4 changes: 2 additions & 2 deletions hw/virtio/vhost-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
return -EPROTO;
}

trace_vhost_user_read(msg->hdr.request, msg->hdr.flags);

return 0;
}

Expand Down Expand Up @@ -544,8 +546,6 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base,
}
}

trace_vhost_user_read(msg.hdr.request, msg.hdr.flags);

return 0;
}

Expand Down
10 changes: 7 additions & 3 deletions hw/virtio/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size)
dev->log_size = size;
}

static int vhost_dev_has_iommu(struct vhost_dev *dev)
static bool vhost_dev_has_iommu(struct vhost_dev *dev)
{
VirtIODevice *vdev = dev->vdev;

Expand All @@ -316,8 +316,12 @@ static int vhost_dev_has_iommu(struct vhost_dev *dev)
* does not have IOMMU, there's no need to enable this feature
* which may cause unnecessary IOTLB miss/update transactions.
*/
return virtio_bus_device_iommu_enabled(vdev) &&
virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
if (vdev) {
return virtio_bus_device_iommu_enabled(vdev) &&
virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
} else {
return false;
}
}

static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
Expand Down
19 changes: 15 additions & 4 deletions hw/virtio/virtio-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,14 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)

nvqs = MIN(nvqs, VIRTIO_QUEUE_MAX);

/* When deassigning, pass a consistent nvqs value
* to avoid leaking notifiers.
/*
* When deassigning, pass a consistent nvqs value to avoid leaking
* notifiers. But first check we've actually been configured, exit
* early if we haven't.
*/
if (!assign && !proxy->nvqs_with_notifiers) {
return 0;
}
assert(assign || nvqs == proxy->nvqs_with_notifiers);

proxy->nvqs_with_notifiers = nvqs;
Expand Down Expand Up @@ -1942,7 +1947,6 @@ static void virtio_pci_reset(DeviceState *qdev)
{
VirtIOPCIProxy *proxy = VIRTIO_PCI(qdev);
VirtioBusState *bus = VIRTIO_BUS(&proxy->bus);
PCIDevice *dev = PCI_DEVICE(qdev);
int i;

virtio_bus_reset(bus);
Expand All @@ -1955,6 +1959,13 @@ static void virtio_pci_reset(DeviceState *qdev)
proxy->vqs[i].avail[0] = proxy->vqs[i].avail[1] = 0;
proxy->vqs[i].used[0] = proxy->vqs[i].used[1] = 0;
}
}

static void virtio_pci_bus_reset(DeviceState *qdev)
{
PCIDevice *dev = PCI_DEVICE(qdev);

virtio_pci_reset(qdev);

if (pci_is_express(dev)) {
pcie_cap_deverr_reset(dev);
Expand Down Expand Up @@ -2022,7 +2033,7 @@ static void virtio_pci_class_init(ObjectClass *klass, void *data)
k->class_id = PCI_CLASS_OTHERS;
device_class_set_parent_realize(dc, virtio_pci_dc_realize,
&vpciklass->parent_dc_realize);
dc->reset = virtio_pci_reset;
dc->reset = virtio_pci_bus_reset;
}

static const TypeInfo virtio_pci_info = {
Expand Down
4 changes: 3 additions & 1 deletion tests/qtest/bios-tables-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,9 @@ static void test_acpi_q35_applesmc(void)
.variant = ".applesmc",
};

test_acpi_one("-device isa-applesmc", &data);
/* supply fake 64-byte OSK to silence missing key warning */
test_acpi_one("-device isa-applesmc,osk=any64characterfakeoskisenough"
"topreventinvalidkeywarningsonstderr", &data);
free_test_data(&data);
}

Expand Down

0 comments on commit 73f065d

Please sign in to comment.