From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvPYk-0004fG-Vj for qemu-devel@nongnu.org; Fri, 13 Jun 2014 07:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WvPYZ-0003xa-Jw for qemu-devel@nongnu.org; Fri, 13 Jun 2014 07:22:14 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:38472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvPYZ-0003xO-29 for qemu-devel@nongnu.org; Fri, 13 Jun 2014 07:22:03 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Jun 2014 12:22:02 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7064B1B08041 for ; Fri, 13 Jun 2014 12:22:27 +0100 (BST) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5DBM0lt35127352 for ; Fri, 13 Jun 2014 11:22:00 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5DBLuFF026680 for ; Fri, 13 Jun 2014 05:21:59 -0600 From: Greg Kurz Date: Fri, 13 Jun 2014 13:21:53 +0200 Message-ID: <20140613112145.22108.98246.stgit@bahia.local> In-Reply-To: <20140613111703.22108.14322.stgit@bahia.local> References: <20140613111703.22108.14322.stgit@bahia.local> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH v8 09/20] exec: introduce target_words_bigendian() helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Stefan Hajnoczi , Juan Quintela , Rusty Russell , Alexander Graf , "Michael S. Tsirkin" , aneesh.kumar@linux.vnet.ibm.com, Anthony Liguori , Amit Shah , Paolo Bonzini , Andreas =?utf-8?q?F=C3=A4rber?= We currently have a virtio_is_big_endian() helper that provides the target endianness to the virtio code. As of today, the helper returns a fixed compile-time value. Of course, this will have to change if we want to support target endianness changes at run-time. Let's move the TARGET_WORDS_BIGENDIAN bits out to a new helper and have virtio_is_big_endian() implemented on top of it. This patch doesn't change any functionality. Signed-off-by: Greg Kurz --- exec.c | 11 +---------- hw/virtio/virtio-pci.c | 3 --- include/exec/cpu-common.h | 1 + include/hw/virtio/virtio.h | 5 +++++ 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/exec.c b/exec.c index 4e179a6..a7d4431 100644 --- a/exec.c +++ b/exec.c @@ -2738,14 +2738,7 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, } #endif -#if !defined(CONFIG_USER_ONLY) - -/* - * A helper function for the _utterly broken_ virtio device model to find out if - * it's running on a big endian machine. Don't do this at home kids! - */ -bool virtio_is_big_endian(void); -bool virtio_is_big_endian(void) +bool target_words_bigendian(void) { #if defined(TARGET_WORDS_BIGENDIAN) return true; @@ -2754,8 +2747,6 @@ bool virtio_is_big_endian(void) #endif } -#endif - #ifndef CONFIG_USER_ONLY bool cpu_physical_memory_is_io(hwaddr phys_addr) { diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index ce97514..390c8d2 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -89,9 +89,6 @@ /* Flags track per-device state like workarounds for quirks in older guests. */ #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG (1 << 0) -/* HACK for virtio to determine if it's running a big endian guest */ -bool virtio_is_big_endian(void); - static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size, VirtIOPCIProxy *dev); diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index a21b65a..eb798c1 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -122,4 +122,5 @@ void qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque); #endif +bool target_words_bigendian(void); #endif /* !CPU_COMMON_H */ diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 3505ce5..daf0bb2 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -255,4 +255,9 @@ void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign, bool set_handler); void virtio_queue_notify_vq(VirtQueue *vq); void virtio_irq(VirtQueue *vq); + +static inline bool virtio_is_big_endian(void) +{ + return target_words_bigendian(); +} #endif