Skip to contentSkip to conversation

pc,pci,vhost,virtio: misc fixes

GIT PULL Michael S. Tsirkin 2 participants 17 messages Oct 30, 2020 Networking

lore
Share & tools
lore
#0 lore raw

The following changes since commit 802427bcdae1ad2eceea8a8877ecad835e3f8fde:

Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20201027-1' into staging (2020-10-29 11:40:04 +0000)

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 73beb01ec54969f76ab32d1e0605a759b6c95ab0:

intel_iommu: Fix two misuse of "0x%u" prints (2020-10-30 06:48:53 -0400)

----------------------------------------------------------------
pc,pci,vhost,virtio: misc fixes

Just a bunch of bugfixes all over the place.

----------------------------------------------------------------
Ben Widawsky (4):
acpi/crs: Prevent bad ranges for host bridges acpi/crs: Support ranges > 32b for hosts
pci: Change error_report to assert(3)
pci: Disallow improper BAR registration for type 1

Eduardo Habkost (1):
pc: Implement -no-hpet as sugar for -machine hpet=on

Felipe Franciosi (1):
virtio: skip guest index check on device load

Greg Kurz (1):

      vhost: Don't special case vq->used_phys in vhost_get_log_size()

Jason Wang (1):
pci: advertise a page aligned ATS

Jin Yu (1):
vhost-blk: set features before setting inflight feature

Mark Cave-Ayland (1):

      pci: Assert irqnum is between 0 and bus->nirqs in pci_bus_change_irq_level

Peter Xu (1):

      intel_iommu: Fix two misuse of "0x%u" prints

Philippe Mathieu-Daudé (2):
hw/virtio/vhost-vdpa: Fix Coverity CID 1432864
hw/pci: Extract pci_bus_change_irq_level() from pci_change_irq_level()

Si-Wei Liu (1):
vhost-vdpa: negotiate VIRTIO_NET_F_STATUS with driver

Stefano Garzarella (1):
vhost-vsock: set vhostfd to non-blocking mode

 include/hw/i386/pc.h      |  1 +
 include/hw/i386/x86.h     |  3 ---
 include/hw/virtio/vhost.h |  1 +
 hw/block/vhost-user-blk.c |  6 +++++
 hw/i386/acpi-build.c      | 12 +++++++--
 hw/i386/intel_iommu.c     |  4 +--
 hw/i386/pc.c              | 63 ++++++++++++++++++++++++++++++++---------------
 hw/i386/pc_piix.c         |  2 +-
 hw/pci/pci.c              | 23 +++++++++++------
 hw/pci/pcie.c             |  5 ++--
 hw/virtio/vhost-vdpa.c    |  4 +--
 hw/virtio/vhost-vsock.c   | 10 ++++++++
 hw/virtio/vhost.c         | 28 +++++++++++++--------
 hw/virtio/virtio.c        | 13 +++++-----
 net/vhost-vdpa.c          |  1 +
 softmmu/vl.c              |  4 +--
 16 files changed, 123 insertions(+), 57 deletions(-)
#1 lore raw

[PULL 02/15] vhost-vsock: set vhostfd to non-blocking mode

From: Stefano Garzarella <[email protected]>

vhost IOTLB API uses read()/write() to exchange iotlb messages with the kernel module.
The QEMU implementation expects a non-blocking fd, indeed commit c471ad0e9b ("vhost_net: device IOTLB support") set it for vhost-net.

Without this patch, if we enable iommu for the vhost-vsock device, QEMU can hang when exchanging IOTLB messages.

As commit 894022e616 ("net: check if the file descriptor is valid before using it") did for tap, let's use qemu_try_set_nonblock() when fd is provided by the user.

Message-Id: <[email protected]>

---
 hw/virtio/vhost-vsock.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/virtio/vhost-vsock.c +10 -0
index f9db4beb47..8ddfb9abfe 100644
@@ -16,6 +16,7 @@
 #include "qapi/error.h"
 #include "hw/virtio/virtio-access.h"
 #include "qemu/error-report.h"
+#include "qemu/sockets.h"
 #include "hw/qdev-properties.h"
 #include "hw/virtio/vhost-vsock.h"
 #include "monitor/monitor.h"
@@ -148,6 +149,13 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp)
             error_prepend(errp, "vhost-vsock: unable to parse vhostfd: ");
             return;
         }
