Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lg3TX-0004o5-Bi for qemu-devel@nongnu.org; Sat, 07 Mar 2009 15:50:27 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lg3TV-0004nt-Mq for qemu-devel@nongnu.org; Sat, 07 Mar 2009 15:50:26 -0500 Received: from [199.232.76.173] (port=43810 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lg3TV-0004nq-IW for qemu-devel@nongnu.org; Sat, 07 Mar 2009 15:50:25 -0500 Received: from savannah.gnu.org ([199.232.41.3]:59927 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 1Lg3TV-0007Ws-5K for qemu-devel@nongnu.org; Sat, 07 Mar 2009 15:50:25 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lg3TL-0002xB-J4 for qemu-devel@nongnu.org; Sat, 07 Mar 2009 20:50:19 +0000 Received: from blueswir1 by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lg3TB-0002tJ-Ig for qemu-devel@nongnu.org; Sat, 07 Mar 2009 20:50:09 +0000 MIME-Version: 1.0 Errors-To: blueswir1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Blue Swirl Message-Id: Date: Sat, 07 Mar 2009 20:50:06 +0000 Subject: [Qemu-devel] [6747] Implement slbmte 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: 6747 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6747 Author: blueswir1 Date: 2009-03-07 20:50:01 +0000 (Sat, 07 Mar 2009) Log Message: ----------- Implement slbmte In order to modify SLB entries on recent PPC64 machines, the slbmte instruction is used. This patch implements the slbmte instruction and makes the "bridge" mode code use the slb set functions, so we can move the SLB into the CPU struct later. This is required for Linux to run on PPC64. Signed-off-by: Alexander Graf Modified Paths: -------------- trunk/target-ppc/cpu.h trunk/target-ppc/helper.c trunk/target-ppc/op_helper.c trunk/target-ppc/translate.c Modified: trunk/target-ppc/cpu.h =================================================================== --- trunk/target-ppc/cpu.h 2009-03-07 20:06:23 UTC (rev 6746) +++ trunk/target-ppc/cpu.h 2009-03-07 20:50:01 UTC (rev 6747) @@ -716,7 +716,8 @@ #if defined(TARGET_PPC64) void ppc_store_asr (CPUPPCState *env, target_ulong value); target_ulong ppc_load_slb (CPUPPCState *env, int slb_nr); -void ppc_store_slb (CPUPPCState *env, int slb_nr, target_ulong rs); +target_ulong ppc_load_sr (CPUPPCState *env, int sr_nr); +void ppc_store_slb (CPUPPCState *env, target_ulong rb, target_ulong rs); #endif /* defined(TARGET_PPC64) */ void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value); #endif /* !defined(CONFIG_USER_ONLY) */ Modified: trunk/target-ppc/helper.c =================================================================== --- trunk/target-ppc/helper.c 2009-03-07 20:06:23 UTC (rev 6746) +++ trunk/target-ppc/helper.c 2009-03-07 20:50:01 UTC (rev 6747) @@ -821,27 +821,34 @@ return rt; } -void ppc_store_slb (CPUPPCState *env, int slb_nr, target_ulong rs) +void ppc_store_slb (CPUPPCState *env, target_ulong rb, target_ulong rs) { target_phys_addr_t sr_base; uint64_t tmp64; uint32_t tmp; + uint64_t vsid; + uint64_t esid; + int flags, valid, slb_nr; + + vsid = rs >> 12; + flags = ((rs >> 8) & 0xf); + + esid = rb >> 28; + valid = (rb & (1 << 27)); + slb_nr = rb & 0xfff; + + tmp64 = (esid << 28) | valid | (vsid >> 24); + tmp = (vsid << 8) | (flags << 3); + + /* Write SLB entry to memory */ sr_base = env->spr[SPR_ASR]; sr_base += 12 * slb_nr; - /* Copy Rs bits 37:63 to SLB 62:88 */ - tmp = rs << 8; - tmp64 = (rs >> 24) & 0x7; - /* Copy Rs bits 33:36 to SLB 89:92 */ - tmp |= ((rs >> 27) & 0xF) << 4; - /* Set the valid bit */ - tmp64 |= 1 << 27; - /* Set ESID */ - tmp64 |= (uint32_t)slb_nr << 28; - LOG_SLB("%s: %d " ADDRX " => " PADDRX " %016" PRIx64 + + LOG_SLB("%s: %d " ADDRX " - " ADDRX " => " PADDRX " %016" PRIx64 " %08" PRIx32 "\n", __func__, - slb_nr, rs, sr_base, tmp64, tmp); - /* Write SLB entry to memory */ + slb_nr, rb, rs, sr_base, tmp64, tmp); + stq_phys(sr_base, tmp64); stl_phys(sr_base + 8, tmp); } @@ -1945,10 +1952,37 @@ } } +#if defined(TARGET_PPC64) +target_ulong ppc_load_sr (CPUPPCState *env, int slb_nr) +{ + // XXX + return 0; +} +#endif + void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value) { LOG_MMU("%s: reg=%d " ADDRX " " ADDRX "\n", __func__, srnum, value, env->sr[srnum]); +#if defined(TARGET_PPC64) + if (env->mmu_model & POWERPC_MMU_64) { + uint64_t rb = 0, rs = 0; + + /* ESID = srnum */ + rb |= ((uint32_t)srnum & 0xf) << 28; + /* Set the valid bit */ + rb |= 1 << 27; + /* Index = ESID */ + rb |= (uint32_t)srnum; + + /* VSID = VSID */ + rs |= (value & 0xfffffff) << 12; + /* flags = flags */ + rs |= ((value >> 27) & 0xf) << 9; + + ppc_store_slb(env, rb, rs); + } else +#endif if (env->sr[srnum] != value) { env->sr[srnum] = value; #if !defined(FLUSH_ALL_TLBS) && 0 Modified: trunk/target-ppc/op_helper.c =================================================================== --- trunk/target-ppc/op_helper.c 2009-03-07 20:06:23 UTC (rev 6746) +++ trunk/target-ppc/op_helper.c 2009-03-07 20:50:01 UTC (rev 6747) @@ -3752,6 +3752,10 @@ /* Segment registers load and store */ target_ulong helper_load_sr (target_ulong sr_num) { +#if defined(TARGET_PPC64) + if (env->mmu_model & POWERPC_MMU_64) + return ppc_load_sr(env, sr_num); +#endif return env->sr[sr_num]; } @@ -3767,9 +3771,9 @@ return ppc_load_slb(env, slb_nr); } -void helper_store_slb (target_ulong slb_nr, target_ulong rs) +void helper_store_slb (target_ulong rb, target_ulong rs) { - ppc_store_slb(env, slb_nr, rs); + ppc_store_slb(env, rb, rs); } void helper_slbia (void) Modified: trunk/target-ppc/translate.c =================================================================== --- trunk/target-ppc/translate.c 2009-03-07 20:06:23 UTC (rev 6746) +++ trunk/target-ppc/translate.c 2009-03-07 20:50:01 UTC (rev 6747) @@ -4300,7 +4300,7 @@ return; } t0 = tcg_const_tl(SR(ctx->opcode)); - gen_helper_load_slb(cpu_gpr[rD(ctx->opcode)], t0); + gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], t0); tcg_temp_free(t0); #endif } @@ -4320,7 +4320,7 @@ t0 = tcg_temp_new(); tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28); tcg_gen_andi_tl(t0, t0, 0xF); - gen_helper_load_slb(cpu_gpr[rD(ctx->opcode)], t0); + gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], t0); tcg_temp_free(t0); #endif } @@ -4337,7 +4337,7 @@ return; } t0 = tcg_const_tl(SR(ctx->opcode)); - gen_helper_store_slb(t0, cpu_gpr[rS(ctx->opcode)]); + gen_helper_store_sr(t0, cpu_gpr[rS(ctx->opcode)]); tcg_temp_free(t0); #endif } @@ -4357,10 +4357,25 @@ t0 = tcg_temp_new(); tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28); tcg_gen_andi_tl(t0, t0, 0xF); - gen_helper_store_slb(t0, cpu_gpr[rS(ctx->opcode)]); + gen_helper_store_sr(t0, cpu_gpr[rS(ctx->opcode)]); tcg_temp_free(t0); #endif } + +/* slbmte */ +GEN_HANDLER2(slbmte, "slbmte", 0x1F, 0x12, 0x0C, 0x00000000, PPC_SEGMENT_64B) +{ +#if defined(CONFIG_USER_ONLY) + gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); +#else + if (unlikely(!ctx->mem_idx)) { + gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); + return; + } + gen_helper_store_slb(cpu_gpr[rB(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); +#endif +} + #endif /* defined(TARGET_PPC64) */ /*** Lookaside buffer management ***/