Received: from eggs.gnu.org ([208.118.235.92]:46124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfvS6-0007Cf-9P for qemu-devel@nongnu.org; Fri, 24 May 2013 13:06:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfvS1-00027m-FX for qemu-devel@nongnu.org; Fri, 24 May 2013 13:06:50 -0400 Received: from mail-ee0-f43.google.com ([74.125.83.43]:62446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfvS1-00027b-26 for qemu-devel@nongnu.org; Fri, 24 May 2013 13:06:45 -0400 Received: by mail-ee0-f43.google.com with SMTP id d41so2746456eek.30 for ; Fri, 24 May 2013 10:06:44 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 24 May 2013 19:05:54 +0200 Message-Id: <1369415157-8953-20-git-send-email-pbonzini@redhat.com> In-Reply-To: <1369415157-8953-1-git-send-email-pbonzini@redhat.com> References: <1369415157-8953-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 Cc: peter.maydell@linaro.org 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 17a3292..42f7636 100644 --- a/exec.c +++ b/exec.c @@ -2260,9 +2260,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); @@ -2270,6 +2267,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 728a6c5..c9833a3 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.8.1.4