+
+        ret = qemu_try_set_nonblock(vhostfd);
+        if (ret < 0) {
+            error_setg_errno(errp, -ret,
+                             "vhost-vsock: unable to set non-blocking mode");
+            return;
+        }
     } else {
         vhostfd = open("/dev/vhost-vsock", O_RDWR);
         if (vhostfd < 0) {
@@ -155,6 +163,8 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp)
                              "vhost-vsock: failed to open vhost device");
             return;
         }
+
+        qemu_set_nonblock(vhostfd);
     }
 
     vhost_vsock_common_realize(vdev, "vhost-vsock");
Signature · 1 line
MST
#2 lore raw

[PULL 07/15] pci: Assert irqnum is between 0 and bus->nirqs in pci_bus_change_irq_level

In reply to Michael S. Tsirkin

From: Mark Cave-Ayland <[email protected]>

These assertions similar to those in the adjacent pci_bus_get_irq_level() function ensure that irqnum lies within the valid PCI bus IRQ range.

Message-Id: <[email protected]>

Message-Id: <[email protected]>

---
 hw/pci/pci.c | 2 ++
 1 file changed, 2 insertions(+)
hw/pci/pci.c +2 -0
index 081ddcadd1..dc4019865b 100644
@@ -250,6 +250,8 @@ static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
 
 static void pci_bus_change_irq_level(PCIBus *bus, int irq_num, int change)
 {
+    assert(irq_num >= 0);
+    assert(irq_num < bus->nirq);
     bus->irq_count[irq_num] += change;
     bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
 }
Signature · 1 line
MST
#3 lore raw

[PULL 10/15] pci: advertise a page aligned ATS

In reply to Michael S. Tsirkin

From: Jason Wang <[email protected]>

After Linux kernel commit 61363c1474b1 ("iommu/vt-d: Enable ATS only if the device uses page aligned address."), ATS will be only enabled if device advertises a page aligned request.

Unfortunately, vhost-net is the only user and we don't advertise the aligned request capability in the past since both vhost IOTLB and address_space_get_iotlb_entry() can support non page aligned request.

Though it's not clear that if the above kernel commit makes sense. Let's advertise a page aligned ATS here to make vhost device IOTLB work with Intel IOMMU again.

Note that in the future we may extend pcie_ats_init() to accept parameters like queue depth and page alignment.

Message-Id: <[email protected]>

---
 hw/pci/pcie.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/pci/pcie.c +3 -2
index 5b48bae0f6..d4010cf8f3 100644
@@ -971,8 +971,9 @@ void pcie_ats_init(PCIDevice *dev, uint16_t offset)
 
     dev->exp.ats_cap = offset;
 
-    /* Invalidate Queue Depth 0, Page Aligned Request 0 */
-    pci_set_word(dev->config + offset + PCI_ATS_CAP, 0);
+    /* Invalidate Queue Depth 0, Page Aligned Request 1 */
+    pci_set_word(dev->config + offset + PCI_ATS_CAP,
+                 PCI_ATS_CAP_PAGE_ALIGNED);
     /* STU 0, Disabled by default */
     pci_set_word(dev->config + offset + PCI_ATS_CTRL, 0);
 
Signature · 1 line
MST
#4 lore raw

[PULL 05/15] hw/virtio/vhost-vdpa: Fix Coverity CID 1432864

In reply to Michael S. Tsirkin

From: Philippe Mathieu-Daudé <[email protected]>

Fix uninitialized value issues reported by Coverity:

Field 'msg.reserved' is uninitialized when calling write().

Fixes a5bd05800f8 ("vhost-vdpa: batch updating IOTLB mappings")
Reported-by Coverity (CID 1432864: UNINIT)

Message-Id: <[email protected]>

---
 hw/virtio/vhost-vdpa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost-vdpa.c +2 -2
