From patchwork Fri Feb 5 10:46:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 8233451 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C6AE9FB33 for ; Fri, 5 Feb 2016 10:47:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DF5320397 for ; Fri, 5 Feb 2016 10:47:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 590AE20390 for ; Fri, 5 Feb 2016 10:47:23 +0000 (UTC) Received: from localhost ([::1]:47423 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRdv8-0003ak-Qp for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 Feb 2016 05:47:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRdu5-0001w4-4g for qemu-devel@nongnu.org; Fri, 05 Feb 2016 05:46:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRdu1-0000q3-TQ for qemu-devel@nongnu.org; Fri, 05 Feb 2016 05:46:17 -0500 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:56058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRdu1-0000pz-KK for qemu-devel@nongnu.org; Fri, 05 Feb 2016 05:46:13 -0500 Received: from localhost by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 5 Feb 2016 10:46:12 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 5 Feb 2016 10:46:10 -0000 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: gkurz@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id A9EF11B08067 for ; Fri, 5 Feb 2016 10:46:21 +0000 (GMT) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u15AkA4f10879412 for ; Fri, 5 Feb 2016 10:46:10 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u15AkAVs012236 for ; Fri, 5 Feb 2016 03:46:10 -0700 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u15Ak9RM012223; Fri, 5 Feb 2016 03:46:09 -0700 Received: from bahia.huguette.org (sig-9-84-79-61.evts.de.ibm.com [9.84.79.61]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 4033B220029; Fri, 5 Feb 2016 11:46:08 +0100 (CET) From: Greg Kurz To: "Michael S. Tsirkin" Date: Fri, 05 Feb 2016 11:46:04 +0100 Message-ID: <20160205104559.21017.3686.stgit@bahia.huguette.org> In-Reply-To: <20160205103927.21017.26364.stgit@bahia.huguette.org> References: <20160205103927.21017.26364.stgit@bahia.huguette.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16020510-0025-0000-0000-000008D9CF21 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.112 Cc: Cornelia Huck , Laurent Vivier , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v4 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Cornelia Huck Reviewed-by: Laurent Vivier --- 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 bb17177f5e7e..9f8ac38ccf2d 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -749,6 +749,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)) { @@ -756,9 +761,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;