File 0115-exec-introduce-target_words_bigendi.patch of Package qemu.6354

From 3b57806db191d3f9af516fa1ab388a98f898f2b3 Mon Sep 17 00:00:00 2001
From: Greg Kurz <gkurz@linux.vnet.ibm.com>
Date: Tue, 24 Jun 2014 19:26:29 +0200
Subject: [PATCH] exec: introduce target_words_bigendian() helper

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 <gkurz@linux.vnet.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 98ed8ecfc9dd9e22e4251251492f062dde32c3c4)
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 exec.c                     | 8 ++------
 hw/virtio/virtio-pci.c     | 3 ---
 include/hw/virtio/virtio.h | 6 ++++++
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/exec.c b/exec.c
index 36b5ef6e96..76d4755f31 100644
--- a/exec.c
+++ b/exec.c
@@ -2741,14 +2741,12 @@ 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);
+bool target_words_bigendian(void)
 {
 #if defined(TARGET_WORDS_BIGENDIAN)
     return true;
@@ -2757,8 +2755,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 ce97514b69..390c8d2dde 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/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 3505ce511e..9000ee2f50 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -255,4 +255,10 @@ 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);
+
+bool target_words_bigendian(void);
+static inline bool virtio_is_big_endian(void)
+{
+    return target_words_bigendian();
+}
 #endif
openSUSE Build Service is sponsored by