index 4f1039910a..01d2101d09 100644
@@ -90,7 +90,7 @@ static void vhost_vdpa_listener_begin(MemoryListener *listener)
 {
     struct vhost_vdpa *v = container_of(listener, struct vhost_vdpa, listener);
     struct vhost_dev *dev = v->dev;
-    struct vhost_msg_v2 msg;
+    struct vhost_msg_v2 msg = {};
     int fd = v->device_fd;
 
     if (!(dev->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) {
@@ -110,7 +110,7 @@ static void vhost_vdpa_listener_commit(MemoryListener *listener)
 {
     struct vhost_vdpa *v = container_of(listener, struct vhost_vdpa, listener);
     struct vhost_dev *dev = v->dev;
-    struct vhost_msg_v2 msg;
+    struct vhost_msg_v2 msg = {};
     int fd = v->device_fd;
 
     if (!(dev->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) {
Signature · 1 line
MST
#5 lore raw

[PULL 03/15] acpi/crs: Prevent bad ranges for host bridges

In reply to Michael S. Tsirkin

From: Ben Widawsky <[email protected]>

Prevent _CRS resources being quietly chopped off and instead throw an assertion. _CRS is used by host bridges to declare regions of io and/or memory that they consume. On some (all?) platforms the host bridge doesn't have PCI header space and so they need some way to convey the information.

Message-Id: <[email protected]>

---
 hw/i386/acpi-build.c | 2 ++
 1 file changed, 2 insertions(+)
hw/i386/acpi-build.c +2 -0
index e3a4bc206c..98ff9f5cef 100644
@@ -866,6 +866,8 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
     crs_range_merge(temp_range_set.mem_ranges);
     for (i = 0; i < temp_range_set.mem_ranges->len; i++) {
         entry = g_ptr_array_index(temp_range_set.mem_ranges, i);
+        assert(entry->limit <= UINT32_MAX &&
+               (entry->limit - entry->base + 1) <= UINT32_MAX);
         aml_append(crs,
                    aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
                                     AML_MAX_FIXED, AML_NON_CACHEABLE,
Signature · 1 line
MST
#6 lore raw

[PULL 08/15] vhost: Don't special case vq->used_phys in vhost_get_log_size()

In reply to Michael S. Tsirkin

From: Greg Kurz <[email protected]>

The first loop in vhost_get_log_size() computes the size of the dirty log bitmap so that it allows to track changes in the entire guest memory, in terms of GPA.

When not using a vIOMMU, the address of the vring's used structure, vq->used_phys, is a GPA. It is thus already covered by the first loop.

When using a vIOMMU, vq->used_phys is a GIOVA that will be translated to an HVA when the vhost backend needs to update the used structure. It will log the corresponding GPAs into the bitmap but it certainly won't log the GIOVA.

So in any case, vq->used_phys shouldn't be explicitly used to size the bitmap. Drop the second loop.

This fixes a crash of the source when migrating a guest using in-kernel vhost-net and iommu_platform=on on POWER, because DMA regions are put over 0x800000000000000ULL. The resulting insanely huge log size causes g_malloc0() to abort.

Message-Id: <[email protected]>

---
 hw/virtio/vhost.c | 10 ----------
 1 file changed, 10 deletions(-)
hw/virtio/vhost.c +0 -10
index 3077fa6ef5..79b2be20df 100644
@@ -172,16 +172,6 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev)
                                        reg->memory_size);
         log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1);
     }
-    for (i = 0; i < dev->nvqs; ++i) {
-        struct vhost_virtqueue *vq = dev->vqs + i;
-
-        if (!vq->used_phys && !vq->used_size) {
-            continue;
-        }
-
-        uint64_t last = vq->used_phys + vq->used_size - 1;
-        log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1);
-    }
     return log_size;
 }
 
Signature · 1 line
MST
#7 lore raw

[PULL 11/15] pci: Change error_report to assert(3)

In reply to Michael S. Tsirkin

From: Ben Widawsky <[email protected]>

Asserts are used for developer bugs. As registering a bar of the wrong size is not something that should be possible for a user to achieve, this is a developer bug.

While here, use the more obvious helper function.

Message-Id: <[email protected]>

---
 hw/pci/pci.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
hw/pci/pci.c +1 -5
index dc4019865b..e5b7c9a42b 100644
@@ -1151,11 +1151,7 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
 
     assert(region_num >= 0);
     assert(region_num < PCI_NUM_REGIONS);
-    if (size & (size-1)) {
-        error_report("ERROR: PCI region size must be pow2 "
-                    "type=0x%x, size=0x%"FMT_PCIBUS"", type, size);
-        exit(1);
-    }
+    assert(is_power_of_2(size));
 
     r = &pci_dev->io_regions[region_num];
     r->addr = PCI_BAR_UNMAPPED;
Signature · 1 line
MST
#8 lore raw

[PULL 04/15] acpi/crs: Support ranges > 32b for hosts

In reply to Michael S. Tsirkin

From: Ben Widawsky <[email protected]>

According to PCIe spec 5.0 Type 1 header space Base Address Registers are defined by 7.5.1.2.1 Base Address Registers (same as Type 0). The _CRS region should allow for the same range (up to 64b). Prior to this change, any host bridge utilizing more than 32b for the BAR would have the address truncated and likely lead to conflicts when the operating systems reads the _CRS object.

Message-Id: <[email protected]>

---
 hw/i386/acpi-build.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
hw/i386/acpi-build.c +8 -2
index 98ff9f5cef..4f66642d88 100644
@@ -786,8 +786,14 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
                 crs_range_insert(temp_range_set.io_ranges,
                                  range_base, range_limit);
             } else { /* "memory" */
-                crs_range_insert(temp_range_set.mem_ranges,
-                                 range_base, range_limit);
+                uint64_t length = range_limit - range_base + 1;
+                if (range_limit <= UINT32_MAX && length <= UINT32_MAX) {
+                    crs_range_insert(temp_range_set.mem_ranges, range_base,
+                                     range_limit);
+                } else {
+                    crs_range_insert(temp_range_set.mem_64bit_ranges,
+                                     range_base, range_limit);
+                }
             }
         }
 
