Received: from eggs.gnu.org ([2001:4830:134:3::10]:36659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiA1e-000428-G8 for qemu-devel@nongnu.org; Thu, 30 May 2013 17:04:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiA1Z-0001kh-TE for qemu-devel@nongnu.org; Thu, 30 May 2013 17:04:46 -0400 Received: from mail-ea0-x229.google.com ([2a00:1450:4013:c01::229]:35604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiA1Z-0001kb-M7 for qemu-devel@nongnu.org; Thu, 30 May 2013 17:04:41 -0400 Received: by mail-ea0-f169.google.com with SMTP id m14so869828eaj.28 for ; Thu, 30 May 2013 14:04:41 -0700 (PDT) Received: from playground.lan (net-37-116-217-184.cust.dsl.vodafone.it. [37.116.217.184]) by mx.google.com with ESMTPSA id y2sm62707218eeu.2.2013.05.30.14.04.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 30 May 2013 14:04:40 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 30 May 2013 23:03:53 +0200 Message-Id: <1369947836-2638-20-git-send-email-pbonzini@redhat.com> In-Reply-To: <1369947836-2638-1-git-send-email-pbonzini@redhat.com> References: <1369947836-2638-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 19/22] memory: correctly handle endian-swapped 64-bit accesses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- exec.c | 12 +++++++++--- memory.c | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/exec.c b/exec.c index 1c4c466..453946e 100644 --- a/exec.c +++ b/exec.c @@ -2263,9 +2263,6 @@ static inline uint64_t ldq_phys_internal(hwaddr addr, false); if (l < 8 || !memory_access_is_direct(section->mr, false)) { /* I/O case */ - - /* XXX This is broken when device endian != cpu endian. - Fix and add "endian" variable check */ #ifdef TARGET_WORDS_BIGENDIAN val = io_mem_read(section->mr, addr1, 4) << 32; val |= io_mem_read(section->mr, addr1 + 4, 4); @@ -2273,6 +2270,15 @@ static inline uint64_t ldq_phys_internal(hwaddr addr, val = io_mem_read(section->mr, addr1, 4); val |= io_mem_read(section->mr, addr1 + 4, 4) << 32; #endif +#if defined(TARGET_WORDS_BIGENDIAN) + if (endian == DEVICE_LITTLE_ENDIAN) { + val = bswap64(val); + } +#else + if (endian == DEVICE_BIG_ENDIAN) { + val = bswap64(val); + } +#endif } else { /* RAM case */ ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr) diff --git a/memory.c b/memory.c index ca27102..f84fc53 100644 --- a/memory.c +++ b/memory.c @@ -957,6 +957,9 @@ static void adjust_endianness(MemoryRegion *mr, uint64_t *data, unsigned size) case 4: *data = bswap32(*data); break; + case 8: + *data = bswap64(*data); + break; default: abort(); } -- 1.7.4.1