From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiADz-000537-BX for qemu-devel@nongnu.org; Thu, 30 May 2013 17:17:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiADu-0006I1-Mj for qemu-devel@nongnu.org; Thu, 30 May 2013 17:17:31 -0400 Received: from mail-ea0-x234.google.com ([2a00:1450:4013:c01::234]:45425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiADu-0006Hv-Fy for qemu-devel@nongnu.org; Thu, 30 May 2013 17:17:26 -0400 Received: by mail-ea0-f180.google.com with SMTP id g10so875076eak.25 for ; Thu, 30 May 2013 14:17:25 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 30 May 2013 23:16:51 +0200 Message-Id: <1369948629-2833-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1369948629-2833-1-git-send-email-pbonzini@redhat.com> References: <1369948629-2833-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 03/21] exec: Allow unaligned address_space_rw List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jan Kiszka From: Jan Kiszka This will be needed for some corner cases with para-virtual I/O ports. Signed-off-by: Jan Kiszka Signed-off-by: Paolo Bonzini --- exec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index bae4d30..5556169 100644 --- a/exec.c +++ b/exec.c @@ -1913,12 +1913,12 @@ static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write) return false; } -static inline int memory_access_size(int l, hwaddr addr) +static inline int memory_access_size(MemoryRegion *mr, int l, hwaddr addr) { - if (l >= 4 && ((addr & 3) == 0)) { + if (l >= 4 && (((addr & 3) == 0 || mr->ops->impl.unaligned))) { return 4; } - if (l >= 2 && ((addr & 1) == 0)) { + if (l >= 2 && (((addr & 1) == 0) || mr->ops->impl.unaligned)) { return 2; } return 1; @@ -1940,7 +1940,7 @@ bool address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, if (is_write) { if (!memory_access_is_direct(section->mr, is_write)) { - l = memory_access_size(l, addr1); + l = memory_access_size(section->mr, l, addr1); /* XXX: could force cpu_single_env to NULL to avoid potential bugs */ if (l == 4) { @@ -1966,7 +1966,7 @@ bool address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, } else { if (!memory_access_is_direct(section->mr, is_write)) { /* I/O case */ - l = memory_access_size(l, addr1); + l = memory_access_size(section->mr, l, addr1); if (l == 4) { /* 32 bit read access */ error |= io_mem_read(section->mr, addr1, &val, 4); @@ -2097,7 +2097,7 @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_ l = len; section = address_space_translate(as, addr, &xlat, &l, is_write); if (!memory_access_is_direct(section->mr, is_write)) { - l = memory_access_size(l, addr); + l = memory_access_size(section->mr, l, addr); if (!memory_region_access_valid(section->mr, xlat, l, is_write)) { return false; } -- 1.8.1.4