qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sergio Lopez <slp@redhat.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: stefanha@gmail.com, peter.maydell@linaro.org,
	qemu-devel@nongnu.org, abologna@redhat.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] virtio-mmio: implement modern (v2) personality (virtio-1)
Date: Tue, 03 Sep 2019 12:22:41 +0200	[thread overview]
Message-ID: <87muflisr2.fsf@redhat.com> (raw)
In-Reply-To: <20190902154135.39043595.cohuck@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3359 bytes --]


Cornelia Huck <cohuck@redhat.com> writes:

> On Thu, 29 Aug 2019 18:50:27 +0200
> Sergio Lopez <slp@redhat.com> wrote:
>
>> Implement the modern (v2) personality, according to the VirtIO 1.0
>> specification.
>> 
>> Support for v2 among guests is not as widespread as it'd be
>> desirable. While the Linux driver has had it for a while, support is
>> missing, at least, from Tianocore EDK II, NetBSD and FreeBSD.
>> 
>> For this reason, the v2 personality is disabled, keeping the legacy
>> behavior as default. Machine types willing to use v2, can enable it
>> using MachineClass's compat_props.
>> 
>> Signed-off-by: Sergio Lopez <slp@redhat.com>
>> ---
>> Changelog:
>> 
>> v2:
>>  - Switch from RFC to PATCH.
>>  - Avoid the modern vs. legacy dichotomy. Use legacy or non-legacy
>>    instead. (Andrea Bolognani, Cornelia Huck)
>>  - Include the register offset in the warning messages. (Stefan
>>    Hajnoczi)
>>  - Fix device endianness for the non-legacy mode. (Michael S. Tsirkin)
>>  - Honor the specs in VIRTIO_MMIO_QUEUE_READY. (Michael S. Tsirkin)
>> ---
>>  hw/virtio/virtio-mmio.c | 296 +++++++++++++++++++++++++++++++++++++---
>>  1 file changed, 279 insertions(+), 17 deletions(-)
>> 
>
>> @@ -146,28 +163,51 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)
>>      case VIRTIO_MMIO_MAGIC_VALUE:
>>          return VIRT_MAGIC;
>>      case VIRTIO_MMIO_VERSION:
>> -        return VIRT_VERSION;
>> +        if (proxy->legacy) {
>> +            return VIRT_VERSION_LEGACY;
>> +        } else {
>> +            return VIRT_VERSION;
>> +        }
>>      case VIRTIO_MMIO_DEVICE_ID:
>>          return vdev->device_id;
>>      case VIRTIO_MMIO_VENDOR_ID:
>>          return VIRT_VENDOR;
>>      case VIRTIO_MMIO_DEVICE_FEATURES:
>> -        if (proxy->host_features_sel) {
>> -            return 0;
>> -        }
>> -        return vdev->host_features;
>> +        return vdev->host_features >> (32 * proxy->host_features_sel);
>
> Hm... I think you want to return 0 for host_features_sel > 0 on legacy
> devices.

You're right, better play safe here.

> Also, there's VirtIODeviceClass->legacy_features, which probably should
> be masked out for non-legacy devices?

Good point.

>> @@ -229,17 +275,33 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
>>      }
>>      switch (offset) {
>>      case VIRTIO_MMIO_DEVICE_FEATURES_SEL:
>> -        proxy->host_features_sel = value;
>> +        if (value) {
>> +            proxy->host_features_sel = 1;
>> +        } else {
>> +            proxy->host_features_sel = 0;
>> +        }
>>          break;
>>      case VIRTIO_MMIO_DRIVER_FEATURES:
>> -        if (!proxy->guest_features_sel) {
>> +        if (!proxy->legacy) {
>> +            proxy->guest_features[proxy->guest_features_sel] = value;
>> +        } else if (!proxy->guest_features_sel) {
>>              virtio_set_features(vdev, value);
>
> If the guest tries to set something !0 for guest_features_sel > 0 on a
> legacy device, should that be logged as a guest bug?

We already have some warnings for unexpected guest behavior, so I agree
we should add this one for completeness.

>>          }
>>          break;
>
> (...)
>
> Otherwise, looks good to me.

Thanks!
Sergio.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

      reply	other threads:[~2019-09-03 10:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-29 16:50 [Qemu-devel] [PATCH v2] virtio-mmio: implement modern (v2) personality (virtio-1) Sergio Lopez
2019-09-02  9:35 ` Stefan Hajnoczi
2019-09-03 10:23   ` Sergio Lopez
2019-09-02 13:41 ` Cornelia Huck
2019-09-03 10:22   ` Sergio Lopez [this message]

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=87muflisr2.fsf@redhat.com \
    --to=slp@redhat.com \
    --cc=abologna@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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).