qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: borntraeger@de.ibm.com, jasowang@redhat.com,
	qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/4] virtio-ccw: feature bits > 31 handling
Date: Mon, 7 Sep 2015 12:50:11 +0200	[thread overview]
Message-ID: <20150907125011.33d835b0@thinkpad-w530> (raw)
In-Reply-To: <1441356869-57861-4-git-send-email-cornelia.huck@de.ibm.com>

> We currently switch off the VERSION_1 feature bit if the guest has
> not negotiated at least revision 1. As no feature bits beyond 31 are
> valid however unless VERSION_1 has been negotiated, make sure that
> legacy guests never see a feature bit beyond 31.
> 
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
>  hw/s390x/virtio-ccw.c | 21 ++++++++-------------
>  1 file changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> index 85e2a5d..eed7b3e 100644
> --- a/hw/s390x/virtio-ccw.c
> +++ b/hw/s390x/virtio-ccw.c
> @@ -468,15 +468,12 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
>                                                  NULL);
>              if (features.index == 0) {
>                  features.features = (uint32_t)vdev->host_features;
> -            } else if (features.index == 1) {
> -                features.features = (uint32_t)(vdev->host_features >> 32);
> +            } else if ((features.index == 1) && (dev->revision >= 1)) {
>                  /*
> -                 * Don't offer version 1 to the guest if it did not
> -                 * negotiate at least revision 1.
> +                 * Only offer feature bits beyond 31 if the guest has
> +                 * negotiated at least revision 1.
>                   */
> -                if (dev->revision <= 0) {
> -                    features.features &= ~(1 << (VIRTIO_F_VERSION_1 - 32));
> -                }
> +                features.features = (uint32_t)(vdev->host_features >> 32);
>              } else {
>                  /* Return zeroes if the guest supports more feature bits. */
>                  features.features = 0;
> @@ -515,14 +512,12 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
>                  virtio_set_features(vdev,
>                                      (vdev->guest_features & 0xffffffff00000000ULL) |
>                                      features.features);
> -            } else if (features.index == 1) {
> +            } else if ((features.index == 1) && (dev->revision >= 1)) {
>                  /*
> -                 * The guest should not set version 1 if it didn't
> -                 * negotiate a revision >= 1.
> +                 * If the guest did not negotiate at least revision 1,
> +                 * we did not offer it any feature bits beyond 31. Such a
> +                 * guest passing us any bit here is therefore buggy.
>                   */
> -                if (dev->revision <= 0) {
> -                    features.features &= ~(1 << (VIRTIO_F_VERSION_1 - 32));
> -                }
>                  virtio_set_features(vdev,
>                                      (vdev->guest_features & 0x00000000ffffffffULL) |
>                                      ((uint64_t)features.features << 32));

Looks sane to me!

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>

David

  reply	other threads:[~2015-09-07 11:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04  8:54 [Qemu-devel] [PATCH 0/4] virtio-1/virtio-ccw related patches Cornelia Huck
2015-09-04  8:54 ` [Qemu-devel] [PATCH 1/4] virtio: ring sizes vs. reset Cornelia Huck
2015-09-10  9:02   ` Michael S. Tsirkin
2015-09-10 10:22     ` Cornelia Huck
2015-09-10 10:43       ` Michael S. Tsirkin
2015-09-10 11:48         ` [Qemu-devel] [PATCH v2] " Cornelia Huck
2015-09-11  2:53           ` Jason Wang
2015-09-04  8:54 ` [Qemu-devel] [PATCH 2/4] virtio-ccw: support ring size changes Cornelia Huck
2015-09-04  8:54 ` [Qemu-devel] [PATCH 3/4] virtio-ccw: feature bits > 31 handling Cornelia Huck
2015-09-07 10:50   ` David Hildenbrand [this message]
2015-09-04  8:54 ` [Qemu-devel] [PATCH 4/4] virtio-ccw: enable virtio-1 Cornelia Huck
2015-09-10  9:07   ` Michael S. Tsirkin
2015-09-10  9:11     ` Cornelia Huck
2015-09-10  9:22       ` Michael S. Tsirkin
2015-09-10 10:29         ` Cornelia Huck
2015-09-11 13:11   ` Cornelia Huck

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=20150907125011.33d835b0@thinkpad-w530 \
    --to=dahi@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).