Signature · 1 line
MST
#9 lore raw

[PULL 01/15] vhost-vdpa: negotiate VIRTIO_NET_F_STATUS with driver

In reply to Michael S. Tsirkin

From: Si-Wei Liu <[email protected]>

Vendor driver may not support or implement config interrupt delivery for link status notifications. In this event, vendor driver is expected to NACK the feature, but guest will keep link always up.

Message-Id: <[email protected]>

---
 net/vhost-vdpa.c | 1 +
 1 file changed, 1 insertion(+)
net/vhost-vdpa.c +1 -0
index e2b3ba85bf..99c476db8c 100644
@@ -55,6 +55,7 @@ const int vdpa_feature_bits[] = {
     VIRTIO_F_IOMMU_PLATFORM,
     VIRTIO_F_RING_PACKED,
     VIRTIO_NET_F_GUEST_ANNOUNCE,
+    VIRTIO_NET_F_STATUS,
     VHOST_INVALID_FEATURE_BIT
 };
 
Signature · 1 line
MST
#10 lore raw

[PULL 13/15] vhost-blk: set features before setting inflight feature

In reply to Michael S. Tsirkin

From: Jin Yu <[email protected]>

Virtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format.

Message-Id: <[email protected]>

---
 include/hw/virtio/vhost.h |  1 +
 hw/block/vhost-user-blk.c |  6 ++++++
 hw/virtio/vhost.c         | 18 ++++++++++++++++++
 3 files changed, 25 insertions(+)
include/hw/virtio/vhost.h +1 -0
index 94585067f7..839bfb153c 100644
@@ -141,6 +141,7 @@ void vhost_dev_reset_inflight(struct vhost_inflight *inflight);
 void vhost_dev_free_inflight(struct vhost_inflight *inflight);
 void vhost_dev_save_inflight(struct vhost_inflight *inflight, QEMUFile *f);
 int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f);
+int vhost_dev_prepare_inflight(struct vhost_dev *hdev);
 int vhost_dev_set_inflight(struct vhost_dev *dev,
                            struct vhost_inflight *inflight);
 int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size,
hw/block/vhost-user-blk.c +6 -0
index a076b1e54d..f67b29bbf3 100644
@@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev)
 
     s->dev.acked_features = vdev->guest_features;
 
+    ret = vhost_dev_prepare_inflight(&s->dev);
+    if (ret < 0) {
+        error_report("Error set inflight format: %d", -ret);
+        goto err_guest_notifiers;
+    }
+
     if (!s->inflight->addr) {
         ret = vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight);
         if (ret < 0) {
hw/virtio/vhost.c +18 -0
index 79b2be20df..f2482378c6 100644
@@ -1645,6 +1645,24 @@ int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f)
     return 0;
 }
 
