From: Gautam Dawar <gdawar@amd.com>
To: Eugenio Perez Martin <eperezma@redhat.com>,
Gautam Dawar <gautam.dawar@amd.com>
Cc: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org,
linux-net-drivers@amd.com, harpreet.anand@amd.com,
tanuj.kamde@amd.com, koushik.dutta@amd.com
Subject: Re: [PATCH] vdpa: fix emulated guest announce feature status handling
Date: Wed, 15 Mar 2023 23:01:38 +0530 [thread overview]
Message-ID: <4eb0278e-cccd-4cca-cdf4-c16c6abe0309@amd.com> (raw)
In-Reply-To: <CAJaqyWcK8CPmrVckC+29QEfmAWNZpSNBmptOfGs=qvGnOiUjJg@mail.gmail.com>
On 3/3/23 20:28, Eugenio Perez Martin wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> On Fri, Mar 3, 2023 at 12:58 PM Gautam Dawar <gautam.dawar@amd.com> wrote:
>> Guest announce capability is emulated by qemu in the .avail_handler
>> shadow virtqueue operation. It updates the status to success in
>> `*s->status` but incorrectly fetches the command execution
>> status from local variable `status` later in call to iov_from_buf().
>> As `status` is initialized to VIRTIO_NET_ERR, it results in a
>> warning "Failed to ack link announce" in virtio_net driver's
>> virtnet_ack_link_announce() function after VM Live Migration.
>> Also, I noticed an invalid check in vhost_vdpa_net_handle_ctrl_avail()
>> that reports an error because status is not updated in call to
>> virtio_net_handle_ctrl_iov():
>>
> status should be updated through &in. It is declared as:
> const struct iovec in = {
> .iov_base = &status,
> .iov_len = sizeof(status),
> };
>
> And it should be filled at the end of virtio_net_handle_ctrl_iov with a call to:
> s = iov_from_buf(in_sg, in_num, 0, &status, sizeof(status));
Apologies for a delayed response. This totally makes sense and I've not
been able to reproduce this issue.
> How do you obtain different values? Maybe const optimizations is
> invalid and the compiler thinks virtio_net_handle_ctrl_iov will never
> change status?
>
> Thanks!
I think the issue might have been a result of incorrectly returning
VIRTIO_NET_F_GUEST_ANNOUNCE in the device features without handling of
VIRTIO_NET_CTRL_ANNOUNCE_ACK in the parent vdpa driver.
We can drop this patch.
Gautam
>> virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, &out, 1);
>> if (status != VIRTIO_NET_OK) {
>> error_report("Bad CVQ processing in model");
>> }
>> Adding an optional OUT status parameter to virtio_net_handle_ctrl_iov()
>> would help resolving this issue and also send the correct status
>> value to the virtio-net driver.
>>
>> Signed-off-by: Gautam Dawar <gautam.dawar@amd.com>
>> ---
>> hw/net/virtio-net.c | 9 +++++++--
>> include/hw/virtio/virtio-net.h | 3 ++-
>> net/vhost-vdpa.c | 3 +--
>> 3 files changed, 10 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
>> index 3ae909041a..36a75592da 100644
>> --- a/hw/net/virtio-net.c
>> +++ b/hw/net/virtio-net.c
>> @@ -1503,7 +1503,8 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
>> size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
>> const struct iovec *in_sg, unsigned in_num,
>> const struct iovec *out_sg,
>> - unsigned out_num)
>> + unsigned out_num,
>> + virtio_net_ctrl_ack *status_out)
>> {
>> VirtIONet *n = VIRTIO_NET(vdev);
>> struct virtio_net_ctrl_hdr ctrl;
>> @@ -1514,6 +1515,8 @@ size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
>> if (iov_size(in_sg, in_num) < sizeof(status) ||
>> iov_size(out_sg, out_num) < sizeof(ctrl)) {
>> virtio_error(vdev, "virtio-net ctrl missing headers");
>> + if (status_out)
>> + *status_out = status;
>> return 0;
>> }
>>
>> @@ -1540,6 +1543,8 @@ size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
>> assert(s == sizeof(status));
>>
>> g_free(iov2);
>> + if (status_out)
>> + *status_out = status;
>> return sizeof(status);
>> }
>>
>> @@ -1555,7 +1560,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
>> }
>>
>> written = virtio_net_handle_ctrl_iov(vdev, elem->in_sg, elem->in_num,
>> - elem->out_sg, elem->out_num);
>> + elem->out_sg, elem->out_num, NULL);
>> if (written > 0) {
>> virtqueue_push(vq, elem, written);
>> virtio_notify(vdev, vq);
>> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
>> index ef234ffe7e..da76cc414d 100644
>> --- a/include/hw/virtio/virtio-net.h
>> +++ b/include/hw/virtio/virtio-net.h
>> @@ -224,7 +224,8 @@ struct VirtIONet {
>> size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
>> const struct iovec *in_sg, unsigned in_num,
>> const struct iovec *out_sg,
>> - unsigned out_num);
>> + unsigned out_num,
>> + virtio_net_ctrl_ack *status);
>> void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
>> const char *type);
>>
>> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
>> index de5ed8ff22..c72b338633 100644
>> --- a/net/vhost-vdpa.c
>> +++ b/net/vhost-vdpa.c
>> @@ -638,8 +638,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
>> return VIRTIO_NET_ERR;
>> }
>>
>> - status = VIRTIO_NET_ERR;
>> - virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, &out, 1);
>> + virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, &out, 1, &status);
>> if (status != VIRTIO_NET_OK) {
>> error_report("Bad CVQ processing in model");
>> }
>> --
>> 2.30.1
>>
prev parent reply other threads:[~2023-03-15 17:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 11:58 [PATCH] vdpa: fix emulated guest announce feature status handling Gautam Dawar
2023-03-03 12:17 ` Michael S. Tsirkin
2023-03-03 14:58 ` Eugenio Perez Martin
2023-03-15 17:31 ` Gautam Dawar [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=4eb0278e-cccd-4cca-cdf4-c16c6abe0309@amd.com \
--to=gdawar@amd.com \
--cc=eperezma@redhat.com \
--cc=gautam.dawar@amd.com \
--cc=harpreet.anand@amd.com \
--cc=jasowang@redhat.com \
--cc=koushik.dutta@amd.com \
--cc=linux-net-drivers@amd.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=tanuj.kamde@amd.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).