From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752679AbbKLMhg (ORCPT ); Thu, 12 Nov 2015 07:37:36 -0500 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:53000 "EHLO e06smtp12.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750946AbbKLMhW (ORCPT ); Thu, 12 Nov 2015 07:37:22 -0500 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: cornelia.huck@de.ibm.com X-IBM-RcptTo: kvm@vger.kernel.org;linux-kernel@vger.kernel.org;netdev@vger.kernel.org Date: Thu, 12 Nov 2015 13:37:14 +0100 From: Cornelia Huck To: Greg Kurz Cc: "Michael S. Tsirkin" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH] vhost: move is_le setup to the backend Message-ID: <20151112133714.58bd33dc.cornelia.huck@de.ibm.com> In-Reply-To: <20151030114235.28847.63465.stgit@bahia.huguette.org> References: <20151030114235.28847.63465.stgit@bahia.huguette.org> Organization: IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz =?UTF-8?B?R2VzY2jDpGZ0c2bDvGhydW5nOg==?= Dirk Wittkopp Sitz der Gesellschaft: =?UTF-8?B?QsO2Ymxpbmdlbg==?= Registergericht: Amtsgericht Stuttgart, HRB 243294 X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; i686-pc-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: 15111212-0009-0000-0000-000006A02CF2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Oct 2015 12:42:35 +0100 Greg Kurz wrote: > The vq->is_le field is used to fix endianness when accessing the vring via > the cpu_to_vhost16() and vhost16_to_cpu() helpers in the following cases: > > 1) host is big endian and device is modern virtio > > 2) host has cross-endian support and device is legacy virtio with a different > endianness than the host > > Both cases rely on the VHOST_SET_FEATURES ioctl, but 2) also needs the > VHOST_SET_VRING_ENDIAN ioctl to be called by userspace. Since vq->is_le > is only needed when the backend is active, it was decided to set it at > backend start. > > This is currently done in vhost_init_used()->vhost_init_is_le() but it > obfuscates the core vhost code. This patch moves the is_le setup to a > dedicated function that is called from the backend code. > > Note vhost_net is the only backend that can pass vq->private_data == NULL to > vhost_init_used(), hence the "if (sock)" branch. > > No behaviour change. > > Signed-off-by: Greg Kurz > --- > drivers/vhost/net.c | 6 ++++++ > drivers/vhost/scsi.c | 3 +++ > drivers/vhost/test.c | 2 ++ > drivers/vhost/vhost.c | 12 +++++++----- > drivers/vhost/vhost.h | 1 + > 5 files changed, 19 insertions(+), 5 deletions(-) Makes sense. Reviewed-by: Cornelia Huck From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cornelia Huck Subject: Re: [PATCH] vhost: move is_le setup to the backend Date: Thu, 12 Nov 2015 13:37:14 +0100 Message-ID: <20151112133714.58bd33dc.cornelia.huck@de.ibm.com> References: <20151030114235.28847.63465.stgit@bahia.huguette.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, "Michael S. Tsirkin" To: Greg Kurz Return-path: In-Reply-To: <20151030114235.28847.63465.stgit@bahia.huguette.org> 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 List-Id: netdev.vger.kernel.org On Fri, 30 Oct 2015 12:42:35 +0100 Greg Kurz wrote: > The vq->is_le field is used to fix endianness when accessing the vring via > the cpu_to_vhost16() and vhost16_to_cpu() helpers in the following cases: > > 1) host is big endian and device is modern virtio > > 2) host has cross-endian support and device is legacy virtio with a different > endianness than the host > > Both cases rely on the VHOST_SET_FEATURES ioctl, but 2) also needs the > VHOST_SET_VRING_ENDIAN ioctl to be called by userspace. Since vq->is_le > is only needed when the backend is active, it was decided to set it at > backend start. > > This is currently done in vhost_init_used()->vhost_init_is_le() but it > obfuscates the core vhost code. This patch moves the is_le setup to a > dedicated function that is called from the backend code. > > Note vhost_net is the only backend that can pass vq->private_data == NULL to > vhost_init_used(), hence the "if (sock)" branch. > > No behaviour change. > > Signed-off-by: Greg Kurz > --- > drivers/vhost/net.c | 6 ++++++ > drivers/vhost/scsi.c | 3 +++ > drivers/vhost/test.c | 2 ++ > drivers/vhost/vhost.c | 12 +++++++----- > drivers/vhost/vhost.h | 1 + > 5 files changed, 19 insertions(+), 5 deletions(-) Makes sense. Reviewed-by: Cornelia Huck