+int vhost_dev_prepare_inflight(struct vhost_dev *hdev)
+{
+    int r;
+ 
+    if (hdev->vhost_ops->vhost_get_inflight_fd == NULL ||
+        hdev->vhost_ops->vhost_set_inflight_fd == NULL) {
+        return 0;
+    }
+ 
+    r = vhost_dev_set_features(hdev, hdev->log_enabled);
+    if (r < 0) {
+        VHOST_OPS_DEBUG("vhost_dev_prepare_inflight failed");
+        return r;
+    }
+
+    return 0;
+}
+
 int vhost_dev_set_inflight(struct vhost_dev *dev,
                            struct vhost_inflight *inflight)
 {
Signature · 1 line
MST
#11 lore raw

[PULL 06/15] hw/pci: Extract pci_bus_change_irq_level() from pci_change_irq_level()

In reply to Michael S. Tsirkin

From: Philippe Mathieu-Daudé <[email protected]>

Extract pci_bus_change_irq_level() from pci_change_irq_level() to make it clearer it operates on the bus.

Message-Id: <[email protected]>

---
 hw/pci/pci.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
hw/pci/pci.c +7 -2
index 100c9381c2..081ddcadd1 100644
@@ -248,6 +248,12 @@ static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
         d->irq_state |= level << irq_num;
 }
 
+static void pci_bus_change_irq_level(PCIBus *bus, int irq_num, int change)
+{
+    bus->irq_count[irq_num] += change;
+    bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
+}
+
 static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
 {
     PCIBus *bus;
@@ -258,8 +264,7 @@ static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
             break;
         pci_dev = bus->parent_dev;
     }
-    bus->irq_count[irq_num] += change;
-    bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
+    pci_bus_change_irq_level(bus, irq_num, change);
 }
 
 int pci_bus_get_irq_level(PCIBus *bus, int irq_num)
Signature · 1 line
MST
#12 lore raw

[PULL 14/15] virtio: skip guest index check on device load

In reply to Michael S. Tsirkin

From: Felipe Franciosi <[email protected]>

QEMU must be careful when loading device state off migration streams to prevent a malicious source from exploiting the emulator. Overdoing these checks has the side effect of allowing a guest to "pin itself" in cloud environments by messing with state which is entirely in its control.

Similarly to what f3081539 achieved in usb_device_post_load(), this commit removes such a check from virtio_load(). Worth noting, the result of a load without this check is the same as if a guest enables a VQ with invalid indexes to begin with. That is, the virtual device is set in a broken state (by the datapath handler) and must be reset.

Message-Id: <[email protected]>

---
 hw/virtio/virtio.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
hw/virtio/virtio.c +7 -6
index 6f8f865aff..ceb58fda6c 100644
@@ -17,6 +17,7 @@
 #include "trace.h"
 #include "exec/address-spaces.h"
 #include "qemu/error-report.h"
+#include "qemu/log.h"
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
 #include "hw/virtio/virtio.h"
@@ -3160,12 +3161,12 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
             nheads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx;
             /* Check it isn't doing strange things with descriptor numbers. */
             if (nheads > vdev->vq[i].vring.num) {
-                error_report("VQ %d size 0x%x Guest index 0x%x "
-                             "inconsistent with Host index 0x%x: delta 0x%x",
-                             i, vdev->vq[i].vring.num,
-                             vring_avail_idx(&vdev->vq[i]),
-                             vdev->vq[i].last_avail_idx, nheads);
-                return -1;
+                qemu_log_mask(LOG_GUEST_ERROR,
+                              "VQ %d size 0x%x Guest index 0x%x "
+                              "inconsistent with Host index 0x%x: delta 0x%x",
+                              i, vdev->vq[i].vring.num,
+                              vring_avail_idx(&vdev->vq[i]),
+                              vdev->vq[i].last_avail_idx, nheads);
             }
             vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]);
             vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]);
Signature · 1 line
MST
#13 lore raw

[PULL 09/15] pc: Implement -no-hpet as sugar for -machine hpet=on

In reply to Michael S. Tsirkin

From: Eduardo Habkost <[email protected]>

Get rid of yet another global variable.

The default will be hpet=on only if CONFIG_HPET=y.

Message-Id: <[email protected]>

---
 include/hw/i386/pc.h  |  1 +
 include/hw/i386/x86.h |  3 ---
 hw/i386/pc.c          | 63 +++++++++++++++++++++++++++++--------------
 hw/i386/pc_piix.c     |  2 +-
 softmmu/vl.c          |  4 +--
 5 files changed, 47 insertions(+), 26 deletions(-)
