virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Sjur Brændeland" <sjur.brandeland@stericsson.com>
Cc: virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 1/6] virtio_host: host-side implementation of virtio rings.
Date: Thu, 17 Jan 2013 14:08:55 +0200	[thread overview]
Message-ID: <20130117120855.GA16311@redhat.com> (raw)
In-Reply-To: <CAJK669ZtShu89xMmryLM7dX0Cy7AoOdyPf7cSdV4v+81E-XF5g@mail.gmail.com>

On Thu, Jan 17, 2013 at 12:49:25PM +0100, Sjur Brændeland wrote:
> On Thu, Jan 17, 2013 at 12:23 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Thu, Jan 17, 2013 at 08:59:38PM +1030, Rusty Russell wrote:
> ...
> >> +static inline int
> >> +__vringh_iov(struct vringh *vrh, u16 i,
> >> +          struct vringh_iov *riov,
> >> +          struct vringh_iov *wiov,
> >> +          bool (*getrange)(u64 addr, struct vringh_range *r),
> >> +          gfp_t gfp,
> >> +          int (*getdesc)(struct vring_desc *dst, const struct vring_desc *s))
> >> +{
> >> +     int err, count = 0, up_next, desc_max;
> >> +     struct vring_desc desc, *descs;
> >> +     struct vringh_range range = { -1ULL, 0 };
> >> +
> >> +     /* We start traversing vring's descriptor table. */
> >> +     descs = vrh->vring.desc;
> >> +     desc_max = vrh->vring.num;
> >> +     up_next = -1;
> >> +
> >> +     riov->i = wiov->i = 0;
> >> +     for (;;) {
> >> +             void *addr;
> >> +             struct vringh_iov *iov;
> >> +
> >> +             err = getdesc(&desc, &descs[i]);
> >> +             if (unlikely(err))
> >> +                     goto fail;
> >> +
> >> +             /* Make sure it's OK, and get offset. */
> >> +             if (!check_range(desc.addr, desc.len, &range, getrange)) {
> >> +                     err = -EINVAL;
> >> +                     goto fail;
> >> +             }
> >> +             addr = (void *)(long)desc.addr + range.offset;
> >
> > Should probably be (void *)(long)(desc.addr + range.offset).
> > Otherwise we risk signed integer overflow.
> >
> >> +
> >> +             if (unlikely(desc.flags & VRING_DESC_F_INDIRECT)) {
> >> +                     err = move_to_indirect(&up_next, &i, addr, &desc,
> >> +                                            &descs, &desc_max);
> >> +                     if (err)
> >> +                             goto fail;
> >> +                     continue;
> >> +             }
> >> +
> >> +             if (count++ == vrh->vring.num) {
> >> +                     vringh_bad("Descriptor loop in %p", descs);
> >> +                     err = -ELOOP;
> >> +                     goto fail;
> >> +             }
> >> +
> >> +             if (desc.flags & VRING_DESC_F_WRITE)
> >> +                     iov = wiov;
> >> +             else {
> >> +                     iov = riov;
> >> +                     if (unlikely(wiov->i)) {
> >> +                             vringh_bad("Readable desc %p after writable",
> >> +                                        &descs[i]);
> >> +                             err = -EINVAL;
> >> +                             goto fail;
> >> +                     }
> >> +             }
> >> +
> >> +             if (unlikely(iov->i == iov->max)) {
> >> +                     err = resize_iovec(iov, gfp);
> >> +                     if (err)
> >> +                             goto fail;
> >> +             }
> >> +
> >> +             iov->iov[iov->i].iov_base = (__force __user void *)addr;
> >> +             iov->iov[iov->i].iov_len = desc.len;
> >
> > The following comment from the previous version still applies:
> >         > This looks like it won't do the right thing if desc.len spans multiple
> >         > ranges. I don't know if this happens in practice but this is something
> >         > vhost supports ATM.
> > in otgher words, we might need to split a single desc to multiple
> > iov entries.
> 
> Splitting descriptors doesn't work for me. As described earlier, I
> receive one IP-frame for each descriptor. So I need to keep
> the original boundaries.
> 
> Regards,
> Sjur

Hmm this kind of conflicts with the description we were
going into with virtio generally.
Other side should be free to lay out request any way it
wants to.
Anyway, in this case this is splitting iovecs really not descriptors.

-- 
MST

  reply	other threads:[~2013-01-17 12:08 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17 10:29 [PATCH 1/6] virtio_host: host-side implementation of virtio rings Rusty Russell
2013-01-17 10:29 ` [PATCH 2/6] tools/virtio: fix compile Rusty Russell
2013-01-17 10:29 ` [PATCH 3/6] tools/virtio: separate headers more Rusty Russell
2013-01-17 10:29 ` [PATCH 4/6] tools/virtio: add vring_test Rusty Russell
2013-01-22  8:25   ` Asias He
2013-01-22 23:03     ` Rusty Russell
2013-01-23  1:40       ` Asias He
2013-01-24  2:22         ` Rusty Russell
2013-01-17 10:29 ` [PATCH 5/6] vringh: separate callback for notification Rusty Russell
2013-01-17 10:29 ` [PATCH 6/6] tools/virtio: adapt for API changes Rusty Russell
2013-01-17 11:23 ` [PATCH 1/6] virtio_host: host-side implementation of virtio rings Michael S. Tsirkin
2013-01-17 11:49   ` Sjur Brændeland
2013-01-17 12:08     ` Michael S. Tsirkin [this message]
2013-01-21  2:36     ` Rusty Russell
2013-01-22 14:54       ` Sjur Brændeland
2013-01-21  2:34   ` Rusty Russell
2013-01-21  9:41     ` Michael S. Tsirkin
2013-01-21 11:52     ` Rusty Russell
2013-01-21 12:24       ` Michael S. Tsirkin
2013-01-21 12:40         ` Michael S. Tsirkin
2013-01-21 22:57         ` Rusty Russell
2013-01-22  6:57           ` Rusty Russell
2013-01-22  7:13           ` Rusty Russell
2013-01-22  8:12 ` Asias He
2013-01-23  1:56   ` Rusty Russell
2013-02-04 20:29 ` Sjur Brændeland
2013-02-04 21:44   ` Rusty Russell
2013-02-12 18:58     ` Sjur Brændeland
2013-02-13 10:25       ` Rusty Russell
2013-02-14 14:54         ` Sjur Brændeland

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=20130117120855.GA16311@redhat.com \
    --to=mst@redhat.com \
    --cc=sjur.brandeland@stericsson.com \
    --cc=virtualization@lists.linux-foundation.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).