From patchwork Tue Jan 12 17:24:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 566640 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D57FD14031E for ; Wed, 13 Jan 2016 04:25:32 +1100 (AEDT) Received: from localhost ([::1]:33372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ2hG-000508-Qi for incoming@patchwork.ozlabs.org; Tue, 12 Jan 2016 12:25:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ2gp-0004Ge-3a for qemu-devel@nongnu.org; Tue, 12 Jan 2016 12:25:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJ2gk-0004k4-43 for qemu-devel@nongnu.org; Tue, 12 Jan 2016 12:25:03 -0500 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:57104) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ2gj-0004jo-QU for qemu-devel@nongnu.org; Tue, 12 Jan 2016 12:24:58 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Jan 2016 17:24:56 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 12 Jan 2016 17:24:54 -0000 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: gkurz@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org;mst@redhat.com Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id AB36B1B08067; Tue, 12 Jan 2016 17:24:55 +0000 (GMT) Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0CHOs9m131330; Tue, 12 Jan 2016 17:24:54 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E6865203D; Tue, 12 Jan 2016 16:23:47 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4B1BC52036; Tue, 12 Jan 2016 16:23:47 +0000 (GMT) Received: from bahia.lab.toulouse-stg.fr.ibm.com (bahia.lab.toulouse-stg.fr.ibm.com [9.101.4.41]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id D7E90220020; Tue, 12 Jan 2016 18:24:53 +0100 (CET) From: Greg Kurz To: "Michael S. Tsirkin" Date: Tue, 12 Jan 2016 18:24:53 +0100 Message-ID: <20160112172406.21438.53782.stgit@bahia.lab.toulouse-stg.fr.ibm.com> In-Reply-To: <20160112170912.21438.67163.stgit@bahia.lab.toulouse-stg.fr.ibm.com> References: <20160112170912.21438.67163.stgit@bahia.lab.toulouse-stg.fr.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16011217-0041-0000-0000-000006EA6934 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.106 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v3 5/6] vhost: simplify vhost_needs_vring_endian() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org After the call to virtio_vdev_has_feature(), we only care for legacy devices, so we don't need the extra check in virtio_is_big_endian(). Also the device_endian field is always set (VIRTIO_DEVICE_ENDIAN_UNKNOWN may only happen on a virtio_load() path that cannot lead here), so we don't need the assert() either. This open codes the device_endian checking in vhost_needs_vring_endian(). It also adds a comment to explain the logic, as recent reviews showed the cross-endian tweaks aren't that obvious. Signed-off-by: Greg Kurz --- hw/virtio/vhost.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index aef750df22ad..9609e2ef3af1 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -748,6 +748,11 @@ static void vhost_log_stop(MemoryListener *listener, /* FIXME: implement */ } +/* The vhost driver natively knows how to handle the vrings of non + * cross-endian legacy devices and modern devices. Only legacy devices + * exposed to a bi-endian guest may require the vhost driver to use a + * specific endianness. + */ static inline bool vhost_needs_vring_endian(VirtIODevice *vdev) { if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { @@ -755,9 +760,9 @@ static inline bool vhost_needs_vring_endian(VirtIODevice *vdev) } #ifdef TARGET_IS_BIENDIAN #ifdef HOST_WORDS_BIGENDIAN - return !virtio_is_big_endian(vdev); + return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_LITTLE; #else - return virtio_is_big_endian(vdev); + return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG; #endif #else return false;