Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MqXh3-0002K1-Sm for qemu-devel@nongnu.org; Wed, 23 Sep 2009 15:40:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MqXgy-0002Af-1s for qemu-devel@nongnu.org; Wed, 23 Sep 2009 15:40:00 -0400 Received: from [199.232.76.173] (port=57989 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqXgx-0002AF-R6 for qemu-devel@nongnu.org; Wed, 23 Sep 2009 15:39:55 -0400 Received: from mail-fx0-f214.google.com ([209.85.220.214]:44676) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MqXgw-0005rZ-Vo for qemu-devel@nongnu.org; Wed, 23 Sep 2009 15:39:55 -0400 Received: by fxm10 with SMTP id 10so897904fxm.8 for ; Wed, 23 Sep 2009 12:39:52 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=[192.168.1.2]) by skyserv with esmtp (Exim 4.69) (envelope-from ) id 1MqXgt-00035u-5W for qemu-devel@nongnu.org; Wed, 23 Sep 2009 23:39:51 +0400 From: Igor V. Kovalenko Date: Wed, 23 Sep 2009 23:39:51 +0400 Message-ID: <20090923193950.11868.90296.stgit@skyserv> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] sparc64-8bit-asi List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Sparc64 alternate space load/store helpers expect 8 bit ASI value, while wrasi implementation sign-extends ASI operand causing for example 0x80 to appear as 0xFFFFFF80. Resulting value falls out of switch in helpers and causes obscure load/store faults. - correct wrasi by masking lower 8 bits of xor result - use lower 8 bits of ASI register in helpers Signed-off-by: Igor V. Kovalenko --- target-sparc/op_helper.c | 5 +++++ target-sparc/translate.c | 1 + 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c index a9558da..8992d1c 100644 --- a/target-sparc/op_helper.c +++ b/target-sparc/op_helper.c @@ -2112,6 +2112,8 @@ uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign) target_ulong last_addr = addr; #endif + asi &= 0xff; + if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) || ((env->def->features & CPU_FEATURE_HYPV) && asi >= 0x30 && asi < 0x80 @@ -2406,6 +2408,9 @@ void helper_st_asi(target_ulong addr, target_ulong val, int asi, int size) #ifdef DEBUG_ASI dump_asi("write", addr, asi, size, val); #endif + + asi &= 0xff; + if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) || ((env->def->features & CPU_FEATURE_HYPV) && asi >= 0x30 && asi < 0x80 diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 928aa61..bf6df50 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -3152,6 +3152,7 @@ static void disas_sparc_insn(DisasContext * dc) break; case 0x3: /* V9 wrasi */ tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); + tcg_gen_andi_tl(cpu_dst, cpu_dst, 0xff); tcg_gen_trunc_tl_i32(cpu_asi, cpu_dst); break; case 0x6: /* V9 wrfprs */