linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <gkurz@linux.vnet.ibm.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: kvm@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>,
	linux-api@vger.kernel.org, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v3 7/7] vhost: feature to set the vring endianness
Date: Wed, 8 Apr 2015 09:36:38 +0200	[thread overview]
Message-ID: <20150408093638.7a233137@bahia.local> (raw)
In-Reply-To: <20150407170131.3899d62c.cornelia.huck@de.ibm.com>

On Tue, 7 Apr 2015 17:01:31 +0200
Cornelia Huck <cornelia.huck@de.ibm.com> wrote:

> On Tue, 07 Apr 2015 14:19:31 +0200
> Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:
> 
> > This patch brings cross-endian support to vhost when used to implement
> > legacy virtio devices. Since it is a relatively rare situation, the
> > feature availability is controlled by a kernel config option (not set
> > by default).
> > 
> > The ioctls introduced by this patch are for legacy only: virtio 1.0
> > devices are returned EPERM.
> > 
> > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> > ---
> >  drivers/vhost/Kconfig      |   10 ++++++++
> >  drivers/vhost/vhost.c      |   55 ++++++++++++++++++++++++++++++++++++++++++++
> >  drivers/vhost/vhost.h      |   17 +++++++++++++-
> >  include/uapi/linux/vhost.h |    5 ++++
> >  4 files changed, 86 insertions(+), 1 deletion(-)
> 
> > +#ifdef CONFIG_VHOST_SET_ENDIAN_LEGACY
> > +static long vhost_set_vring_endian_legacy(struct vhost_virtqueue *vq,
> > +					  void __user *argp)
> > +{
> > +	struct vhost_vring_state s;
> > +
> > +	if (vhost_has_feature(vq, VIRTIO_F_VERSION_1))
> > +		return -EPERM;
> > +
> > +	if (copy_from_user(&s, argp, sizeof(s)))
> > +		return -EFAULT;
> > +
> > +	vq->legacy_is_little_endian = !!s.num;
> > +	return 0;
> > +}
> > +
> > +static long vhost_get_vring_endian_legacy(struct vhost_virtqueue *vq,
> > +					  u32 idx,
> > +					  void __user *argp)
> > +{
> > +	struct vhost_vring_state s = {
> > +		.index = idx,
> > +		.num = vq->legacy_is_little_endian
> > +	};
> > +
> > +	if (vhost_has_feature(vq, VIRTIO_F_VERSION_1))
> > +		return -EPERM;
> > +
> > +	if (copy_to_user(argp, &s, sizeof(s)))
> > +		return -EFAULT;
> > +
> > +	return 0;
> > +}
> > +#else
> > +static long vhost_set_vring_endian_legacy(struct vhost_virtqueue *vq,
> > +					  void __user *argp)
> > +{
> > +	return 0;
> 
> I'm wondering whether this handler should return an error if the
> feature is not configured for the kernel? How can the userspace caller
> find out whether it has successfully prompted the kernel to handle the
> endianness correctly?
> 

Yes you're right. I think -ENOIOCTLCMD as suggested by Michael is a good
candidate.

Thanks.

> > +}
> > +
> > +static long vhost_get_vring_endian_legacy(struct vhost_virtqueue *vq,
> > +					  u32 idx,
> > +					  void __user *argp)
> > +{
> > +	return 0;
> > +}
> > +#endif /* CONFIG_VHOST_SET_ENDIAN_LEGACY */

  reply	other threads:[~2015-04-08  7:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 12:09 [PATCH v3 0/7] vhost: support for cross endian guests Greg Kurz
2015-04-07 12:09 ` [PATCH v3 1/7] virtio: introduce virtio_is_little_endian() helper Greg Kurz
2015-04-07 12:09 ` [PATCH v3 2/7] tun: add tun_is_little_endian() helper Greg Kurz
2015-04-07 12:09 ` [PATCH v3 3/7] macvtap: introduce macvtap_is_little_endian() helper Greg Kurz
2015-04-07 12:15 ` [PATCH v3 4/7] vringh: introduce vringh_is_little_endian() helper Greg Kurz
2015-04-07 12:15 ` [PATCH v3 5/7] vhost: introduce vhost_is_little_endian() helper Greg Kurz
2015-04-07 12:19 ` [PATCH v3 7/7] vhost: feature to set the vring endianness Greg Kurz
     [not found]   ` <20150407121557.4213.95569.stgit-to6p26YowclJmDnNpxttO7KMsZMIf1jtdfLczzV0R5oAvxtiuMwx3w@public.gmane.org>
2015-04-07 15:01     ` Cornelia Huck
2015-04-08  7:36       ` Greg Kurz [this message]
2015-04-07 15:52     ` Michael S. Tsirkin
2015-04-08  8:23       ` Greg Kurz
2015-04-07 16:11   ` Michael S. Tsirkin
2015-04-08  8:25     ` Greg Kurz
     [not found] ` <20150407120929.4213.8225.stgit-to6p26YowclJmDnNpxttO7KMsZMIf1jtdfLczzV0R5oAvxtiuMwx3w@public.gmane.org>
2015-04-07 12:15   ` [PATCH v3 6/7] virtio: add explicit big-endian support to memory accessors Greg Kurz
2015-04-07 15:56     ` Michael S. Tsirkin
     [not found]       ` <20150407175522-mutt-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-04-21  7:47         ` Greg Kurz
2015-04-07 15:55   ` [PATCH v3 0/7] vhost: support for cross endian guests Michael S. Tsirkin
     [not found]     ` <20150407175443-mutt-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-04-07 16:08       ` Greg Kurz

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=20150408093638.7a233137@bahia.local \
    --to=gkurz@linux.vnet.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.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).