From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753302AbbDHHg5 (ORCPT ); Wed, 8 Apr 2015 03:36:57 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:41977 "EHLO e06smtp13.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752906AbbDHHgz (ORCPT ); Wed, 8 Apr 2015 03:36:55 -0400 Date: Wed, 8 Apr 2015 09:36:38 +0200 From: Greg Kurz To: Cornelia Huck Cc: Rusty Russell , "Michael S. Tsirkin" , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v3 7/7] vhost: feature to set the vring endianness Message-ID: <20150408093638.7a233137@bahia.local> In-Reply-To: <20150407170131.3899d62c.cornelia.huck@de.ibm.com> References: <20150407120929.4213.8225.stgit@bahia.lab.toulouse-stg.fr.ibm.com> <20150407121557.4213.95569.stgit@bahia.lab.toulouse-stg.fr.ibm.com> <20150407170131.3899d62c.cornelia.huck@de.ibm.com> Organization: IBM X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.27; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15040807-0013-0000-0000-00000391E43A Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 7 Apr 2015 17:01:31 +0200 Cornelia Huck wrote: > On Tue, 07 Apr 2015 14:19:31 +0200 > Greg Kurz 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 > > --- > > 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 */ From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg Kurz Subject: Re: [PATCH v3 7/7] vhost: feature to set the vring endianness Date: Wed, 8 Apr 2015 09:36:38 +0200 Message-ID: <20150408093638.7a233137@bahia.local> References: <20150407120929.4213.8225.stgit@bahia.lab.toulouse-stg.fr.ibm.com> <20150407121557.4213.95569.stgit@bahia.lab.toulouse-stg.fr.ibm.com> <20150407170131.3899d62c.cornelia.huck@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150407170131.3899d62c.cornelia.huck@de.ibm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Cornelia Huck Cc: kvm@vger.kernel.org, "Michael S. Tsirkin" , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org List-Id: linux-api@vger.kernel.org On Tue, 7 Apr 2015 17:01:31 +0200 Cornelia Huck wrote: > On Tue, 07 Apr 2015 14:19:31 +0200 > Greg Kurz 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 > > --- > > 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 */