From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932320AbcCBB1r (ORCPT ); Tue, 1 Mar 2016 20:27:47 -0500 Received: from foss.arm.com ([217.140.101.70]:55788 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755352AbcCBB1n (ORCPT ); Tue, 1 Mar 2016 20:27:43 -0500 Date: Wed, 2 Mar 2016 01:27:54 +0000 From: Will Deacon To: Andre Przywara Cc: Sasha Levin , Pekka Enberg , kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] virtio: fix endianness check for vhost support Message-ID: <20160302012753.GF14022@arm.com> References: <1456850978-14091-1-git-send-email-andre.przywara@arm.com> <1456850978-14091-4-git-send-email-andre.przywara@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1456850978-14091-4-git-send-email-andre.przywara@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 01, 2016 at 04:49:38PM +0000, Andre Przywara wrote: > Currently we deny any VHOST_* functionality if the architecture > supports guests with different endianness than the host. Most of the > time even on those architectures the endianness of guest and host are > the same, though, so we are denying the glory of VHOST needlessly. > Switch from compile time determination to a run time scheme, which > takes the actual endianness of the guest into account. > For this we change the semantics of VIRTIO_ENDIAN_HOST to return the > actual endianness of the host (the endianness of kvmtool at compile > time, really). The actual check in vhost_net now compares this against > the guest endianness. > This enables vhost support on ARM and ARM64. > > Signed-off-by: Andre Przywara > --- > include/kvm/virtio.h | 9 +++++++-- > virtio/net.c | 2 +- > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/include/kvm/virtio.h b/include/kvm/virtio.h > index 768ee96..66530fd 100644 > --- a/include/kvm/virtio.h > +++ b/include/kvm/virtio.h > @@ -17,10 +17,15 @@ > #define VIRTIO_PCI_O_CONFIG 0 > #define VIRTIO_PCI_O_MSIX 1 > > -#define VIRTIO_ENDIAN_HOST 0 > #define VIRTIO_ENDIAN_LE (1 << 0) > #define VIRTIO_ENDIAN_BE (1 << 1) > > +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > +#define VIRTIO_ENDIAN_HOST VIRTIO_ENDIAN_LE > +#else > +#define VIRTIO_ENDIAN_HOST VIRTIO_ENDIAN_BE > +#endif pci.h already uses __BYTE_ORDER and __LITTLE_ENDIAN, so we should at least be consistent here. Will