From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
qemu-devel@nongnu.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
"Jason Wang" <jasowang@redhat.com>
Subject: Re: [PATCH 2/4] vhost: convert byte order on SVQ used event write
Date: Mon, 31 Oct 2022 11:09:46 -0400 [thread overview]
Message-ID: <20221031110630-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAJaqyWeLrKZGet7q+sJUQ_DzAHQGm5onvVK8vdbq9C1xVrD77w@mail.gmail.com>
On Mon, Oct 31, 2022 at 02:02:16PM +0100, Eugenio Perez Martin wrote:
> On Mon, Oct 31, 2022 at 1:33 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Mon, Oct 31, 2022 at 09:54:34AM +0100, Eugenio Perez Martin wrote:
> > > On Sat, Oct 29, 2022 at 12:48 AM Philippe Mathieu-Daudé
> > > <philmd@linaro.org> wrote:
> > > >
> > > > On 28/10/22 18:02, Eugenio Pérez wrote:
> > > > > This causes errors on virtio modern devices on big endian hosts
> > > > >
> > > > > Fixes: 01f8beacea2a ("vhost: toggle device callbacks using used event idx")
> > > > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > > > > ---
> > > > > hw/virtio/vhost-shadow-virtqueue.c | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
> > > > > index 70766ea740..467099f5d9 100644
> > > > > --- a/hw/virtio/vhost-shadow-virtqueue.c
> > > > > +++ b/hw/virtio/vhost-shadow-virtqueue.c
> > > > > @@ -382,7 +382,7 @@ static bool vhost_svq_enable_notification(VhostShadowVirtqueue *svq)
> > > > > {
> > > > > if (virtio_vdev_has_feature(svq->vdev, VIRTIO_RING_F_EVENT_IDX)) {
> > > > > uint16_t *used_event = &svq->vring.avail->ring[svq->vring.num];
> > > > > - *used_event = svq->shadow_used_idx;
> > > > > + *used_event = cpu_to_le16(svq->shadow_used_idx);
> > > >
> > > > This looks correct, but what about:
> > > >
> > > > virtio_stw_p(svq->vdev, used_event, svq->shadow_used_idx);
> > > >
> > >
> > > Hi Philippe,
> > >
> > > I think this has the same answer as [1], the endianness conversion
> > > from the guest to the host may not be the same as the one needed from
> > > qemu SVQ to the vdpa device. Please let me know if it is not the case.
> > >
> > > Thanks!
> > >
> > > [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-10/msg06081.html
> >
> > So considering legacy, i do not belive you can make a legacy
> > device on top of modern one using SVQ alone.
> >
>
> Right, more work is needed. For example, config r/w conversions. But
> it's a valid use case where SVQ helps too.
I am not sure why it's valid frankly.
> > So I'd say SVQ should follow virtio endian-ness, not LE.
>
> At this moment both the device that the guest sees and the vdpa device
> must be modern ones to enable SVQ. So the event idx must be stored in
> the vring in LE. Similar access functions as virtio_ld* and virtio_st*
> are needed if SVQ supports legacy vdpa devices in the future.
>
> The point is that svq->shadow_avail_idx is decoupled from the guest's
> avail ring, event idx, etc. It will always be in the host's CPU
> endianness, regardless of the guest's one. And, for the moment, the
> event idx write must be in LE.
>
> There is a more fundamental problem about using virtio_{st,ld}* here:
> These read from and write to guest's memory, but neither
> svq->shadow_used_idx or shadow vring are in guest's memory but only in
> qemu's VA. To start the support of legacy vdpa devices would involve a
> deeper change here, since all shadow vring writes and reads are
> written this way.
>
> Thanks!
Yea generally, I don't know how it can work given legacy
will never attach a PASID to a VQ.
But maybe given we add yet another variant of endian-ness
it is time to actually use sparse tags for this stuff.
> >
> >
> > > > > } else {
> > > > > svq->vring.avail->flags &= ~cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
> > > > > }
> > > >
> >
next prev parent reply other threads:[~2022-10-31 15:11 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 16:02 [PATCH 0/4] Endianess and coding style fixes for SVQ event idx support Eugenio Pérez
2022-10-28 16:02 ` [PATCH 1/4] vhost: Delete useless casting Eugenio Pérez
2022-10-28 22:43 ` Philippe Mathieu-Daudé
2022-10-28 16:02 ` [PATCH 2/4] vhost: convert byte order on SVQ used event write Eugenio Pérez
2022-10-28 22:48 ` Philippe Mathieu-Daudé
2022-10-31 8:17 ` Michael S. Tsirkin
2022-10-31 9:48 ` Philippe Mathieu-Daudé
2022-10-31 8:54 ` Eugenio Perez Martin
2022-10-31 12:33 ` Michael S. Tsirkin
2022-10-31 13:02 ` Eugenio Perez Martin
2022-10-31 15:09 ` Michael S. Tsirkin [this message]
2022-10-31 16:05 ` Eugenio Perez Martin
2022-10-31 17:29 ` Michael S. Tsirkin
2022-10-28 16:02 ` [PATCH 3/4] vhost: Fix lines over 80 characters Eugenio Pérez
2022-10-28 16:45 ` Michael S. Tsirkin
2022-10-31 7:43 ` Eugenio Perez Martin
2022-10-28 16:02 ` [PATCH 4/4] vhost: convert byte order on avail_event read Eugenio Pérez
2022-10-28 22:53 ` Philippe Mathieu-Daudé
2022-10-31 8:29 ` Eugenio Perez Martin
2022-10-31 12:35 ` Michael S. Tsirkin
2022-11-01 2:27 ` Jason Wang
2022-10-29 8:24 ` [PATCH 0/4] Endianess and coding style fixes for SVQ event idx support Michael S. Tsirkin
2022-10-31 8:14 ` Philippe Mathieu-Daudé
2022-11-01 2:41 ` Jason Wang
[not found] ` <CAJFLiB+kQ9mjy6V7uKXwoONhJ9-uiw2O3v-7WoM-B5Zaiv-jXg@mail.gmail.com>
2022-11-18 2:49 ` Lei Yang
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=20221031110630-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@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).