Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L8woy-00040h-Ce for qemu-devel@nongnu.org; Sat, 06 Dec 2008 08:03:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L8wov-0003zk-LN for qemu-devel@nongnu.org; Sat, 06 Dec 2008 08:03:42 -0500 Received: from [199.232.76.173] (port=45837 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8wot-0003zO-Hj for qemu-devel@nongnu.org; Sat, 06 Dec 2008 08:03:40 -0500 Received: from savannah.gnu.org ([199.232.41.3]:43147 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L8wor-0000nM-Pv for qemu-devel@nongnu.org; Sat, 06 Dec 2008 08:03:38 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L8woq-0000Nr-R2 for qemu-devel@nongnu.org; Sat, 06 Dec 2008 13:03:36 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L8woq-0000Nl-BC for qemu-devel@nongnu.org; Sat, 06 Dec 2008 13:03:36 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Sat, 06 Dec 2008 13:03:36 +0000 Subject: [Qemu-devel] [5892] target-ppc: convert msr load/store to TCG Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5892 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5892 Author: aurel32 Date: 2008-12-06 13:03:35 +0000 (Sat, 06 Dec 2008) Log Message: ----------- target-ppc: convert msr load/store to TCG Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/target-ppc/helper.h trunk/target-ppc/op.c trunk/target-ppc/op_helper.c trunk/target-ppc/op_helper.h trunk/target-ppc/translate.c Modified: trunk/target-ppc/helper.h =================================================================== --- trunk/target-ppc/helper.h 2008-12-06 12:19:14 UTC (rev 5891) +++ trunk/target-ppc/helper.h 2008-12-06 13:03:35 UTC (rev 5892) @@ -7,6 +7,7 @@ DEF_HELPER_3(td, void, tl, tl, i32) #endif #if !defined(CONFIG_USER_ONLY) +DEF_HELPER_1(store_msr, void, tl) DEF_HELPER_0(rfi, void) DEF_HELPER_0(rfsvc, void) DEF_HELPER_0(40x_rfci, void) Modified: trunk/target-ppc/op.c =================================================================== --- trunk/target-ppc/op.c 2008-12-06 12:19:14 UTC (rev 5891) +++ trunk/target-ppc/op.c 2008-12-06 13:03:35 UTC (rev 5892) @@ -79,40 +79,8 @@ RETURN(); } #endif - -void OPPROTO op_load_msr (void) -{ - T0 = env->msr; - RETURN(); -} - -void OPPROTO op_store_msr (void) -{ - do_store_msr(); - RETURN(); -} - -#if defined (TARGET_PPC64) -void OPPROTO op_store_msr_32 (void) -{ - T0 = (env->msr & ~0xFFFFFFFFULL) | (T0 & 0xFFFFFFFF); - do_store_msr(); - RETURN(); -} #endif -void OPPROTO op_update_riee (void) -{ - /* We don't call do_store_msr here as we won't trigger - * any special case nor change hflags - */ - T0 &= (1 << MSR_RI) | (1 << MSR_EE); - env->msr &= ~(1 << MSR_RI) | (1 << MSR_EE); - env->msr |= T0; - RETURN(); -} -#endif - /* SPR */ void OPPROTO op_load_spr (void) { @@ -394,17 +362,6 @@ } #if !defined(CONFIG_USER_ONLY) -void OPPROTO op_wrte (void) -{ - /* We don't call do_store_msr here as we won't trigger - * any special case nor change hflags - */ - T0 &= 1 << MSR_EE; - env->msr &= ~(1 << MSR_EE); - env->msr |= T0; - RETURN(); -} - void OPPROTO op_440_tlbre (void) { do_440_tlbre(PARAM1); Modified: trunk/target-ppc/op_helper.c =================================================================== --- trunk/target-ppc/op_helper.c 2008-12-06 12:19:14 UTC (rev 5891) +++ trunk/target-ppc/op_helper.c 2008-12-06 13:03:35 UTC (rev 5892) @@ -1488,17 +1488,17 @@ } #if !defined (CONFIG_USER_ONLY) -void cpu_dump_rfi (target_ulong RA, target_ulong msr); - -void do_store_msr (void) +void helper_store_msr (target_ulong val) { - T0 = hreg_store_msr(env, T0, 0); - if (T0 != 0) { + val = hreg_store_msr(env, val, 0); + if (val != 0) { env->interrupt_request |= CPU_INTERRUPT_EXITTB; - raise_exception(env, T0); + raise_exception(env, val); } } +void cpu_dump_rfi (target_ulong RA, target_ulong msr); + static always_inline void do_rfi (target_ulong nip, target_ulong msr, target_ulong msrm, int keep_msrh) { Modified: trunk/target-ppc/op_helper.h =================================================================== --- trunk/target-ppc/op_helper.h 2008-12-06 12:19:14 UTC (rev 5891) +++ trunk/target-ppc/op_helper.h 2008-12-06 13:03:35 UTC (rev 5892) @@ -28,10 +28,6 @@ void ppc_store_dump_spr (int sprn, target_ulong val); /* Misc */ -#if !defined(CONFIG_USER_ONLY) -void do_store_msr (void); -#endif - /* POWER / PowerPC 601 specific helpers */ #if !defined(CONFIG_USER_ONLY) void do_POWER_rac (void); Modified: trunk/target-ppc/translate.c =================================================================== --- trunk/target-ppc/translate.c 2008-12-06 12:19:14 UTC (rev 5891) +++ trunk/target-ppc/translate.c 2008-12-06 13:03:35 UTC (rev 5892) @@ -63,6 +63,7 @@ static TCGv_i64 cpu_avrh[32], cpu_avrl[32]; static TCGv_i32 cpu_crf[8]; static TCGv cpu_nip; +static TCGv cpu_msr; static TCGv cpu_ctr; static TCGv cpu_lr; static TCGv cpu_xer; @@ -153,6 +154,9 @@ cpu_nip = tcg_global_mem_new(TCG_AREG0, offsetof(CPUState, nip), "nip"); + cpu_msr = tcg_global_mem_new(TCG_AREG0, + offsetof(CPUState, msr), "msr"); + cpu_ctr = tcg_global_mem_new(TCG_AREG0, offsetof(CPUState, ctr), "ctr"); @@ -3876,8 +3880,7 @@ GEN_EXCP_PRIVREG(ctx); return; } - gen_op_load_msr(); - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); + tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_msr); #endif } @@ -3984,14 +3987,18 @@ tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]); if (ctx->opcode & 0x00010000) { /* Special form that does not need any synchronisation */ - gen_op_update_riee(); + TCGv t0 = tcg_temp_new(); + tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)], (1 << MSR_RI) | (1 << MSR_EE)); + tcg_gen_andi_tl(cpu_msr, cpu_msr, ~((1 << MSR_RI) | (1 << MSR_EE))); + tcg_gen_or_tl(cpu_msr, cpu_msr, t0); + tcg_temp_free(t0); } else { /* XXX: we need to update nip before the store * if we enter power saving mode, we will exit the loop * directly from ppc_store_msr */ gen_update_nip(ctx, ctx->nip); - gen_op_store_msr(); + gen_helper_store_msr(cpu_gpr[rS(ctx->opcode)]); /* Must stop the translation as machine state (may have) changed */ /* Note that mtmsr is not always defined as context-synchronizing */ ctx->exception = POWERPC_EXCP_STOP; @@ -4012,7 +4019,11 @@ tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]); if (ctx->opcode & 0x00010000) { /* Special form that does not need any synchronisation */ - gen_op_update_riee(); + TCGv t0 = tcg_temp_new(); + tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)], (1 << MSR_RI) | (1 << MSR_EE)); + tcg_gen_andi_tl(cpu_msr, cpu_msr, ~((1 << MSR_RI) | (1 << MSR_EE))); + tcg_gen_or_tl(cpu_msr, cpu_msr, t0); + tcg_temp_free(t0); } else { /* XXX: we need to update nip before the store * if we enter power saving mode, we will exit the loop @@ -4020,13 +4031,20 @@ */ gen_update_nip(ctx, ctx->nip); #if defined(TARGET_PPC64) - if (!ctx->sf_mode) - gen_op_store_msr_32(); - else + if (!ctx->sf_mode) { + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + tcg_gen_andi_tl(t0, cpu_msr, 0xFFFFFFFF00000000ULL); + tcg_gen_ext32u_tl(t1, cpu_gpr[rS(ctx->opcode)]); + tcg_gen_or_tl(t0, t0, t1); + tcg_temp_free(t1); + gen_helper_store_msr(t0); + tcg_temp_free(t0); + } else #endif - gen_op_store_msr(); + gen_helper_store_msr(cpu_gpr[rS(ctx->opcode)]); /* Must stop the translation as machine state (may have) changed */ - /* Note that mtmsrd is not always defined as context-synchronizing */ + /* Note that mtmsr is not always defined as context-synchronizing */ ctx->exception = POWERPC_EXCP_STOP; } #endif @@ -5978,12 +5996,16 @@ #if defined(CONFIG_USER_ONLY) GEN_EXCP_PRIVOPC(ctx); #else + TCGv t0; if (unlikely(!ctx->supervisor)) { GEN_EXCP_PRIVOPC(ctx); return; } - tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rD(ctx->opcode)]); - gen_op_wrte(); + t0 = tcg_temp_new(); + tcg_gen_andi_tl(t0, cpu_gpr[rD(ctx->opcode)], (1 << MSR_EE)); + tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE)); + tcg_gen_or_tl(cpu_msr, cpu_msr, t0); + tcg_temp_free(t0); /* Stop translation to have a chance to raise an exception * if we just set msr_ee to 1 */ @@ -6001,12 +6023,13 @@ GEN_EXCP_PRIVOPC(ctx); return; } - tcg_gen_movi_tl(cpu_T[0], ctx->opcode & 0x00010000); - gen_op_wrte(); - /* Stop translation to have a chance to raise an exception - * if we just set msr_ee to 1 - */ - GEN_STOP(ctx); + if (ctx->opcode & 0x00010000) { + tcg_gen_ori_tl(cpu_msr, cpu_msr, (1 << MSR_EE)); + /* Stop translation to have a chance to raise an exception */ + GEN_STOP(ctx); + } else { + tcg_gen_andi_tl(cpu_msr, cpu_msr, (1 << MSR_EE)); + } #endif }