include/hw/i386/pc.h +1 -0
index 84639d0ebc..911e460097 100644
@@ -43,6 +43,7 @@ typedef struct PCMachineState {
     bool smbus_enabled;
     bool sata_enabled;
     bool pit_enabled;
+    bool hpet_enabled;
 
     /* NUMA information: */
     uint64_t numa_nodes;
include/hw/i386/x86.h +0 -3
index bfa9cb2a25..739fac5087 100644
@@ -126,7 +126,4 @@ qemu_irq x86_allocate_cpu_irq(void);
 void gsi_handler(void *opaque, int n, int level);
 void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
 
-/* hpet.c */
-extern int no_hpet;
-
 #endif
hw/i386/pc.c +43 -20

89 lines not on this page · raw message

hw/i386/pc_piix.c +1 -1
index 0cf22a57ad..13d1628f13 100644
@@ -216,7 +216,7 @@ static void pc_init1(MachineState *machine,
         i440fx_state = NULL;
         isa_bus = isa_bus_new(NULL, get_system_memory(), system_io,
                               &error_abort);
-        no_hpet = 1;
+        pcms->hpet_enabled = false;
     }
     isa_bus_irqs(isa_bus, x86ms->gsi);
 
softmmu/vl.c +2 -2
index 7c1c6d37ef..a537a0377f 100644
@@ -146,7 +146,6 @@ static Chardev **serial_hds;
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
 int win2k_install_hack = 0;
 int singlestep = 0;
-int no_hpet = 0;
 int fd_bootchk = 1;
 static int no_reboot;
 int no_shutdown = 0;
@@ -3562,7 +3561,8 @@ void qemu_init(int argc, char **argv, char **envp)
                 qemu_opts_parse_noisily(olist, "acpi=off", false);
                 break;
             case QEMU_OPTION_no_hpet:
-                no_hpet = 1;
+                olist = qemu_find_opts("machine");
+                qemu_opts_parse_noisily(olist, "hpet=off", false);
                 break;
             case QEMU_OPTION_no_reboot:
                 no_reboot = 1;
Signature · 1 line
MST
#14 lore raw

[PULL 15/15] intel_iommu: Fix two misuse of "0x%u" prints

In reply to Michael S. Tsirkin

From: Peter Xu <[email protected]>

Dave magically found this. Fix them with "0x%x".

Message-Id: <[email protected]>

---
 hw/i386/intel_iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/i386/intel_iommu.c +2 -2
index 749eb6ad63..70ac837733 100644
@@ -2665,7 +2665,7 @@ static uint64_t vtd_mem_read(void *opaque, hwaddr addr, unsigned size)
 
     if (addr + size > DMAR_REG_SIZE) {
         error_report_once("%s: MMIO over range: addr=0x%" PRIx64
-                          " size=0x%u", __func__, addr, size);
+                          " size=0x%x", __func__, addr, size);
         return (uint64_t)-1;
     }
 
@@ -2716,7 +2716,7 @@ static void vtd_mem_write(void *opaque, hwaddr addr,
 
     if (addr + size > DMAR_REG_SIZE) {
         error_report_once("%s: MMIO over range: addr=0x%" PRIx64
-                          " size=0x%u", __func__, addr, size);
+                          " size=0x%x", __func__, addr, size);
         return;
     }
 
Signature · 1 line
MST
#15 lore raw

[PULL 12/15] pci: Disallow improper BAR registration for type 1

In reply to Michael S. Tsirkin

From: Ben Widawsky <[email protected]>

Prevent future developers working on root complexes, root ports, or bridges that also wish to implement a BAR for those, from shooting themselves in the foot. PCI type 1 headers only support 2 base address registers. It is incorrect and difficult to figure out what is wrong with the device when this mistake is made. With this, it is immediate and obvious what has gone wrong.

Message-Id: <[email protected]>

---
 hw/pci/pci.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/pci/pci.c +6 -0
index e5b7c9a42b..0131d9d02c 100644
@@ -1148,11 +1148,17 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
     uint32_t addr; /* offset in pci config space */
     uint64_t wmask;
     pcibus_t size = memory_region_size(memory);
