qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	Alexander Graf <agraf@suse.de>,
	Richard Henderson <rth@twiddle.net>,
	David Hildenbrand <david@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
	Halil Pasic <pasic@linux.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>
Subject: [Qemu-devel] [PULL 01/12] virtio-ccw: clean up notify
Date: Tue, 19 Jun 2018 14:04:23 +0200	[thread overview]
Message-ID: <20180619120434.25062-2-cohuck@redhat.com> (raw)
In-Reply-To: <20180619120434.25062-1-cohuck@redhat.com>

From: Halil Pasic <pasic@linux.ibm.com>

Coverity recently started complaining about virtio_ccw_notify().  Turns
out, there is a couple of things that can be cleaned up.  Let's clean!

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: CID 1390619
Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Message-Id: <20180516132757.68558-1-pasic@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
 hw/s390x/virtio-ccw.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 0a9bec484b..b92a85d0b0 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1001,10 +1001,15 @@ static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
     SubchDev *sch = ccw_dev->sch;
     uint64_t indicators;
 
-    /* queue indicators + secondary indicators */
-    if (vector >= VIRTIO_QUEUE_MAX + 64) {
+    if (vector == VIRTIO_NO_VECTOR) {
         return;
     }
+    /*
+     * vector < VIRTIO_QUEUE_MAX: notification for a virtqueue
+     * vector == VIRTIO_QUEUE_MAX: configuration change notification
+     * bits beyond that are unused and should never be notified for
+     */
+    assert(vector <= VIRTIO_QUEUE_MAX);
 
     if (vector < VIRTIO_QUEUE_MAX) {
         if (!dev->indicators) {
@@ -1027,6 +1032,7 @@ static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
                 css_adapter_interrupt(CSS_IO_ADAPTER_VIRTIO, dev->thinint_isc);
             }
         } else {
+            assert(vector < NR_CLASSIC_INDICATOR_BITS);
             indicators = address_space_ldq(&address_space_memory,
                                            dev->indicators->addr,
                                            MEMTXATTRS_UNSPECIFIED,
@@ -1040,12 +1046,11 @@ static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
         if (!dev->indicators2) {
             return;
         }
-        vector = 0;
         indicators = address_space_ldq(&address_space_memory,
                                        dev->indicators2->addr,
                                        MEMTXATTRS_UNSPECIFIED,
                                        NULL);
-        indicators |= 1ULL << vector;
+        indicators |= 1ULL;
         address_space_stq(&address_space_memory, dev->indicators2->addr,
                           indicators, MEMTXATTRS_UNSPECIFIED, NULL);
         css_conditional_io_interrupt(sch);
-- 
2.14.4

  reply	other threads:[~2018-06-19 12:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 12:04 [Qemu-devel] [PULL 00/12] next round of s390x patches Cornelia Huck
2018-06-19 12:04 ` Cornelia Huck [this message]
2018-06-19 12:04 ` [Qemu-devel] [PULL 02/12] vfio-ccw: add force unlimited prefetch property Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 03/12] vfio-ccw: remove orb.c64 (64 bit data addresses) check Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 04/12] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 05/12] s390x/cpumodels: add z14 Model ZR1 Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 06/12] pc-bios/s390-ccw: define loadparm length Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 07/12] roms: Update SLOF submodule to current status Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 08/12] pc-bios/s390-ccw/net: Update code for the latest changes in SLOF Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 09/12] pc-bios/s390-ccw/net: Add support for pxelinux-style config files Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 10/12] pc-bios/s390-ccw/net: Try to load pxelinux.cfg file accoring to the UUID Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 11/12] pc-bios/s390-ccw: Optimize the s390-netboot.img for size Cornelia Huck
2018-06-19 12:04 ` [Qemu-devel] [PULL 12/12] pc-bios/s390-ccw: Update the s390-netboot.img binary Cornelia Huck
2018-06-20  9:52 ` [Qemu-devel] [PULL 00/12] next round of s390x patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180619120434.25062-2-cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=david@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).