From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTWdt-0002jo-I8 for qemu-devel@nongnu.org; Fri, 28 Mar 2014 09:16:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTWdp-0008HV-6a for qemu-devel@nongnu.org; Fri, 28 Mar 2014 09:16:17 -0400 Received: from mail-pd0-x22b.google.com ([2607:f8b0:400e:c02::22b]:46597) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTWdp-0008HK-05 for qemu-devel@nongnu.org; Fri, 28 Mar 2014 09:16:13 -0400 Received: by mail-pd0-f171.google.com with SMTP id r10so4833739pdi.2 for ; Fri, 28 Mar 2014 06:16:12 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Fri, 28 Mar 2014 09:16:07 -0400 Message-Id: <1396012567-23937-2-git-send-email-rth@twiddle.net> In-Reply-To: <1396012567-23937-1-git-send-email-rth@twiddle.net> References: <1396012567-23937-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PULL for-2.0] tcg-arm: Avoid ldrd/strd for user-only emulation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org The arm ldrd/strd insns must cause alignment traps, whereas at least for armv7 ldr/str must handle unaligned operations. While this is hardly the only problem facing user-only emu, this solves one problem for i386 on armv7 emulation. Reviewed-by: Peter Maydell Reported-by: Huw Davies Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c index c8884b3..a65fc65 100644 --- a/tcg/arm/tcg-target.c +++ b/tcg/arm/tcg-target.c @@ -60,6 +60,13 @@ static int arm_arch = __ARM_ARCH; bool use_idiv_instructions; #endif +/* ??? Ought to think about changing CONFIG_SOFTMMU to always defined. */ +#ifdef CONFIG_SOFTMMU +# define USING_SOFTMMU 1 +#else +# define USING_SOFTMMU 0 +#endif + #ifndef NDEBUG static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { "%r0", @@ -1404,7 +1411,9 @@ static inline void tcg_out_qemu_ld_index(TCGContext *s, TCGMemOp opc, TCGReg dl = (bswap ? datahi : datalo); TCGReg dh = (bswap ? datalo : datahi); - if (use_armv6_instructions && (dl & 1) == 0 && dh == dl + 1) { + /* Avoid ldrd for user-only emulation, to handle unaligned. */ + if (USING_SOFTMMU && use_armv6_instructions + && (dl & 1) == 0 && dh == dl + 1) { tcg_out_ldrd_r(s, COND_AL, dl, addrlo, addend); } else if (dl != addend) { tcg_out_ld32_rwb(s, COND_AL, dl, addend, addrlo); @@ -1463,7 +1472,9 @@ static inline void tcg_out_qemu_ld_direct(TCGContext *s, TCGMemOp opc, TCGReg dl = (bswap ? datahi : datalo); TCGReg dh = (bswap ? datalo : datahi); - if (use_armv6_instructions && (dl & 1) == 0 && dh == dl + 1) { + /* Avoid ldrd for user-only emulation, to handle unaligned. */ + if (USING_SOFTMMU && use_armv6_instructions + && (dl & 1) == 0 && dh == dl + 1) { tcg_out_ldrd_8(s, COND_AL, dl, addrlo, 0); } else if (dl == addrlo) { tcg_out_ld32_12(s, COND_AL, dh, addrlo, bswap ? 0 : 4); @@ -1548,12 +1559,13 @@ static inline void tcg_out_qemu_st_index(TCGContext *s, int cond, TCGMemOp opc, } break; case MO_64: + /* Avoid strd for user-only emulation, to handle unaligned. */ if (bswap) { tcg_out_bswap32(s, cond, TCG_REG_R0, datahi); tcg_out_st32_rwb(s, cond, TCG_REG_R0, addend, addrlo); tcg_out_bswap32(s, cond, TCG_REG_R0, datalo); tcg_out_st32_12(s, cond, TCG_REG_R0, addend, 4); - } else if (use_armv6_instructions + } else if (USING_SOFTMMU && use_armv6_instructions && (datalo & 1) == 0 && datahi == datalo + 1) { tcg_out_strd_r(s, cond, datalo, addrlo, addend); } else { @@ -1592,12 +1604,13 @@ static inline void tcg_out_qemu_st_direct(TCGContext *s, TCGMemOp opc, } break; case MO_64: + /* Avoid strd for user-only emulation, to handle unaligned. */ if (bswap) { tcg_out_bswap32(s, COND_AL, TCG_REG_R0, datahi); tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addrlo, 0); tcg_out_bswap32(s, COND_AL, TCG_REG_R0, datalo); tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addrlo, 4); - } else if (use_armv6_instructions + } else if (USING_SOFTMMU && use_armv6_instructions && (datalo & 1) == 0 && datahi == datalo + 1) { tcg_out_strd_8(s, COND_AL, datalo, addrlo, 0); } else { -- 1.8.3.1