pc,pci,virtio: bugfixes, improvements
The following changes since commit 609d7596524ab204ccd71ef42c9eee4c7c338ea4:
Update version for v6.0.0 release (2021-04-29 18:05:29 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to f7a6df5f5bf3acc219352a1b25573ae2082d7e42:
Fix build with 64 bits time_t (2021-05-14 10:26:18 -0400)
----------------------------------------------------------------
pc,pci,virtio: bugfixes, improvements
Fixes all over the place. Faster boot for virtio. ioeventfd support for mmio.
----------------------------------------------------------------
Fabrice Fontaine (1):
Fix build with 64 bits time_t
Greg Kurz (5):
virtio-blk: Fix rollback path in virtio_blk_data_plane_start()
virtio-blk: Configure all host notifiers in a single MR transaction
virtio-scsi: Set host notifiers and callbacks separately
virtio-scsi: Configure all host notifiers in a single MR transaction
checkpatch: Fix use of uninitialized value
Igor Mammedov (1):
x86: acpi: use offset instead of pointer when using build_header()
Jean-Philippe Brucker (1):
amd_iommu: Fix pte_override_page_mask()
Maciej S. Szmigiero (1):
pc-dimm: remove unnecessary get_vmstate_memory_region() method
Pavel Dovgalyuk (1):
hw/virtio: enable ioeventfd configuring for mmio
Philippe Mathieu-Daudé (3):
hw/virtio: Pass virtio_feature_get_config_size() a const argument
virtio-blk: Constify VirtIOFeature feature_sizes[]
virtio-net: Constify VirtIOFeature feature_sizes[]Roman Kapl (1):
amd_iommu: fix wrong MMIO operations
Vincent Bernat (1):
hw/smbios: support for type 41 (onboard devices extended information)
Zenghui Yu (1):
vhost-vdpa: Make vhost_vdpa_get_device_id() static
include/hw/firmware/smbios.h | 14 ++++- include/hw/mem/pc-dimm.h | 5 -- include/hw/virtio/vhost-vdpa.h | 2 - include/hw/virtio/virtio-mmio.h | 5 ++ include/hw/virtio/virtio.h | 2 +- contrib/vhost-user-input/main.c | 8 ++- hw/acpi/aml-build.c | 15 +++-- hw/arm/virt.c | 7 ++- hw/block/dataplane/virtio-blk.c | 36 +++++++++++- hw/block/virtio-blk.c | 2 +- hw/i386/acpi-build.c | 8 ++- hw/i386/amd_iommu.c | 10 ++-- hw/i386/fw_cfg.c | 4 +- hw/input/virtio-input-host.c | 5 +- hw/mem/pc-dimm.c | 33 +++++------ hw/net/virtio-net.c | 2 +- hw/scsi/virtio-scsi-dataplane.c | 56 ++++++++++++------ hw/smbios/smbios.c | 124 +++++++++++++++++++++++++++++++++++++++- hw/virtio/vhost-vdpa.c | 4 +- hw/virtio/virtio-mmio.c | 11 +++- hw/virtio/virtio.c | 2 +- qemu-options.hx | 30 +++++++++- scripts/checkpatch.pl | 1 + 23 files changed, 311 insertions(+), 75 deletions(-)
[PULL 08/16] virtio-blk: Fix rollback path in virtio_blk_data_plane_start()
From: Greg Kurz <[email protected]>
When dataplane multiqueue support was added in QEMU 2.7, the path that would rollback guest notifiers assignment in case of error simply got dropped.
Later on, when Error was added to blk_set_aio_context() in QEMU 4.1, another error path was introduced, but it ommits to rollback both host and guest notifiers.
It seems cleaner to fix the rollback path in one go. The patch is simple enough that it can be adjusted if backported to a pre-4.1 QEMU.
Message-Id: <[email protected]>
--- hw/block/dataplane/virtio-blk.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
hw/block/dataplane/virtio-blk.c +9 -2
@@ -207,7 +207,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false);virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i); } - goto fail_guest_notifiers; + goto fail_host_notifiers; } }
@@ -221,7 +221,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)aio_context_release (old_context);if (r <0 ) {error_report_err (local_err); - goto fail_guest_notifiers; + goto fail_aio_context; }/* Process queued requests before the ones in vring */
@@ -245,6 +245,13 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)aio_context_release (s->ctx);return 0 ; + fail_aio_context: +for (i =0 ; i < nvqs; i++) { +virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false); +virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i); + } + fail_host_notifiers: + k->set_guest_notifiers (qbus->parent, nvqs, false); fail_guest_notifiers:/* * If we failed to set up the guest notifiers queued requests will be
Signature · 1 line
MST
[PULL 01/16] amd_iommu: Fix pte_override_page_mask()
In reply to Michael S. TsirkinFrom: Jean-Philippe Brucker <[email protected]>
AMD IOMMU PTEs have a special mode allowing to specify an arbitrary page size. Quoting the AMD IOMMU specification: "When the Next Level bits [of a pte] are 7h, the size of the page is determined by the first zero bit in the page address, starting from bit 12."
So if the lowest bits of the page address is 0, the page is 8kB. If the lowest bits are 011, the page is 32kB. Currently pte_override_page_mask() doesn't compute the right value for this page size and amdvi_translate() can return the wrong guest-physical address. With a Linux guest, DMA from SATA devices accesses the wrong memory and causes probe failure:
qemu-system-x86_64 ... -device amd-iommu -drive id=hd1,file=foo.bin,if=none \
-device ahci,id=ahci -device ide-hd,drive=hd1,bus=ahci.0
[ 6.613093] ata1.00: qc timeout (cmd 0xec) [ 6.615062] ata1.00: failed to IDENTIFY (I/O error, err_mask=0x4)
Fix the page mask.
Message-Id: <[email protected]>
--- hw/i386/amd_iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/i386/amd_iommu.c +2 -2
@@ -860,8 +860,8 @@ static inline uint8_t get_pte_translation_mode(uint64_t pte)static inline uint64_t pte_override_page_mask (uint64_t pte) { -uint8_t page_mask =12 ; -uint64_t addr = (pte &AMDVI_DEV_PT_ROOT_MASK ) ^AMDVI_DEV_PT_ROOT_MASK ; +uint8_t page_mask =13 ; +uint64_t addr = (pte &AMDVI_DEV_PT_ROOT_MASK ) >>12 ;/* find the first zero bit */ while (addr &1 ) { page_mask++;
Signature · 1 line
MST
[PULL 10/16] virtio-scsi: Set host notifiers and callbacks separately
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
Host notifiers are guaranteed to be idle until the callbacks are hooked up with virtio_queue_aio_set_host_notifier_handler(). They thus don't need to be set or unset with the AioContext lock held.
Do this outside the critical section, like virtio-blk already does : basically downgrading virtio_scsi_vring_init() to only setup the host notifier and set the callback in the caller.
This will allow to batch addition/deletion of ioeventds in a single memory transaction, which is expected to greatly improve initialization time.
Message-Id: <[email protected]>
--- hw/scsi/virtio-scsi-dataplane.c | 40 ++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-)
hw/scsi/virtio-scsi-dataplane.c +22 -18
@@ -94,8 +94,7 @@ static bool virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,return progress; } -static int virtio_scsi_vring_init (VirtIOSCSI *s,VirtQueue *vq,int n, -VirtIOHandleAIOOutput fn) +static int virtio_scsi_set_host_notifier (VirtIOSCSI *s,VirtQueue *vq,int n) {BusState *qbus =BUS (qdev_get_parent_bus (DEVICE (s)));int rc;
@@ -109,7 +108,6 @@ static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n,return rc; } -virtio_queue_aio_set_host_notifier_handler (vq, s->ctx, fn);return 0 ; }
@@ -154,38 +152,44 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) goto fail_guest_notifiers; } -aio_context_acquire (s->ctx); - rc =virtio_scsi_vring_init (s, vs->ctrl_vq,0 , - virtio_scsi_data_plane_handle_ctrl); -if (rc) { - goto fail_vrings; + rc =virtio_scsi_set_host_notifier (s, vs->ctrl_vq,0 ); +if (rc !=0 ) { + goto fail_host_notifiers; } vq_init_count++; - rc =virtio_scsi_vring_init (s, vs->event_vq,1 , - virtio_scsi_data_plane_handle_event); -if (rc) { - goto fail_vrings; + rc =virtio_scsi_set_host_notifier (s, vs->event_vq,1 ); +if (rc !=0 ) { + goto fail_host_notifiers; } vq_init_count++; +for (i =0 ; i < vs->conf.num_queues; i++) { - rc =virtio_scsi_vring_init (s, vs->cmd_vqs[i], i +2 , - virtio_scsi_data_plane_handle_cmd); + rc =virtio_scsi_set_host_notifier (s, vs->cmd_vqs[i], i +2 );if (rc) { - goto fail_vrings; + goto fail_host_notifiers; } vq_init_count++; } +aio_context_acquire (s->ctx); +virtio_queue_aio_set_host_notifier_handler (vs->ctrl_vq, s->ctx, + virtio_scsi_data_plane_handle_ctrl); +virtio_queue_aio_set_host_notifier_handler (vs->event_vq, s->ctx, + virtio_scsi_data_plane_handle_event); + +for (i =0 ; i < vs->conf.num_queues; i++) { +virtio_queue_aio_set_host_notifier_handler (vs->cmd_vqs[i], s->ctx, + virtio_scsi_data_plane_handle_cmd); + } + s->dataplane_starting = false; s->dataplane_started = true;aio_context_release (s->ctx);return 0 ; -fail_vrings: -aio_wait_bh_oneshot (s->ctx, virtio_scsi_dataplane_stop_bh, s); -aio_context_release (s->ctx); +fail_host_notifiers:for (i =0 ; i < vq_init_count; i++) {virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false);virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i);
Signature · 1 line
MST
[PULL 14/16] hw/virtio: enable ioeventfd configuring for mmio
In reply to Michael S. TsirkinFrom: Pavel Dovgalyuk <[email protected]>
This patch adds ioeventfd flag for virtio-mmio configuration. It allows switching ioeventfd on and off.
Message-Id: <161700379211.1135943.8859209566937991305.stgit@pasha-ThinkPad-X280>
--- include/hw/virtio/virtio-mmio.h | 5 +++++ hw/virtio/virtio-mmio.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
include/hw/virtio/virtio-mmio.h +5 -0
@@ -49,12 +49,17 @@ typedef struct VirtIOMMIOQueue {uint32_t used[2 ]; } VirtIOMMIOQueue; +#define VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT 1 +#define VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD \ + (1 << VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT) +struct VirtIOMMIOProxy {/* Generic */ SysBusDevice parent_obj;MemoryRegion iomem;qemu_irq irq;bool legacy; +uint32_t flags;/* Guest accessible state needing migration and reset */ uint32_t host_features_sel;uint32_t guest_features_sel;
hw/virtio/virtio-mmio.c +10 -1
@@ -36,7 +36,9 @@static bool virtio_mmio_ioeventfd_enabled (DeviceState *d) { -return kvm_eventfds_enabled (); +VirtIOMMIOProxy *proxy =VIRTIO_MMIO (d); + +return (proxy->flags &VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD ) !=0 ; } static int virtio_mmio_ioeventfd_assign(DeviceState *d,
@@ -720,6 +722,8 @@ static Property virtio_mmio_properties[] = {DEFINE_PROP_BOOL ("format_transport_address" , VirtIOMMIOProxy, format_transport_address, true),DEFINE_PROP_BOOL ("force-legacy" , VirtIOMMIOProxy, legacy, true), +DEFINE_PROP_BIT ("ioeventfd" , VirtIOMMIOProxy, flags, +VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD_BIT , true), DEFINE_PROP_END_OF_LIST(), };
@@ -731,6 +735,11 @@ static void virtio_mmio_realizefn(DeviceState *d, Error **errp)qbus_create_inplace (&proxy->bus,sizeof (proxy->bus),TYPE_VIRTIO_MMIO_BUS , d,NULL );sysbus_init_irq (sbd, &proxy->irq); + +if (!kvm_eventfds_enabled ()) { + proxy->flags &= ~VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD ; + } +if (proxy->legacy) { memory_region_init_io(&proxy->iomem, OBJECT(d), &virtio_legacy_mem_ops, proxy,
Signature · 1 line
MST
[PULL 09/16] virtio-blk: Configure all host notifiers in a single MR transaction
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
This allows the virtio-blk-pci device to batch the setup of all its host notifiers. This significantly improves boot time of VMs with a high number of vCPUs, e.g. from 3m26.186s down to 0m58.023s for a pseries machine with 384 vCPUs.
Note that memory_region_transaction_commit() must be called before virtio_bus_cleanup_host_notifier() because the latter might close ioeventfds that the transaction still assumes to be around when it commits.
Message-Id: <[email protected]>
--- hw/block/dataplane/virtio-blk.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
hw/block/dataplane/virtio-blk.c +25 -0
@@ -198,19 +198,30 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) goto fail_guest_notifiers; } +memory_region_transaction_begin (); +/* Set up virtqueue notify */ for (i =0 ; i < nvqs; i++) { r =virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, true);if (r !=0 ) { +int j = i; +fprintf (stderr,"virtio-blk failed to set host notifier (%d)\n" , r);while (i--) {virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false); + } + +memory_region_transaction_commit (); + +while (j--) {virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i); } goto fail_host_notifiers; } } +memory_region_transaction_commit (); + s->starting = false; vblk->dataplane_started = true;trace_virtio_blk_data_plane_start (s);
@@ -246,8 +257,15 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)return 0 ; fail_aio_context: +memory_region_transaction_begin (); +for (i =0 ; i < nvqs; i++) {virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false); + } + +memory_region_transaction_commit (); + +for (i =0 ; i < nvqs; i++) {virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i); } fail_host_notifiers:
@@ -312,8 +330,15 @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev)aio_context_release (s->ctx); +memory_region_transaction_begin (); +for (i =0 ; i < nvqs; i++) {virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false); + } + +memory_region_transaction_commit (); + +for (i =0 ; i < nvqs; i++) {virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i); }
Signature · 1 line
MST
[PULL 13/16] hw/smbios: support for type 41 (onboard devices extended information)
In reply to Michael S. TsirkinFrom: Vincent Bernat <[email protected]>
Type 41 defines the attributes of devices that are onboard. The original intent was to imply the BIOS had some level of control over the enablement of the associated devices.
If network devices are present in this table, by default, udev will name the corresponding interfaces enoX, X being the instance number. Without such information, udev will fallback to using the PCI ID and this usually gives ens3 or ens4. This can be a bit annoying as the name of the network card may depend on the order of options and may change if a new PCI device is added earlier on the commande line. Being able to provide SMBIOS type 41 entry ensure the name of the interface won't change and helps the user guess the right name without booting a first time.
This can be invoked with:
$QEMU -netdev user,id=internet
-device virtio-net-pci,mac=50:54:00:00:00:42,netdev=internet,id=internet-dev \
-smbios type=41,designation='Onboard LAN',instance=1,kind=ethernet,pcidev=internet-dev
The PCI segment is assumed to be 0. This should hold true for most cases.
$ dmidecode -t 41
# dmidecode 3.3
Getting SMBIOS data from sysfs.
SMBIOS 2.8 present. Handle 0x2900, DMI type 41, 11 bytes
Onboard Device
Reference Designation: Onboard LAN
Type: Ethernet
Status: Enabled
Type Instance: 1
Bus Address: 0000:00:09.0
$ ip -brief a
lo UNKNOWN 127.0.0.1/8 ::1/128
eno1 UP 10.0.2.14/24 fec0::5254:ff:fe00:42/64 fe80::5254:ff:fe00:42/64Message-Id: <[email protected]>
--- include/hw/firmware/smbios.h | 14 +++- hw/arm/virt.c | 7 +- hw/i386/fw_cfg.c | 4 +- hw/smbios/smbios.c | 124 ++++++++++++++++++++++++++++++++++- qemu-options.hx | 30 ++++++++- 5 files changed, 173 insertions(+), 6 deletions(-)
include/hw/firmware/smbios.h +13 -1
@@ -258,6 +258,17 @@ struct smbios_type_32 {uint8_t boot_status; }QEMU_PACKED ; +/* SMBIOS type 41 - Onboard Devices Extended Information */ +struct smbios_type_41 { +struct smbios_structure_header header; +uint8_t reference_designation_str; +uint8_t device_type; +uint8_t device_type_instance; +uint16_t segment_group_number; +uint8_t bus_number; +uint8_t device_number; +}QEMU_PACKED ; +/* SMBIOS type 127 -- End-of-table */ struct smbios_type_127 {struct smbios_structure_header header;
@@ -273,5 +284,6 @@ void smbios_get_tables(MachineState *ms,const struct smbios_phys_mem_area *mem_array, const unsigned int mem_array_size, uint8_t **tables, size_t *tables_len, - uint8_t **anchor, size_t *anchor_len); + uint8_t **anchor, size_t *anchor_len, + Error **errp);#endif /* QEMU_SMBIOS_H */
hw/arm/virt.c +5 -2
@@ -53,6 +53,7 @@#include "sysemu/kvm.h" #include "hw/loader.h" #include "exec/address-spaces.h" +#include "qapi/error.h" #include "qemu/bitops.h" #include "qemu/error-report.h" #include "qemu/module.h"
@@ -1524,8 +1525,10 @@ static void virt_build_smbios(VirtMachineState *vms) vmc->smbios_old_sys_ver ?"1.0" : mc->name, false, true, SMBIOS_ENTRY_POINT_30); -smbios_get_tables (MACHINE (vms),NULL ,0 , &smbios_tables, &smbios_tables_len, - &smbios_anchor, &smbios_anchor_len); +smbios_get_tables (MACHINE (vms),NULL ,0 , + &smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len, + &error_fatal);if (smbios_anchor) { fw_cfg_add_file(vms->fw_cfg, "etc/smbios/smbios-tables",
hw/i386/fw_cfg.c +3 -1
@@ -22,6 +22,7 @@#include "hw/nvram/fw_cfg.h" #include "e820_memory_layout.h" #include "kvm/kvm_i386.h" +#include "qapi/error.h" #include CONFIG_DEVICES struct hpet_fw_config hpet_cfg = {.count =UINT8_MAX };
@@ -78,7 +79,8 @@ void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg) }smbios_get_tables (ms, mem_array, array_count, &smbios_tables, &smbios_tables_len, - &smbios_anchor, &smbios_anchor_len); + &smbios_anchor, &smbios_anchor_len, + &error_fatal);g_free (mem_array);if (smbios_anchor) {
hw/smbios/smbios.c +123 -1
166 lines not on this page · raw message
qemu-options.hx +29 -1
@@ -2370,7 +2370,9 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, " specify SMBIOS type 11 fields\n" "-smbios type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str]\n" " [,asset=str][,part=str][,speed=%d]\n" - " specify SMBIOS type 17 fields\n", + " specify SMBIOS type 17 fields\n" + "-smbios type=41[,designation=str][,kind=str][,instance=%d][,pcidev=str]\n" + " specify SMBIOS type 41 fields\n", QEMU_ARCH_I386 | QEMU_ARCH_ARM) SRST ``-smbios file=binary``
@@ -2432,6 +2434,32 @@ SRST ``-smbios type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str][,asset=str][,part=str][,speed=%d]`` Specify SMBIOS type 17 fields + +``-smbios type=41[,designation=str][,kind=str][,instance=%d][,pcidev=str]`` + Specify SMBIOS type 41 fields + + This argument can be repeated multiple times. Its main use is to allow network interfaces be created + as ``enoX`` on Linux, with X being the instance number, instead of the name depending on the interface + position on the PCI bus. + + Here is an example of use: + + .. parsed-literal:: + + -netdev user,id=internet \\ + -device virtio-net-pci,mac=50:54:00:00:00:42,netdev=internet,id=internet-dev \\ + -smbios type=41,designation='Onboard LAN',instance=1,kind=ethernet,pcidev=internet-dev + + In the guest OS, the device should then appear as ``eno1``: + + ..parsed-literal:: + + $ ip -brief l + lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP> + eno1 UP 50:54:00:00:00:42 <BROADCAST,MULTICAST,UP,LOWER_UP> + + Currently, the PCI device has to be attached to the root bus. + ERST DEFHEADING()
Signature · 1 line
MST
[PULL 15/16] vhost-vdpa: Make vhost_vdpa_get_device_id() static
In reply to Michael S. TsirkinFrom: Zenghui Yu <[email protected]>
As it's only used inside hw/virtio/vhost-vdpa.c.
Message-Id: <[email protected]>
--- include/hw/virtio/vhost-vdpa.h | 2 -- hw/virtio/vhost-vdpa.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-)
include/hw/virtio/vhost-vdpa.h +0 -2
@@ -22,6 +22,4 @@ typedef struct vhost_vdpa { } VhostVDPA;extern AddressSpace address_space_memory; -extern int vhost_vdpa_get_device_id (struct vhost_dev *dev, -uint32_t *device_id);#endif
hw/virtio/vhost-vdpa.c +2 -2
@@ -371,8 +371,8 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev)return 0 ; } -int vhost_vdpa_get_device_id (struct vhost_dev *dev, -uint32_t *device_id) +static int vhost_vdpa_get_device_id (struct vhost_dev *dev, +uint32_t *device_id) {int ret; ret =vhost_vdpa_call (dev,VHOST_VDPA_GET_DEVICE_ID , device_id);
Signature · 1 line
MST
[PULL 04/16] virtio-blk: Constify VirtIOFeature feature_sizes[]
In reply to Michael S. TsirkinFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- hw/block/virtio-blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/virtio-blk.c +1 -1
@@ -40,7 +40,7 @@* Starting from the discard feature, we can use this array to properly * set the config size depending on the features enabled. */ -static VirtIOFeature feature_sizes[] = { +static const VirtIOFeature feature_sizes[] = { {.flags =1ULL <<VIRTIO_BLK_F_DISCARD , .end = endof(struct virtio_blk_config, discard_sector_alignment)}, {.flags =1ULL <<VIRTIO_BLK_F_WRITE_ZEROES ,
Signature · 1 line
MST
[PULL 06/16] amd_iommu: fix wrong MMIO operations
In reply to Michael S. TsirkinFrom: Roman Kapl <[email protected]>
Address was swapped with value when writing MMIO registers, so the user saw garbage in lot of cases. The interrupt status was not correctly set.
Message-Id: <[email protected]>
--- hw/i386/amd_iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/i386/amd_iommu.c +3 -3
@@ -99,7 +99,7 @@ static uint64_t amdvi_readq(AMDVIState *s, hwaddr addr) }/* internal write */ -static void amdvi_writeq_raw (AMDVIState *s,uint64_t val,hwaddr addr) +static void amdvi_writeq_raw (AMDVIState *s,hwaddr addr,uint64_t val) {stq_le_p (&s->mmior[addr], val); }
@@ -382,7 +382,7 @@ static void amdvi_completion_wait(AMDVIState *s, uint64_t *cmd) }/* set completion interrupt */ if (extract64 (cmd[0 ],1 ,1 )) { -amdvi_test_mask (s,AMDVI_MMIO_STATUS ,AMDVI_MMIO_STATUS_COMP_INT ); +amdvi_assign_orq (s,AMDVI_MMIO_STATUS ,AMDVI_MMIO_STATUS_COMP_INT );/* generate interrupt */ amdvi_generate_msi_interrupt (s); }
@@ -553,7 +553,7 @@ static void amdvi_cmdbuf_run(AMDVIState *s)trace_amdvi_command_exec (s->cmdbuf_head, s->cmdbuf_tail, s->cmdbuf);amdvi_cmdbuf_exec (s); s->cmdbuf_head +=AMDVI_COMMAND_SIZE ; -amdvi_writeq_raw (s, s->cmdbuf_head,AMDVI_MMIO_COMMAND_HEAD ); +amdvi_writeq_raw (s,AMDVI_MMIO_COMMAND_HEAD , s->cmdbuf_head);/* wrap head pointer */ if (s->cmdbuf_head >= s->cmdbuf_len *AMDVI_COMMAND_SIZE ) {
Signature · 1 line
MST
[PULL 07/16] pc-dimm: remove unnecessary get_vmstate_memory_region() method
In reply to Michael S. TsirkinFrom: "Maciej S. Szmigiero" <[email protected]>
The get_vmstate_memory_region() method from PCDIMMDeviceClass is only ever called from this class and is never overridden, so it can be converted into an ordinary function.
This saves us from having to do an indirect call in order to reach it.
Message-Id: <f42da25471dc4b967796642388294e61e6587047.1619303649.git.maciej.szmigiero@oracle.com>
--- include/hw/mem/pc-dimm.h | 5 ----- hw/mem/pc-dimm.c | 33 ++++++++++++++------------------- 2 files changed, 14 insertions(+), 24 deletions(-)
include/hw/mem/pc-dimm.h +0 -5
@@ -56,9 +56,6 @@ struct PCDIMMDevice {* PCDIMMDeviceClass: * @realize: called after common dimm is realized so that the dimm based * devices get the chance to do specified operations. -* @get_vmstate_memory_region: returns #MemoryRegion which indicates the -* memory of @dimm should be kept during live migration. Will not fail -* after the device was realized. */ struct PCDIMMDeviceClass {/* private */
@@ -66,8 +63,6 @@ struct PCDIMMDeviceClass {/* public */ void (*realize)(PCDIMMDevice *dimm,Error **errp); - MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm, - Error **errp); }; void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,
hw/mem/pc-dimm.c +14 -19
@@ -34,6 +34,16 @@static int pc_dimm_get_free_slot (const int *hint,int max_slots,Error **errp); +static MemoryRegion *pc_dimm_get_memory_region (PCDIMMDevice *dimm,Error **errp) +{ +if (!dimm->hostmem) { +error_setg (errp,"'" PC_DIMM_MEMDEV_PROP "' property must be set" ); +return NULL ; + } + +return host_memory_backend_get_memory (dimm->hostmem); +} +void pc_dimm_pre_plug (PCDIMMDevice *dimm,MachineState *machine,const uint64_t *legacy_align,Error **errp) {
@@ -66,9 +76,8 @@ void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,void pc_dimm_plug (PCDIMMDevice *dimm,MachineState *machine) { -PCDIMMDeviceClass *ddc =PC_DIMM_GET_CLASS (dimm); -MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region (dimm, - &error_abort); +MemoryRegion *vmstate_mr =pc_dimm_get_memory_region (dimm, + &error_abort);memory_device_plug (MEMORY_DEVICE (dimm), machine);vmstate_register_ram (vmstate_mr,DEVICE (dimm));
@@ -76,9 +85,8 @@ void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine)void pc_dimm_unplug (PCDIMMDevice *dimm,MachineState *machine) { -PCDIMMDeviceClass *ddc =PC_DIMM_GET_CLASS (dimm); -MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region (dimm, - &error_abort); +MemoryRegion *vmstate_mr =pc_dimm_get_memory_region (dimm, + &error_abort);memory_device_unplug (MEMORY_DEVICE (dimm), machine);vmstate_unregister_ram (vmstate_mr,DEVICE (dimm));
@@ -205,16 +213,6 @@ static void pc_dimm_unrealize(DeviceState *dev)host_memory_backend_set_mapped (dimm->hostmem, false); } -static MemoryRegion *pc_dimm_get_memory_region (PCDIMMDevice *dimm,Error **errp) -{ -if (!dimm->hostmem) { -error_setg (errp,"'" PC_DIMM_MEMDEV_PROP "' property must be set" ); -return NULL ; - } - -return host_memory_backend_get_memory (dimm->hostmem); -} -static uint64_t pc_dimm_md_get_addr (const MemoryDeviceState *md) { return object_property_get_uint(OBJECT(md), PC_DIMM_ADDR_PROP,
@@ -266,7 +264,6 @@ static void pc_dimm_md_fill_device_info(const MemoryDeviceState *md,static void pc_dimm_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc); -PCDIMMDeviceClass *ddc =PC_DIMM_CLASS (oc);MemoryDeviceClass *mdc =MEMORY_DEVICE_CLASS (oc); dc->realize = pc_dimm_realize;
@@ -274,8 +271,6 @@ static void pc_dimm_class_init(ObjectClass *oc, void *data)device_class_set_props (dc, pc_dimm_properties); dc->desc ="DIMM memory module" ; - ddc->get_vmstate_memory_region = pc_dimm_get_memory_region; - mdc->get_addr = pc_dimm_md_get_addr; mdc->set_addr = pc_dimm_md_set_addr;/* for a dimm plugged_size == region_size */
Signature · 1 line
MST
[PULL 03/16] hw/virtio: Pass virtio_feature_get_config_size() a const argument
In reply to Michael S. TsirkinFrom: Philippe Mathieu-Daudé <[email protected]>
The VirtIOFeature structure isn't modified, mark it const.
Message-Id: <[email protected]>
--- include/hw/virtio/virtio.h | 2 +- hw/virtio/virtio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +1 -1
@@ -43,7 +43,7 @@ typedef struct VirtIOFeature {size_t end; } VirtIOFeature; -size_t virtio_feature_get_config_size (VirtIOFeature *features, +size_t virtio_feature_get_config_size (const VirtIOFeature *features,uint64_t host_features);typedef struct VirtQueue VirtQueue ;
hw/virtio/virtio.c +1 -1
@@ -2982,7 +2982,7 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t val)return ret; } -size_t virtio_feature_get_config_size (VirtIOFeature *feature_sizes, +size_t virtio_feature_get_config_size (const VirtIOFeature *feature_sizes,uint64_t host_features) {size_t config_size =0 ;
Signature · 1 line
MST
[PULL 11/16] virtio-scsi: Configure all host notifiers in a single MR transaction
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
This allows the virtio-scsi-pci device to batch the setup of all its host notifiers. This significantly improves boot time of VMs with a high number of vCPUs, e.g. from 6m5.563s down to 1m2.884s for a pseries machine with 384 vCPUs.
Note that memory_region_transaction_commit() must be called before virtio_bus_cleanup_host_notifier() because the latter might close ioeventfds that the transaction still assumes to be around when it commits.
Message-Id: <[email protected]>
--- hw/scsi/virtio-scsi-dataplane.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
hw/scsi/virtio-scsi-dataplane.c +16 -0
@@ -152,6 +152,8 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) goto fail_guest_notifiers; } +memory_region_transaction_begin (); + rc =virtio_scsi_set_host_notifier (s, vs->ctrl_vq,0 );if (rc !=0 ) { goto fail_host_notifiers;
@@ -173,6 +175,8 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) vq_init_count++; } +memory_region_transaction_commit (); +aio_context_acquire (s->ctx);virtio_queue_aio_set_host_notifier_handler (vs->ctrl_vq, s->ctx, virtio_scsi_data_plane_handle_ctrl);
@@ -192,6 +196,11 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) fail_host_notifiers:for (i =0 ; i < vq_init_count; i++) {virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false); + } + +memory_region_transaction_commit (); + +for (i =0 ; i < vq_init_count; i++) {virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i); } k->set_guest_notifiers (qbus->parent, vs->conf.num_queues +2 , false);
@@ -229,8 +238,15 @@ void virtio_scsi_dataplane_stop(VirtIODevice *vdev)blk_drain_all ();/* ensure there are no in-flight requests */ +memory_region_transaction_begin (); +for (i =0 ; i < vs->conf.num_queues +2 ; i++) {virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false); + } + +memory_region_transaction_commit (); + +for (i =0 ; i < vs->conf.num_queues +2 ; i++) {virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i); }
Signature · 1 line
MST
[PULL 05/16] virtio-net: Constify VirtIOFeature feature_sizes[]
In reply to Michael S. TsirkinFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/virtio-net.c +1 -1
@@ -89,7 +89,7 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX | \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) -static VirtIOFeature feature_sizes[] = { +static const VirtIOFeature feature_sizes[] = { {.flags =1ULL <<VIRTIO_NET_F_MAC , .end = endof(struct virtio_net_config, mac)}, {.flags =1ULL <<VIRTIO_NET_F_STATUS ,
Signature · 1 line
MST
[PULL 16/16] Fix build with 64 bits time_t
In reply to Michael S. TsirkinFrom: Fabrice Fontaine <[email protected]>
time element is deprecated on new input_event structure in kernel's input.h [1]
This will avoid the following build failure:
hw/input/virtio-input-host.c: In function 'virtio_input_host_handle_status':hw/input/virtio-input-host.c:198:28: error: 'struct input_event' has no member named 'time'
198 | if (gettimeofday(&evdev.time, NULL)) {
| ^
Fixes:
- http://autobuild.buildroot.org/results/a538167e288c14208d557cd45446df86d3d599d5
- http://autobuild.buildroot.org/results/efd4474fb4b6c0ce0ab3838ce130429c51e43bbb
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=152194fe9c3f
Message-Id: <[email protected]>
--- contrib/vhost-user-input/main.c | 8 ++++++-- hw/input/virtio-input-host.c | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-)
contrib/vhost-user-input/main.c +6 -2
@@ -6,12 +6,13 @@#include "qemu/osdep.h" -#include <linux/input.h> +#include <sys/ioctl.h> #include "qemu/iov.h" #include "qemu/bswap.h" #include "qemu/sockets.h" #include "libvhost-user-glib.h" +#include "standard-headers/linux/input.h" #include "standard-headers/linux/virtio_input.h" #include "qapi/error.h"
@@ -113,13 +114,16 @@ vi_evdev_watch(VuDev *dev, int condition, void *data)static void vi_handle_status (VuInput *vi,virtio_input_event *event) {struct input_event evdev; +struct timeval tval;int rc; -if (gettimeofday (&evdev.time,NULL )) { +if (gettimeofday (&tval,NULL )) {perror ("vi_handle_status: gettimeofday" );return ; } + evdev.input_event_sec = tval.tv_sec; + evdev.input_event_usec = tval.tv_usec; evdev.type =le16toh (event->type); evdev.code =le16toh (event->code); evdev.value =le32toh (event->value);
hw/input/virtio-input-host.c +4 -1
@@ -193,13 +193,16 @@ static void virtio_input_host_handle_status(VirtIOInput *vinput, {VirtIOInputHost *vih =VIRTIO_INPUT_HOST (vinput);struct input_event evdev; +struct timeval tval;int rc; -if (gettimeofday (&evdev.time,NULL )) { +if (gettimeofday (&tval,NULL )) {perror ("virtio_input_host_handle_status: gettimeofday" );return ; } + evdev.input_event_sec = tval.tv_sec; + evdev.input_event_usec = tval.tv_usec; evdev.type =le16_to_cpu (event->type); evdev.code =le16_to_cpu (event->code); evdev.value =le32_to_cpu (event->value);
Signature · 1 line
MST
[PULL 12/16] checkpatch: Fix use of uninitialized value
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
checkfilename() doesn't always set $acpi_testexpected. Fix the following warning:
Use of uninitialized value $acpi_testexpected in string eq at
./scripts/checkpatch.pl line 1529.
Message-Id: <[email protected]>
--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
@@ -1532,6 +1532,7 @@ sub process { ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && (defined($1) || defined($2)))) && !(($realfile ne '') && + defined($acpi_testexpected) && ($realfile eq $acpi_testexpected))) { $reported_maintainer_file = 1; WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
Signature · 1 line
MST
[PULL 02/16] x86: acpi: use offset instead of pointer when using build_header()
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Do the same as in commit
(4d027afeb3a97 Virt: ACPI: fix qemu assert due to re-assigned table data address)
for remaining tables that happen to use saved at
the beginning pointer to build header to avoid assert
when table_data is relocated due to implicit re-size.
In this case user is trying to start Windows 10 and getting assert at
hw/acpi/bios-linker-loader.c:239:
bios_linker_loader_add_checksum: Assertion `start_offset < file->blob->len' failed.
Message-Id: <[email protected]>
--- hw/acpi/aml-build.c | 15 +++++++++------ hw/i386/acpi-build.c | 8 ++++++-- 2 files changed, 15 insertions(+), 8 deletions(-)
hw/acpi/aml-build.c +9 -6
@@ -1830,6 +1830,7 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,int i;unsigned rsdt_entries_offset;AcpiRsdtDescriptorRev1 *rsdt; +int rsdt_start = table_data->len;const unsigned table_data_len = (sizeof (uint32_t ) * table_offsets->len);const unsigned rsdt_entry_size =sizeof (rsdt->table_offset_entry[0 ]);const size_t rsdt_len =sizeof (*rsdt) + table_data_len;
@@ -1846,7 +1847,8 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, ACPI_BUILD_TABLE_FILE, ref_tbl_offset); }build_header (linker, table_data, - (void *)rsdt,"RSDT" , rsdt_len,1 , oem_id, oem_table_id); + (void *)(table_data->data + rsdt_start), +"RSDT" , rsdt_len,1 , oem_id, oem_table_id); }/* Build xsdt table */
@@ -1857,6 +1859,7 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,int i;unsigned xsdt_entries_offset;AcpiXsdtDescriptorRev2 *xsdt; +int xsdt_start = table_data->len;const unsigned table_data_len = (sizeof (uint64_t ) * table_offsets->len);const unsigned xsdt_entry_size =sizeof (xsdt->table_offset_entry[0 ]);const size_t xsdt_len =sizeof (*xsdt) + table_data_len;
@@ -1873,7 +1876,8 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, ACPI_BUILD_TABLE_FILE, ref_tbl_offset); }build_header (linker, table_data, - (void *)xsdt,"XSDT" , xsdt_len,1 , oem_id, oem_table_id); + (void *)(table_data->data + xsdt_start), +"XSDT" , xsdt_len,1 , oem_id, oem_table_id); } void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
@@ -2053,10 +2057,9 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,uint64_t control_area_start_address;TPMIf *tpmif =tpm_find ();uint32_t start_method; -void *tpm2_ptr; tpm2_start = table_data->len; - tpm2_ptr =acpi_data_push (table_data,sizeof (AcpiTableHeader)); +acpi_data_push (table_data,sizeof (AcpiTableHeader));/* Platform Class */ build_append_int_noprefix (table_data,TPM2_ACPI_CLASS_CLIENT ,2 );
@@ -2095,8 +2098,8 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog, log_addr_offset,8 , ACPI_BUILD_TPMLOG_FILE, 0);build_header (linker, table_data, - tpm2_ptr,"TPM2" , table_data->len - tpm2_start,4 , oem_id, - oem_table_id); + (void *)(table_data->data + tpm2_start), +"TPM2" , table_data->len - tpm2_start,4 , oem_id, oem_table_id); } Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset,
hw/i386/acpi-build.c +6 -2
@@ -1816,6 +1816,7 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) {Acpi20Hpet *hpet; +int hpet_start = table_data->len; hpet =acpi_data_push (table_data,sizeof (*hpet));/* Note timer_block_id value must be kept in sync with value advertised by
@@ -1824,13 +1825,15 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id, hpet->timer_block_id =cpu_to_le32 (0x8086a201 ); hpet->addr.address =cpu_to_le64 (HPET_BASE );build_header (linker, table_data, - (void *)hpet,"HPET" ,sizeof (*hpet),1 , oem_id, oem_table_id); + (void *)(table_data->data + hpet_start), +"HPET" ,sizeof (*hpet),1 , oem_id, oem_table_id); }static void build_tpm_tcpa (GArray *table_data,BIOSLinker *linker,GArray *tcpalog,const char *oem_id,const char *oem_table_id) { +int tcpa_start = table_data->len;Acpi20Tcpa *tcpa =acpi_data_push (table_data,sizeof *tcpa);unsigned log_addr_size =sizeof (tcpa->log_area_start_address); unsigned log_addr_offset =
@@ -1849,7 +1852,8 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog, ACPI_BUILD_TPMLOG_FILE, 0);build_header (linker, table_data, - (void *)tcpa,"TCPA" ,sizeof (*tcpa),2 , oem_id, oem_table_id); + (void *)(table_data->data + tcpa_start), +"TCPA" ,sizeof (*tcpa),2 , oem_id, oem_table_id); }#define HOLE_640K_START (640 * KiB)
Signature · 1 line
MST
Peter Maydell
AppliedQuoted 16 lines · Michael S. Tsirkin
The following changes since commit
609d7596524ab204ccd71ef42c9eee4c7c338ea4:Update version for v6.0.0 release (2021-04-29 18:05:29 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
f7a6df5f5bf3acc219352a1b25573ae2082d7e42:Fix build with 64 bits
time_t(2021-05-14 10:26:18 -0400)----------------------------------------------------------------
pc,pci,virtio: bugfixes, improvements
Quoted 6 lines
Fixes all over the place. Faster boot for virtio. ioeventfd support for mmio.
Signed-off-by Michael S. Tsirkin <[email protected]>----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.
-- PMM