From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759302AbcAUJzx (ORCPT ); Thu, 21 Jan 2016 04:55:53 -0500 Received: from e06smtp08.uk.ibm.com ([195.75.94.104]:42953 "EHLO e06smtp08.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759272AbcAUJzr (ORCPT ); Thu, 21 Jan 2016 04:55:47 -0500 X-IBM-Helo: d06dlp01.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, 21 Jan 2016 10:55:39 +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 1/2] vhost: helpers to enable/disable vring endianness Message-ID: <20160121105539.63093cb6.cornelia.huck@de.ibm.com> In-Reply-To: <20160113170941.23705.93915.stgit@bahia.huguette.org> References: <20160113170934.23705.62626.stgit@bahia.huguette.org> <20160113170941.23705.93915.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: 16012109-0033-0000-0000-00000575DE68 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Jan 2016 18:09:41 +0100 Greg Kurz wrote: > The default use case for vhost is when the host and the vring have the > same endianness (default native endianness). But there are cases where > they differ and vhost should byteswap when accessing the vring: > - the host is big endian and the vring comes from a virtio 1.0 device > which is always little endian > - the architecture is bi-endian and the vring comes from a legacy virtio > device with a different endianness than the endianness of the host (aka > legacy cross-endian) > > These cases are handled by the vq->is_le and the optional vq->user_be, > with the following logic: > - if none of the fields is enabled, vhost access the vring without byteswap > - if the vring is virtio 1.0 and the host is big endian, vq->is_le is > enabled to enforce little endian access to the vring > - if the vring is legacy cross-endian, userspace enables vq->user_be > to inform vhost about the vring endianness. This endianness is then > enforced for vring accesses through vq->is_le again > > The logic is unclear in the current code. > > This patch introduces helpers with explicit enable and disable semantics, > for better clarity. > > No behaviour change. > > Signed-off-by: Greg Kurz > --- > drivers/vhost/vhost.c | 28 +++++++++++++++++++--------- > 1 file changed, 19 insertions(+), 9 deletions(-) Reviewed-by: Cornelia Huck