From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWKgy-00020U-DB for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:11:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWKgu-0006Yg-9m for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:11:36 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:38275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWKgu-0006YG-1E for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:11:32 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Mar 2015 08:11:31 -0000 From: Greg Kurz Date: Fri, 13 Mar 2015 09:11:25 +0100 Message-ID: <20150313081125.4669.92074.stgit@bahia.local> In-Reply-To: <20150313090312.742d135c@bahia.local> References: <20150313090312.742d135c@bahia.local> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 2/2] memory: fix the eventfd data endianness according to the host List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Cedric Le Goater , "Michael S. Tsirkin" , qemu-stable@nongnu.org, Michael Roth The data argument is a host entity. It is not related to the target endianness. Let's introduce a HOST_WORDS_BIGENDIAN based helper for that. This patch fixes ioeventfd and vhost for a ppc64le host running a ppc64le guest (only virtqueue 0 was handled, all others being byteswapped because of TARGET_WORDS_BIGENDIAN). It doesn't change functionnality for fixed endian architectures (i.e. doesn't break x86). Reported-by: Cédric Le Goater Signed-off-by: Greg Kurz --- memory.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/memory.c b/memory.c index 6291cc0..1e29d40 100644 --- a/memory.c +++ b/memory.c @@ -1549,6 +1549,15 @@ void memory_region_clear_flush_coalesced(MemoryRegion *mr) } } +static bool eventfd_wrong_endianness(MemoryRegion *mr) +{ +#ifdef HOST_WORDS_BIGENDIAN + return mr->ops->endianness == DEVICE_LITTLE_ENDIAN; +#else + return mr->ops->endianness == DEVICE_BIG_ENDIAN; +#endif +} + void memory_region_add_eventfd(MemoryRegion *mr, hwaddr addr, unsigned size, @@ -1565,7 +1574,7 @@ void memory_region_add_eventfd(MemoryRegion *mr, }; unsigned i; - adjust_endianness(&mrfd.data, size, memory_region_wrong_endianness(mr)); + adjust_endianness(&mrfd.data, size, eventfd_wrong_endianness(mr)); memory_region_transaction_begin(); for (i = 0; i < mr->ioeventfd_nb; ++i) { if (memory_region_ioeventfd_before(mrfd, mr->ioeventfds[i])) { @@ -1598,7 +1607,7 @@ void memory_region_del_eventfd(MemoryRegion *mr, }; unsigned i; - adjust_endianness(&mrfd.data, size, memory_region_wrong_endianness(mr)); + adjust_endianness(&mrfd.data, size, eventfd_wrong_endianness(mr)); memory_region_transaction_begin(); for (i = 0; i < mr->ioeventfd_nb; ++i) { if (memory_region_ioeventfd_equal(mrfd, mr->ioeventfds[i])) {