From patchwork Fri Feb 5 10:46:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 579432 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 3D504140B8C for ; Fri, 5 Feb 2016 21:48:32 +1100 (AEDT) Received: from localhost ([::1]:47434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRdwE-0005wh-Bj for incoming@patchwork.ozlabs.org; Fri, 05 Feb 2016 05:48:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRduJ-0002Jy-Id for qemu-devel@nongnu.org; Fri, 05 Feb 2016 05:46:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRduG-0000s7-Av for qemu-devel@nongnu.org; Fri, 05 Feb 2016 05:46:31 -0500 Received: from e06smtp05.uk.ibm.com ([195.75.94.101]:38796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRduF-0000rj-WF for qemu-devel@nongnu.org; Fri, 05 Feb 2016 05:46:28 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 5 Feb 2016 10:46:26 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 5 Feb 2016 10:46:25 -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 b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id BA1941B0805F for ; Fri, 5 Feb 2016 10:46:36 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u15AkPNf56688652 for ; Fri, 5 Feb 2016 10:46:25 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u15AkPcI026445 for ; Fri, 5 Feb 2016 03:46:25 -0700 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u15AkNhI026349; Fri, 5 Feb 2016 03:46:24 -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 D5301220029; Fri, 5 Feb 2016 11:46:20 +0100 (CET) From: Greg Kurz To: "Michael S. Tsirkin" Date: Fri, 05 Feb 2016 11:46:18 +0100 Message-ID: <20160205104614.21017.35928.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-0021-0000-0000-000005B0310C X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.101 Cc: Cornelia Huck , Laurent Vivier , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v4 6/6] virtio: optimize virtio_access_is_big_endian() for little-endian targets 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 When adding cross-endian support, we introduced the TARGET_IS_BIENDIAN macro and the virtio_access_is_big_endian() helper to have a branchless fast path in the virtio memory accessors for targets that don't switch endian. This was considered as a strong requirement at the time. Now we have added a runtime check for virtio 1.0, which ruins the benefit of the virtio_access_is_big_endian() helper for always little-endian targets. With this patch, always little-endian targets stop checking for virtio 1.0, since the result is little-endian in all cases. Reviewed-by: Cornelia Huck Reviewed-by: Laurent Vivier Signed-off-by: Greg Kurz --- include/hw/virtio/virtio-access.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h index f1f12afe9089..8dc84f520316 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -19,13 +19,13 @@ static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) { +#if defined(TARGET_IS_BIENDIAN) + return virtio_is_big_endian(vdev); +#elif defined(TARGET_WORDS_BIGENDIAN) if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { /* Devices conforming to VIRTIO 1.0 or later are always LE. */ return false; } -#if defined(TARGET_IS_BIENDIAN) - return virtio_is_big_endian(vdev); -#elif defined(TARGET_WORDS_BIGENDIAN) return true; #else return false;