+    uint8_t hdr_type;
 
     assert(region_num >= 0);
     assert(region_num < PCI_NUM_REGIONS);
     assert(is_power_of_2(size));
 
+    /* A PCI bridge device (with Type 1 header) may only have at most 2 BARs */
+    hdr_type =
+        pci_dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
+    assert(hdr_type != PCI_HEADER_TYPE_BRIDGE || region_num < 2);
+
     r = &pci_dev->io_regions[region_num];
     r->addr = PCI_BAR_UNMAPPED;
     r->size = size;
Signature · 1 line
MST
#16 lore raw
In reply to Michael S. Tsirkin
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PULL 00/15] pc,pci,vhost,virtio: misc fixes

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
39f4788 intel_iommu: Fix two misuse of "0x%u" prints
74f2dcec virtio: skip guest index check on device load
09b8db3 vhost-blk: set features before setting inflight feature c4153ec pci: Disallow improper BAR registration for type 1
a3f7935 pci: Change error_report to assert(3)
f4ae4c4 pci: advertise a page aligned ATS
f7c0efa pc: Implement -no-hpet as sugar for -machine hpet=on
dc519f1 vhost: Don't special case vq->used_phys in vhost_get_log_size() ba55ed1 pci: Assert irqnum is between 0 and bus->nirqs in pci_bus_change_irq_level 8a29952 hw/pci: Extract pci_bus_change_irq_level() from pci_change_irq_level() 9f715d8 hw/virtio/vhost-vdpa: Fix Coverity CID 1432864
6b2610b acpi/crs: Support ranges > 32b for hosts
e078a8b acpi/crs: Prevent bad ranges for host bridges
2f40e4c vhost-vsock: set vhostfd to non-blocking mode
3e6364c vhost-vdpa: negotiate VIRTIO_NET_F_STATUS with driver

=== OUTPUT BEGIN ===
1/15 Checking commit 3e6364c17855 (vhost-vdpa: negotiate VIRTIO_NET_F_STATUS with driver) 2/15 Checking commit 2f40e4cb435e (vhost-vsock: set vhostfd to non-blocking mode)
3/15 Checking commit e078a8b3da52 (acpi/crs: Prevent bad ranges for host bridges)
4/15 Checking commit 6b2610b14d1c (acpi/crs: Support ranges > 32b for hosts)
5/15 Checking commit 9f715d839623 (hw/virtio/vhost-vdpa: Fix Coverity CID 1432864)
6/15 Checking commit 8a29952670fa (hw/pci: Extract pci_bus_change_irq_level() from pci_change_irq_level()) 7/15 Checking commit ba55ed16b392 (pci: Assert irqnum is between 0 and bus->nirqs in pci_bus_change_irq_level) 8/15 Checking commit dc519f19095f (vhost: Don't special case vq->used_phys in vhost_get_log_size()) 9/15 Checking commit f7c0efad3f32 (pc: Implement -no-hpet as sugar for -machine hpet=on)
WARNING: Block comments use a leading /* on a separate line
#53: FILE: hw/i386/pc.c:1152:
+ /* For pc-piix-*, hpet's intcap is always IRQ2. For pc-q35-1.7

WARNING: Block comments should align the * on each line #54: FILE: hw/i386/pc.c:1153:
+ /* For pc-piix-*, hpet's intcap is always IRQ2. For pc-q35-1.7
+ * and earlier, use IRQ2 for compat. Otherwise, use IRQ16~23,

total: 0 errors, 2 warnings, 127 lines checked

Patch 9/15 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
10/15 Checking commit f4ae4c4df1e6 (pci: advertise a page aligned ATS)
11/15 Checking commit a3f79352c50f (pci: Change error_report to assert(3)) 12/15 Checking commit c4153ecc2f8c (pci: Disallow improper BAR registration for type 1) 13/15 Checking commit 09b8db37041f (vhost-blk: set features before setting inflight feature)
ERROR: trailing whitespace
#45: FILE: hw/virtio/vhost.c:1651:
+ $

ERROR: trailing whitespace
#50: FILE: hw/virtio/vhost.c:1656:
+ $

total: 2 errors, 0 warnings, 43 lines checked

Patch 13/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

14/15 Checking commit 74f2dceca92c (virtio: skip guest index check on device load) 15/15 Checking commit 39f4788eefc0 (intel_iommu: Fix two misuse of "0x%u" prints) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]