ppc-for-9.1-1 queue
The following changes since commit 70581940cabcc51b329652becddfbc6a261b1b83:
Merge tag 'pull-tcg-20240523' of https://gitlab.com/rth7680/qemu into staging (2024-05-23 09:47:40 -0700)
are available in the Git repository at:
https://gitlab.com/npiggin/qemu.git tags/pull-ppc-for-9.1-1-20240524
for you to fetch changes up to 4e0e22a2de927ec827e3464f7aedd47ed22268d2:
target/ppc: Remove pp_check() and reuse ppc_hash32_pp_prot() (2024-05-24 08:57:51 +1000)
----------------------------------------------------------------
* Fix an interesting TLB invalidate race
* Implement more instructions with decodetree
* Add the POWER8/9/10 BHRB facility
* Add missing instructions, registers, SMT support
* First round of a big MMU xlate cleanup
----------------------------------------------------------------
BALATON Zoltan (33):
target/ppc: Remove unused helper
target/ppc/mmu_common.c: Move calculation of a value closer to its usage target/ppc/mmu_common.c: Remove unneeded local variable target/ppc/mmu_common.c: Simplify checking for real mode target/ppc/mmu_common.c: Drop cases for unimplemented MPC8xx MMU target/ppc/mmu_common.c: Introduce mmu6xx_get_physical_address() target/ppc/mmu_common.c: Move else branch to avoid large if block target/ppc/mmu_common.c: Move some debug logging target/ppc/mmu_common.c: Eliminate ret from mmu6xx_get_physical_address() target/ppc/mmu_common.c: Split out BookE cases before checking real mode target/ppc/mmu_common.c: Split off real mode cases in get_physical_address_wtlb() target/ppc/mmu_common.c: Inline and remove check_physical() target/ppc/mmu_common.c: Fix misindented qemu_log_mask() calls target/ppc/mmu_common.c: Deindent ppc_jumbo_xlate() target/ppc/mmu_common.c: Replace hard coded constants in ppc_jumbo_xlate() target/ppc/mmu_common.c: Don't use mmu_ctx_t for mmu40x_get_physical_address() target/ppc/mmu_common.c: Don't use mmu_ctx_t in mmubooke_get_physical_address() target/ppc/mmu_common.c: Don't use mmu_ctx_t in mmubooke206_get_physical_address() target/ppc/mmu_common.c: Remove BookE from direct store handling target/ppc/mmu_common.c: Split off BookE handling from ppc_jumbo_xlate() target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 1 target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 2 target/ppc/mmu_common.c: Split off real mode handling from get_physical_address_wtlb() target/ppc/mmu_common.c: Split off 40x cases from ppc_jumbo_xlate() target/ppc/mmu_common.c: Transform ppc_jumbo_xlate() into ppc_6xx_xlate() target/ppc/mmu_common.c: Move mmu_ctx_t type to mmu_common.c target/ppc: Remove id_tlbs flag from CPU env
target/ppc: Split off common embedded TLB init
target/ppc/mmu-hash32.c: Drop a local variable target/ppc/mmu-radix64.c: Drop a local variable
target/ppc: Add a function to check for page protection bit
target/ppc: Move out BookE and related MMU functions from mmu_common.c target/ppc: Remove pp_check() and reuse ppc_hash32_pp_prot()
Chinmay Rath (13):
target/ppc: Merge various fpu helpers
target/ppc: Move floating-point arithmetic instructions to decodetree. target/ppc: Move mul{li, lw, lwo, hw, hwu} instructions to decodetree. target/ppc: Make divw[u] handler method decodetree compatible. target/ppc: Move divw[u, e, eu] instructions to decodetree. target/ppc: Move neg, darn, mod{sw, uw} to decodetree. target/ppc: Move multiply fixed-point insns (64-bit operands) to decodetree. target/ppc: Move div/mod fixed-point insns (64 bits operands) to decodetree. target/ppc: Move cmp{rb, eqb}, tw[i], td[i], isel instructions to decodetree. target/ppc: Move logical fixed-point instructions to decodetree. target/ppc: Move VMX storage access instructions to decodetree target/ppc: Move VMX integer logical instructions to decodetree. target/ppc: Move VMX integer max/min instructions to decodetree.
Dr. David Alan Gilbert (1):
target/ppc: Remove unused struct 'mmu_ctx_hash32'
Glenn Miles (4):
This commit is preparatory to the addition of Branch History Rolling Buffer (BHRB) functionality, which is being provided today starting with the P8 processor.
This commit continues adding support for the Branch History Rolling Buffer (BHRB) as is provided starting with the P8 processor and continuing with its successors. This commit is limited to the recording and filtering of taken branches. Add support for the clrbhrb and mfbhrbe instructions.
Adds migration support for Branch History Rolling Buffer (BHRB) internal state.
Nicholas Piggin (21):
spapr: avoid overhead of finding vhyp class in critical operations ppc/spapr: Add ibm,pi-features
target/ppc: Fix broadcast tlbie synchronisation tcg/cputlb: Remove non-synced variants of global TLB flushes tcg/cputlb: remove other-cpu capability from TLB flushing target/ppc: Move sync instructions to decodetree target/ppc: Fix embedded memory barriers
target/ppc: Add ISA v3.1 variants of sync instruction target/ppc: larx/stcx generation need only apply DEF_MEMOP() once target/ppc: Remove redundant MEMOP_GET_SIZE macro target/ppc: Make checkstop actually stop the system target/ppc: improve checkstop logging
target/ppc: Implement attn instruction on BookS 64-bit processors target/ppc: BookE DECAR SPR is 32-bit
target/ppc: Add PPR32 SPR
target/ppc: add helper to write per-LPAR SPRs target/ppc: Add SMT support to simple SPRs
target/ppc: Add SMT support to PTCR SPR
target/ppc: Implement LDBAR, TTR SPRs
target/ppc: Implement SPRC/SPRD SPRs
target/ppc: add SMT support to msgsnd broadcast
accel/tcg/cputlb.c | 145 +-- docs/devel/multi-thread-tcg.rst | 13 +- hw/ppc/pegasos2.c | 3 +- hw/ppc/spapr.c | 28 + include/exec/exec-all.h | 97 +- target/ppc/cpu.h | 64 +- target/ppc/cpu_init.c | 235 +++-- target/ppc/excp_helper.c | 134 ++- target/ppc/fpu_helper.c | 235 ++--- target/ppc/helper.h | 98 +- target/ppc/helper_regs.c | 40 +- target/ppc/insn32.decode | 204 ++++ target/ppc/int_helper.c | 24 +- target/ppc/internal.h | 40 +- target/ppc/kvm.c | 4 +- target/ppc/machine.c | 23 +- target/ppc/mem_helper.c | 12 +- target/ppc/meson.build | 1 + target/ppc/misc_helper.c | 132 ++- target/ppc/mmu-book3s-v3.h | 4 +- target/ppc/mmu-booke.c | 531 +++++++++++ target/ppc/mmu-booke.h | 17 + target/ppc/mmu-hash32.c | 60 +- target/ppc/mmu-hash32.h | 45 + target/ppc/mmu-hash64.c | 18 +- target/ppc/mmu-radix64.c | 9 +- target/ppc/mmu_common.c | 1197 ++++++------------------ target/ppc/mmu_helper.c | 39 +- target/ppc/power8-pmu-regs.c.inc | 5 + target/ppc/power8-pmu.c | 48 +- target/ppc/power8-pmu.h | 11 +- target/ppc/spr_common.h | 8 + target/ppc/translate.c | 1151 ++++------------------- target/ppc/translate/bhrb-impl.c.inc | 43 + target/ppc/translate/branch-impl.c.inc | 2 +- target/ppc/translate/fixedpoint-impl.c.inc | 727 ++++++++++++++ target/ppc/translate/fp-impl.c.inc | 285 +++--- target/ppc/translate/fp-ops.c.inc | 31 - target/ppc/translate/misc-impl.c.inc | 157 ++++ target/ppc/translate/processor-ctrl-impl.c.inc | 2 +- target/ppc/translate/storage-ctrl-impl.c.inc | 7 + target/ppc/translate/vmx-impl.c.inc | 280 +++--- target/ppc/translate/vmx-ops.c.inc | 50 - 43 files changed, 3267 insertions(+), 2992 deletions(-) create mode 100644 target/ppc/mmu-booke.c create mode 100644 target/ppc/mmu-booke.h create mode 100644 target/ppc/translate/bhrb-impl.c.inc create mode 100644 target/ppc/translate/misc-impl.c.inc
[PULL 19/72] target/ppc: Move VMX storage access instructions to decodetree
From: Chinmay Rath <[email protected]>
Moving the following instructions to decodetree specification :
{l,st}ve{b,h,w}x,
{l,st}v{x,xl},
lvs{l,r} : X-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured using the '-d in_asm,op' flag.
--- target/ppc/helper.h | 12 +- target/ppc/insn32.decode | 17 +++ target/ppc/mem_helper.c | 12 +- target/ppc/translate.c | 2 - target/ppc/translate/vmx-impl.c.inc | 221 ++++++++++++---------------- target/ppc/translate/vmx-ops.c.inc | 19 --- 6 files changed, 120 insertions(+), 163 deletions(-)
target/ppc/helper.h +6 -6
@@ -267,12 +267,12 @@ DEF_HELPER_5(VMSUMSHS, void, env, avr, avr, avr, avr) DEF_HELPER_FLAGS_5(VMLADDUHM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32) DEF_HELPER_FLAGS_2(mtvscr, TCG_CALL_NO_RWG, void, env, i32) DEF_HELPER_FLAGS_1(mfvscr, TCG_CALL_NO_RWG, i32, env) -DEF_HELPER_3(lvebx, void, env, avr, tl) -DEF_HELPER_3(lvehx, void, env, avr, tl) -DEF_HELPER_3(lvewx, void, env, avr, tl) -DEF_HELPER_3(stvebx, void, env, avr, tl) -DEF_HELPER_3(stvehx, void, env, avr, tl) -DEF_HELPER_3(stvewx, void, env, avr, tl) +DEF_HELPER_3(LVEBX, void, env, avr, tl) +DEF_HELPER_3(LVEHX, void, env, avr, tl) +DEF_HELPER_3(LVEWX, void, env, avr, tl) +DEF_HELPER_3(STVEBX, void, env, avr, tl) +DEF_HELPER_3(STVEHX, void, env, avr, tl) +DEF_HELPER_3(STVEWX, void, env, avr, tl)#if defined(TARGET_PPC64 ) DEF_HELPER_4(lxvl, void, env, tl, vsr, tl)DEF_HELPER_4 (lxvll, void, env, tl, vsr, tl)
target/ppc/insn32.decode +17 -0
@@ -661,6 +661,23 @@ DSCRIQ 111111 ..... ..... ...... 001100010 . @Z22_tap_sh_rc VPMSUMD 000100 ..... ..... ..... 10011001000 @VX +## Vector Load/Store Instructions + +LVEBX 011111 ..... ..... ..... 0000000111 - @X +LVEHX 011111 ..... ..... ..... 0000100111 - @X +LVEWX 011111 ..... ..... ..... 0001000111 - @X +LVX 011111 ..... ..... ..... 0001100111 - @X +LVXL 011111 ..... ..... ..... 0101100111 - @X + +STVEBX 011111 ..... ..... ..... 0010000111 - @X +STVEHX 011111 ..... ..... ..... 0010100111 - @X +STVEWX 011111 ..... ..... ..... 0011000111 - @X +STVX 011111 ..... ..... ..... 0011100111 - @X +STVXL 011111 ..... ..... ..... 0111100111 - @X + +LVSL 011111 ..... ..... ..... 0000000110 - @X +LVSR 011111 ..... ..... ..... 0000100110 - @X + ## Vector Integer Instructions VCMPEQUB 000100 ..... ..... ..... . 0000000110 @VC
target/ppc/mem_helper.c +6 -6
@@ -404,9 +404,9 @@ target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg, } \ }#define I (x) (x) -LVE(lvebx, cpu_ldub_data_ra, I, u8) -LVE(lvehx, cpu_lduw_data_ra, bswap16, u16) -LVE(lvewx, cpu_ldl_data_ra, bswap32, u32) +LVE(LVEBX, cpu_ldub_data_ra, I, u8) +LVE(LVEHX, cpu_lduw_data_ra, bswap16, u16) +LVE(LVEWX, cpu_ldl_data_ra, bswap32, u32)#undef I#undef LVE
@@ -432,9 +432,9 @@ LVE(lvewx, cpu_ldl_data_ra, bswap32, u32) } \ }#define I (x) (x) -STVE(stvebx, cpu_stb_data_ra, I, u8) -STVE(stvehx, cpu_stw_data_ra, bswap16, u16) -STVE(stvewx, cpu_stl_data_ra, bswap32, u32) +STVE(STVEBX, cpu_stb_data_ra, I, u8) +STVE(STVEHX, cpu_stw_data_ra, bswap16, u16) +STVE(STVEWX, cpu_stl_data_ra, bswap32, u32)#undef I#undef LVE
target/ppc/translate.c +0 -2
@@ -5790,8 +5790,6 @@ GEN_HANDLER2_E(icbt_440, "icbt", 0x1F, 0x16, 0x00, 0x03E00001, PPC_BOOKE, PPC2_BOOKE206),GEN_HANDLER2 (icbt_440,"icbt" ,0x1F ,0x06 ,0x08 ,0x03E00001 ,PPC_440_SPEC ), -GEN_HANDLER (lvsl,0x1f ,0x06 ,0x00 ,0x00000001 ,PPC_ALTIVEC ), -GEN_HANDLER (lvsr,0x1f ,0x06 ,0x01 ,0x00000001 ,PPC_ALTIVEC ),GEN_HANDLER (mfvscr,0x04 ,0x2 ,0x18 ,0x001ff800 ,PPC_ALTIVEC ), GEN_HANDLER(mtvscr, 0x04, 0x2, 0x19, 0x03ff0000, PPC_ALTIVEC),
target/ppc/translate/vmx-impl.c.inc +91 -130
292 lines not on this page · raw message
target/ppc/translate/vmx-ops.c.inc +0 -19
@@ -1,22 +1,3 @@ -#define GEN_VR_LDX(name, opc2, opc3) \ -GEN_HANDLER(name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC) -#define GEN_VR_STX(name, opc2, opc3) \ -GEN_HANDLER(st##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC) -#define GEN_VR_LVE(name, opc2, opc3) \ - GEN_HANDLER(lve##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC) -#define GEN_VR_STVE(name, opc2, opc3) \ - GEN_HANDLER(stve##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC) -GEN_VR_LDX(lvx, 0x07, 0x03), -GEN_VR_LDX(lvxl, 0x07, 0x0B), -GEN_VR_LVE(bx, 0x07, 0x00), -GEN_VR_LVE(hx, 0x07, 0x01), -GEN_VR_LVE(wx, 0x07, 0x02), -GEN_VR_STX(svx, 0x07, 0x07), -GEN_VR_STX(svxl, 0x07, 0x0F), -GEN_VR_STVE(bx, 0x07, 0x04), -GEN_VR_STVE(hx, 0x07, 0x05), -GEN_VR_STVE(wx, 0x07, 0x06), - #define GEN_VX_LOGICAL(name, tcg_op, opc2, opc3) \ GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
Signature · 1 line
2.43.0
[PULL 20/72] target/ppc: Move VMX integer logical instructions to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
Moving the following instructions to decodetree specification:
v{and, andc, nand, or, orc, nor, xor, eqv} : VX-form
The changes were verified by validating that the tcp ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/insn32.decode | 11 +++++++++++ target/ppc/translate/vmx-impl.c.inc | 22 ++++++++++------------ target/ppc/translate/vmx-ops.c.inc | 15 --------------- 3 files changed, 21 insertions(+), 27 deletions(-)
target/ppc/insn32.decode +11 -0
@@ -709,6 +709,17 @@ VCMPNEZW 000100 ..... ..... ..... . 0110000111 @VC VCMPSQ 000100 ... -- ..... ..... 00101000001 @VX_bf VCMPUQ 000100 ... -- ..... ..... 00100000001 @VX_bf +## Vector Integer Logical Instructions + +VAND 000100 ..... ..... ..... 10000000100 @VX +VANDC 000100 ..... ..... ..... 10001000100 @VX +VNAND 000100 ..... ..... ..... 10110000100 @VX +VOR 000100 ..... ..... ..... 10010000100 @VX +VORC 000100 ..... ..... ..... 10101000100 @VX +VNOR 000100 ..... ..... ..... 10100000100 @VX +VXOR 000100 ..... ..... ..... 10011000100 @VX +VEQV 000100 ..... ..... ..... 11010000100 @VX + ## Vector Integer Average Instructions VAVGSB 000100 ..... ..... ..... 10100000010 @VX
target/ppc/translate/vmx-impl.c.inc +10 -12
@@ -205,16 +205,6 @@ static void glue(gen_, name)(DisasContext *ctx) \ 16, 16); \ } -/* Logical operations */ -GEN_VXFORM_V(vand, MO_64, tcg_gen_gvec_and, 2, 16); -GEN_VXFORM_V(vandc, MO_64, tcg_gen_gvec_andc, 2, 17); -GEN_VXFORM_V(vor, MO_64, tcg_gen_gvec_or, 2, 18); -GEN_VXFORM_V(vxor, MO_64, tcg_gen_gvec_xor, 2, 19); -GEN_VXFORM_V(vnor, MO_64, tcg_gen_gvec_nor, 2, 20); -GEN_VXFORM_V(veqv, MO_64, tcg_gen_gvec_eqv, 2, 26); -GEN_VXFORM_V(vnand, MO_64, tcg_gen_gvec_nand, 2, 22); -GEN_VXFORM_V(vorc, MO_64, tcg_gen_gvec_orc, 2, 21); - #define GEN_VXFORM(name, opc2, opc3) \ static void glue(gen_, name)(DisasContext *ctx) \ { \
@@ -727,6 +717,16 @@ TRANS_FLAGS(ALTIVEC, VRLH, do_vector_gvec3_VX, MO_16, tcg_gen_gvec_rotlv) TRANS_FLAGS(ALTIVEC, VRLW, do_vector_gvec3_VX, MO_32, tcg_gen_gvec_rotlv) TRANS_FLAGS2(ALTIVEC_207, VRLD, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_rotlv) +/* Logical operations */ +TRANS_FLAGS(ALTIVEC, VAND, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_and); +TRANS_FLAGS(ALTIVEC, VANDC, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_andc); +TRANS_FLAGS(ALTIVEC, VOR, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_or); +TRANS_FLAGS(ALTIVEC, VXOR, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_xor); +TRANS_FLAGS(ALTIVEC, VNOR, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_nor); +TRANS_FLAGS2(ALTIVEC_207, VEQV, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_eqv); +TRANS_FLAGS2(ALTIVEC_207, VNAND, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_nand); +TRANS_FLAGS2(ALTIVEC_207, VORC, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_orc); + static TCGv_vec do_vrl_mask_vec(unsigned vece, TCGv_vec vrb) { TCGv_vec t0 = tcg_temp_new_vec_matching(vrb),
@@ -3331,8 +3331,6 @@ TRANS_FLAGS2(ISA310, VMODUQ, do_vx_helper, gen_helper_VMODUQ) #undef DIVS64 #undef DIVU64 -#undef GEN_VX_LOGICAL -#undef GEN_VX_LOGICAL_207 #undef GEN_VXFORM #undef GEN_VXFORM_207 #undef GEN_VXFORM_DUAL
target/ppc/translate/vmx-ops.c.inc +0 -15
@@ -1,18 +1,3 @@ -#define GEN_VX_LOGICAL(name, tcg_op, opc2, opc3) \ -GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC) - -#define GEN_VX_LOGICAL_207(name, tcg_op, opc2, opc3) \ -GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207) - -GEN_VX_LOGICAL(vand, tcg_gen_and_i64, 2, 16), -GEN_VX_LOGICAL(vandc, tcg_gen_andc_i64, 2, 17), -GEN_VX_LOGICAL(vor, tcg_gen_or_i64, 2, 18), -GEN_VX_LOGICAL(vxor, tcg_gen_xor_i64, 2, 19), -GEN_VX_LOGICAL(vnor, tcg_gen_nor_i64, 2, 20), -GEN_VX_LOGICAL_207(veqv, tcg_gen_eqv_i64, 2, 26), -GEN_VX_LOGICAL_207(vnand, tcg_gen_nand_i64, 2, 22), -GEN_VX_LOGICAL_207(vorc, tcg_gen_orc_i64, 2, 21), - #define GEN_VXFORM(name, opc2, opc3) \ GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
Signature · 1 line
2.43.0
[PULL 03/72] target/ppc: Fix broadcast tlbie synchronisation
In reply to Nicholas PigginWith mttcg, broadcast tlbie instructions do not wait until other vCPUs have been kicked out of TCG execution before they complete (including necessary subsequent tlbsync, etc., instructions). This is contrary to the ISA, and it permits other vCPUs to use translations after the TLB flush. For example:
CPU0 // *memP is initially 0, memV maps to memP with *pte *pte = 0; ptesync ; tlbie ; eieio ; tlbsync ; ptesync *memP = 1; CPU1 assert(*memV == 0);
It is possible for the assertion to fail because CPU1 translates memV using the TLB after CPU0 has stored 1 to the underlying memory. This race was observed with a careful test case where CPU1 checks run in a very large expensive TB so it can run for the entire CPU0 period between clearing the pte and storing the memory, but host vCPU thread preemption could cause the race to hit anywhere.
As explained in commit 4ddc104689b ("target/ppc: Fix tlbie"), it is not enough to just use tlb_flush_all_cpus_synced(), because that does not execute until the calling CPU has finished its TB. It is also required that the TB is ended at the point where the TLB flush must subsequently take effect.
--- target/ppc/helper_regs.c | 2 +- target/ppc/mmu_helper.c | 2 +- target/ppc/translate.c | 7 +++++++ target/ppc/translate/storage-ctrl-impl.c.inc | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-)
target/ppc/helper_regs.c +1 -1
@@ -334,7 +334,7 @@ void check_tlb_flush(CPUPPCState *env, bool global)if (global && (env->tlb_need_flush &TLB_NEED_GLOBAL_FLUSH )) { env->tlb_need_flush &= ~TLB_NEED_GLOBAL_FLUSH ; env->tlb_need_flush &= ~TLB_NEED_LOCAL_FLUSH ; -tlb_flush_all_cpus (cs); +tlb_flush_all_cpus_synced (cs);return ; }
target/ppc/mmu_helper.c +1 -1
@@ -534,7 +534,7 @@ void helper_tlbie_isa300(CPUPPCState *env, target_ulong rb, target_ulong rs,if (local) {tlb_flush_page (env_cpu (env), addr); }else { -tlb_flush_page_all_cpus (env_cpu (env), addr); +tlb_flush_page_all_cpus_synced (env_cpu (env), addr); }return ;
target/ppc/translate.c +7 -0
@@ -3494,6 +3494,13 @@ static inline void gen_check_tlb_flush(DisasContext *ctx, bool global) gen_helper_check_tlb_flush_local(tcg_env); }gen_set_label (l); +if (global) { +/* +* Global TLB flush uses async-work which must run before the +* next instruction, so this must be the last in the TB. +*/ + ctx->base.is_jmp =DISAS_EXIT_UPDATE ; + } }#else static inline void gen_check_tlb_flush (DisasContext *ctx,bool global) { }
target/ppc/translate/storage-ctrl-impl.c.inc +7 -0
@@ -224,6 +224,13 @@ static bool do_tlbie(DisasContext *ctx, arg_X_tlbie *a, bool local) a->prs << TLBIE_F_PRS_SHIFT | a->r << TLBIE_F_R_SHIFT | local << TLBIE_F_LOCAL_SHIFT)); + if (!local) { + /* + * Global TLB flush uses async-work which must run before the + * next instruction, so this must be the last in the TB. + */ + ctx->base.is_jmp = DISAS_EXIT_UPDATE; + } return true; #endif
Signature · 1 line
2.43.0
[PULL 06/72] target/ppc: Move sync instructions to decodetree
In reply to Nicholas PigginThis tries to faithfully reproduce the odd BookE logic. Note the e206 check in gen_msync_4xx() is always false, so not carried over.
It does change the handling of non-zero reserved bits outside the defined fields from being illegal to being ignored, which the architecture specifies ot help with backward compatibility of new fields. The existing behaviour causes illegal instruction exceptions when using new POWER10 sync variants that add new fields, after this the instructions are accepted and are implemented as supersets of the new behaviour, as intended.
--- target/ppc/insn32.decode | 7 ++ target/ppc/translate.c | 102 +-------------------- target/ppc/translate/misc-impl.c.inc | 130 +++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 100 deletions(-) create mode 100644 target/ppc/translate/misc-impl.c.inc
target/ppc/insn32.decode +7 -0
@@ -998,3 +998,10 @@ MSGSND 011111 ----- ----- ..... 0011001110 - @X_rb MSGCLRP 011111 ----- ----- ..... 0010101110 - @X_rb MSGSNDP 011111 ----- ----- ..... 0010001110 - @X_rb MSGSYNC 011111 ----- ----- ----- 1101110110 - + +# Memory Barrier Instructions + +&X_sync l +@X_sync ...... ... l:2 ..... ..... .......... . &X_sync +SYNC 011111 --- .. ----- ----- 1001010110 - @X_sync +EIEIO 011111 ----- ----- ----- 1101010110 -
target/ppc/translate.c +2 -100
144 lines not on this page · raw message
target/ppc/translate/misc-impl.c.inc new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 18/72] target/ppc: Move logical fixed-point instructions to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
Moving the below instructions to decodetree specification :
andi[s]., {ori, xori}[s] : D-form
{and, andc, nand, or, orc, nor, xor, eqv}[.],
exts{b, h, w}[.], cnt{l, t}z{w, d}[.],
popcnt{b, w, d}, prty{w, d}, cmp, bpermd : X-formWith this patch, all the fixed-point logical instructions have been moved to decodetree.
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/helper.h | 8 +- target/ppc/insn32.decode | 38 +++ target/ppc/int_helper.c | 10 +- target/ppc/translate.c | 359 --------------------- target/ppc/translate/fixedpoint-impl.c.inc | 300 +++++++++++++++++ 5 files changed, 347 insertions(+), 368 deletions(-)
target/ppc/helper.h +4 -4
@@ -58,8 +58,8 @@ DEF_HELPER_4(DIVDE, i64, env, i64, i64, i32) DEF_HELPER_4(DIVWEU, tl, env, tl, tl, i32) DEF_HELPER_4(DIVWE, tl, env, tl, tl, i32) -DEF_HELPER_FLAGS_1(popcntb, TCG_CALL_NO_RWG_SE, tl, tl) -DEF_HELPER_FLAGS_2(cmpb, TCG_CALL_NO_RWG_SE, tl, tl, tl) +DEF_HELPER_FLAGS_1(POPCNTB, TCG_CALL_NO_RWG_SE, tl, tl) +DEF_HELPER_FLAGS_2(CMPB, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_3(sraw, tl, env, tl, tl) DEF_HELPER_FLAGS_2(CFUGED, TCG_CALL_NO_RWG_SE, i64, i64, i64)DEF_HELPER_FLAGS_2 (PDEPD ,TCG_CALL_NO_RWG_SE , i64, i64, i64)
@@ -68,8 +68,8 @@ DEF_HELPER_FLAGS_1(CDTBCD, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(CBCDTD, TCG_CALL_NO_RWG_SE, tl, tl)#if defined(TARGET_PPC64 ) DEF_HELPER_FLAGS_2(CMPEQB, TCG_CALL_NO_RWG_SE, i32, tl, tl) -DEF_HELPER_FLAGS_1(popcntw, TCG_CALL_NO_RWG_SE, tl, tl) -DEF_HELPER_FLAGS_2(bpermd, TCG_CALL_NO_RWG_SE, i64, i64, i64) +DEF_HELPER_FLAGS_1(POPCNTW, TCG_CALL_NO_RWG_SE, tl, tl) +DEF_HELPER_FLAGS_2(BPERMD, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_3(srad, tl, env, tl, tl) DEF_HELPER_FLAGS_0(DARN32, TCG_CALL_NO_RWG, tl)DEF_HELPER_FLAGS_0 (DARN64 ,TCG_CALL_NO_RWG , tl)
target/ppc/insn32.decode +38 -0
@@ -35,6 +35,9 @@ &D rt ra si:int64_t @D ...... rt:5 ra:5 si:s16 &D +&D_ui rt ra ui:uint64_t +@D_ui ...... rt:5 ra:5 ui:16 &D_ui + &D_bf bf l:bool ra imm @D_bfs ...... bf:3 . l:1 ra:5 imm:s16 &D_bf @D_bfu ...... bf:3 . l:1 ra:5 imm:16 &D_bf
@@ -102,6 +105,9 @@ &X_sa rs ra @X_sa ...... rs:5 ra:5 ..... .......... . &X_sa +&X_sa_rc rs ra rc +@X_sa_rc ...... rs:5 ra:5 ..... .......... rc:1 &X_sa_rc + %x_frtp 22:4 !function=times_2 %x_frap 17:4 !function=times_2 %x_frbp 12:4 !function=times_2
@@ -419,6 +425,38 @@ MODUD 011111 ..... ..... ..... 0100001001 - @X ## Fixed-Point Logical Instructions +ANDI_ 011100 ..... ..... ................ @D_ui +ANDIS_ 011101 ..... ..... ................ @D_ui +ORI 011000 ..... ..... ................ @D_ui +ORIS 011001 ..... ..... ................ @D_ui +XORI 011010 ..... ..... ................ @D_ui +XORIS 011011 ..... ..... ................ @D_ui + +AND 011111 ..... ..... ..... 0000011100 . @X_rc +ANDC 011111 ..... ..... ..... 0000111100 . @X_rc +NAND 011111 ..... ..... ..... 0111011100 . @X_rc +OR 011111 ..... ..... ..... 0110111100 . @X_rc +ORC 011111 ..... ..... ..... 0110011100 . @X_rc +NOR 011111 ..... ..... ..... 0001111100 . @X_rc +XOR 011111 ..... ..... ..... 0100111100 . @X_rc +EQV 011111 ..... ..... ..... 0100011100 . @X_rc +CMPB 011111 ..... ..... ..... 0111111100 . @X_rc + +EXTSB 011111 ..... ..... ----- 1110111010 . @X_sa_rc +EXTSH 011111 ..... ..... ----- 1110011010 . @X_sa_rc +EXTSW 011111 ..... ..... ----- 1111011010 . @X_sa_rc +CNTLZW 011111 ..... ..... ----- 0000011010 . @X_sa_rc +CNTTZW 011111 ..... ..... ----- 1000011010 . @X_sa_rc +CNTLZD 011111 ..... ..... ----- 0000111010 . @X_sa_rc +CNTTZD 011111 ..... ..... ----- 1000111010 . @X_sa_rc +POPCNTB 011111 ..... ..... ----- 0001111010 . @X_sa_rc + +POPCNTW 011111 ..... ..... ----- 0101111010 - @X_sa +POPCNTD 011111 ..... ..... ----- 0111111010 - @X_sa +PRTYW 011111 ..... ..... ----- 0010011010 - @X_sa +PRTYD 011111 ..... ..... ----- 0010111010 - @X_sa + +BPERMD 011111 ..... ..... ..... 0011111100 - @X CFUGED 011111 ..... ..... ..... 0011011100 - @X CNTLZDM 011111 ..... ..... ..... 0000111011 - @X CNTTZDM 011111 ..... ..... ..... 1000111011 - @X
target/ppc/int_helper.c +5 -5
@@ -201,7 +201,7 @@ uint64_t helper_DARN64(void)return ret; } -uint64_t helper_bpermd (uint64_t rs,uint64_t rb) +uint64_t helper_BPERMD (uint64_t rs,uint64_t rb) {int i;uint64_t ra =0 ;
@@ -219,7 +219,7 @@ uint64_t helper_bpermd(uint64_t rs, uint64_t rb)#endif -target_ulong helper_cmpb (target_ulong rs,target_ulong rb) +target_ulong helper_CMPB (target_ulong rs,target_ulong rb) {target_ulong mask =0xff ;target_ulong ra =0 ;
@@ -288,7 +288,7 @@ target_ulong helper_srad(CPUPPCState *env, target_ulong value,#endif #if defined(TARGET_PPC64 ) -target_ulong helper_popcntb (target_ulong val) +target_ulong helper_POPCNTB (target_ulong val) {/* Note that we don't fold past bytes */ val = (val & 0x5555555555555555ULL) + ((val >> 1) &
@@ -300,7 +300,7 @@ target_ulong helper_popcntb(target_ulong val)return val; } -target_ulong helper_popcntw (target_ulong val) +target_ulong helper_POPCNTW (target_ulong val) {/* Note that we don't fold past words. */ val = (val & 0x5555555555555555ULL) + ((val >> 1) &
@@ -316,7 +316,7 @@ target_ulong helper_popcntw(target_ulong val) return val; }#else -target_ulong helper_popcntb (target_ulong val) +target_ulong helper_POPCNTB (target_ulong val) {/* Note that we don't fold past bytes */ val = (val &0x55555555 ) + ((val >>1 ) &0x55555555 );
target/ppc/translate.c +0 -359
392 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +300 -0
312 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 23/72] This commit continues adding support for the Branch History Rolling Buffer (BHRB) as is provided starting with the P8 processor and continuing with its successors. This commit is limited to the recording and filtering of taken branches.
In reply to Nicholas PigginFrom: Glenn Miles <[email protected]>
The following changes were made:
- Enabled functionality on P10 processors only due to performance impact seen with P8 and P9 where it is not disabled for non problem state branches.
- Added a BHRB buffer for storing branch instruction and target addresses for taken branches
- Renamed gen_update_cfar to gen_update_branch_history and added a 'target' parameter to hold the branch target address and 'inst_type' parameter to use for filtering
- Added TCG code to gen_update_branch_history that stores data to the BHRB and updates the BHRB offset.
- Added BHRB resource initialization and reset functions
--- target/ppc/cpu.h | 17 +++++ target/ppc/cpu_init.c | 37 +++++++++- target/ppc/power8-pmu.c | 33 +++++++++ target/ppc/power8-pmu.h | 7 ++ target/ppc/translate.c | 97 ++++++++++++++++++++++++-- target/ppc/translate/branch-impl.c.inc | 2 +- 6 files changed, 185 insertions(+), 8 deletions(-)
target/ppc/cpu.h +17 -0
@@ -548,6 +548,8 @@ FIELD(MSR, LE, MSR_LE, 1) MMCR2_FC4P0 | MMCR2_FC5P0 | MMCR2_FC6P0)#define MMCRA_BHRBRD PPC_BIT(26)/* BHRB Recording Disable */ +#define MMCRA_IFM_MASK PPC_BITMASK(32, 33)/* BHRB Instruction Filtering */ +#define MMCRA_IFM_SHIFT PPC_BIT_NR(33)#define MMCR1_EVT_SIZE 8/* extract64() does a right shift before extracting */
@@ -774,6 +776,8 @@ enum {POWERPC_FLAG_SMT =0x00400000 ,/* Using "LPAR per core" mode (as opposed to per-thread) */ POWERPC_FLAG_SMT_1LPAR =0x00800000 , +/* Has BHRB */ + POWERPC_FLAG_BHRB = 0x01000000, };/*
@@ -1215,6 +1219,9 @@ struct pnv_tod_tbst {#define PPC_CPU_OPCODES_LEN 0x40#define PPC_CPU_INDIRECT_OPCODES_LEN 0x20 +#define BHRB_MAX_NUM_ENTRIES_LOG2 (5) +#define BHRB_MAX_NUM_ENTRIES (1 << BHRB_MAX_NUM_ENTRIES_LOG2) +struct CPUArchState {/* Most commonly used resources during translated code execution first */ target_ulong gpr[32 ];/* general purpose registers */
@@ -1311,6 +1318,16 @@ struct CPUArchState {int dcache_line_size;int icache_line_size; +#ifdef TARGET_PPC64 +/* Branch History Rolling Buffer (BHRB) resources */ +target_ulong bhrb_num_entries; +intptr_t bhrb_base; +target_ulong bhrb_filter; +target_ulong bhrb_offset; +target_ulong bhrb_offset_mask; +uint64_t bhrb[BHRB_MAX_NUM_ENTRIES ]; +#endif +/* These resources are used during exception processing */ /* CPU model definition */ target_ulong msr_mask;
target/ppc/cpu_init.c +36 -1
@@ -6142,6 +6142,28 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data) pcc->l1_icache_size =0x8000 ; } +static void bhrb_init_state (CPUPPCState *env,target_long num_entries_log2) +{ +if (env->flags &POWERPC_FLAG_BHRB ) { +if (num_entries_log2 >BHRB_MAX_NUM_ENTRIES_LOG2 ) { + num_entries_log2 =BHRB_MAX_NUM_ENTRIES_LOG2 ; + } + env->bhrb_num_entries =1 << num_entries_log2; + env->bhrb_base = (intptr_t )&env->bhrb[0 ]; + env->bhrb_offset_mask = (env->bhrb_num_entries *sizeof (uint64_t )) -1 ; + } +} + +static void bhrb_reset_state (CPUPPCState *env) +{ +if (env->flags &POWERPC_FLAG_BHRB ) { + env->bhrb_offset =0 ; + env->bhrb_filter =0 ; +memset (env->bhrb,0 ,sizeof (env->bhrb)); + } +} + +#define POWER8_BHRB_ENTRIES_LOG2 5static void init_proc_POWER8 (CPUPPCState *env) {/* Common Registers */
@@ -6183,6 +6205,8 @@ static void init_proc_POWER8(CPUPPCState *env) env->dcache_line_size =128 ; env->icache_line_size =128 ; +bhrb_init_state (env,POWER8_BHRB_ENTRIES_LOG2 ); +/* Allocate hardware IRQ controller */ init_excp_POWER8 (env);ppcPOWER7_irq_init (env_archcpu (env));
@@ -6307,6 +6331,7 @@ static struct ppc_radix_page_info POWER9_radix_page_info = { };#endif /* CONFIG_USER_ONLY */ +#define POWER9_BHRB_ENTRIES_LOG2 5static void init_proc_POWER9 (CPUPPCState *env) {/* Common Registers */
@@ -6357,6 +6382,8 @@ static void init_proc_POWER9(CPUPPCState *env) env->dcache_line_size =128 ; env->icache_line_size =128 ; +bhrb_init_state (env,POWER9_BHRB_ENTRIES_LOG2 ); +/* Allocate hardware IRQ controller */ init_excp_POWER9 (env);ppcPOWER9_irq_init (env_archcpu (env));
@@ -6497,6 +6524,7 @@ static struct ppc_radix_page_info POWER10_radix_page_info = { };#endif /* !CONFIG_USER_ONLY */ +#define POWER10_BHRB_ENTRIES_LOG2 5static void init_proc_POWER10 (CPUPPCState *env) {/* Common Registers */
@@ -6546,6 +6574,8 @@ static void init_proc_POWER10(CPUPPCState *env) env->dcache_line_size =128 ; env->icache_line_size =128 ; +bhrb_init_state (env,POWER10_BHRB_ENTRIES_LOG2 ); +/* Allocate hardware IRQ controller */ init_excp_POWER10 (env);ppcPOWER9_irq_init (env_archcpu (env));
@@ -6650,7 +6680,8 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data) pcc->flags =POWERPC_FLAG_VRE |POWERPC_FLAG_SE |POWERPC_FLAG_BE |POWERPC_FLAG_PMM |POWERPC_FLAG_BUS_CLK |POWERPC_FLAG_CFAR | -POWERPC_FLAG_VSX |POWERPC_FLAG_SCV ; +POWERPC_FLAG_VSX |POWERPC_FLAG_SCV | +POWERPC_FLAG_BHRB ; pcc->l1_dcache_size =0x8000 ; pcc->l1_icache_size =0x8000 ; }
@@ -7222,6 +7253,10 @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type) } env->spr[i] = spr->default_value; } + +#if defined(TARGET_PPC64 ) +bhrb_reset_state (env); +#endif }#ifndef CONFIG_USER_ONLY
target/ppc/power8-pmu.c +33 -0
@@ -82,6 +82,37 @@ static void pmu_update_summaries(CPUPPCState *env) env->pmc_cyc_cnt = cyc_cnt; } +static void hreg_bhrb_filter_update (CPUPPCState *env) +{ +target_long ifm; + +if (!(env->spr[SPR_POWER_MMCR0 ] &MMCR0_PMAE )) { +/* disable recording to BHRB */ + env->bhrb_filter =BHRB_TYPE_NORECORD ; +return ; + } + + ifm = (env->spr[SPR_POWER_MMCRA ] &MMCRA_IFM_MASK ) >>MMCRA_IFM_SHIFT ; +switch (ifm) { +case 0 : +/* record all branches */ + env->bhrb_filter =-1 ; +break ; +case 1 : +/* only record calls (LK = 1) */ + env->bhrb_filter =BHRB_TYPE_CALL ; +break ; +case 2 : +/* only record indirect branches */ + env->bhrb_filter =BHRB_TYPE_INDIRECT ; +break ; +case 3 : +/* only record conditional branches */ + env->bhrb_filter =BHRB_TYPE_COND ; +break ; + } +} +void pmu_mmcr01a_updated (CPUPPCState *env) {PowerPCCPU *cpu =env_archcpu (env);
@@ -95,6 +126,8 @@ void pmu_mmcr01a_updated(CPUPPCState *env)ppc_set_irq (cpu,PPC_INTERRUPT_PERFM ,0 ); } +hreg_bhrb_filter_update (env); +/* * Should this update overflow timers (if mmcr0 is updated) so they * get set in cpu_post_load?
target/ppc/power8-pmu.h +7 -0
@@ -13,6 +13,13 @@#ifndef POWER8_PMU_H #define POWER8_PMU_H +#define BHRB_TYPE_NORECORD 0x00 +#define BHRB_TYPE_CALL 0x01 +#define BHRB_TYPE_INDIRECT 0x02 +#define BHRB_TYPE_COND 0x04 +#define BHRB_TYPE_OTHER 0x08 +#define BHRB_TYPE_XL_FORM 0x10 +#if defined(TARGET_PPC64 ) && !defined(CONFIG_USER_ONLY )#define PMC_COUNTER_NEGATIVE_VAL 0x80000000UL
target/ppc/translate.c +91 -6
177 lines not on this page · raw message
target/ppc/translate/branch-impl.c.inc +1 -1
@@ -17,7 +17,7 @@ static bool trans_RFEBB(DisasContext *ctx, arg_XL_s *arg) REQUIRE_INSNS_FLAGS2(ctx, ISA207S); translator_io_start(&ctx->base); - gen_update_cfar(ctx, ctx->cia); + gen_update_branch_history(ctx, ctx->cia, NULL, BHRB_TYPE_NORECORD); gen_helper_rfebb(tcg_env, cpu_gpr[arg->s]); ctx->base.is_jmp = DISAS_CHAIN;
Signature · 1 line
2.43.0
[PULL 16/72] target/ppc: Move div/mod fixed-point insns (64 bits operands) to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
Moving the below instructions to decodetree specification :
divd[u, e, eu][o][.] : XO-form
mod{sd, ud} : X-formWith this patch, all the fixed-point arithmetic instructions have been moved to decodetree.
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured using the '-d in_asm,op' flag. Also, remaned do_divwe method in fixedpoint-impl.c.inc to do_dive because it is now used to divide doubleword operands as well, and not just words.
--- target/ppc/helper.h | 4 +- target/ppc/insn32.decode | 8 +++ target/ppc/int_helper.c | 4 +- target/ppc/translate.c | 63 ++-------------------- target/ppc/translate/fixedpoint-impl.c.inc | 58 ++++++++++++++++++-- 5 files changed, 70 insertions(+), 67 deletions(-)
target/ppc/helper.h +2 -2
@@ -52,8 +52,8 @@ DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32)#if defined(TARGET_PPC64 ) -DEF_HELPER_4(divdeu, i64, env, i64, i64, i32) -DEF_HELPER_4(divde, i64, env, i64, i64, i32) +DEF_HELPER_4(DIVDEU, i64, env, i64, i64, i32) +DEF_HELPER_4(DIVDE, i64, env, i64, i64, i32)#endif DEF_HELPER_4(DIVWEU, tl, env, tl, tl, i32)DEF_HELPER_4 (DIVWE , tl, env, tl, tl, i32)
target/ppc/insn32.decode +8 -0
@@ -393,6 +393,14 @@ MADDLD 000100 ..... ..... ..... ..... 110011 @VA MADDHD 000100 ..... ..... ..... ..... 110000 @VA MADDHDU 000100 ..... ..... ..... ..... 110001 @VA +DIVD 011111 ..... ..... ..... . 111101001 . @XO +DIVDU 011111 ..... ..... ..... . 111001001 . @XO +DIVDE 011111 ..... ..... ..... . 110101001 . @XO +DIVDEU 011111 ..... ..... ..... . 110001001 . @XO + +MODSD 011111 ..... ..... ..... 1100001001 - @X +MODUD 011111 ..... ..... ..... 0100001001 - @X + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/int_helper.c +2 -2
@@ -101,7 +101,7 @@ target_ulong helper_DIVWE(CPUPPCState *env, target_ulong ra, target_ulong rb,#if defined(TARGET_PPC64 ) -uint64_t helper_divdeu (CPUPPCState *env,uint64_t ra,uint64_t rb,uint32_t oe) +uint64_t helper_DIVDEU (CPUPPCState *env,uint64_t ra,uint64_t rb,uint32_t oe) {uint64_t rt =0 ;int overflow =0 ;
@@ -120,7 +120,7 @@ uint64_t helper_divdeu(CPUPPCState *env, uint64_t ra, uint64_t rb, uint32_t oe)return rt; } -uint64_t helper_divde (CPUPPCState *env,uint64_t rau,uint64_t rbu,uint32_t oe) +uint64_t helper_DIVDE (CPUPPCState *env,uint64_t rau,uint64_t rbu,uint32_t oe) {uint64_t rt =0 ;int64_t ra = (int64_t )rau;
target/ppc/translate.c +3 -60
89 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +55 -3
76 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 02/72] ppc/spapr: Add ibm,pi-features
In reply to Nicholas PigginThe ibm,pi-features property has a bit to say whether or not msgsndp should be used. Linux checks if it is being run under KVM and avoids msgsndp anyway, but it would be preferable to rely on this bit.
--- hw/ppc/spapr.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
hw/ppc/spapr.c +28 -0
@@ -353,6 +353,32 @@ static void spapr_dt_pa_features(SpaprMachineState *spapr,_FDT ((fdt_setprop (fdt, offset,"ibm,pa-features" , pa_features, pa_size))); } +static void spapr_dt_pi_features (SpaprMachineState *spapr, +PowerPCCPU *cpu, +void *fdt,int offset) +{ +uint8_t pi_features[] = {1 ,0 , +0x00 }; + +if (kvm_enabled () &&ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_3_00 , +0 , cpu->compat_pvr)) { +/* +* POWER9 and later CPUs with KVM run in LPAR-per-thread mode where +* all threads are essentially independent CPUs, and msgsndp does not +* work (because it is physically-addressed) and therefore is +* emulated by KVM, so disable it here to ensure XIVE will be used. +* This is both KVM and CPU implementation-specific behaviour so a KVM +* cap would be cleanest, but for now this works. If KVM ever permits +* native msgsndp execution by guests, a cap could be added at that +* time. +*/ + pi_features[2 ] |=0x08 ;/* 4: No msgsndp */ + } + +_FDT ((fdt_setprop (fdt, offset,"ibm,pi-features" , pi_features, +sizeof (pi_features)))); +} +static hwaddr spapr_node0_size (MachineState *machine) {if (machine->numa_state->num_nodes) {
@@ -815,6 +841,8 @@ static void spapr_dt_cpu(CPUState *cs, void *fdt, int offset,spapr_dt_pa_features (spapr, cpu, fdt, offset); +spapr_dt_pi_features (spapr, cpu, fdt, offset); +_FDT ((fdt_setprop_cell (fdt, offset,"ibm,chip-id" , cs->cpu_index / vcpus_per_socket)));
Signature · 1 line
2.43.0
[PULL 13/72] target/ppc: Move divw[u, e, eu] instructions to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
Moving the following instructions to decodetree specification :
divw[u, e, eu][o][.] : XO-form
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/helper.h | 4 +-- target/ppc/insn32.decode | 5 ++++ target/ppc/int_helper.c | 4 +-- target/ppc/translate.c | 31 ---------------------- target/ppc/translate/fixedpoint-impl.c.inc | 24 +++++++++++++++++ 5 files changed, 33 insertions(+), 35 deletions(-)
target/ppc/helper.h +2 -2
@@ -55,8 +55,8 @@ DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32) DEF_HELPER_4(divdeu, i64, env, i64, i64, i32) DEF_HELPER_4(divde, i64, env, i64, i64, i32)#endif -DEF_HELPER_4(divweu, tl, env, tl, tl, i32) -DEF_HELPER_4(divwe, tl, env, tl, tl, i32) +DEF_HELPER_4(DIVWEU, tl, env, tl, tl, i32) +DEF_HELPER_4(DIVWE, tl, env, tl, tl, i32) DEF_HELPER_FLAGS_1(popcntb, TCG_CALL_NO_RWG_SE, tl, tl)DEF_HELPER_FLAGS_2 (cmpb,TCG_CALL_NO_RWG_SE , tl, tl, tl)
target/ppc/insn32.decode +5 -0
@@ -371,6 +371,11 @@ MULLWO 011111 ..... ..... ..... 1 011101011 . @XO_tab_rc MULHW 011111 ..... ..... ..... - 001001011 . @XO_tab_rc MULHWU 011111 ..... ..... ..... - 000001011 . @XO_tab_rc +DIVW 011111 ..... ..... ..... . 111101011 . @XO +DIVWU 011111 ..... ..... ..... . 111001011 . @XO +DIVWE 011111 ..... ..... ..... . 110101011 . @XO +DIVWEU 011111 ..... ..... ..... . 110001011 . @XO + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/int_helper.c +2 -2
@@ -44,7 +44,7 @@ static inline void helper_update_ov_legacy(CPUPPCState *env, int ov) } } -target_ulong helper_divweu (CPUPPCState *env,target_ulong ra,target_ulong rb, +target_ulong helper_DIVWEU (CPUPPCState *env,target_ulong ra,target_ulong rb,uint32_t oe) {uint64_t rt =0 ;
@@ -71,7 +71,7 @@ target_ulong helper_divweu(CPUPPCState *env, target_ulong ra, target_ulong rb,return (target_ulong )rt; } -target_ulong helper_divwe (CPUPPCState *env,target_ulong ra,target_ulong rb, +target_ulong helper_DIVWE (CPUPPCState *env,target_ulong ra,target_ulong rb,uint32_t oe) {int64_t rt =0 ;
target/ppc/translate.c +0 -31
@@ -1777,21 +1777,6 @@ static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret,gen_set_Rc0 (ctx, ret); } } -/* Div functions */ -#define GEN_INT_ARITH_DIVW (name, opc3, sign, compute_ov) \ -static void glue(gen_, name)(DisasContext *ctx) \ -{ \ - gen_op_arith_divw(ctx, cpu_gpr[rD(ctx->opcode)], \ - cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \ - sign, compute_ov, Rc(ctx->opcode)); \ -} -/* divwu divwu. divwuo divwuo. */ -GEN_INT_ARITH_DIVW (divwu,0x0E ,0 ,0 ); -GEN_INT_ARITH_DIVW (divwuo,0x1E ,0 ,1 ); -/* divw divw. divwo divwo. */ -GEN_INT_ARITH_DIVW (divw,0x0F ,1 ,0 ); -GEN_INT_ARITH_DIVW (divwo,0x1F ,1 ,1 ); -/* div[wd]eu[o][.] */ #define GEN_DIVE (name, hlpr, compute_ov) \ static void gen_##name(DisasContext *ctx) \
@@ -1804,11 +1789,6 @@ static void gen_##name(DisasContext *ctx) \ } \ } -GEN_DIVE (divweu, divweu,0 ); -GEN_DIVE (divweuo, divweu,1 ); -GEN_DIVE (divwe, divwe,0 ); -GEN_DIVE (divweo, divwe,1 ); -#if defined(TARGET_PPC64 )static inline void gen_op_arith_divd (DisasContext *ctx,TCGv ret,TCGv arg1,TCGv arg2,int sign,int compute_ov)
@@ -6470,17 +6450,6 @@ GEN_HANDLER_E(maddhd_maddhdu, 0x04, 0x18, 0xFF, 0x00000000, PPC_NONE,GEN_HANDLER_E (maddld,0x04 ,0x19 ,0xFF ,0x00000000 ,PPC_NONE ,PPC2_ISA300 ), #endif -#undef GEN_INT_ARITH_DIVW -#define GEN_INT_ARITH_DIVW (name, opc3, sign, compute_ov) \ -GEN_HANDLER(name, 0x1F, 0x0B, opc3, 0x00000000, PPC_INTEGER) -GEN_INT_ARITH_DIVW (divwu,0x0E ,0 ,0 ), -GEN_INT_ARITH_DIVW (divwuo,0x1E ,0 ,1 ), -GEN_INT_ARITH_DIVW (divw,0x0F ,1 ,0 ), -GEN_INT_ARITH_DIVW (divwo,0x1F ,1 ,1 ), -GEN_HANDLER_E (divwe,0x1F ,0x0B ,0x0D ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), -GEN_HANDLER_E (divweo,0x1F ,0x0B ,0x1D ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), -GEN_HANDLER_E (divweu,0x1F ,0x0B ,0x0C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ), -GEN_HANDLER_E (divweuo,0x1F ,0x0B ,0x1C ,0 ,PPC_NONE ,PPC2_DIVE_ISA206 ),GEN_HANDLER_E (modsw,0x1F ,0x0B ,0x18 ,0x00000001 ,PPC_NONE ,PPC2_ISA300 ), GEN_HANDLER_E(moduw, 0x1F, 0x0B, 0x08, 0x00000001, PPC_NONE, PPC2_ISA300),
target/ppc/translate/fixedpoint-impl.c.inc +24 -0
@@ -461,6 +461,30 @@ static bool do_mulhw(DisasContext *ctx, arg_XO_tab_rc *a, TRANS(MULHW, do_mulhw, tcg_gen_muls2_i32) TRANS(MULHWU, do_mulhw, tcg_gen_mulu2_i32) +static bool do_divw(DisasContext *ctx, arg_XO *a, int sign) +{ + gen_op_arith_divw(ctx, cpu_gpr[a->rt], cpu_gpr[a->ra], cpu_gpr[a->rb], + sign, a->oe, a->rc); + return true; +} + +static bool do_divwe(DisasContext *ctx, arg_XO *a, + void (*helper)(TCGv, TCGv_ptr, TCGv, TCGv, TCGv_i32)) +{ + REQUIRE_INSNS_FLAGS2(ctx, DIVE_ISA206); + helper(cpu_gpr[a->rt], tcg_env, cpu_gpr[a->ra], cpu_gpr[a->rb], + tcg_constant_i32(a->oe)); + if (unlikely(a->rc)) { + gen_set_Rc0(ctx, cpu_gpr[a->rt]); + } + return true; +} + +TRANS(DIVW, do_divw, 1); +TRANS(DIVWU, do_divw, 0); +TRANS(DIVWE, do_divwe, gen_helper_DIVWE); +TRANS(DIVWEU, do_divwe, gen_helper_DIVWEU); + static bool trans_INVALID(DisasContext *ctx, arg_INVALID *a) { gen_invalid(ctx);
Signature · 1 line
2.43.0
[PULL 38/72] target/ppc: add SMT support to msgsnd broadcast
In reply to Nicholas Pigginmsgsnd has a broadcast mode that sends hypervisor doorbells to all threads belonging to the same core as the target. A "subcore" mode sends to all or one thread depending on 1LPAR mode.
--- target/ppc/cpu.h | 6 +- target/ppc/excp_helper.c | 57 +++++++++++++------ target/ppc/helper.h | 2 +- .../ppc/translate/processor-ctrl-impl.c.inc | 2 +- 4 files changed, 46 insertions(+), 21 deletions(-)
target/ppc/cpu.h +5 -1
@@ -1163,7 +1163,11 @@ FIELD(FPSCR, FI, FPSCR_FI, 1)#define DBELL_TYPE_DBELL_SERVER (0x05 << DBELL_TYPE_SHIFT) -#define DBELL_BRDCAST PPC_BIT(37) +#define DBELL_BRDCAST_MASK PPC_BITMASK(37, 38) +#define DBELL_BRDCAST_SHIFT 25 +#define DBELL_BRDCAST_SUBPROC (0x1 << DBELL_BRDCAST_SHIFT) +#define DBELL_BRDCAST_CORE (0x2 << DBELL_BRDCAST_SHIFT) +#define DBELL_LPIDTAG_SHIFT 14#define DBELL_LPIDTAG_MASK (0xfff << DBELL_LPIDTAG_SHIFT)#define DBELL_PIRTAG_MASK 0x3fff
target/ppc/excp_helper.c +39 -18
84 lines not on this page · raw message
target/ppc/helper.h +1 -1
@@ -695,7 +695,7 @@ DEF_HELPER_FLAGS_3(store_sr, TCG_CALL_NO_RWG, void, env, tl, tl) DEF_HELPER_1(msgsnd, void, tl) DEF_HELPER_2(msgclr, void, env, tl) -DEF_HELPER_1(book3s_msgsnd, void, tl) +DEF_HELPER_2(book3s_msgsnd, void, env, tl) DEF_HELPER_2(book3s_msgclr, void, env, tl)#endif
target/ppc/translate/processor-ctrl-impl.c.inc +1 -1
@@ -59,7 +59,7 @@ static bool trans_MSGSND(DisasContext *ctx, arg_X_rb *a) #if !defined(CONFIG_USER_ONLY) if (is_book3s_arch2x(ctx)) { - gen_helper_book3s_msgsnd(cpu_gpr[a->rb]); + gen_helper_book3s_msgsnd(tcg_env, cpu_gpr[a->rb]); } else { gen_helper_msgsnd(cpu_gpr[a->rb]); }
Signature · 1 line
2.43.0
[PULL 33/72] target/ppc: add helper to write per-LPAR SPRs
In reply to Nicholas PigginAn SPR can be either per-thread, per-core, or per-LPAR. Per-LPAR means per-thread or per-core, depending on 1LPAR mode.
--- target/ppc/spr_common.h | 2 ++ target/ppc/translate.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
target/ppc/spr_common.h +2 -0
@@ -83,6 +83,8 @@ void spr_read_generic(DisasContext *ctx, int gprn, int sprn);void spr_write_generic (DisasContext *ctx,int sprn,int gprn);void spr_write_generic32 (DisasContext *ctx,int sprn,int gprn);void spr_core_write_generic (DisasContext *ctx,int sprn,int gprn); +void spr_core_write_generic32 (DisasContext *ctx,int sprn,int gprn); +void spr_core_lpar_write_generic (DisasContext *ctx,int sprn,int gprn);void spr_write_MMCR0 (DisasContext *ctx,int sprn,int gprn);void spr_write_MMCR1 (DisasContext *ctx,int sprn,int gprn);void spr_write_MMCRA (DisasContext *ctx,int sprn,int gprn);
target/ppc/translate.c +28 -0
@@ -473,6 +473,34 @@ void spr_core_write_generic(DisasContext *ctx, int sprn, int gprn)spr_store_dump_spr (sprn); } +void spr_core_write_generic32 (DisasContext *ctx,int sprn,int gprn) +{ +TCGv t0; + +if (!(ctx->flags &POWERPC_FLAG_SMT )) { +spr_write_generic32 (ctx, sprn, gprn); +return ; + } + +if (!gen_serialize (ctx)) { +return ; + } + + t0 =tcg_temp_new (); +tcg_gen_ext32u_tl (t0, cpu_gpr[gprn]); +gen_helper_spr_core_write_generic (tcg_env,tcg_constant_i32 (sprn), t0); +spr_store_dump_spr (sprn); +} + +void spr_core_lpar_write_generic (DisasContext *ctx,int sprn,int gprn) +{ +if (ctx->flags &POWERPC_FLAG_SMT_1LPAR ) { +spr_core_write_generic (ctx, sprn, gprn); + }else { +spr_write_generic (ctx, sprn, gprn); + } +} +static void spr_write_CTRL_ST (DisasContext *ctx,int sprn,int gprn) {/* This does not implement >1 thread */
Signature · 1 line
2.43.0
[PULL 35/72] target/ppc: Add SMT support to PTCR SPR
In reply to Nicholas PigginPTCR is a per-core register.
--- target/ppc/misc_helper.c | 16 ++++++++++++++-- target/ppc/translate.c | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-)
target/ppc/misc_helper.c +14 -2
@@ -173,6 +173,7 @@ void helper_store_sdr1(CPUPPCState *env, target_ulong val)void helper_store_ptcr (CPUPPCState *env,target_ulong val) {if (env->spr[SPR_PTCR ] != val) { +CPUState *cs =env_cpu (env);PowerPCCPU *cpu =env_archcpu (env);target_ulong ptcr_mask =PTCR_PATB |PTCR_PATS ;target_ulong patbsize = val &PTCR_PATS ;
@@ -194,8 +195,19 @@ void helper_store_ptcr(CPUPPCState *env, target_ulong val)return ; } - env->spr[SPR_PTCR ] = val; -tlb_flush (env_cpu (env)); +if (cs->nr_threads ==1 || !(env->flags &POWERPC_FLAG_SMT_1LPAR )) { + env->spr[SPR_PTCR ] = val; +tlb_flush (cs); + }else { +CPUState *ccs; + + THREAD_SIBLING_FOREACH(cs, ccs) { +PowerPCCPU *ccpu =POWERPC_CPU (ccs); +CPUPPCState *cenv = &ccpu->env; + cenv->spr[SPR_PTCR ] = val; +tlb_flush (ccs); + } + } } }
target/ppc/translate.c +4 -0
@@ -909,6 +909,10 @@ void spr_write_hior(DisasContext *ctx, int sprn, int gprn) }void spr_write_ptcr (DisasContext *ctx,int sprn,int gprn) { +if (!gen_serialize_core (ctx)) { +return ; + } +gen_helper_store_ptcr (tcg_env, cpu_gpr[gprn]); }
Signature · 1 line
2.43.0
[PULL 21/72] target/ppc: Move VMX integer max/min instructions to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
Moving the following instructions to decodetree specification :
v{max, min}{u, s}{b, h, w, d} : VX-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/insn32.decode | 22 +++++++++++++++++ target/ppc/translate/vmx-impl.c.inc | 37 ++++++++++++++++------------- target/ppc/translate/vmx-ops.c.inc | 16 ------------- 3 files changed, 43 insertions(+), 32 deletions(-)
target/ppc/insn32.decode +22 -0
@@ -852,6 +852,28 @@ VEXTSD2Q 000100 ..... 11011 ..... 11000000010 @VX_tb VNEGD 000100 ..... 00111 ..... 11000000010 @VX_tb VNEGW 000100 ..... 00110 ..... 11000000010 @VX_tb +## Vector Integer Maximum/Minimum Instructions + +VMAXUB 000100 ..... ..... ..... 00000000010 @VX +VMAXUH 000100 ..... ..... ..... 00001000010 @VX +VMAXUW 000100 ..... ..... ..... 00010000010 @VX +VMAXUD 000100 ..... ..... ..... 00011000010 @VX + +VMAXSB 000100 ..... ..... ..... 00100000010 @VX +VMAXSH 000100 ..... ..... ..... 00101000010 @VX +VMAXSW 000100 ..... ..... ..... 00110000010 @VX +VMAXSD 000100 ..... ..... ..... 00111000010 @VX + +VMINUB 000100 ..... ..... ..... 01000000010 @VX +VMINUH 000100 ..... ..... ..... 01001000010 @VX +VMINUW 000100 ..... ..... ..... 01010000010 @VX +VMINUD 000100 ..... ..... ..... 01011000010 @VX + +VMINSB 000100 ..... ..... ..... 01100000010 @VX +VMINSH 000100 ..... ..... ..... 01101000010 @VX +VMINSW 000100 ..... ..... ..... 01110000010 @VX +VMINSD 000100 ..... ..... ..... 01111000010 @VX + ## Vector Mask Manipulation Instructions MTVSRBM 000100 ..... 10000 ..... 11001000010 @VX_tb
target/ppc/translate/vmx-impl.c.inc +21 -16
@@ -342,22 +342,6 @@ GEN_VXFORM_V(vsububm, MO_8, tcg_gen_gvec_sub, 0, 16); GEN_VXFORM_V(vsubuhm, MO_16, tcg_gen_gvec_sub, 0, 17); GEN_VXFORM_V(vsubuwm, MO_32, tcg_gen_gvec_sub, 0, 18); GEN_VXFORM_V(vsubudm, MO_64, tcg_gen_gvec_sub, 0, 19); -GEN_VXFORM_V(vmaxub, MO_8, tcg_gen_gvec_umax, 1, 0); -GEN_VXFORM_V(vmaxuh, MO_16, tcg_gen_gvec_umax, 1, 1); -GEN_VXFORM_V(vmaxuw, MO_32, tcg_gen_gvec_umax, 1, 2); -GEN_VXFORM_V(vmaxud, MO_64, tcg_gen_gvec_umax, 1, 3); -GEN_VXFORM_V(vmaxsb, MO_8, tcg_gen_gvec_smax, 1, 4); -GEN_VXFORM_V(vmaxsh, MO_16, tcg_gen_gvec_smax, 1, 5); -GEN_VXFORM_V(vmaxsw, MO_32, tcg_gen_gvec_smax, 1, 6); -GEN_VXFORM_V(vmaxsd, MO_64, tcg_gen_gvec_smax, 1, 7); -GEN_VXFORM_V(vminub, MO_8, tcg_gen_gvec_umin, 1, 8); -GEN_VXFORM_V(vminuh, MO_16, tcg_gen_gvec_umin, 1, 9); -GEN_VXFORM_V(vminuw, MO_32, tcg_gen_gvec_umin, 1, 10); -GEN_VXFORM_V(vminud, MO_64, tcg_gen_gvec_umin, 1, 11); -GEN_VXFORM_V(vminsb, MO_8, tcg_gen_gvec_smin, 1, 12); -GEN_VXFORM_V(vminsh, MO_16, tcg_gen_gvec_smin, 1, 13); -GEN_VXFORM_V(vminsw, MO_32, tcg_gen_gvec_smin, 1, 14); -GEN_VXFORM_V(vminsd, MO_64, tcg_gen_gvec_smin, 1, 15); GEN_VXFORM(vmrghb, 6, 0); GEN_VXFORM(vmrghh, 6, 1); GEN_VXFORM(vmrghw, 6, 2);
@@ -727,6 +711,27 @@ TRANS_FLAGS2(ALTIVEC_207, VEQV, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_eqv); TRANS_FLAGS2(ALTIVEC_207, VNAND, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_nand); TRANS_FLAGS2(ALTIVEC_207, VORC, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_orc); +/* Integer Max/Min operations */ +TRANS_FLAGS(ALTIVEC, VMAXUB, do_vector_gvec3_VX, MO_8, tcg_gen_gvec_umax); +TRANS_FLAGS(ALTIVEC, VMAXUH, do_vector_gvec3_VX, MO_16, tcg_gen_gvec_umax); +TRANS_FLAGS(ALTIVEC, VMAXUW, do_vector_gvec3_VX, MO_32, tcg_gen_gvec_umax); +TRANS_FLAGS2(ALTIVEC_207, VMAXUD, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_umax); + +TRANS_FLAGS(ALTIVEC, VMAXSB, do_vector_gvec3_VX, MO_8, tcg_gen_gvec_smax); +TRANS_FLAGS(ALTIVEC, VMAXSH, do_vector_gvec3_VX, MO_16, tcg_gen_gvec_smax); +TRANS_FLAGS(ALTIVEC, VMAXSW, do_vector_gvec3_VX, MO_32, tcg_gen_gvec_smax); +TRANS_FLAGS2(ALTIVEC_207, VMAXSD, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_smax); + +TRANS_FLAGS(ALTIVEC, VMINUB, do_vector_gvec3_VX, MO_8, tcg_gen_gvec_umin); +TRANS_FLAGS(ALTIVEC, VMINUH, do_vector_gvec3_VX, MO_16, tcg_gen_gvec_umin); +TRANS_FLAGS(ALTIVEC, VMINUW, do_vector_gvec3_VX, MO_32, tcg_gen_gvec_umin); +TRANS_FLAGS2(ALTIVEC_207, VMINUD, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_umin); + +TRANS_FLAGS(ALTIVEC, VMINSB, do_vector_gvec3_VX, MO_8, tcg_gen_gvec_smin); +TRANS_FLAGS(ALTIVEC, VMINSH, do_vector_gvec3_VX, MO_16, tcg_gen_gvec_smin); +TRANS_FLAGS(ALTIVEC, VMINSW, do_vector_gvec3_VX, MO_32, tcg_gen_gvec_smin); +TRANS_FLAGS2(ALTIVEC_207, VMINSD, do_vector_gvec3_VX, MO_64, tcg_gen_gvec_smin); + static TCGv_vec do_vrl_mask_vec(unsigned vece, TCGv_vec vrb) { TCGv_vec t0 = tcg_temp_new_vec_matching(vrb),
target/ppc/translate/vmx-ops.c.inc +0 -16
@@ -33,22 +33,6 @@ GEN_VXFORM_DUAL(vsubuhm, bcdsub, 0, 17, PPC_ALTIVEC, PPC_NONE), GEN_VXFORM_DUAL(vsubuwm, bcdus, 0, 18, PPC_ALTIVEC, PPC2_ISA300), GEN_VXFORM_DUAL(vsubudm, bcds, 0, 19, PPC2_ALTIVEC_207, PPC2_ISA300), GEN_VXFORM_300(bcds, 0, 27), -GEN_VXFORM(vmaxub, 1, 0), -GEN_VXFORM(vmaxuh, 1, 1), -GEN_VXFORM(vmaxuw, 1, 2), -GEN_VXFORM_207(vmaxud, 1, 3), -GEN_VXFORM(vmaxsb, 1, 4), -GEN_VXFORM(vmaxsh, 1, 5), -GEN_VXFORM(vmaxsw, 1, 6), -GEN_VXFORM_207(vmaxsd, 1, 7), -GEN_VXFORM(vminub, 1, 8), -GEN_VXFORM(vminuh, 1, 9), -GEN_VXFORM(vminuw, 1, 10), -GEN_VXFORM_207(vminud, 1, 11), -GEN_VXFORM(vminsb, 1, 12), -GEN_VXFORM(vminsh, 1, 13), -GEN_VXFORM(vminsw, 1, 14), -GEN_VXFORM_207(vminsd, 1, 15), GEN_VXFORM(vmrghb, 6, 0), GEN_VXFORM(vmrghh, 6, 1), GEN_VXFORM(vmrghw, 6, 2),
Signature · 1 line
2.43.0
[PULL 29/72] target/ppc: improve checkstop logging
In reply to Nicholas PigginChange the logging not to print to stderr as well, because a checkstop is a guest error (or perhaps a simulated machine error) rather than a QEMU error, so send it to the log.
Update the checkstop message, and log CPU registers too.
--- target/ppc/excp_helper.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
target/ppc/excp_helper.c +8 -6
@@ -430,17 +430,19 @@ static void powerpc_mcheck_checkstop(CPUPPCState *env)/* KVM guests always have MSR[ME] enabled */ #ifdef CONFIG_TCG CPUState *cs =env_cpu (env); +FILE *f;if (FIELD_EX64 (env->msr,MSR ,ME )) {return ; } -/* Machine check exception is not enabled. Enter checkstop state. */ -fprintf (stderr,"Machine check while not allowed. " -"Entering checkstop state\n" ); -if (qemu_log_separate ()) { -qemu_log ("Machine check while not allowed. " -"Entering checkstop state\n" ); + f =qemu_log_trylock (); +if (f) { +fprintf (f,"Entering checkstop state: " +"machine check with MSR[ME]=0\n" ); +cpu_dump_state (cs, f,CPU_DUMP_FPU |CPU_DUMP_CCOP ); +qemu_log_unlock (f); + }/* * This stops the machine and logs CPU state without killing QEMU
Signature · 1 line
2.43.0
[PULL 01/72] spapr: avoid overhead of finding vhyp class in critical operations
In reply to Nicholas PigginPPC_VIRTUAL_HYPERVISOR_GET_CLASS is used in critical operations like interrupts and TLB misses and is quite costly. Running the kvm-unit-tests sieve program with radix MMU enabled thrashes the TCG TLB and spends a lot of time in TLB and page table walking code. The test takes 67 seconds to complete with a lot of time being spent in code related to finding the vhyp class:
12.01% [.] g_str_hash
8.94% [.] g_hash_table_lookup
8.06% [.] object_class_dynamic_cast
6.21% [.] address_space_ldq
4.94% [.] __strcmp_avx2
4.28% [.] tlb_set_page_full
4.08% [.] address_space_translate_internal
3.17% [.] object_class_dynamic_cast_assert
2.84% [.] ppc_radix64_xlateKeep a pointer to the class and avoid this lookup. This reduces the execution time to 40 seconds.
--- hw/ppc/pegasos2.c | 1 + target/ppc/cpu.h | 3 ++- target/ppc/cpu_init.c | 9 +++------ target/ppc/excp_helper.c | 16 ++++------------ target/ppc/kvm.c | 4 +--- target/ppc/mmu-book3s-v3.h | 4 +--- target/ppc/mmu-hash64.c | 16 ++++------------ target/ppc/mmu-radix64.c | 4 +--- 8 files changed, 17 insertions(+), 40 deletions(-)
hw/ppc/pegasos2.c +1 -0
@@ -400,6 +400,7 @@ static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason) machine->fdt = fdt; pm->cpu->vhyp =PPC_VIRTUAL_HYPERVISOR (machine); + pm->cpu->vhyp_class =PPC_VIRTUAL_HYPERVISOR_GET_CLASS (pm->cpu->vhyp); }enum pegasos2_rtas_tokens {
target/ppc/cpu.h +2 -1
@@ -1435,6 +1435,7 @@ struct ArchCPU {int vcpu_id;uint32_t compat_pvr;PPCVirtualHypervisor *vhyp; +PPCVirtualHypervisorClass *vhyp_class;void *machine_data;int32_t node_id;/* NUMA node this CPU belongs to */ PPCHash64Options *hash64_opts;
@@ -1532,7 +1533,7 @@ DECLARE_OBJ_CHECKERS(PPCVirtualHypervisor, PPCVirtualHypervisorClass,static inline bool vhyp_cpu_in_nested (PowerPCCPU *cpu) { -return PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp)->cpu_in_nested (cpu); +return cpu->vhyp_class->cpu_in_nested (cpu); }#endif /* CONFIG_USER_ONLY */
target/ppc/cpu_init.c +3 -6
@@ -6661,6 +6661,7 @@ void cpu_ppc_set_vhyp(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp)CPUPPCState *env = &cpu->env; cpu->vhyp = vhyp; + cpu->vhyp_class =PPC_VIRTUAL_HYPERVISOR_GET_CLASS (vhyp);/* * With a virtual hypervisor mode we never allow the CPU to go
@@ -7248,9 +7249,7 @@ static void ppc_cpu_exec_enter(CPUState *cs)PowerPCCPU *cpu =POWERPC_CPU (cs);if (cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->cpu_exec_enter (cpu->vhyp, cpu); + cpu->vhyp_class->cpu_exec_enter (cpu->vhyp, cpu); } }
@@ -7259,9 +7258,7 @@ static void ppc_cpu_exec_exit(CPUState *cs)PowerPCCPU *cpu =POWERPC_CPU (cs);if (cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->cpu_exec_exit (cpu->vhyp, cpu); + cpu->vhyp_class->cpu_exec_exit (cpu->vhyp, cpu); } }#endif /* CONFIG_TCG */
target/ppc/excp_helper.c +4 -12
@@ -794,9 +794,7 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp)* HV mode, we need to keep hypercall support. */ if (lev ==1 && cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->hypercall (cpu->vhyp, cpu); + cpu->vhyp_class->hypercall (cpu->vhyp, cpu);powerpc_reset_excp_state (cpu);return ; }
@@ -946,9 +944,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp)* HV mode, we need to keep hypercall support. */ if (lev ==1 && cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->hypercall (cpu->vhyp, cpu); + cpu->vhyp_class->hypercall (cpu->vhyp, cpu);powerpc_reset_excp_state (cpu);return ; }
@@ -1437,9 +1433,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)/* "PAPR mode" built-in hypercall emulation */ if (lev ==1 &&books_vhyp_handles_hcall (cpu)) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->hypercall (cpu->vhyp, cpu); + cpu->vhyp_class->hypercall (cpu->vhyp, cpu);powerpc_reset_excp_state (cpu);return ; }
@@ -1574,10 +1568,8 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp) }if ((new_msr &MSR_HVB ) &&books_vhyp_handles_hv_excp (cpu)) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp);/* Deliver interrupt to L1 by returning from the H_ENTER_NESTED call */ - vhc->deliver_hv_excp (cpu, excp); + cpu->vhyp_class->deliver_hv_excp (cpu, excp);powerpc_reset_excp_state (cpu); }else {/* Sanity check */
target/ppc/kvm.c +1 -3
@@ -865,9 +865,7 @@ int kvmppc_put_books_sregs(PowerPCCPU *cpu) sregs.pvr = env->spr[SPR_PVR ];if (cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - sregs.u.s.sdr1 = vhc->encode_hpt_for_kvm_pr (cpu->vhyp); + sregs.u.s.sdr1 = cpu->vhyp_class->encode_hpt_for_kvm_pr (cpu->vhyp); }else { sregs.u.s.sdr1 = env->spr[SPR_SDR1 ]; }
target/ppc/mmu-book3s-v3.h +1 -3
@@ -108,9 +108,7 @@ static inline hwaddr ppc_hash64_hpt_mask(PowerPCCPU *cpu)uint64_t base;if (cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); -return vhc->hpt_mask (cpu->vhyp); +return cpu->vhyp_class->hpt_mask (cpu->vhyp); }if (cpu->env.mmu_model ==POWERPC_MMU_3_00 ) {ppc_v3_pate_t pate;
target/ppc/mmu-hash64.c +4 -12
@@ -517,9 +517,7 @@ const ppc_hash_pte64_t *ppc_hash64_map_hptes(PowerPCCPU *cpu,const ppc_hash_pte64_t *hptes;if (cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); -return vhc->map_hptes (cpu->vhyp, ptex, n); +return cpu->vhyp_class->map_hptes (cpu->vhyp, ptex, n); } base =ppc_hash64_hpt_base (cpu);
@@ -539,9 +537,7 @@ void ppc_hash64_unmap_hptes(PowerPCCPU *cpu, const ppc_hash_pte64_t *hptes, hwaddr ptex, int n) {if (cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->unmap_hptes (cpu->vhyp, hptes, ptex, n); + cpu->vhyp_class->unmap_hptes (cpu->vhyp, hptes, ptex, n);return ; }
@@ -821,9 +817,7 @@ static void ppc_hash64_set_r(PowerPCCPU *cpu, hwaddr ptex, uint64_t pte1)hwaddr base, offset = ptex *HASH_PTE_SIZE_64 +HPTE64_DW1_R ;if (cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->hpte_set_r (cpu->vhyp, ptex, pte1); + cpu->vhyp_class->hpte_set_r (cpu->vhyp, ptex, pte1);return ; } base =ppc_hash64_hpt_base (cpu);
@@ -838,9 +832,7 @@ static void ppc_hash64_set_c(PowerPCCPU *cpu, hwaddr ptex, uint64_t pte1)hwaddr base, offset = ptex *HASH_PTE_SIZE_64 +HPTE64_DW1_C ;if (cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->hpte_set_c (cpu->vhyp, ptex, pte1); + cpu->vhyp_class->hpte_set_c (cpu->vhyp, ptex, pte1);return ; } base =ppc_hash64_hpt_base (cpu);
target/ppc/mmu-radix64.c +1 -3
@@ -678,9 +678,7 @@ static bool ppc_radix64_xlate_impl(PowerPCCPU *cpu, vaddr eaddr,/* Get Partition Table */ if (cpu->vhyp) { -PPCVirtualHypervisorClass *vhc; - vhc =PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); -if (!vhc->get_pate (cpu->vhyp, cpu, lpid, &pate)) { +if (!cpu->vhyp_class->get_pate (cpu->vhyp, cpu, lpid, &pate)) {if (guest_visible) {ppc_radix64_raise_hsi (cpu, access_type, eaddr, eaddr,DSISR_R_BADCONFIG );
Signature · 1 line
2.43.0
[PULL 14/72] target/ppc: Move neg, darn, mod{sw, uw} to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
Moving the below instructions to decodetree specification :
neg[o][.] : XO-form
mod{sw, uw}, darn : X-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/helper.h | 4 +- target/ppc/insn32.decode | 8 ++++ target/ppc/int_helper.c | 4 +- target/ppc/translate.c | 56 ---------------------- target/ppc/translate/fixedpoint-impl.c.inc | 48 +++++++++++++++++++ 5 files changed, 60 insertions(+), 60 deletions(-)
target/ppc/helper.h +2 -2
@@ -71,8 +71,8 @@ DEF_HELPER_FLAGS_2(cmpeqb, TCG_CALL_NO_RWG_SE, i32, tl, tl) DEF_HELPER_FLAGS_1(popcntw, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_2(bpermd, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_3(srad, tl, env, tl, tl) -DEF_HELPER_FLAGS_0(darn32, TCG_CALL_NO_RWG, tl) -DEF_HELPER_FLAGS_0(darn64, TCG_CALL_NO_RWG, tl) +DEF_HELPER_FLAGS_0(DARN32, TCG_CALL_NO_RWG, tl) +DEF_HELPER_FLAGS_0(DARN64, TCG_CALL_NO_RWG, tl)#endif DEF_HELPER_FLAGS_1 (cntlsw32,TCG_CALL_NO_RWG_SE , i32, i32)
target/ppc/insn32.decode +8 -0
@@ -196,6 +196,9 @@ &X_a ra @X_a ...... ra:3 .. ..... ..... .......... . &X_a +&X_tl rt l +@X_tl ...... rt:5 ... l:2 ..... .......... . &X_tl + &XO rt ra rb oe:bool rc:bool @XO ...... rt:5 ra:5 rb:5 oe:1 ......... rc:1 &XO
@@ -376,6 +379,11 @@ DIVWU 011111 ..... ..... ..... . 111001011 . @XO DIVWE 011111 ..... ..... ..... . 110101011 . @XO DIVWEU 011111 ..... ..... ..... . 110001011 . @XO +MODSW 011111 ..... ..... ..... 1100001011 - @X +MODUW 011111 ..... ..... ..... 0100001011 - @X +DARN 011111 ..... --- .. ----- 1011110011 - @X_tl +NEG 011111 ..... ..... ----- . 001101000 . @XO_ta + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/int_helper.c +2 -2
@@ -171,7 +171,7 @@ uint32_t helper_cmpeqb(target_ulong ra, target_ulong rb)/* * Return a random number. */ -uint64_t helper_darn32 (void ) +uint64_t helper_DARN32 (void ) {Error *err =NULL ;uint32_t ret;
@@ -186,7 +186,7 @@ uint64_t helper_darn32(void)return ret; } -uint64_t helper_darn64 (void ) +uint64_t helper_DARN64 (void ) {Error *err =NULL ;uint64_t ret;
target/ppc/translate.c +0 -56
92 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +48 -0
54 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 10/72] target/ppc: Move floating-point arithmetic instructions to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
This patch moves the below instructions to decodetree specification :
f{add, sub, mul, div, re, rsqrte, madd, msub, nmadd, nmsub}[s][.] : A-form
ft{div, sqrt} : X-form
With this patch, all the floating-point arithmetic instructions have been moved to decodetree.
The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/fpu_helper.c | 38 ++-- target/ppc/helper.h | 44 ++--- target/ppc/insn32.decode | 42 +++++ target/ppc/translate/fp-impl.c.inc | 285 +++++++++++------------------ target/ppc/translate/fp-ops.c.inc | 31 ---- 5 files changed, 192 insertions(+), 248 deletions(-)
target/ppc/fpu_helper.c +19 -19
@@ -673,7 +673,7 @@ static uint64_t do_fmadds(CPUPPCState *env, float64 a, float64 b, uint64_t helper_##op(CPUPPCState *env, uint64_t arg1, \ uint64_t arg2, uint64_t arg3) \ { return do_fmadd(env, arg1, arg2, arg3, madd_flags, GETPC()); } \ - uint64_t helper_##op##s(CPUPPCState *env, uint64_t arg1, \ + uint64_t helper_##op##S(CPUPPCState *env, uint64_t arg1, \ uint64_t arg2, uint64_t arg3) \ { return do_fmadds(env, arg1, arg2, arg3, madd_flags, GETPC()); }
@@ -682,10 +682,10 @@ static uint64_t do_fmadds(CPUPPCState *env, float64 a, float64 b,#define NMADD_FLGS float_muladd_negate_result#define NMSUB_FLGS (float_muladd_negate_c | float_muladd_negate_result) -FPU_FMADD(fmadd, MADD_FLGS) -FPU_FMADD(fnmadd, NMADD_FLGS) -FPU_FMADD(fmsub, MSUB_FLGS) -FPU_FMADD (fnmsub,NMSUB_FLGS ) +FPU_FMADD(FMADD, MADD_FLGS) +FPU_FMADD(FNMADD, NMADD_FLGS) +FPU_FMADD(FMSUB, MSUB_FLGS) +FPU_FMADD (FNMSUB ,NMSUB_FLGS ) /* frsp - frsp. */static uint64_t do_frsp (CPUPPCState *env,uint64_t arg,uintptr_t retaddr)
@@ -778,18 +778,18 @@ float64 helper_##name(CPUPPCState *env, float64 arg1, float64 arg2) \return ret; \ } -FPU_FRE(fre, float64_div) -FPU_FRE(fres, float64r32_div) -FPU_FRSQRTE(frsqrte, float64_div) -FPU_FRSQRTE(frsqrtes, float64r32_div) -FPU_HELPER(fadd, float64_add, addsub_flags_handler) -FPU_HELPER(fadds, float64r32_add, addsub_flags_handler) -FPU_HELPER(fsub, float64_sub, addsub_flags_handler) -FPU_HELPER(fsubs, float64r32_sub, addsub_flags_handler) -FPU_HELPER(fmul, float64_mul, mul_flags_handler) -FPU_HELPER(fmuls, float64r32_mul, mul_flags_handler) -FPU_HELPER(fdiv, float64_div, div_flags_handler) -FPU_HELPER (fdivs, float64r32_div, div_flags_handler) +FPU_FRE(FRE, float64_div) +FPU_FRE(FRES, float64r32_div) +FPU_FRSQRTE(FRSQRTE, float64_div) +FPU_FRSQRTE(FRSQRTES, float64r32_div) +FPU_HELPER(FADD, float64_add, addsub_flags_handler) +FPU_HELPER(FADDS, float64r32_add, addsub_flags_handler) +FPU_HELPER(FSUB, float64_sub, addsub_flags_handler) +FPU_HELPER(FSUBS, float64r32_sub, addsub_flags_handler) +FPU_HELPER(FMUL, float64_mul, mul_flags_handler) +FPU_HELPER(FMULS, float64r32_mul, mul_flags_handler) +FPU_HELPER(FDIV, float64_div, div_flags_handler) +FPU_HELPER (FDIVS , float64r32_div, div_flags_handler) /* fsel - fsel. */uint64_t helper_FSEL (uint64_t a,uint64_t b,uint64_t c)
@@ -806,7 +806,7 @@ uint64_t helper_FSEL(uint64_t a, uint64_t b, uint64_t c) } } -uint32_t helper_ftdiv (uint64_t fra,uint64_t frb) +uint32_t helper_FTDIV (uint64_t fra,uint64_t frb) {int fe_flag =0 ;int fg_flag =0 ;
@@ -842,7 +842,7 @@ uint32_t helper_ftdiv(uint64_t fra, uint64_t frb)return 0x8 | (fg_flag ?4 :0 ) | (fe_flag ?2 :0 ); } -uint32_t helper_ftsqrt (uint64_t frb) +uint32_t helper_FTSQRT (uint64_t frb) {int fe_flag =0 ;int fg_flag =0 ;
target/ppc/helper.h +22 -22
54 lines not on this page · raw message
target/ppc/insn32.decode +42 -0
63 lines not on this page · raw message
target/ppc/translate/fp-impl.c.inc +109 -176
347 lines not on this page · raw message
target/ppc/translate/fp-ops.c.inc +0 -31
@@ -1,36 +1,6 @@ -#define _GEN_FLOAT_ACB(name, op, op1, op2, isfloat, set_fprf, type) \ -GEN_HANDLER(f##name, op1, op2, 0xFF, 0x00000000, type) -#define GEN_FLOAT_ACB(name, op2, set_fprf, type) \ -_GEN_FLOAT_ACB(name, name, 0x3F, op2, 0, set_fprf, type), \ -_GEN_FLOAT_ACB(name##s, name, 0x3B, op2, 1, set_fprf, type) -#define _GEN_FLOAT_AB(name, op, op1, op2, inval, isfloat, set_fprf, type) \ -GEN_HANDLER(f##name, op1, op2, 0xFF, inval, type) -#define GEN_FLOAT_AB(name, op2, inval, set_fprf, type) \ -_GEN_FLOAT_AB(name, name, 0x3F, op2, inval, 0, set_fprf, type), \ -_GEN_FLOAT_AB(name##s, name, 0x3B, op2, inval, 1, set_fprf, type) -#define _GEN_FLOAT_AC(name, op, op1, op2, inval, isfloat, set_fprf, type) \ -GEN_HANDLER(f##name, op1, op2, 0xFF, inval, type) -#define GEN_FLOAT_AC(name, op2, inval, set_fprf, type) \ -_GEN_FLOAT_AC(name, name, 0x3F, op2, inval, 0, set_fprf, type), \ -_GEN_FLOAT_AC(name##s, name, 0x3B, op2, inval, 1, set_fprf, type) #define GEN_FLOAT_B(name, op2, op3, set_fprf, type) \ GEN_HANDLER(f##name, 0x3F, op2, op3, 0x001F0000, type) -#define GEN_FLOAT_BS(name, op1, op2, set_fprf, type) \ -GEN_HANDLER(f##name, op1, op2, 0xFF, 0x001F07C0, type) -GEN_FLOAT_AB(add, 0x15, 0x000007C0, 1, PPC_FLOAT), -GEN_FLOAT_AB(div, 0x12, 0x000007C0, 1, PPC_FLOAT), -GEN_FLOAT_AC(mul, 0x19, 0x0000F800, 1, PPC_FLOAT), -GEN_FLOAT_BS(re, 0x3F, 0x18, 1, PPC_FLOAT_EXT), -GEN_FLOAT_BS(res, 0x3B, 0x18, 1, PPC_FLOAT_FRES), -GEN_FLOAT_BS(rsqrte, 0x3F, 0x1A, 1, PPC_FLOAT_FRSQRTE), -GEN_FLOAT_AB(sub, 0x14, 0x000007C0, 1, PPC_FLOAT), -GEN_FLOAT_ACB(madd, 0x1D, 1, PPC_FLOAT), -GEN_FLOAT_ACB(msub, 0x1C, 1, PPC_FLOAT), -GEN_FLOAT_ACB(nmadd, 0x1F, 1, PPC_FLOAT), -GEN_FLOAT_ACB(nmsub, 0x1E, 1, PPC_FLOAT), -GEN_HANDLER_E(ftdiv, 0x3F, 0x00, 0x04, 1, PPC_NONE, PPC2_FP_TST_ISA206), -GEN_HANDLER_E(ftsqrt, 0x3F, 0x00, 0x05, 1, PPC_NONE, PPC2_FP_TST_ISA206), GEN_FLOAT_B(ctiw, 0x0E, 0x00, 0, PPC_FLOAT), GEN_HANDLER_E(fctiwu, 0x3F, 0x0E, 0x04, 0, PPC_NONE, PPC2_FP_CVT_ISA206), GEN_FLOAT_B(ctiwz, 0x0F, 0x00, 0, PPC_FLOAT),
@@ -61,7 +31,6 @@ GEN_STXF(stfiw, st32fiw, 0x17, 0x1E, PPC_FLOAT_STFIWX) GEN_HANDLER_E(stfdepx, 0x1F, 0x1F, 0x16, 0x00000001, PPC_NONE, PPC2_BOOKE206), GEN_HANDLER_E(stfdpx, 0x1F, 0x17, 0x1C, 0x00200001, PPC_NONE, PPC2_ISA205), -GEN_HANDLER(frsqrtes, 0x3B, 0x1A, 0xFF, 0x001F07C0, PPC_FLOAT_FRSQRTES), GEN_HANDLER(fcmpo, 0x3F, 0x00, 0x01, 0x00600001, PPC_FLOAT), GEN_HANDLER(fcmpu, 0x3F, 0x00, 0x00, 0x00600001, PPC_FLOAT), GEN_HANDLER(fabs, 0x3F, 0x08, 0x08, 0x001F0000, PPC_FLOAT),
Signature · 1 line
2.43.0
[PULL 15/72] target/ppc: Move multiply fixed-point insns (64-bit operands) to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
Moving the following instructions to decodetree :
mul{ld, ldo, hd, hdu}[.] : XO-form
madd{hd, hdu, ld} : VA-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag.
--- target/ppc/insn32.decode | 9 ++ target/ppc/translate.c | 101 -------------------- target/ppc/translate/fixedpoint-impl.c.inc | 105 +++++++++++++++++++++ 3 files changed, 114 insertions(+), 101 deletions(-)
target/ppc/insn32.decode +9 -0
@@ -384,6 +384,15 @@ MODUW 011111 ..... ..... ..... 0100001011 - @X DARN 011111 ..... --- .. ----- 1011110011 - @X_tl NEG 011111 ..... ..... ----- . 001101000 . @XO_ta +MULLD 011111 ..... ..... ..... 0 011101001 . @XO_tab_rc +MULLDO 011111 ..... ..... ..... 1 011101001 . @XO_tab_rc +MULHD 011111 ..... ..... ..... - 001001001 . @XO_tab_rc +MULHDU 011111 ..... ..... ..... - 000001001 . @XO_tab_rc + +MADDLD 000100 ..... ..... ..... ..... 110011 @VA +MADDHD 000100 ..... ..... ..... ..... 110000 @VA +MADDHDU 000100 ..... ..... ..... ..... 110001 @VA + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/translate.c +0 -101
131 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +105 -0
111 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 63/72] target/ppc/mmu_common.c: Split off 40x cases from ppc_jumbo_xlate()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Introduce ppc_40x_xlate() to split off 40x handlning leaving only 6xx in ppc_jumbo_xlate() now.
--- target/ppc/mmu_common.c | 150 +++++++++++++++++++++++++--------------- 1 file changed, 93 insertions(+), 57 deletions(-)
target/ppc/mmu_common.c +93 -57
@@ -1258,6 +1258,74 @@ static bool ppc_real_mode_xlate(PowerPCCPU *cpu, vaddr eaddr,return false; } +static bool ppc_40x_xlate (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +int mmu_idx,bool guest_visible) +{ +CPUState *cs =CPU (cpu); +CPUPPCState *env = &cpu->env; +int ret; + +if (ppc_real_mode_xlate (cpu, eaddr, access_type, raddrp, psizep, protp)) { +return true; + } + + ret =mmu40x_get_physical_address (env, raddrp, protp, eaddr, access_type); +if (ret ==0 ) { + *psizep =TARGET_PAGE_BITS ; +return true; + }else if (!guest_visible) { +return false; + } + +log_cpu_state_mask (CPU_LOG_MMU , cs,0 ); +if (access_type ==MMU_INST_FETCH ) { +switch (ret) { +case -1 : +/* No matches in page tables or TLB */ + cs->exception_index =POWERPC_EXCP_ITLB ; + env->error_code =0 ; + env->spr[SPR_40x_DEAR] = eaddr; + env->spr[SPR_40x_ESR] =0x00000000 ; +break ; +case -2 : +/* Access rights violation */ + cs->exception_index =POWERPC_EXCP_ISI ; + env->error_code =0x08000000 ; +break ; +default : +g_assert_not_reached (); + } + }else { +switch (ret) { +case -1 : +/* No matches in page tables or TLB */ + cs->exception_index =POWERPC_EXCP_DTLB ; + env->error_code =0 ; + env->spr[SPR_40x_DEAR] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_40x_ESR] =0x00800000 ; + }else { + env->spr[SPR_40x_ESR] =0x00000000 ; + } +break ; +case -2 : +/* Access rights violation */ + cs->exception_index =POWERPC_EXCP_DSI ; + env->error_code =0 ; + env->spr[SPR_40x_DEAR] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_40x_ESR] |=0x00800000 ; + } +break ; +default : +g_assert_not_reached (); + } + } +return false; +} +/* Perform address translation */ /* TODO: Split this by mmu_model. */ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,
@@ -1301,23 +1369,11 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,switch (ret) {case -1 :/* No matches in page tables or TLB */ -switch (env->mmu_model) { -case POWERPC_MMU_SOFT_6xx: - cs->exception_index =POWERPC_EXCP_IFTLB ; - env->error_code =1 <<18 ; - env->spr[SPR_IMISS ] = eaddr; - env->spr[SPR_ICMP ] =0x80000000 | ctx.ptem; - goto tlb_miss; -case POWERPC_MMU_SOFT_4xx: - cs->exception_index =POWERPC_EXCP_ITLB ; - env->error_code =0 ; - env->spr[SPR_40x_DEAR] = eaddr; - env->spr[SPR_40x_ESR] =0x00000000 ; -break ; -default : -g_assert_not_reached (); - } -break ; + cs->exception_index =POWERPC_EXCP_IFTLB ; + env->error_code =1 <<18 ; + env->spr[SPR_IMISS ] = eaddr; + env->spr[SPR_ICMP ] =0x80000000 | ctx.ptem; + goto tlb_miss;case -2 :/* Access rights violation */ cs->exception_index =POWERPC_EXCP_ISI ;
@@ -1339,54 +1395,31 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,switch (ret) {case -1 :/* No matches in page tables or TLB */ -switch (env->mmu_model) { -case POWERPC_MMU_SOFT_6xx: -if (access_type ==MMU_DATA_STORE ) { - cs->exception_index =POWERPC_EXCP_DSTLB ; - env->error_code =1 <<16 ; - }else { - cs->exception_index =POWERPC_EXCP_DLTLB ; - env->error_code =0 ; - } - env->spr[SPR_DMISS ] = eaddr; - env->spr[SPR_DCMP ] =0x80000000 | ctx.ptem; - tlb_miss: - env->error_code |= ctx.key <<19 ; - env->spr[SPR_HASH1 ] =ppc_hash32_hpt_base (cpu) + -get_pteg_offset32 (cpu, ctx.hash[0 ]); - env->spr[SPR_HASH2 ] =ppc_hash32_hpt_base (cpu) + -get_pteg_offset32 (cpu, ctx.hash[1 ]); -break ; -case POWERPC_MMU_SOFT_4xx: - cs->exception_index =POWERPC_EXCP_DTLB ; +if (access_type ==MMU_DATA_STORE ) { + cs->exception_index =POWERPC_EXCP_DSTLB ; + env->error_code =1 <<16 ; + }else { + cs->exception_index =POWERPC_EXCP_DLTLB ; env->error_code =0 ; - env->spr[SPR_40x_DEAR] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_40x_ESR] =0x00800000 ; - }else { - env->spr[SPR_40x_ESR] =0x00000000 ; - } -break ; -default : -g_assert_not_reached (); } + env->spr[SPR_DMISS ] = eaddr; + env->spr[SPR_DCMP ] =0x80000000 | ctx.ptem; +tlb_miss: + env->error_code |= ctx.key <<19 ; + env->spr[SPR_HASH1 ] =ppc_hash32_hpt_base (cpu) + +get_pteg_offset32 (cpu, ctx.hash[0 ]); + env->spr[SPR_HASH2 ] =ppc_hash32_hpt_base (cpu) + +get_pteg_offset32 (cpu, ctx.hash[1 ]);break ;case -2 :/* Access rights violation */ cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; -if (env->mmu_model == POWERPC_MMU_SOFT_4xx) { - env->spr[SPR_40x_DEAR] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_40x_ESR] |=0x00800000 ; - } + env->spr[SPR_DAR ] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_DSISR ] =0x0A000000 ; }else { - env->spr[SPR_DAR ] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_DSISR ] =0x0A000000 ; - }else { - env->spr[SPR_DSISR ] =0x08000000 ; - } + env->spr[SPR_DSISR ] =0x08000000 ; }break ;case -4 :
@@ -1462,6 +1495,9 @@ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,case POWERPC_MMU_BOOKE206 :return ppc_booke_xlate (cpu, eaddr, access_type, raddrp, psizep, protp, mmu_idx, guest_visible); +case POWERPC_MMU_SOFT_4xx: +return ppc_40x_xlate (cpu, eaddr, access_type, raddrp, + psizep, protp, mmu_idx, guest_visible);case POWERPC_MMU_REAL :return ppc_real_mode_xlate (cpu, eaddr, access_type, raddrp, psizep, protp);
Signature · 1 line
2.43.0
[PULL 24/72] Add support for the clrbhrb and mfbhrbe instructions.
In reply to Nicholas PigginFrom: Glenn Miles <[email protected]>
Since neither instruction is believed to be critical to performance, both instructions were implemented using helper functions.
Access to both instructions is controlled by bits in the HFSCR (for privileged state) and MMCR0 (for problem state). A new function, helper_mmcr0_facility_check, was added for checking MMCR0[BHRBA] and raising a facility_unavailable exception if required.
NOTE: For P8 and P9, due to a performance issue, branch history will not be kept, but the instructions will be allowed to execute as normal with the exception that the mfbhrbe instruction will always return a zero value.
--- target/ppc/cpu.h | 2 ++ target/ppc/helper.h | 7 ++++ target/ppc/insn32.decode | 8 +++++ target/ppc/misc_helper.c | 50 ++++++++++++++++++++++++++++ target/ppc/translate.c | 2 ++ target/ppc/translate/bhrb-impl.c.inc | 43 ++++++++++++++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 target/ppc/translate/bhrb-impl.c.inc
target/ppc/cpu.h +2 -0
@@ -535,6 +535,7 @@ FIELD(MSR, LE, MSR_LE, 1)#define MMCR0_PMCjCE PPC_BIT(49)/* MMCR0 PMCj Condition Enabled */ #define MMCR0_FCP PPC_BIT(34)/* Freeze Counters/BHRB if PR=1 */ #define MMCR0_FCPC PPC_BIT(51)/* Condition for FCP bit */ +#define MMCR0_BHRBA_NR PPC_BIT_NR(42)/* BHRB Available */ /* MMCR0 userspace r/w mask */ #define MMCR0_UREG_MASK (MMCR0_FC | MMCR0_PMAO | MMCR0_PMAE)/* MMCR2 userspace r/w mask */
@@ -634,6 +635,7 @@ FIELD(MSR, LE, MSR_LE, 1)/* HFSCR bits */ #define HFSCR_MSGP PPC_BIT(53)/* Privileged Message Send Facilities */ +#define HFSCR_BHRB PPC_BIT(59)/* BHRB Instructions */ #define HFSCR_IC_MSGP 0xA#define DBCR0_ICMP (1 << 27)
target/ppc/helper.h +7 -0
@@ -820,3 +820,10 @@ DEF_HELPER_4(DSCLIQ, void, env, fprp, fprp, i32) DEF_HELPER_1(tbegin, void, env) DEF_HELPER_FLAGS_1(fixup_thrm, TCG_CALL_NO_RWG, void, env) + +#if !defined(CONFIG_USER_ONLY ) +#if defined(TARGET_PPC64 ) +DEF_HELPER_1(clrbhrb, void, env) +DEF_HELPER_FLAGS_2(mfbhrbe, TCG_CALL_NO_WG, i64, env, i32) +#endif +#endif
target/ppc/insn32.decode +8 -0
@@ -1190,3 +1190,11 @@ MSGSYNC 011111 ----- ----- ----- 1101110110 - @X_sync ...... .. l:3 ... sc:2 ..... .......... . &X_sync SYNC 011111 -- ... --- .. ----- 1001010110 - @X_sync EIEIO 011111 ----- ----- ----- 1101010110 - + +# Branch History Rolling Buffer (BHRB) Instructions + +&XFX_bhrbe rt bhrbe +@XFX_bhrbe ...... rt:5 bhrbe:10 .......... - &XFX_bhrbe + +MFBHRBE 011111 ..... ..... ..... 0100101110 - @XFX_bhrbe +CLRBHRB 011111 ----- ----- ----- 0110101110 -
target/ppc/misc_helper.c +50 -0
59 lines not on this page · raw message
target/ppc/translate.c +2 -0
@@ -5647,6 +5647,8 @@ static bool resolve_PLS_D(DisasContext *ctx, arg_D *d, arg_PLS_D *a)#include "translate/misc-impl.c.inc" +#include "translate/bhrb-impl.c.inc" +/* Handles lfdp */ static void gen_dform39 (DisasContext *ctx) {
target/ppc/translate/bhrb-impl.c.inc new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 36/72] target/ppc: Implement LDBAR, TTR SPRs
In reply to Nicholas PigginLDBAR, TTR are a Power-specific SPRs. These simple implementations are enough for IBM proprietary firmware for now.
--- target/ppc/cpu.h | 2 ++ target/ppc/cpu_init.c | 10 ++++++++++ 2 files changed, 12 insertions(+)
target/ppc/cpu.h +2 -0
@@ -2098,6 +2098,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_DEXCR (0x33C)#define SPR_IC (0x350)#define SPR_VTB (0x351) +#define SPR_LDBAR (0x352)#define SPR_MMCRC (0x353)#define SPR_PSSCR (0x357)#define SPR_440_INV0 (0x370)
@@ -2144,6 +2145,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_440_IVLIM (0x399)#define SPR_TSCR (0x399)#define SPR_750_DMAU (0x39A) +#define SPR_POWER_TTR (0x39A)#define SPR_750_DMAL (0x39B)#define SPR_440_RSTCFG (0x39B)#define SPR_BOOKE_DCDBTRL (0x39C)
target/ppc/cpu_init.c +10 -0
@@ -5767,6 +5767,16 @@ static void register_power_common_book4_sprs(CPUPPCState *env) &spr_access_nop, &spr_write_generic, &spr_access_nop, &spr_write_generic, 0x00000000); +spr_register_hv (env,SPR_LDBAR ,"LDBAR" , +SPR_NOACCESS ,SPR_NOACCESS , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_core_lpar_write_generic, +0x00000000 ); +spr_register_hv (env,SPR_POWER_TTR ,"TTR" , +SPR_NOACCESS ,SPR_NOACCESS , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_core_write_generic, +0x00000000 );#endif }
Signature · 1 line
2.43.0
[PULL 65/72] target/ppc/mmu_common.c: Move mmu_ctx_t type to mmu_common.c
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Remove mmu_ctx_t definition from internal.h as this type is only used within mmu_common.c.
--- target/ppc/internal.h | 12 ------------ target/ppc/mmu_common.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 12 deletions(-)
target/ppc/internal.h +0 -12
@@ -257,8 +257,6 @@ static inline int prot_for_access_type(MMUAccessType access_type)/* PowerPC MMU emulation */ -typedef struct mmu_ctx_t mmu_ctx_t ; -bool ppc_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type,hwaddr *raddrp,int *psizep,int *protp,int mmu_idx,bool guest_visible);
@@ -266,16 +264,6 @@ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,/* Software driven TLB helpers */ int ppc6xx_tlb_getnum (CPUPPCState *env,target_ulong eaddr,int way,int is_code); -/* Context used internally during MMU translations */ -struct mmu_ctx_t { -hwaddr raddr;/* Real address */ -hwaddr eaddr;/* Effective address */ -int prot;/* Protection bits */ -hwaddr hash[2 ];/* Pagetable hash values */ -target_ulong ptem;/* Virtual segment ID | API */ -int key;/* Access key */ -int nx;/* Non-execute area */ -};#endif /* !CONFIG_USER_ONLY */
target/ppc/mmu_common.c +11 -0
@@ -36,6 +36,17 @@/* #define DUMP_PAGE_TABLES */ +/* Context used internally during MMU translations */ +typedef struct { +hwaddr raddr;/* Real address */ +hwaddr eaddr;/* Effective address */ +int prot;/* Protection bits */ +hwaddr hash[2 ];/* Pagetable hash values */ +target_ulong ptem;/* Virtual segment ID | API */ +int key;/* Access key */ +int nx;/* Non-execute area */ +}mmu_ctx_t ; +void ppc_store_sdr1 (CPUPPCState *env,target_ulong value) {PowerPCCPU *cpu =env_archcpu (env);
Signature · 1 line
2.43.0
[PULL 56/72] target/ppc/mmu_common.c: Don't use mmu_ctx_t in mmubooke_get_physical_address()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
mmubooke_get_physical_address() only uses the raddr and prot fields from mmu_ctx_t. Pass these directly instead of using a ctx struct.
--- target/ppc/mmu_common.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)
target/ppc/mmu_common.c +10 -20
@@ -634,36 +634,25 @@ static int mmubooke_check_tlb(CPUPPCState *env, ppcemb_tlb_t *tlb,return access_type ==MMU_INST_FETCH ?-3 :-2 ; } -static int mmubooke_get_physical_address (CPUPPCState *env,mmu_ctx_t *ctx, -target_ulong address, +static int mmubooke_get_physical_address (CPUPPCState *env,hwaddr *raddr, +int *prot,target_ulong address,MMUAccessType access_type) {ppcemb_tlb_t *tlb; -hwaddr raddr; -int i, ret; +int i, ret =-1 ; - ret =-1 ; - raddr = (hwaddr)-1ULL ;for (i =0 ; i < env->nb_tlb; i++) { tlb = &env->tlb.tlbe[i]; - ret =mmubooke_check_tlb (env, tlb, &raddr, &ctx->prot, address, + ret =mmubooke_check_tlb (env, tlb, raddr, prot, address, access_type, i);if (ret !=-1 ) {break ; } } - -if (ret >=0 ) { - ctx->raddr = raddr; -qemu_log_mask (CPU_LOG_MMU ,"%s: access granted " TARGET_FMT_lx -" => " HWADDR_FMT_plx" %d %d\n" , __func__, - address, ctx->raddr, ctx->prot, ret); - }else { -qemu_log_mask (CPU_LOG_MMU ,"%s: access refused " TARGET_FMT_lx -" => " HWADDR_FMT_plx" %d %d\n" , __func__, - address, raddr, ctx->prot, ret); - } - +qemu_log_mask (CPU_LOG_MMU , +"%s: access %s " TARGET_FMT_lx" => " HWADDR_FMT_plx +" %d %d\n" , __func__, ret <0 ?"refused" :"granted" , + address, ret <0 ?-1 : *raddr, ret ==-1 ?0 : *prot, ret);return ret; }
@@ -1143,7 +1132,8 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx,bool real_mode;if (env->mmu_model ==POWERPC_MMU_BOOKE ) { -return mmubooke_get_physical_address (env, ctx, eaddr, access_type); +return mmubooke_get_physical_address (env, &ctx->raddr, &ctx->prot, + eaddr, access_type); }else if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) {return mmubooke206_get_physical_address (env, ctx, eaddr, access_type, mmu_idx);
Signature · 1 line
2.43.0
[PULL 40/72] target/ppc: Remove unused helper
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
The helper_rac function is defined but not used, remove it.
--- target/ppc/helper.h | 2 -- target/ppc/mmu_helper.c | 24 ------------------------ 2 files changed, 26 deletions(-)
target/ppc/helper.h +0 -2
@@ -701,8 +701,6 @@ DEF_HELPER_2(book3s_msgclr, void, env, tl) DEF_HELPER_4(dlmzb, tl, env, tl, tl, i32)#if !defined(CONFIG_USER_ONLY ) -DEF_HELPER_2(rac, tl, env, tl) - DEF_HELPER_2(load_dcr, tl, env, tl) DEF_HELPER_3(store_dcr, void, env, tl, tl)#endif
target/ppc/mmu_helper.c +0 -24
@@ -596,30 +596,6 @@ void helper_6xx_tlbi(CPUPPCState *env, target_ulong EPN)do_6xx_tlb (env,EPN ,1 ); } -/*****************************************************************************/ -/* PowerPC 601 specific instructions (POWER bridge) */ - -target_ulong helper_rac (CPUPPCState *env,target_ulong addr) -{ -mmu_ctx_t ctx; -int nb_BATs; -target_ulong ret =0 ; - -/* -* We don't have to generate many instances of this instruction, -* as rac is supervisor only. -* -* XXX: FIX THIS: Pretend we have no BAT -*/ - nb_BATs = env->nb_BATs; - env->nb_BATs =0 ; -if (get_physical_address_wtlb (env, &ctx, addr,0 ,ACCESS_INT ,0 ) ==0 ) { - ret = ctx.raddr; - } - env->nb_BATs = nb_BATs; -return ret; -} -static inline target_ulong booke_tlb_to_page_size (int size) {return 1024 << (2 * size);
Signature · 1 line
2.43.0
[PULL 34/72] target/ppc: Add SMT support to simple SPRs
In reply to Nicholas PigginAMOR, MMCRC, HRMOR, TSCR, HMEER, RPR SPRs are per-core or per-LPAR registers with simple (generic) implementations.
--- target/ppc/cpu_init.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
target/ppc/cpu_init.c +6 -6
@@ -246,7 +246,7 @@ static void register_amr_sprs(CPUPPCState *env)spr_register_hv (env,SPR_AMOR ,"AMOR" ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_core_lpar_write_generic,0 );#endif /* !CONFIG_USER_ONLY */ }
@@ -5472,7 +5472,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env)spr_register_hv (env,SPR_MMCRC ,"MMCRC" ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic32, + &spr_read_generic, &spr_core_write_generic32,0x00000000 ); spr_register_hv(env, SPR_MMCRH, "MMCRH", SPR_NOACCESS, SPR_NOACCESS,
@@ -5512,7 +5512,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env)spr_register_hv (env,SPR_HRMOR ,"HRMOR" ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_core_write_generic,0x00000000 ); }
@@ -5740,7 +5740,7 @@ static void register_power_common_book4_sprs(CPUPPCState *env)spr_register_hv (env,SPR_TSCR ,"TSCR" ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic32, + &spr_read_generic, &spr_core_write_generic32,0x00000000 ); spr_register_hv(env, SPR_HMER, "HMER", SPR_NOACCESS, SPR_NOACCESS,
@@ -5750,7 +5750,7 @@ static void register_power_common_book4_sprs(CPUPPCState *env)spr_register_hv (env,SPR_HMEER ,"HMEER" ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_core_write_generic,0x00000000 ); spr_register_hv(env, SPR_TFMR, "TFMR", SPR_NOACCESS, SPR_NOACCESS,
@@ -5826,7 +5826,7 @@ static void register_power8_rpr_sprs(CPUPPCState *env)spr_register_hv (env,SPR_RPR ,"RPR" ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_core_write_generic,0x00000103070F1F3F );#endif }
Signature · 1 line
2.43.0
[PULL 48/72] target/ppc/mmu_common.c: Eliminate ret from mmu6xx_get_physical_address()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Return directly, which is simpler than dragging a return value through multpile if and else blocks.
--- target/ppc/mmu_common.c | 84 +++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 45 deletions(-)
target/ppc/mmu_common.c +39 -45
@@ -386,7 +386,6 @@ static int mmu6xx_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx,target_ulong vsid, sr, pgidx;int ds, target_page_bits;bool pr; -int ret;/* First try to find a BAT entry if there are any */ if (env->nb_BATs &&get_bat_6xx_tlb (env, ctx, eaddr, access_type) ==0 ) {
@@ -419,7 +418,6 @@ static int mmu6xx_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx,qemu_log_mask (CPU_LOG_MMU ,"pte segment: key=%d ds %d nx %d vsid " TARGET_FMT_lx"\n" , ctx->key, ds, ctx->nx, vsid); - ret =-1 ;if (!ds) {/* Check if instruction fetch is allowed, if needed */ if (type ==ACCESS_CODE && ctx->nx) {
@@ -436,51 +434,47 @@ static int mmu6xx_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx,/* Initialize real address with an invalid value */ ctx->raddr = (hwaddr)-1ULL ;/* Software TLB search */ - ret =ppc6xx_tlb_check (env, ctx, eaddr, access_type); - }else { -qemu_log_mask (CPU_LOG_MMU ,"direct store...\n" ); -/* Direct-store segment : absolutely *BUGGY* for now */ - -switch (type) { -case ACCESS_INT : -/* Integer load/store : only access allowed */ -break ; -case ACCESS_CODE : -/* No code fetch is allowed in direct-store areas */ -return -4 ; -case ACCESS_FLOAT : -/* Floating point load/store */ -return -4 ; -case ACCESS_RES : -/* lwarx, ldarx or srwcx. */ -return -4 ; -case ACCESS_CACHE : -/* -* dcba, dcbt, dcbtst, dcbf, dcbi, dcbst, dcbz, or icbi -* -* Should make the instruction do no-op. As it already do -* no-op, it's quite easy :-) -*/ - ctx->raddr = eaddr; -return 0 ; -case ACCESS_EXT : -/* eciwx or ecowx */ -return -4 ; -default : -qemu_log_mask (CPU_LOG_MMU ,"ERROR: instruction should not need " -"address translation\n" ); -return -4 ; - } -if ((access_type ==MMU_DATA_STORE || ctx->key !=1 ) && - (access_type ==MMU_DATA_LOAD || ctx->key !=0 )) { - ctx->raddr = eaddr; - ret =2 ; - }else { - ret =-2 ; - } +return ppc6xx_tlb_check (env, ctx, eaddr, access_type); } -return ret; +/* Direct-store segment : absolutely *BUGGY* for now */ +qemu_log_mask (CPU_LOG_MMU ,"direct store...\n" ); +switch (type) { +case ACCESS_INT : +/* Integer load/store : only access allowed */ +break ; +case ACCESS_CODE : +/* No code fetch is allowed in direct-store areas */ +return -4 ; +case ACCESS_FLOAT : +/* Floating point load/store */ +return -4 ; +case ACCESS_RES : +/* lwarx, ldarx or srwcx. */ +return -4 ; +case ACCESS_CACHE : +/* +* dcba, dcbt, dcbtst, dcbf, dcbi, dcbst, dcbz, or icbi +* +* Should make the instruction do no-op. As it already do +* no-op, it's quite easy :-) +*/ + ctx->raddr = eaddr; +return 0 ; +case ACCESS_EXT : +/* eciwx or ecowx */ +return -4 ; +default : +qemu_log_mask (CPU_LOG_MMU ,"ERROR: instruction should not need address" +" translation\n" ); +return -4 ; + } +if ((access_type ==MMU_DATA_STORE || ctx->key !=1 ) && + (access_type ==MMU_DATA_LOAD || ctx->key !=0 )) { + ctx->raddr = eaddr; +return 2 ; + } +return -2 ; }/* Generic TLB check function for embedded PowerPC implementations */
Signature · 1 line
2.43.0
[PULL 41/72] target/ppc/mmu_common.c: Move calculation of a value closer to its usage
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
In mmubooke_check_tlb() and mmubooke206_check_tlb() prot2 is calculated first but only used after an unrelated check that can return before tha value is used. Move the calculation after the check, closer to where it is used, to keep them together and avoid computing it when not needed.
--- target/ppc/mmu_common.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)
target/ppc/mmu_common.c +17 -19
@@ -635,12 +635,6 @@ static int mmubooke_check_tlb(CPUPPCState *env, ppcemb_tlb_t *tlb,return -1 ; } -if (FIELD_EX64 (env->msr,MSR ,PR )) { - prot2 = tlb->prot &0xF ; - }else { - prot2 = (tlb->prot >>4 ) &0xF ; - } -/* Check the address space */ if ((access_type == MMU_INST_FETCH ? FIELD_EX64(env->msr, MSR, IR) :
@@ -649,6 +643,11 @@ static int mmubooke_check_tlb(CPUPPCState *env, ppcemb_tlb_t *tlb,return -1 ; } +if (FIELD_EX64 (env->msr,MSR ,PR )) { + prot2 = tlb->prot &0xF ; + }else { + prot2 = (tlb->prot >>4 ) &0xF ; + } *prot = prot2;if (prot2 &prot_for_access_type (access_type)) {qemu_log_mask (CPU_LOG_MMU ,"%s: good TLB!\n" , __func__);
@@ -830,6 +829,18 @@ static int mmubooke206_check_tlb(CPUPPCState *env, ppcmas_tlb_t *tlb, found_tlb: +/* Check the address space and permissions */ +if (access_type ==MMU_INST_FETCH ) { +/* There is no way to fetch code using epid load */ +assert (!use_epid); + as =FIELD_EX64 (env->msr,MSR ,IR ); + } + +if (as != ((tlb->mas1 &MAS1_TS ) >>MAS1_TS_SHIFT )) { +qemu_log_mask (CPU_LOG_MMU ,"%s: AS doesn't match\n" , __func__); +return -1 ; + } +if (pr) {if (tlb->mas7_3 &MAS3_UR ) { prot2 |=PAGE_READ ;
@@ -851,19 +862,6 @@ found_tlb: prot2 |=PAGE_EXEC ; } } - -/* Check the address space and permissions */ -if (access_type ==MMU_INST_FETCH ) { -/* There is no way to fetch code using epid load */ -assert (!use_epid); - as =FIELD_EX64 (env->msr,MSR ,IR ); - } - -if (as != ((tlb->mas1 &MAS1_TS ) >>MAS1_TS_SHIFT )) { -qemu_log_mask (CPU_LOG_MMU ,"%s: AS doesn't match\n" , __func__); -return -1 ; - } - *prot = prot2;if (prot2 &prot_for_access_type (access_type)) {qemu_log_mask (CPU_LOG_MMU ,"%s: good TLB!\n" , __func__);
Signature · 1 line
2.43.0
[PULL 50/72] target/ppc/mmu_common.c: Split off real mode cases in get_physical_address_wtlb()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
The real mode handling is identical in the remaining switch cases. Split off these common real mode cases into a separate conditional to leave only the else branches in the switch that are different.
--- target/ppc/mmu_common.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-)
target/ppc/mmu_common.c +9 -25
@@ -1172,7 +1172,6 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, MMUAccessType access_type, int type, int mmu_idx) { - int ret = -1; bool real_mode;if (env->mmu_model ==POWERPC_MMU_BOOKE ) {
@@ -1184,38 +1183,23 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, real_mode = (type ==ACCESS_CODE ) ? !FIELD_EX64 (env->msr,MSR ,IR ) : !FIELD_EX64 (env->msr,MSR ,DR ); +if (real_mode && (env->mmu_model == POWERPC_MMU_SOFT_6xx || + env->mmu_model == POWERPC_MMU_SOFT_4xx || + env->mmu_model ==POWERPC_MMU_REAL )) { +return check_physical (env, ctx, eaddr, access_type); + }switch (env->mmu_model) {case POWERPC_MMU_SOFT_6xx: -if (real_mode) { - ret =check_physical (env, ctx, eaddr, access_type); - }else { - ret =mmu6xx_get_physical_address (env, ctx, eaddr, access_type, - type); - } -break ; - +return mmu6xx_get_physical_address (env, ctx, eaddr, access_type, type);case POWERPC_MMU_SOFT_4xx: -if (real_mode) { - ret =check_physical (env, ctx, eaddr, access_type); - }else { - ret =mmu40x_get_physical_address (env, ctx, eaddr, access_type); - } -break ; +return mmu40x_get_physical_address (env, ctx, eaddr, access_type);case POWERPC_MMU_REAL : -if (real_mode) { - ret =check_physical (env, ctx, eaddr, access_type); - }else { -cpu_abort (env_cpu (env), -"PowerPC in real mode do not do any translation\n" ); - } -return -1 ; +cpu_abort (env_cpu (env), +"PowerPC in real mode do not do any translation\n" );default :cpu_abort (env_cpu (env),"Unknown or invalid MMU model\n" ); -return -1 ; } - -return ret; } static void booke206_update_mas_tlb_miss(CPUPPCState *env, target_ulong address,
Signature · 1 line
2.43.0
[PULL 39/72] target/ppc: Remove unused struct 'mmu_ctx_hash32'
In reply to Nicholas PigginFrom: "Dr. David Alan Gilbert" <[email protected]>
I think it's use was removed by
Commit 5883d8b296 ("mmu-hash*: Don't use full ppc_hash{32, 64}_translate() path for get_phys_page_debug()")
--- target/ppc/mmu-hash32.c | 6 ------ 1 file changed, 6 deletions(-)
target/ppc/mmu-hash32.c +0 -6
@@ -37,12 +37,6 @@# define LOG_BATS (...) do { } while (0)#endif -struct mmu_ctx_hash32 { -hwaddr raddr;/* Real address */ -int prot;/* Protection bits */ -int key;/* Access key */ -}; -static int ppc_hash32_pp_prot (int key,int pp,int nx) {int prot;
Signature · 1 line
2.43.0
[PULL 11/72] target/ppc: Move mul{li, lw, lwo, hw, hwu} instructions to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
Moving the following instructions to decodetree specification :
mulli : D-form
mul{lw, lwo, hw, hwu}[.] : XO-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the '-d in_asm,op' flag. Also cleaned up code for mullw[o][.] as per review comments while keeping the logic of the tcg ops generated semantically same.
--- target/ppc/insn32.decode | 9 +++ target/ppc/translate.c | 89 ---------------------- target/ppc/translate/fixedpoint-impl.c.inc | 66 ++++++++++++++++ 3 files changed, 75 insertions(+), 89 deletions(-)
target/ppc/insn32.decode +9 -0
@@ -202,6 +202,9 @@ &XO_ta rt ra oe:bool rc:bool @XO_ta ...... rt:5 ra:5 ..... oe:1 ......... rc:1 &XO_ta +&XO_tab_rc rt ra rb rc:bool +@XO_tab_rc ...... rt:5 ra:5 rb:5 . ......... rc:1 &XO_tab_rc + %xx_xt 0:1 21:5 %xx_xb 1:1 11:5 %xx_xa 2:1 16:5
@@ -362,6 +365,12 @@ SUBFE 011111 ..... ..... ..... . 010001000 . @XO SUBFME 011111 ..... ..... ----- . 011101000 . @XO_ta SUBFZE 011111 ..... ..... ----- . 011001000 . @XO_ta +MULLI 000111 ..... ..... ................ @D +MULLW 011111 ..... ..... ..... 0 011101011 . @XO_tab_rc +MULLWO 011111 ..... ..... ..... 1 011101011 . @XO_tab_rc +MULHW 011111 ..... ..... ..... - 001001011 . @XO_tab_rc +MULHWU 011111 ..... ..... ..... - 000001011 . @XO_tab_rc + ## Fixed-Point Logical Instructions CFUGED 011111 ..... ..... ..... 0011011100 - @X
target/ppc/translate.c +0 -89
101 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +66 -0
72 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 60/72] target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 1
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Move setting error_code that appears in every case out in front and hoist the common fall through case for BOOKE206 as well which allows removing the nested switches.
--- target/ppc/mmu_common.c | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-)
target/ppc/mmu_common.c +12 -29
@@ -1220,58 +1220,41 @@ static bool ppc_booke_xlate(PowerPCCPU *cpu, vaddr eaddr, }log_cpu_state_mask (CPU_LOG_MMU , cs,0 ); + env->error_code =0 ; +if (ret ==-1 ) { +if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) { +booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); + } + }if (access_type ==MMU_INST_FETCH ) {switch (ret) {case -1 :/* No matches in page tables or TLB */ -switch (env->mmu_model) { -case POWERPC_MMU_BOOKE206 : -booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); -/* fall through */ -case POWERPC_MMU_BOOKE : - cs->exception_index =POWERPC_EXCP_ITLB ; - env->error_code =0 ; - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); -break ; -default : -g_assert_not_reached (); - } + cs->exception_index =POWERPC_EXCP_ITLB ; + env->spr[SPR_BOOKE_DEAR ] = eaddr; + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type);break ;case -2 :/* Access rights violation */ cs->exception_index =POWERPC_EXCP_ISI ; - env->error_code =0 ;break ;case -3 :/* No execute protection violation */ cs->exception_index =POWERPC_EXCP_ISI ; env->spr[SPR_BOOKE_ESR ] =0 ; - env->error_code =0 ;break ; } }else {switch (ret) {case -1 :/* No matches in page tables or TLB */ -switch (env->mmu_model) { -case POWERPC_MMU_BOOKE206 : -booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); -/* fall through */ -case POWERPC_MMU_BOOKE : - cs->exception_index =POWERPC_EXCP_DTLB ; - env->error_code =0 ; - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); -break ; -default : -g_assert_not_reached (); - } + cs->exception_index =POWERPC_EXCP_DTLB ; + env->spr[SPR_BOOKE_DEAR ] = eaddr; + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type);break ;case -2 :/* Access rights violation */ cs->exception_index =POWERPC_EXCP_DSI ; - env->error_code =0 ; env->spr[SPR_BOOKE_DEAR ] = eaddr; env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type);break ;
Signature · 1 line
2.43.0
[PULL 66/72] target/ppc: Remove id_tlbs flag from CPU env
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
This flag for split instruction/data TLBs is only set for 6xx soft TLB MMU model and not used otherwise so no need to have a separate flag for that.
--- hw/ppc/pegasos2.c | 2 +- target/ppc/cpu.h | 5 ++++- target/ppc/cpu_init.c | 19 +++++-------------- target/ppc/helper_regs.c | 1 - target/ppc/mmu_common.c | 10 ++-------- target/ppc/mmu_helper.c | 12 ++---------- 6 files changed, 14 insertions(+), 35 deletions(-)
hw/ppc/pegasos2.c +1 -1
@@ -985,7 +985,7 @@ static void *build_fdt(MachineState *machine, int *fdt_size) cpu->env.icache_line_size);qemu_fdt_setprop_cell (fdt, cp,"i-cache-line-size" , cpu->env.icache_line_size); -if (cpu->env.id_tlbs) { +if (ppc_is_split_tlb (cpu)) {qemu_fdt_setprop_cell (fdt, cp,"i-tlb-sets" , cpu->env.nb_ways);qemu_fdt_setprop_cell (fdt, cp,"i-tlb-size" , cpu->env.tlb_per_way);qemu_fdt_setprop_cell (fdt, cp,"d-tlb-sets" , cpu->env.nb_ways);
target/ppc/cpu.h +4 -1
@@ -1281,7 +1281,6 @@ struct CPUArchState {int tlb_per_way;/* Speed-up helper: used to avoid divisions at run time */ int nb_ways;/* Number of ways in the TLB set */ int last_way;/* Last used way used to allocate TLB in a LRU way */ -int id_tlbs;/* If 1, MMU has separated TLBs for instructions & data */ int nb_pids;/* Number of available PID registers */ int tlb_type;/* Type of TLB we're dealing with */ ppc_tlb_t tlb;/* TLB is optional. Allocate them only if needed */
@@ -2897,6 +2896,10 @@ static inline void booke206_fixed_size_tlbn(CPUPPCState *env, const int tlbn, tlb->mas1 |= ((uint32_t)tsize) << MAS1_TSIZE_SHIFT; } +static inline bool ppc_is_split_tlb (PowerPCCPU *cpu) +{ +return cpu->env.tlb_type ==TLB_6XX ; +}#endif static inline bool msr_is_64bit (CPUPPCState *env,target_ulong msr)
target/ppc/cpu_init.c +5 -14
@@ -2137,7 +2137,6 @@ static void init_proc_405(CPUPPCState *env)#if !defined(CONFIG_USER_ONLY ) env->nb_tlb =64 ; env->nb_ways =1 ; - env->id_tlbs =0 ; env->tlb_type =TLB_EMB ;#endif init_excp_4xx (env);
@@ -2211,7 +2210,6 @@ static void init_proc_440EP(CPUPPCState *env)#if !defined(CONFIG_USER_ONLY ) env->nb_tlb =64 ; env->nb_ways =1 ; - env->id_tlbs =0 ; env->tlb_type =TLB_EMB ;#endif init_excp_BookE (env);
@@ -2311,7 +2309,6 @@ static void init_proc_440GP(CPUPPCState *env)#if !defined(CONFIG_USER_ONLY ) env->nb_tlb =64 ; env->nb_ways =1 ; - env->id_tlbs =0 ; env->tlb_type =TLB_EMB ;#endif init_excp_BookE (env);
@@ -2386,7 +2383,6 @@ static void init_proc_440x5(CPUPPCState *env)#if !defined(CONFIG_USER_ONLY ) env->nb_tlb =64 ; env->nb_ways =1 ; - env->id_tlbs =0 ; env->tlb_type =TLB_EMB ;#endif init_excp_BookE (env);
@@ -2754,7 +2750,6 @@ static void init_proc_e200(CPUPPCState *env)#if !defined(CONFIG_USER_ONLY ) env->nb_tlb =64 ; env->nb_ways =1 ; - env->id_tlbs =0 ; env->tlb_type =TLB_EMB ;#endif init_excp_e200 (env,0xFFFF0000UL );
@@ -2874,7 +2869,6 @@ static void init_proc_e500(CPUPPCState *env, int version)/* Memory management */ env->nb_pids =3 ; env->nb_ways =2 ; - env->id_tlbs =0 ;switch (version) {case fsl_e500v1: tlbncfg[0 ] =register_tlbncfg (2 ,1 ,1 ,0 ,256 );
@@ -6927,20 +6921,17 @@ static void init_ppc_proc(PowerPCCPU *cpu) }/* Allocate TLBs buffer when needed */ #if !defined(CONFIG_USER_ONLY ) -if (env->nb_tlb !=0 ) { -int nb_tlb = env->nb_tlb; -if (env->id_tlbs !=0 ) { - nb_tlb *=2 ; - } +if (env->nb_tlb) {switch (env->tlb_type) {case TLB_6XX : - env->tlb.tlb6 =g_new0 (ppc6xx_tlb_t, nb_tlb); +/* 6xx has separate TLBs for instructions and data hence times 2 */ + env->tlb.tlb6 =g_new0 (ppc6xx_tlb_t,2 * env->nb_tlb);break ;case TLB_EMB : - env->tlb.tlbe =g_new0 (ppcemb_tlb_t, nb_tlb); + env->tlb.tlbe =g_new0 (ppcemb_tlb_t, env->nb_tlb);break ;case TLB_MAS : - env->tlb.tlbm =g_new0 (ppcmas_tlb_t, nb_tlb); + env->tlb.tlbm =g_new0 (ppcmas_tlb_t, env->nb_tlb);break ; }/* Pre-compute some useful values */
target/ppc/helper_regs.c +0 -1
@@ -730,7 +730,6 @@ void register_6xx_7xx_soft_tlb(CPUPPCState *env, int nb_tlbs, int nb_ways)#if !defined(CONFIG_USER_ONLY ) env->nb_tlb = nb_tlbs; env->nb_ways = nb_ways; - env->id_tlbs =1 ; env->tlb_type =TLB_6XX ; spr_register(env, SPR_DMISS, "DMISS", SPR_NOACCESS, SPR_NOACCESS,
target/ppc/mmu_common.c +2 -8
@@ -128,8 +128,8 @@ int ppc6xx_tlb_getnum(CPUPPCState *env, target_ulong eaddr, nr = (eaddr >>TARGET_PAGE_BITS ) & (env->tlb_per_way -1 );/* Select TLB way */ nr += env->tlb_per_way * way; -/* 6xx have separate TLBs for instructions and data */ -if (is_code && env->id_tlbs ==1 ) { +/* 6xx has separate TLBs for instructions and data */ +if (is_code) { nr += env->nb_tlb; }
@@ -1065,13 +1065,7 @@ static void mmu6xx_dump_mmu(CPUPPCState *env)mmu6xx_dump_BATs (env,ACCESS_INT );mmu6xx_dump_BATs (env,ACCESS_CODE ); -if (env->id_tlbs !=1 ) { -qemu_printf ("ERROR: 6xx MMU should have separated TLB" -" for code and data\n" ); - } -qemu_printf ("\nTLBs [EPN EPN + SIZE]\n" ); -for (type =0 ; type <2 ; type++) {for (way =0 ; way < env->nb_ways; way++) { for (entry = env->nb_tlb * type + env->tlb_per_way * way;
target/ppc/mmu_helper.c +2 -10
@@ -45,14 +45,8 @@static inline void ppc6xx_tlb_invalidate_all (CPUPPCState *env) {ppc6xx_tlb_t *tlb; -int nr, max; +int nr, max =2 * env->nb_tlb; -/* LOG_SWTLB("Invalidate all TLBs\n"); */ -/* Invalidate all defined software TLB */ - max = env->nb_tlb; -if (env->id_tlbs ==1 ) { - max *=2 ; - }for (nr =0 ; nr < max; nr++) { tlb = &env->tlb.tlb6[nr];pte_invalidate (&tlb->pte0);
@@ -308,9 +302,7 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr)switch (env->mmu_model) {case POWERPC_MMU_SOFT_6xx:ppc6xx_tlb_invalidate_virt (env, addr,0 ); -if (env->id_tlbs ==1 ) { -ppc6xx_tlb_invalidate_virt (env, addr,1 ); - } +ppc6xx_tlb_invalidate_virt (env, addr,1 );break ;case POWERPC_MMU_32B :/*
Signature · 1 line
2.43.0
[PULL 71/72] target/ppc: Move out BookE and related MMU functions from mmu_common.c
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Add a new mmu-booke.c file for BookE and related MMU bits from mmu_common.c.
--- target/ppc/cpu.h | 4 - target/ppc/meson.build | 1 + target/ppc/mmu-booke.c | 531 ++++++++++++++++++++++++++++++++++++++++ target/ppc/mmu-booke.h | 17 ++ target/ppc/mmu_common.c | 507 +------------------------------------- target/ppc/mmu_helper.c | 1 + 6 files changed, 551 insertions(+), 510 deletions(-) create mode 100644 target/ppc/mmu-booke.c create mode 100644 target/ppc/mmu-booke.h
target/ppc/cpu.h +0 -4
@@ -1642,10 +1642,6 @@ void ppc_tlb_invalidate_all(CPUPPCState *env);void ppc_tlb_invalidate_one (CPUPPCState *env,target_ulong addr);void cpu_ppc_set_vhyp (PowerPCCPU *cpu,PPCVirtualHypervisor *vhyp);void cpu_ppc_set_1lpar (PowerPCCPU *cpu); -int ppcmas_tlb_check (CPUPPCState *env,ppcmas_tlb_t *tlb,hwaddr *raddrp, -target_ulong address,uint32_t pid); -int ppcemb_tlb_search (CPUPPCState *env,target_ulong address,uint32_t pid); -hwaddr booke206_tlb_to_page_size (CPUPPCState *env,ppcmas_tlb_t *tlb);#endif void ppc_store_fpscr (CPUPPCState *env,target_ulong val);
target/ppc/meson.build +1 -0
@@ -37,6 +37,7 @@ ppc_system_ss.add(files( 'arch_dump.c', 'machine.c', 'mmu-hash32.c', + 'mmu-booke.c', 'mmu_common.c', 'ppc-qmp-cmds.c', ))
target/ppc/mmu-booke.c new file +531 -0
531 lines not on this page · raw message
target/ppc/mmu-booke.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef PPC_MMU_BOOKE_H +#define PPC_MMU_BOOKE_H + +#include "cpu.h" + +int ppcemb_tlb_search (CPUPPCState *env,target_ulong address,uint32_t pid); +int mmu40x_get_physical_address (CPUPPCState *env,hwaddr *raddr,int *prot, +target_ulong address, +MMUAccessType access_type); +hwaddr booke206_tlb_to_page_size (CPUPPCState *env,ppcmas_tlb_t *tlb); +int ppcmas_tlb_check (CPUPPCState *env,ppcmas_tlb_t *tlb,hwaddr *raddrp, +target_ulong address,uint32_t pid); +bool ppc_booke_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp,int mmu_idx, +bool guest_visible); + +#endif
target/ppc/mmu_common.c +1 -506
525 lines not on this page · raw message
target/ppc/mmu_helper.c +1 -0
@@ -33,6 +33,7 @@#include "internal.h" #include "mmu-book3s-v3.h" #include "mmu-radix64.h" +#include "mmu-booke.h" #include "exec/helper-proto.h" #include "exec/cpu_ldst.h"
Signature · 1 line
2.43.0
[PULL 08/72] target/ppc: Add ISA v3.1 variants of sync instruction
In reply to Nicholas PigginPOWER10 adds a new field to sync for store-store syncs, and some new variants of the existing syncs that include persistent memory.
Implement the store-store syncs and plwsync/phwsync.
--- target/ppc/insn32.decode | 6 ++-- target/ppc/translate/misc-impl.c.inc | 41 ++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 15 deletions(-)
target/ppc/insn32.decode +3 -3
@@ -1001,7 +1001,7 @@ MSGSYNC 011111 ----- ----- ----- 1101110110 - # Memory Barrier Instructions -&X_sync l -@X_sync ...... ... l:2 ..... ..... .......... . &X_sync -SYNC 011111 --- .. ----- ----- 1001010110 - @X_sync +&X_sync l sc +@X_sync ...... .. l:3 ... sc:2 ..... .......... . &X_sync +SYNC 011111 -- ... --- .. ----- 1001010110 - @X_sync EIEIO 011111 ----- ----- ----- 1101010110 -
target/ppc/translate/misc-impl.c.inc +29 -12
55 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 45/72] target/ppc/mmu_common.c: Introduce mmu6xx_get_physical_address()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Repurpose get_segment_6xx_tlb() to do the whole address translation for POWERPC_MMU_SOFT_6xx MMU model by moving the BAT check there and renaming it to match other similar functions. These are only called once together so no need to keep these separate functions and combining them simplifies the caller allowing further restructuring.
--- target/ppc/mmu_common.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
target/ppc/mmu_common.c +12 -14
@@ -360,19 +360,23 @@ static int get_bat_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx,return ret; } -/* Perform segment based translation */ -static int get_segment_6xx_tlb (CPUPPCState *env,mmu_ctx_t *ctx, -target_ulong eaddr,MMUAccessType access_type, -int type) +static int mmu6xx_get_physical_address (CPUPPCState *env,mmu_ctx_t *ctx, +target_ulong eaddr, +MMUAccessType access_type,int type) {PowerPCCPU *cpu =env_archcpu (env);hwaddr hash; -target_ulong vsid; +target_ulong vsid, sr, pgidx;int ds, target_page_bits;bool pr;int ret; -target_ulong sr, pgidx; +/* First try to find a BAT entry if there are any */ +if (env->nb_BATs &&get_bat_6xx_tlb (env, ctx, eaddr, access_type) ==0 ) { +return 0 ; + } + +/* Perform segment based translation when no BATs matched */ pr =FIELD_EX64 (env->msr,MSR ,PR ); ctx->eaddr = eaddr;
@@ -1194,14 +1198,8 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx,if (real_mode) { ret =check_physical (env, ctx, eaddr, access_type); }else { -/* Try to find a BAT */ -if (env->nb_BATs !=0 ) { - ret =get_bat_6xx_tlb (env, ctx, eaddr, access_type); - } -if (ret <0 ) { -/* We didn't match any BAT entry or don't have BATs */ - ret =get_segment_6xx_tlb (env, ctx, eaddr, access_type, type); - } + ret =mmu6xx_get_physical_address (env, ctx, eaddr, access_type, + type); }break ;
Signature · 1 line
2.43.0
[PULL 32/72] target/ppc: Add PPR32 SPR
In reply to Nicholas PigginPPR32 provides access to the upper half of PPR.
--- target/ppc/cpu.h | 1 + target/ppc/cpu_init.c | 12 ++++++++++++ target/ppc/spr_common.h | 2 ++ target/ppc/translate.c | 24 ++++++++++++++++++++++++ 4 files changed, 39 insertions(+)
target/ppc/cpu.h +1 -0
@@ -2120,6 +2120,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_POWER_MMCRS (0x37E)#define SPR_WORT (0x37F)#define SPR_PPR (0x380) +#define SPR_PPR32 (0x382)#define SPR_750_GQR0 (0x390)#define SPR_440_DNV0 (0x390)#define SPR_750_GQR1 (0x391)
target/ppc/cpu_init.c +12 -0
@@ -5606,6 +5606,14 @@ static void register_HEIR64_spr(CPUPPCState *env) 0x00000000); } +static void register_power7_common_sprs (CPUPPCState *env) +{ +spr_register (env,SPR_PPR32 ,"PPR32" , + &spr_read_ppr32, &spr_write_ppr32, + &spr_read_ppr32, &spr_write_ppr32, +0x00000000 ); +} +static void register_power8_tce_address_control_sprs (CPUPPCState *env) { spr_register_kvm(env, SPR_TAR, "TAR",
@@ -6101,6 +6109,7 @@ static void init_proc_POWER7(CPUPPCState *env)register_power6_common_sprs (env);register_HEIR32_spr (env);register_power6_dbg_sprs (env); +register_power7_common_sprs (env);register_power7_book4_sprs (env);/* env variables */
@@ -6247,6 +6256,7 @@ static void init_proc_POWER8(CPUPPCState *env)register_power6_common_sprs (env);register_HEIR32_spr (env);register_power6_dbg_sprs (env); +register_power7_common_sprs (env);register_power8_tce_address_control_sprs (env);register_power8_ids_sprs (env);register_power8_ebb_sprs (env);
@@ -6414,6 +6424,7 @@ static void init_proc_POWER9(CPUPPCState *env)register_power6_common_sprs (env);register_HEIR32_spr (env);register_power6_dbg_sprs (env); +register_power7_common_sprs (env);register_power8_tce_address_control_sprs (env);register_power8_ids_sprs (env);register_power8_ebb_sprs (env);
@@ -6608,6 +6619,7 @@ static void init_proc_POWER10(CPUPPCState *env)register_power6_common_sprs (env);register_HEIR64_spr (env);register_power6_dbg_sprs (env); +register_power7_common_sprs (env);register_power8_tce_address_control_sprs (env);register_power8_ids_sprs (env);register_power8_ebb_sprs (env);
target/ppc/spr_common.h +2 -0
@@ -203,6 +203,8 @@ void spr_read_tfmr(DisasContext *ctx, int gprn, int sprn);void spr_write_tfmr (DisasContext *ctx,int sprn,int gprn);void spr_write_lpcr (DisasContext *ctx,int sprn,int gprn);void spr_read_dexcr_ureg (DisasContext *ctx,int gprn,int sprn); +void spr_read_ppr32 (DisasContext *ctx,int sprn,int gprn); +void spr_write_ppr32 (DisasContext *ctx,int sprn,int gprn);#endif void register_low_BATs (CPUPPCState *env);
target/ppc/translate.c +24 -0
@@ -1352,6 +1352,30 @@ void spr_read_dexcr_ureg(DisasContext *ctx, int gprn, int sprn)gen_load_spr (t0, sprn +16 ); tcg_gen_ext32u_tl(cpu_gpr[gprn], t0); } + +/* The PPR32 SPR accesses the upper 32-bits of PPR */ +void spr_read_ppr32 (DisasContext *ctx,int gprn,int sprn) +{ +gen_load_spr (cpu_gpr[gprn],SPR_PPR ); +tcg_gen_shri_tl (cpu_gpr[gprn], cpu_gpr[gprn],32 ); +spr_load_dump_spr (SPR_PPR ); +} + +void spr_write_ppr32 (DisasContext *ctx,int sprn,int gprn) +{ +TCGv t0 =tcg_temp_new (); + +/* +* Don't clobber the low 32-bits of the PPR. These are all reserved bits +* but TCG does implement them, so it would be surprising to zero them +* here. "Priority nops" are similarly careful not to clobber reserved +* bits. +*/ +gen_load_spr (t0,SPR_PPR ); +tcg_gen_deposit_tl (t0, t0, cpu_gpr[gprn],32 ,32 ); +gen_store_spr (SPR_PPR , t0); +spr_store_dump_spr (SPR_PPR ); +}#endif #define GEN_HANDLER (name, opc1, opc2, opc3, inval, type) \
Signature · 1 line
2.43.0
[PULL 53/72] target/ppc/mmu_common.c: Deindent ppc_jumbo_xlate()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Instead of putting a large block of code in an if, invert the condition and return early to be able to deindent the code block.
--- target/ppc/mmu_common.c | 319 ++++++++++++++++++++-------------------- 1 file changed, 159 insertions(+), 160 deletions(-)
target/ppc/mmu_common.c +159 -160
@@ -1264,187 +1264,186 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, *protp = ctx.prot; *psizep =TARGET_PAGE_BITS ;return true; + }else if (!guest_visible) { +return false; } -if (guest_visible) { -log_cpu_state_mask (CPU_LOG_MMU , cs,0 ); -if (type ==ACCESS_CODE ) { -switch (ret) { -case -1 : -/* No matches in page tables or TLB */ -switch (env->mmu_model) { -case POWERPC_MMU_SOFT_6xx: - cs->exception_index =POWERPC_EXCP_IFTLB ; - env->error_code =1 <<18 ; - env->spr[SPR_IMISS ] = eaddr; - env->spr[SPR_ICMP ] =0x80000000 | ctx.ptem; - goto tlb_miss; -case POWERPC_MMU_SOFT_4xx: - cs->exception_index =POWERPC_EXCP_ITLB ; - env->error_code =0 ; - env->spr[SPR_40x_DEAR] = eaddr; - env->spr[SPR_40x_ESR] =0x00000000 ; -break ; -case POWERPC_MMU_BOOKE206 : -booke206_update_mas_tlb_miss (env, eaddr,2 , mmu_idx); -/* fall through */ -case POWERPC_MMU_BOOKE : - cs->exception_index =POWERPC_EXCP_ITLB ; - env->error_code =0 ; - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx,MMU_DATA_LOAD ); -break ; -case POWERPC_MMU_REAL : -cpu_abort (cs,"PowerPC in real mode should never raise " -"any MMU exceptions\n" ); -default : -cpu_abort (cs,"Unknown or invalid MMU model\n" ); - } +log_cpu_state_mask (CPU_LOG_MMU , cs,0 ); +if (type ==ACCESS_CODE ) { +switch (ret) { +case -1 : +/* No matches in page tables or TLB */ +switch (env->mmu_model) { +case POWERPC_MMU_SOFT_6xx: + cs->exception_index =POWERPC_EXCP_IFTLB ; + env->error_code =1 <<18 ; + env->spr[SPR_IMISS ] = eaddr; + env->spr[SPR_ICMP ] =0x80000000 | ctx.ptem; + goto tlb_miss; +case POWERPC_MMU_SOFT_4xx: + cs->exception_index =POWERPC_EXCP_ITLB ; + env->error_code =0 ; + env->spr[SPR_40x_DEAR] = eaddr; + env->spr[SPR_40x_ESR] =0x00000000 ;break ; -case -2 : -/* Access rights violation */ - cs->exception_index =POWERPC_EXCP_ISI ; -if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || - (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { - env->error_code =0 ; - }else { - env->error_code =0x08000000 ; - } +case POWERPC_MMU_BOOKE206 : +booke206_update_mas_tlb_miss (env, eaddr,2 , mmu_idx); +/* fall through */ +case POWERPC_MMU_BOOKE : + cs->exception_index =POWERPC_EXCP_ITLB ; + env->error_code =0 ; + env->spr[SPR_BOOKE_DEAR ] = eaddr; + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx,MMU_DATA_LOAD );break ; -case -3 : -/* No execute protection violation */ -if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || - (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { - env->spr[SPR_BOOKE_ESR ] =0x00000000 ; - env->error_code =0 ; +case POWERPC_MMU_REAL : +cpu_abort (cs,"PowerPC in real mode should never raise " +"any MMU exceptions\n" ); +default : +cpu_abort (cs,"Unknown or invalid MMU model\n" ); + } +break ; +case -2 : +/* Access rights violation */ + cs->exception_index =POWERPC_EXCP_ISI ; +if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || + (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { + env->error_code =0 ; + }else { + env->error_code =0x08000000 ; + } +break ; +case -3 : +/* No execute protection violation */ +if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || + (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { + env->spr[SPR_BOOKE_ESR ] =0x00000000 ; + env->error_code =0 ; + }else { + env->error_code =0x10000000 ; + } + cs->exception_index =POWERPC_EXCP_ISI ; +break ; +case -4 : +/* Direct store exception */ +/* No code fetch is allowed in direct-store areas */ + cs->exception_index =POWERPC_EXCP_ISI ; +if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || + (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { + env->error_code =0 ; + }else { + env->error_code =0x10000000 ; + } +break ; + } + }else { +switch (ret) { +case -1 : +/* No matches in page tables or TLB */ +switch (env->mmu_model) { +case POWERPC_MMU_SOFT_6xx: +if (access_type ==MMU_DATA_STORE ) { + cs->exception_index =POWERPC_EXCP_DSTLB ; + env->error_code =1 <<16 ; }else { - env->error_code =0x10000000 ; + cs->exception_index =POWERPC_EXCP_DLTLB ; + env->error_code =0 ; } - cs->exception_index =POWERPC_EXCP_ISI ; + env->spr[SPR_DMISS ] = eaddr; + env->spr[SPR_DCMP ] =0x80000000 | ctx.ptem; + tlb_miss: + env->error_code |= ctx.key <<19 ; + env->spr[SPR_HASH1 ] =ppc_hash32_hpt_base (cpu) + +get_pteg_offset32 (cpu, ctx.hash[0 ]); + env->spr[SPR_HASH2 ] =ppc_hash32_hpt_base (cpu) + +get_pteg_offset32 (cpu, ctx.hash[1 ]);break ; -case -4 : -/* Direct store exception */ -/* No code fetch is allowed in direct-store areas */ - cs->exception_index =POWERPC_EXCP_ISI ; -if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || - (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { - env->error_code =0 ; +case POWERPC_MMU_SOFT_4xx: + cs->exception_index =POWERPC_EXCP_DTLB ; + env->error_code =0 ; + env->spr[SPR_40x_DEAR] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_40x_ESR] =0x00800000 ; }else { - env->error_code =0x10000000 ; + env->spr[SPR_40x_ESR] =0x00000000 ; }break ; - } - }else { -switch (ret) { -case -1 : -/* No matches in page tables or TLB */ -switch (env->mmu_model) { -case POWERPC_MMU_SOFT_6xx: -if (access_type ==MMU_DATA_STORE ) { - cs->exception_index =POWERPC_EXCP_DSTLB ; - env->error_code =1 <<16 ; - }else { - cs->exception_index =POWERPC_EXCP_DLTLB ; - env->error_code =0 ; - } - env->spr[SPR_DMISS ] = eaddr; - env->spr[SPR_DCMP ] =0x80000000 | ctx.ptem; - tlb_miss: - env->error_code |= ctx.key <<19 ; - env->spr[SPR_HASH1 ] =ppc_hash32_hpt_base (cpu) + -get_pteg_offset32 (cpu, ctx.hash[0 ]); - env->spr[SPR_HASH2 ] =ppc_hash32_hpt_base (cpu) + -get_pteg_offset32 (cpu, ctx.hash[1 ]); -break ; -case POWERPC_MMU_SOFT_4xx: - cs->exception_index =POWERPC_EXCP_DTLB ; - env->error_code =0 ; - env->spr[SPR_40x_DEAR] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_40x_ESR] =0x00800000 ; - }else { - env->spr[SPR_40x_ESR] =0x00000000 ; - } -break ; -case POWERPC_MMU_BOOKE206 : -booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); -/* fall through */ -case POWERPC_MMU_BOOKE : - cs->exception_index =POWERPC_EXCP_DTLB ; - env->error_code =0 ; - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); -break ; -case POWERPC_MMU_REAL : -cpu_abort (cs,"PowerPC in real mode should never raise " +case POWERPC_MMU_BOOKE206 : +booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); +/* fall through */ +case POWERPC_MMU_BOOKE : + cs->exception_index =POWERPC_EXCP_DTLB ; + env->error_code =0 ; + env->spr[SPR_BOOKE_DEAR ] = eaddr; + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); +break ; +case POWERPC_MMU_REAL : +cpu_abort (cs,"PowerPC in real mode should never raise " "any MMU exceptions\n" ); -default : -cpu_abort (cs,"Unknown or invalid MMU model\n" ); +default : +cpu_abort (cs,"Unknown or invalid MMU model\n" ); + } +break ; +case -2 : +/* Access rights violation */ + cs->exception_index =POWERPC_EXCP_DSI ; + env->error_code =0 ; +if (env->mmu_model == POWERPC_MMU_SOFT_4xx) { + env->spr[SPR_40x_DEAR] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_40x_ESR] |=0x00800000 ; + } + }else if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || + (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { + env->spr[SPR_BOOKE_DEAR ] = eaddr; + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); + }else { + env->spr[SPR_DAR ] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_DSISR ] =0x0A000000 ; + }else { + env->spr[SPR_DSISR ] =0x08000000 ; } + } +break ; +case -4 : +/* Direct store exception */ +switch (type) { +case ACCESS_FLOAT : +/* Floating point load/store */ + cs->exception_index =POWERPC_EXCP_ALIGN ; + env->error_code =POWERPC_EXCP_ALIGN_FP ; + env->spr[SPR_DAR ] = eaddr;break ; -case -2 : -/* Access rights violation */ +case ACCESS_RES : +/* lwarx, ldarx or stwcx. */ cs->exception_index =POWERPC_EXCP_DSI ; env->error_code =0 ; -if (env->mmu_model == POWERPC_MMU_SOFT_4xx) { - env->spr[SPR_40x_DEAR] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_40x_ESR] |=0x00800000 ; - } - }else if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || - (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); + env->spr[SPR_DAR ] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_DSISR ] =0x06000000 ; }else { - env->spr[SPR_DAR ] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_DSISR ] =0x0A000000 ; - }else { - env->spr[SPR_DSISR ] =0x08000000 ; - } + env->spr[SPR_DSISR ] =0x04000000 ; }break ; -case -4 : -/* Direct store exception */ -switch (type) { -case ACCESS_FLOAT : -/* Floating point load/store */ - cs->exception_index =POWERPC_EXCP_ALIGN ; - env->error_code =POWERPC_EXCP_ALIGN_FP ; - env->spr[SPR_DAR ] = eaddr; -break ; -case ACCESS_RES : -/* lwarx, ldarx or stwcx. */ - cs->exception_index =POWERPC_EXCP_DSI ; - env->error_code =0 ; - env->spr[SPR_DAR ] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_DSISR ] =0x06000000 ; - }else { - env->spr[SPR_DSISR ] =0x04000000 ; - } -break ; -case ACCESS_EXT : -/* eciwx or ecowx */ - cs->exception_index =POWERPC_EXCP_DSI ; - env->error_code =0 ; - env->spr[SPR_DAR ] = eaddr; -if (access_type ==MMU_DATA_STORE ) { - env->spr[SPR_DSISR ] =0x06100000 ; - }else { - env->spr[SPR_DSISR ] =0x04100000 ; - } -break ; -default : -printf ("DSI: invalid exception (%d)\n" , ret); - cs->exception_index =POWERPC_EXCP_PROGRAM ; - env->error_code = -POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ; - env->spr[SPR_DAR ] = eaddr; -break ; +case ACCESS_EXT : +/* eciwx or ecowx */ + cs->exception_index =POWERPC_EXCP_DSI ; + env->error_code =0 ; + env->spr[SPR_DAR ] = eaddr; +if (access_type ==MMU_DATA_STORE ) { + env->spr[SPR_DSISR ] =0x06100000 ; + }else { + env->spr[SPR_DSISR ] =0x04100000 ; }break ; +default : +printf ("DSI: invalid exception (%d)\n" , ret); + cs->exception_index =POWERPC_EXCP_PROGRAM ; + env->error_code =POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ; + env->spr[SPR_DAR ] = eaddr; +break ; } +break ; } }return false;
Signature · 1 line
2.43.0
[PULL 57/72] target/ppc/mmu_common.c: Don't use mmu_ctx_t in mmubooke206_get_physical_address()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
mmubooke206_get_physical_address() only uses the raddr and prot fields from mmu_ctx_t. Pass these directly instead of using a ctx struct.
--- target/ppc/mmu_common.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-)
target/ppc/mmu_common.c +10 -22
@@ -836,27 +836,22 @@ found_tlb:return access_type ==MMU_INST_FETCH ?-3 :-2 ; } -static int mmubooke206_get_physical_address (CPUPPCState *env,mmu_ctx_t *ctx, -target_ulong address, +static int mmubooke206_get_physical_address (CPUPPCState *env,hwaddr *raddr, +int *prot,target_ulong address,MMUAccessType access_type,int mmu_idx) {ppcmas_tlb_t *tlb; -hwaddr raddr; -int i, j, ret; - - ret =-1 ; - raddr = (hwaddr)-1ULL ; +int i, j, ret =-1 ;for (i =0 ; i <BOOKE206_MAX_TLBN ; i++) {int ways =booke206_tlb_ways (env, i); -for (j =0 ; j < ways; j++) { tlb =booke206_get_tlbm (env, i, address, j);if (!tlb) {continue ; } - ret =mmubooke206_check_tlb (env, tlb, &raddr, &ctx->prot, address, + ret =mmubooke206_check_tlb (env, tlb, raddr, prot, address, access_type, mmu_idx);if (ret !=-1 ) { goto found_tlb;
@@ -866,17 +861,10 @@ static int mmubooke206_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, found_tlb: -if (ret >=0 ) { - ctx->raddr = raddr; -qemu_log_mask (CPU_LOG_MMU ,"%s: access granted " TARGET_FMT_lx -" => " HWADDR_FMT_plx" %d %d\n" , __func__, address, - ctx->raddr, ctx->prot, ret); - }else { -qemu_log_mask (CPU_LOG_MMU ,"%s: access refused " TARGET_FMT_lx -" => " HWADDR_FMT_plx" %d %d\n" , __func__, address, - raddr, ctx->prot, ret); - } - +qemu_log_mask (CPU_LOG_MMU ,"%s: access %s " TARGET_FMT_lx" => " + HWADDR_FMT_plx" %d %d\n" , __func__, + ret <0 ?"refused" :"granted" , address, + ret <0 ?-1 : *raddr, ret ==-1 ?0 : *prot, ret);return ret; }
@@ -1135,8 +1123,8 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx,return mmubooke_get_physical_address (env, &ctx->raddr, &ctx->prot, eaddr, access_type); }else if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) { -return mmubooke206_get_physical_address (env, ctx, eaddr, access_type, - mmu_idx); +return mmubooke206_get_physical_address (env, &ctx->raddr, &ctx->prot, + eaddr, access_type, mmu_idx); } real_mode = (type == ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, IR)
Signature · 1 line
2.43.0
[PULL 61/72] target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 2
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Merge the code fetch and data access cases in a common switch.
--- target/ppc/mmu_common.c | 52 ++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 32 deletions(-)
target/ppc/mmu_common.c +20 -32
@@ -1221,45 +1221,33 @@ static bool ppc_booke_xlate(PowerPCCPU *cpu, vaddr eaddr,log_cpu_state_mask (CPU_LOG_MMU , cs,0 ); env->error_code =0 ; -if (ret ==-1 ) { +switch (ret) { +case -1 : +/* No matches in page tables or TLB */ if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) {booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); } - } -if (access_type ==MMU_INST_FETCH ) { -switch (ret) { -case -1 : -/* No matches in page tables or TLB */ - cs->exception_index =POWERPC_EXCP_ITLB ; - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); -break ; -case -2 : -/* Access rights violation */ - cs->exception_index =POWERPC_EXCP_ISI ; -break ; -case -3 : -/* No execute protection violation */ - cs->exception_index =POWERPC_EXCP_ISI ; - env->spr[SPR_BOOKE_ESR ] =0 ; -break ; - } - }else { -switch (ret) { -case -1 : -/* No matches in page tables or TLB */ - cs->exception_index =POWERPC_EXCP_DTLB ; - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); -break ; -case -2 : -/* Access rights violation */ - cs->exception_index =POWERPC_EXCP_DSI ; + cs->exception_index = (access_type ==MMU_INST_FETCH ) ? +POWERPC_EXCP_ITLB :POWERPC_EXCP_DTLB ; + env->spr[SPR_BOOKE_DEAR ] = eaddr; + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); +break ; +case -2 : +/* Access rights violation */ + cs->exception_index = (access_type ==MMU_INST_FETCH ) ? +POWERPC_EXCP_ISI :POWERPC_EXCP_DSI ; +if (access_type !=MMU_INST_FETCH ) { env->spr[SPR_BOOKE_DEAR ] = eaddr; env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); -break ; } +break ; +case -3 : +/* No execute protection violation */ + cs->exception_index =POWERPC_EXCP_ISI ; + env->spr[SPR_BOOKE_ESR ] =0 ; +break ; } +return false; }
Signature · 1 line
2.43.0
[PULL 67/72] target/ppc: Split off common embedded TLB init
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Several 4xx CPUs and e200 share the same TLB settings enclosed in an ifdef. Split it off in a common function to reduce code duplication and the number of ifdefs.
--- target/ppc/cpu_init.c | 46 ++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 29 deletions(-)
target/ppc/cpu_init.c +17 -29
@@ -2127,18 +2127,22 @@ static int check_attn_hid0_power9(CPUPPCState *env) }#endif +static void init_tlbs_emb (CPUPPCState *env) +{ +#ifndef CONFIG_USER_ONLY + env->nb_tlb =64 ; + env->nb_ways =1 ; + env->tlb_type =TLB_EMB ; +#endif +} +static void init_proc_405 (CPUPPCState *env) {register_40x_sprs (env);register_405_sprs (env);register_usprgh_sprs (env); -/* Memory management */ -#if !defined(CONFIG_USER_ONLY ) - env->nb_tlb =64 ; - env->nb_ways =1 ; - env->tlb_type =TLB_EMB ; -#endif +init_tlbs_emb (env);init_excp_4xx (env); env->dcache_line_size =32 ; env->icache_line_size =32 ;
@@ -2206,12 +2210,8 @@ static void init_proc_440EP(CPUPPCState *env)SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_write_generic, 0x00000000); -/* Memory management */ -#if !defined(CONFIG_USER_ONLY ) - env->nb_tlb =64 ; - env->nb_ways =1 ; - env->tlb_type =TLB_EMB ; -#endif + +init_tlbs_emb (env);init_excp_BookE (env); env->dcache_line_size =32 ; env->icache_line_size =32 ;
@@ -2305,12 +2305,7 @@ static void init_proc_440GP(CPUPPCState *env)register_440_sprs (env);register_usprgh_sprs (env); -/* Memory management */ -#if !defined(CONFIG_USER_ONLY ) - env->nb_tlb =64 ; - env->nb_ways =1 ; - env->tlb_type =TLB_EMB ; -#endif +init_tlbs_emb (env);init_excp_BookE (env); env->dcache_line_size =32 ; env->icache_line_size =32 ;
@@ -2379,12 +2374,8 @@ static void init_proc_440x5(CPUPPCState *env)SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_write_generic, 0x00000000); -/* Memory management */ -#if !defined(CONFIG_USER_ONLY ) - env->nb_tlb =64 ; - env->nb_ways =1 ; - env->tlb_type =TLB_EMB ; -#endif + +init_tlbs_emb (env);init_excp_BookE (env); env->dcache_line_size =32 ; env->icache_line_size =32 ;
@@ -2747,11 +2738,8 @@ static void init_proc_e200(CPUPPCState *env)SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_write_generic, 0x00000000); -#if !defined(CONFIG_USER_ONLY ) - env->nb_tlb =64 ; - env->nb_ways =1 ; - env->tlb_type =TLB_EMB ; -#endif + +init_tlbs_emb (env);init_excp_e200 (env,0xFFFF0000UL ); env->dcache_line_size =32 ; env->icache_line_size =32 ;
Signature · 1 line
2.43.0
[PULL 51/72] target/ppc/mmu_common.c: Inline and remove check_physical()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
This function just does two assignments and and unnecessary check that is always true so inline it in the only caller left and remove it.
--- target/ppc/mmu_common.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)
target/ppc/mmu_common.c +3 -23
@@ -1145,28 +1145,6 @@ void dump_mmu(CPUPPCState *env) } } -static int check_physical (CPUPPCState *env,mmu_ctx_t *ctx,target_ulong eaddr, -MMUAccessType access_type) -{ - ctx->raddr = eaddr; - ctx->prot =PAGE_READ |PAGE_EXEC ; - -switch (env->mmu_model) { -case POWERPC_MMU_SOFT_6xx: -case POWERPC_MMU_SOFT_4xx: -case POWERPC_MMU_REAL : -case POWERPC_MMU_BOOKE : - ctx->prot |=PAGE_WRITE ; -break ; - -default : -/* Caller's checks mean we should never get here for other models */ -g_assert_not_reached (); - } - -return 0 ; -} - int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, target_ulong eaddr, MMUAccessType access_type, int type,
@@ -1186,7 +1164,9 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx,if (real_mode && (env->mmu_model == POWERPC_MMU_SOFT_6xx || env->mmu_model == POWERPC_MMU_SOFT_4xx || env->mmu_model ==POWERPC_MMU_REAL )) { -return check_physical (env, ctx, eaddr, access_type); + ctx->raddr = eaddr; + ctx->prot =PAGE_RWX ; +return 0 ; }switch (env->mmu_model) {
Signature · 1 line
2.43.0
[PULL 05/72] tcg/cputlb: remove other-cpu capability from TLB flushing
In reply to Nicholas PigginSome TLB flush operations can flush other CPUs. The problem with this is they used non-synced variants of flushes (i.e., that return before the destination has completed the flush). Since all TLB flush users need the _synced variants, and that last user (ppc) of the non-synced flush was buggy, this is a footgun waiting to go off. There do not seem to be any callers that flush other CPUs, so remove the capability.
--- accel/tcg/cputlb.c | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-)
accel/tcg/cputlb.c +9 -33
@@ -418,12 +418,9 @@ void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap) {tlb_debug ("mmu_idx: 0x%" PRIx16"\n" , idxmap); -if (cpu->created && !qemu_cpu_is_self (cpu)) { -async_run_on_cpu (cpu, tlb_flush_by_mmuidx_async_work, -RUN_ON_CPU_HOST_INT (idxmap)); - }else { -tlb_flush_by_mmuidx_async_work (cpu,RUN_ON_CPU_HOST_INT (idxmap)); - } +assert_cpu_is_self (cpu); + +tlb_flush_by_mmuidx_async_work (cpu,RUN_ON_CPU_HOST_INT (idxmap)); }void tlb_flush (CPUState *cpu)
@@ -612,28 +609,12 @@ void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, uint16_t idxmap) {tlb_debug ("addr: %016" VADDR_PRIx" mmu_idx:%" PRIx16"\n" , addr, idxmap); +assert_cpu_is_self (cpu); +/* This should already be page aligned */ addr &=TARGET_PAGE_MASK ; -if (qemu_cpu_is_self (cpu)) { -tlb_flush_page_by_mmuidx_async_0 (cpu, addr, idxmap); - }else if (idxmap <TARGET_PAGE_SIZE ) { -/* -* Most targets have only a few mmu_idx. In the case where -* we can stuff idxmap into the low TARGET_PAGE_BITS, avoid -* allocating memory for this operation. -*/ -async_run_on_cpu (cpu, tlb_flush_page_by_mmuidx_async_1, -RUN_ON_CPU_TARGET_PTR (addr | idxmap)); - }else { -TLBFlushPageByMMUIdxData *d =g_new (TLBFlushPageByMMUIdxData,1 ); - -/* Otherwise allocate a structure, freed by the worker. */ - d->addr = addr; - d->idxmap = idxmap; -async_run_on_cpu (cpu, tlb_flush_page_by_mmuidx_async_2, -RUN_ON_CPU_HOST_PTR (d)); - } +tlb_flush_page_by_mmuidx_async_0 (cpu, addr, idxmap); }void tlb_flush_page (CPUState *cpu,vaddr addr)
@@ -796,6 +777,8 @@ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, {TLBFlushRangeData d; +assert_cpu_is_self (cpu); +/* * If all bits are significant, and len is small, * this devolves to tlb_flush_page.
@@ -816,14 +799,7 @@ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, d.idxmap = idxmap; d.bits = bits; -if (qemu_cpu_is_self (cpu)) { -tlb_flush_range_by_mmuidx_async_0 (cpu, d); - }else { -/* Otherwise allocate a structure, freed by the worker. */ -TLBFlushRangeData *p =g_memdup (&d,sizeof (d)); -async_run_on_cpu (cpu, tlb_flush_range_by_mmuidx_async_1, -RUN_ON_CPU_HOST_PTR (p)); - } +tlb_flush_range_by_mmuidx_async_0 (cpu, d); } void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr,
Signature · 1 line
2.43.0
[PULL 12/72] target/ppc: Make divw[u] handler method decodetree compatible.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
The handler methods for divw[u] instructions internally use Rc(ctx->opcode), for extraction of Rc field of instructions, which poses a problem if we move the above said instructions to decodetree, as the ctx->opcode field is not popluated in decodetree. Hence, making it decodetree compatible, so that the mentioned insns can be safely move to decodetree specs.
--- target/ppc/translate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
target/ppc/translate.c +5 -4
@@ -1737,8 +1737,9 @@ static inline void gen_op_arith_add(DisasContext *ctx, TCGv ret, TCGv arg1, } } -static inline void gen_op_arith_divw (DisasContext *ctx,TCGv ret,TCGv arg1, -TCGv arg2,int sign,int compute_ov) +static inline void gen_op_arith_divw (DisasContext *ctx,TCGv ret, +TCGv arg1,TCGv arg2,bool sign, +bool compute_ov,bool compute_rc0) {TCGv_i32 t0 =tcg_temp_new_i32 ();TCGv_i32 t1 =tcg_temp_new_i32 ();
@@ -1772,7 +1773,7 @@ static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret, TCGv arg1,tcg_gen_or_tl (cpu_so, cpu_so, cpu_ov); } -if (unlikely (Rc (ctx->opcode) !=0 )) { +if (unlikely (compute_rc0)) {gen_set_Rc0 (ctx, ret); } }
@@ -1782,7 +1783,7 @@ static void glue(gen_, name)(DisasContext *ctx) \ { \gen_op_arith_divw (ctx, cpu_gpr[rD (ctx->opcode)], \ cpu_gpr[rA (ctx->opcode)], cpu_gpr[rB (ctx->opcode)], \ - sign, compute_ov); \ + sign, compute_ov,Rc (ctx->opcode)); \ }/* divwu divwu. divwuo divwuo. */ GEN_INT_ARITH_DIVW (divwu,0x0E ,0 ,0 );
Signature · 1 line
2.43.0
[PULL 47/72] target/ppc/mmu_common.c: Move some debug logging
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Move the debug logging within ppc6xx_tlb_check() from after its only call to simplify the caller.
--- target/ppc/mmu_common.c | 54 ++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 30 deletions(-)
target/ppc/mmu_common.c +24 -30
@@ -225,17 +225,14 @@ static int ppc6xx_tlb_check(CPUPPCState *env, mmu_ctx_t *ctx, access_type == MMU_INST_FETCH ? 'I' : 'D');switch (ppc6xx_tlb_pte_check (ctx, tlb->pte0, tlb->pte1,0 , access_type)) { -case -3 : -/* TLB inconsistency */ -return -1 ;case -2 :/* Access violation */ ret =-2 ; best = nr;break ; -case -1 : +case -1 :/* No match */ +case -3 :/* TLB inconsistency */ default : -/* No match */ break ;case 0 :/* access granted */
@@ -251,14 +248,34 @@ static int ppc6xx_tlb_check(CPUPPCState *env, mmu_ctx_t *ctx, } }if (best !=-1 ) { - done: +done:qemu_log_mask (CPU_LOG_MMU ,"found TLB at addr " HWADDR_FMT_plx" prot=%01x ret=%d\n" , ctx->raddr &TARGET_PAGE_MASK , ctx->prot, ret);/* Update page flags */ pte_update_flags (ctx, &env->tlb.tlb6[best].pte1, ret, access_type); } - +#if defined(DUMP_PAGE_TABLES ) +if (qemu_loglevel_mask (CPU_LOG_MMU )) { +CPUState *cs =env_cpu (env); +hwaddr base =ppc_hash32_hpt_base (env_archcpu (env)); +hwaddr len =ppc_hash32_hpt_mask (env_archcpu (env)) +0x80 ; +uint32_t a0, a1, a2, a3; + +qemu_log ("Page table: " HWADDR_FMT_plx" len " HWADDR_FMT_plx"\n" , + base, len); +for (hwaddr curaddr = base; curaddr < base + len; curaddr +=16 ) { + a0 =ldl_phys (cs->as, curaddr); + a1 =ldl_phys (cs->as, curaddr +4 ); + a2 =ldl_phys (cs->as, curaddr +8 ); + a3 =ldl_phys (cs->as, curaddr +12 ); +if (a0 !=0 || a1 !=0 || a2 !=0 || a3 !=0 ) { +qemu_log (HWADDR_FMT_plx": %08x %08x %08x %08x\n" , + curaddr, a0, a1, a2, a3); + } + } + } +#endif return ret; }
@@ -420,29 +437,6 @@ static int mmu6xx_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, ctx->raddr = (hwaddr)-1ULL ;/* Software TLB search */ ret =ppc6xx_tlb_check (env, ctx, eaddr, access_type); -#if defined(DUMP_PAGE_TABLES ) -if (qemu_loglevel_mask (CPU_LOG_MMU )) { -CPUState *cs =env_cpu (env); -hwaddr curaddr; -uint32_t a0, a1, a2, a3; - -qemu_log ("Page table: " HWADDR_FMT_plx" len " HWADDR_FMT_plx"\n" , -ppc_hash32_hpt_base (cpu),ppc_hash32_hpt_mask (cpu) +0x80 ); -for (curaddr =ppc_hash32_hpt_base (cpu); - curaddr < (ppc_hash32_hpt_base (cpu) - +ppc_hash32_hpt_mask (cpu) +0x80 ); - curaddr +=16 ) { - a0 =ldl_phys (cs->as, curaddr); - a1 =ldl_phys (cs->as, curaddr +4 ); - a2 =ldl_phys (cs->as, curaddr +8 ); - a3 =ldl_phys (cs->as, curaddr +12 ); -if (a0 !=0 || a1 !=0 || a2 !=0 || a3 !=0 ) { -qemu_log (HWADDR_FMT_plx": %08x %08x %08x %08x\n" , - curaddr, a0, a1, a2, a3); - } - } - } -#endif }else {qemu_log_mask (CPU_LOG_MMU ,"direct store...\n" );/* Direct-store segment : absolutely *BUGGY* for now */
Signature · 1 line
2.43.0
[PULL 44/72] target/ppc/mmu_common.c: Drop cases for unimplemented MPC8xx MMU
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Drop MPC8xx cases from get_physical_address_wtlb() and ppc_jumbo_xlate(). The default case would still catch this and abort the same way and there is still a warning about it in ppc_tlb_invalidate_all() which is called in ppc_cpu_reset_hold() so likely we never get here but to make sure add a case to ppc_xlate() to the same effect.
--- target/ppc/mmu_common.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
target/ppc/mmu_common.c +2 -10
@@ -1219,10 +1219,6 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, ret =mmubooke206_get_physical_address (env, ctx, eaddr, access_type, mmu_idx);break ; -case POWERPC_MMU_MPC8xx: -/* XXX: TODO */ -cpu_abort (env_cpu (env),"MPC8xx MMU model is not implemented\n" ); -break ;case POWERPC_MMU_REAL :if (real_mode) { ret =check_physical (env, ctx, eaddr, access_type);
@@ -1353,8 +1349,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, env->spr[SPR_BOOKE_DEAR ] = eaddr; env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx,MMU_DATA_LOAD );break ; -case POWERPC_MMU_MPC8xx: -cpu_abort (cs,"MPC8xx MMU model is not implemented\n" );case POWERPC_MMU_REAL :cpu_abort (cs,"PowerPC in real mode should never raise " "any MMU exceptions\n" );
@@ -1427,9 +1421,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, env->spr[SPR_40x_ESR] =0x00000000 ; }break ; -case POWERPC_MMU_MPC8xx: -/* XXX: TODO */ -cpu_abort (cs,"MPC8xx MMU model is not implemented\n" );case POWERPC_MMU_BOOKE206 :booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx);/* fall through */
@@ -1539,7 +1530,8 @@ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,case POWERPC_MMU_32B :return ppc_hash32_xlate (cpu, eaddr, access_type, raddrp, psizep, protp, mmu_idx, guest_visible); - +case POWERPC_MMU_MPC8xx: +cpu_abort (env_cpu (&cpu->env),"MPC8xx MMU model is not implemented\n" );default :return ppc_jumbo_xlate (cpu, eaddr, access_type, raddrp, psizep, protp, mmu_idx, guest_visible);
Signature · 1 line
2.43.0
[PULL 30/72] target/ppc: Implement attn instruction on BookS 64-bit processors
In reply to Nicholas Pigginattn is an implementation-specific instruction that on POWER (and G5/
970) can be enabled with a HID bit (disabled = illegal), and executing it causes the host processor to stop and the service processor to be notified. Generally used for debugging.
Implement attn and make it checkstop the system, which should be good enough for QEMU debugging.
--- target/ppc/cpu.h | 12 +++++ target/ppc/cpu_init.c | 69 ++++++++++++++++++++++++++++ target/ppc/excp_helper.c | 43 +++++++++++++---- target/ppc/helper.h | 1 + target/ppc/insn32.decode | 4 ++ target/ppc/translate/misc-impl.c.inc | 10 ++++ 6 files changed, 130 insertions(+), 9 deletions(-)
target/ppc/cpu.h +12 -0
@@ -1375,6 +1375,9 @@ struct CPUArchState {/* Power management */ int (*check_pow)(CPUPPCState *env); +/* attn instruction enable */ +int (*check_attn)(CPUPPCState *env); +#if !defined(CONFIG_USER_ONLY )void *load_info;/* holds boot loading state */ #endif
@@ -1523,6 +1526,7 @@ struct PowerPCCPUClass {int n_host_threads;void (*init_proc)(CPUPPCState *env);int (*check_pow)(CPUPPCState *env); +int (*check_attn)(CPUPPCState *env); };ObjectClass *ppc_cpu_class_by_name (const char *name);
@@ -2320,6 +2324,8 @@ void ppc_compat_add_property(Object *obj, const char *name,#define HID0_NAP (1 << 22)/* pre-2.06 */ #define HID0_HILE PPC_BIT(19)/* POWER8 */ #define HID0_POWER9_HILE PPC_BIT(4) +#define HID0_ENABLE_ATTN PPC_BIT(31)/* POWER8 */ +#define HID0_POWER9_ENABLE_ATTN PPC_BIT(3)/*****************************************************************************/ /* PowerPC Instructions types definitions */
@@ -3025,6 +3031,12 @@ static inline int check_pow_nocheck(CPUPPCState *env)return 1 ; } +/* attn enable check */ +static inline int check_attn_none (CPUPPCState *env) +{ +return 0 ; +} +/*****************************************************************************/ /* PowerPC implementations definitions */
target/ppc/cpu_init.c +69 -0
345 lines not on this page · raw message
target/ppc/excp_helper.c +34 -9
67 lines not on this page · raw message
target/ppc/helper.h +1 -0
@@ -825,5 +825,6 @@ DEF_HELPER_FLAGS_1(fixup_thrm, TCG_CALL_NO_RWG, void, env)#if defined(TARGET_PPC64 ) DEF_HELPER_1(clrbhrb, void, env) DEF_HELPER_FLAGS_2(mfbhrbe, TCG_CALL_NO_WG, i64, env, i32) +DEF_HELPER_1(attn, noreturn, env)#endif #endif
target/ppc/insn32.decode +4 -0
@@ -1198,3 +1198,7 @@ EIEIO 011111 ----- ----- ----- 1101010110 - MFBHRBE 011111 ..... ..... ..... 0100101110 - @XFX_bhrbe CLRBHRB 011111 ----- ----- ----- 0110101110 - + +## Misc POWER instructions + +ATTN 000000 00000 00000 00000 0100000000 0
target/ppc/translate/misc-impl.c.inc +10 -0
@@ -145,3 +145,13 @@ static bool trans_EIEIO(DisasContext *ctx, arg_EIEIO *a) return true; } + +static bool trans_ATTN(DisasContext *ctx, arg_ATTN *a) +{ +#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) + gen_helper_attn(tcg_env); + return true; +#else + return false; +#endif +}
Signature · 1 line
2.43.0
[PULL 59/72] target/ppc/mmu_common.c: Split off BookE handling from ppc_jumbo_xlate()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Introduce ppc_booke_xlate() to handle BookE and BookE 2.06 cases to reduce ppc_jumbo_xlate() further.
--- target/ppc/mmu_common.c | 146 ++++++++++++++++++++++++++-------------- 1 file changed, 96 insertions(+), 50 deletions(-)
target/ppc/mmu_common.c +96 -50
@@ -1117,21 +1117,9 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, MMUAccessType access_type, int type, int mmu_idx) { - bool real_mode; - -if (env->mmu_model ==POWERPC_MMU_BOOKE ) { -return mmubooke_get_physical_address (env, &ctx->raddr, &ctx->prot, - eaddr, access_type); - }else if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) { -return mmubooke206_get_physical_address (env, &ctx->raddr, &ctx->prot, - eaddr, access_type, mmu_idx); - } - - real_mode = (type ==ACCESS_CODE ) ? !FIELD_EX64 (env->msr,MSR ,IR ) - : !FIELD_EX64 (env->msr,MSR ,DR ); -if (real_mode && (env->mmu_model == POWERPC_MMU_SOFT_6xx || - env->mmu_model == POWERPC_MMU_SOFT_4xx || - env->mmu_model ==POWERPC_MMU_REAL )) { + bool real_mode = (type == ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, IR) + : !FIELD_EX64 (env->msr,MSR ,DR ); +if (real_mode) { ctx->raddr = eaddr; ctx->prot =PAGE_RWX ;return 0 ;
@@ -1205,6 +1193,93 @@ static void booke206_update_mas_tlb_miss(CPUPPCState *env, target_ulong address, env->spr[SPR_BOOKE_MAS0 ] |= env->last_way <<MAS0_NV_SHIFT ; } +static bool ppc_booke_xlate (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +int mmu_idx,bool guest_visible) +{ +CPUState *cs =CPU (cpu); +CPUPPCState *env = &cpu->env; +hwaddr raddr; +int prot, ret; + +if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) { + ret =mmubooke206_get_physical_address (env, &raddr, &prot, eaddr, + access_type, mmu_idx); + }else { + ret =mmubooke_get_physical_address (env, &raddr, &prot, eaddr, + access_type); + } +if (ret ==0 ) { + *raddrp = raddr; + *protp = prot; + *psizep =TARGET_PAGE_BITS ; +return true; + }else if (!guest_visible) { +return false; + } + +log_cpu_state_mask (CPU_LOG_MMU , cs,0 ); +if (access_type ==MMU_INST_FETCH ) { +switch (ret) { +case -1 : +/* No matches in page tables or TLB */ +switch (env->mmu_model) { +case POWERPC_MMU_BOOKE206 : +booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); +/* fall through */ +case POWERPC_MMU_BOOKE : + cs->exception_index =POWERPC_EXCP_ITLB ; + env->error_code =0 ; + env->spr[SPR_BOOKE_DEAR ] = eaddr; + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); +break ; +default : +g_assert_not_reached (); + } +break ; +case -2 : +/* Access rights violation */ + cs->exception_index =POWERPC_EXCP_ISI ; + env->error_code =0 ; +break ; +case -3 : +/* No execute protection violation */ + cs->exception_index =POWERPC_EXCP_ISI ; + env->spr[SPR_BOOKE_ESR ] =0 ; + env->error_code =0 ; +break ; + } + }else { +switch (ret) { +case -1 : +/* No matches in page tables or TLB */ +switch (env->mmu_model) { +case POWERPC_MMU_BOOKE206 : +booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); +/* fall through */ +case POWERPC_MMU_BOOKE : + cs->exception_index =POWERPC_EXCP_DTLB ; + env->error_code =0 ; + env->spr[SPR_BOOKE_DEAR ] = eaddr; + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); +break ; +default : +g_assert_not_reached (); + } +break ; +case -2 : +/* Access rights violation */ + cs->exception_index =POWERPC_EXCP_DSI ; + env->error_code =0 ; + env->spr[SPR_BOOKE_DEAR ] = eaddr; + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); +break ; + } + } +return false; +} +/* Perform address translation */ /* TODO: Split this by mmu_model. */ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,
@@ -1257,15 +1332,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, env->spr[SPR_40x_DEAR] = eaddr; env->spr[SPR_40x_ESR] =0x00000000 ;break ; -case POWERPC_MMU_BOOKE206 : -booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); -/* fall through */ -case POWERPC_MMU_BOOKE : - cs->exception_index =POWERPC_EXCP_ITLB ; - env->error_code =0 ; - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); -break ;case POWERPC_MMU_REAL :cpu_abort (cs,"PowerPC in real mode should never raise " "any MMU exceptions\n" );
@@ -1276,23 +1342,12 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,case -2 :/* Access rights violation */ cs->exception_index =POWERPC_EXCP_ISI ; -if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || - (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { - env->error_code =0 ; - }else { - env->error_code =0x08000000 ; - } + env->error_code =0x08000000 ;break ;case -3 :/* No execute protection violation */ -if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || - (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { - env->spr[SPR_BOOKE_ESR ] =0x00000000 ; - env->error_code =0 ; - }else { - env->error_code =0x10000000 ; - } cs->exception_index =POWERPC_EXCP_ISI ; + env->error_code =0x10000000 ;break ;case -4 :/* Direct store exception */
@@ -1333,15 +1388,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, env->spr[SPR_40x_ESR] =0x00000000 ; }break ; -case POWERPC_MMU_BOOKE206 : -booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx); -/* fall through */ -case POWERPC_MMU_BOOKE : - cs->exception_index =POWERPC_EXCP_DTLB ; - env->error_code =0 ; - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); -break ;case POWERPC_MMU_REAL :cpu_abort (cs,"PowerPC in real mode should never raise " "any MMU exceptions\n" );
@@ -1358,10 +1404,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,if (access_type ==MMU_DATA_STORE ) { env->spr[SPR_40x_ESR] |=0x00800000 ; } - }else if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || - (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { - env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type); }else { env->spr[SPR_DAR ] = eaddr;if (access_type ==MMU_DATA_STORE ) {
@@ -1440,6 +1482,10 @@ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,case POWERPC_MMU_32B :return ppc_hash32_xlate (cpu, eaddr, access_type, raddrp, psizep, protp, mmu_idx, guest_visible); +case POWERPC_MMU_BOOKE : +case POWERPC_MMU_BOOKE206 : +return ppc_booke_xlate (cpu, eaddr, access_type, raddrp, + psizep, protp, mmu_idx, guest_visible);case POWERPC_MMU_MPC8xx:cpu_abort (env_cpu (&cpu->env),"MPC8xx MMU model is not implemented\n" );default :
Signature · 1 line
2.43.0
[PULL 64/72] target/ppc/mmu_common.c: Transform ppc_jumbo_xlate() into ppc_6xx_xlate()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Now that only 6xx cases left in ppc_jumbo_xlate() we can change it to ppc_6xx_xlate() also removing get_physical_address_wtlb().
--- target/ppc/internal.h | 5 +---- target/ppc/mmu_common.c | 38 ++++++++++++-------------------------- 2 files changed, 13 insertions(+), 30 deletions(-)
target/ppc/internal.h +1 -4
@@ -262,10 +262,7 @@ typedef struct mmu_ctx_t mmu_ctx_t;bool ppc_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type,hwaddr *raddrp,int *psizep,int *protp,int mmu_idx,bool guest_visible); -int get_physical_address_wtlb (CPUPPCState *env,mmu_ctx_t *ctx, -target_ulong eaddr, -MMUAccessType access_type,int type, -int mmu_idx); +/* Software driven TLB helpers */ int ppc6xx_tlb_getnum (CPUPPCState *env,target_ulong eaddr,int way,int is_code);
target/ppc/mmu_common.c +12 -26
@@ -1112,22 +1112,6 @@ void dump_mmu(CPUPPCState *env) } } -int get_physical_address_wtlb (CPUPPCState *env,mmu_ctx_t *ctx, -target_ulong eaddr, -MMUAccessType access_type,int type, -int mmu_idx) -{ -switch (env->mmu_model) { -case POWERPC_MMU_SOFT_6xx: -return mmu6xx_get_physical_address (env, ctx, eaddr, access_type, type); -case POWERPC_MMU_SOFT_4xx: -return mmu40x_get_physical_address (env, &ctx->raddr, &ctx->prot, eaddr, - access_type); -default : -cpu_abort (env_cpu (env),"Unknown or invalid MMU model\n" ); - } -} -static void booke206_update_mas_tlb_miss (CPUPPCState *env,target_ulong address,MMUAccessType access_type,int mmu_idx) {
@@ -1326,12 +1310,10 @@ static bool ppc_40x_xlate(PowerPCCPU *cpu, vaddr eaddr,return false; } -/* Perform address translation */ -/* TODO: Split this by mmu_model. */ -static bool ppc_jumbo_xlate (PowerPCCPU *cpu,vaddr eaddr, -MMUAccessType access_type, -hwaddr *raddrp,int *psizep,int *protp, -int mmu_idx,bool guest_visible) +static bool ppc_6xx_xlate (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp, +int mmu_idx,bool guest_visible) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -1353,8 +1335,10 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, type =ACCESS_INT ; } - ret =get_physical_address_wtlb (env, &ctx, eaddr, access_type, - type, mmu_idx); + ctx.prot =0 ; + ctx.hash[0 ] =0 ; + ctx.hash[1 ] =0 ; + ret =mmu6xx_get_physical_address (env, &ctx, eaddr, access_type, type);if (ret ==0 ) { *raddrp = ctx.raddr; *protp = ctx.prot;
@@ -1498,14 +1482,16 @@ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,case POWERPC_MMU_SOFT_4xx:return ppc_40x_xlate (cpu, eaddr, access_type, raddrp, psizep, protp, mmu_idx, guest_visible); +case POWERPC_MMU_SOFT_6xx: +return ppc_6xx_xlate (cpu, eaddr, access_type, raddrp, + psizep, protp, mmu_idx, guest_visible);case POWERPC_MMU_REAL :return ppc_real_mode_xlate (cpu, eaddr, access_type, raddrp, psizep, protp);case POWERPC_MMU_MPC8xx:cpu_abort (env_cpu (&cpu->env),"MPC8xx MMU model is not implemented\n" );default : -return ppc_jumbo_xlate (cpu, eaddr, access_type, raddrp, - psizep, protp, mmu_idx, guest_visible); +cpu_abort (CPU (cpu),"Unknown or invalid MMU model\n" ); } }
Signature · 1 line
2.43.0
[PULL 68/72] target/ppc/mmu-hash32.c: Drop a local variable
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
In ppc_hash32_xlate() the value of need_prop is checked in two places but precalculating it does not help because when we reach the first check we always return and not reach the second place so the value will only be used once. We can drop the local variable and calculate it when needed, which makes these checks using it similar to other places with such checks.
--- target/ppc/mmu-hash32.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
target/ppc/mmu-hash32.c +2 -5
@@ -386,7 +386,6 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,hwaddr pte_offset;ppc_hash_pte32_t pte;int prot; -int need_prot;hwaddr raddr;/* There are no hash32 large pages. */
@@ -400,13 +399,11 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,return true; } - need_prot =prot_for_access_type (access_type); -/* 2. Check Block Address Translation entries (BATs) */ if (env->nb_BATs !=0 ) { raddr =ppc_hash32_bat_lookup (cpu, eaddr, access_type, protp, mmu_idx);if (raddr !=-1 ) { -if (need_prot & ~*protp) { +if (prot_for_access_type (access_type) & ~*protp) {if (guest_visible) {if (access_type ==MMU_INST_FETCH ) { cs->exception_index =POWERPC_EXCP_ISI ;
@@ -474,7 +471,7 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, prot =ppc_hash32_pte_prot (mmu_idx, sr, pte); -if (need_prot & ~prot) { +if (prot_for_access_type (access_type) & ~prot) {/* Access right violation */ qemu_log_mask (CPU_LOG_MMU ,"PTE access rejected\n" );if (guest_visible) {
Signature · 1 line
2.43.0
[PULL 62/72] target/ppc/mmu_common.c: Split off real mode handling from get_physical_address_wtlb()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Add ppc_real_mode_xlate() to handle real mode translation and allow removing this case from ppc_jumbo_xlate().
--- target/ppc/mmu_common.c | 46 ++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-)
target/ppc/mmu_common.c +27 -19
@@ -1117,23 +1117,12 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, MMUAccessType access_type, int type, int mmu_idx) { - bool real_mode = (type == ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, IR) - : !FIELD_EX64 (env->msr,MSR ,DR ); -if (real_mode) { - ctx->raddr = eaddr; - ctx->prot =PAGE_RWX ; -return 0 ; - } - switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: return mmu6xx_get_physical_address(env, ctx, eaddr, access_type, type);case POWERPC_MMU_SOFT_4xx:return mmu40x_get_physical_address (env, &ctx->raddr, &ctx->prot, eaddr, access_type); -case POWERPC_MMU_REAL : -cpu_abort (env_cpu (env), -"PowerPC in real mode do not do any translation\n" );default :cpu_abort (env_cpu (env),"Unknown or invalid MMU model\n" ); }
@@ -1251,6 +1240,24 @@ static bool ppc_booke_xlate(PowerPCCPU *cpu, vaddr eaddr,return false; } +static bool ppc_real_mode_xlate (PowerPCCPU *cpu,vaddr eaddr, +MMUAccessType access_type, +hwaddr *raddrp,int *psizep,int *protp) +{ +CPUPPCState *env = &cpu->env; + +if (access_type ==MMU_INST_FETCH ? !FIELD_EX64 (env->msr,MSR ,IR ) + : !FIELD_EX64 (env->msr,MSR ,DR )) { + *raddrp = eaddr; + *protp =PAGE_RWX ; + *psizep =TARGET_PAGE_BITS ; +return true; + }else if (env->mmu_model ==POWERPC_MMU_REAL ) { +cpu_abort (CPU (cpu),"PowerPC in real mode shold not do translation\n" ); + } +return false; +} +/* Perform address translation */ /* TODO: Split this by mmu_model. */ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,
@@ -1264,6 +1271,10 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,int type;int ret; +if (ppc_real_mode_xlate (cpu, eaddr, access_type, raddrp, psizep, protp)) { +return true; + } +if (access_type ==MMU_INST_FETCH ) {/* code access */ type =ACCESS_CODE ;
@@ -1303,11 +1314,8 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, env->spr[SPR_40x_DEAR] = eaddr; env->spr[SPR_40x_ESR] =0x00000000 ;break ; -case POWERPC_MMU_REAL : -cpu_abort (cs,"PowerPC in real mode should never raise " -"any MMU exceptions\n" );default : -cpu_abort (cs,"Unknown or invalid MMU model\n" ); +g_assert_not_reached (); }break ;case -2 :
@@ -1359,11 +1367,8 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, env->spr[SPR_40x_ESR] =0x00000000 ; }break ; -case POWERPC_MMU_REAL : -cpu_abort (cs,"PowerPC in real mode should never raise " -"any MMU exceptions\n" );default : -cpu_abort (cs,"Unknown or invalid MMU model\n" ); +g_assert_not_reached (); }break ;case -2 :
@@ -1457,6 +1462,9 @@ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,case POWERPC_MMU_BOOKE206 :return ppc_booke_xlate (cpu, eaddr, access_type, raddrp, psizep, protp, mmu_idx, guest_visible); +case POWERPC_MMU_REAL : +return ppc_real_mode_xlate (cpu, eaddr, access_type, raddrp, psizep, + protp);case POWERPC_MMU_MPC8xx:cpu_abort (env_cpu (&cpu->env),"MPC8xx MMU model is not implemented\n" );default :
Signature · 1 line
2.43.0
[PULL 55/72] target/ppc/mmu_common.c: Don't use mmu_ctx_t for mmu40x_get_physical_address()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
mmu40x_get_physical_address() only uses the raddr and prot fields from mmu_ctx_t. Pass these directly instead of using a ctx struct.
--- target/ppc/mmu_common.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-)
target/ppc/mmu_common.c +15 -22
@@ -519,20 +519,18 @@ int ppcemb_tlb_search(CPUPPCState *env, target_ulong address, uint32_t pid)return -1 ; } -static int mmu40x_get_physical_address (CPUPPCState *env,mmu_ctx_t *ctx, -target_ulong address, +static int mmu40x_get_physical_address (CPUPPCState *env,hwaddr *raddr, +int *prot,target_ulong address,MMUAccessType access_type) {ppcemb_tlb_t *tlb; -hwaddr raddr;int i, ret, zsel, zpr, pr; ret =-1 ; - raddr = (hwaddr)-1ULL ; pr =FIELD_EX64 (env->msr,MSR ,PR );for (i =0 ; i < env->nb_tlb; i++) { tlb = &env->tlb.tlbe[i]; -if (!ppcemb_tlb_check (env, tlb, &raddr, address, +if (!ppcemb_tlb_check (env, tlb, raddr, address, env->spr[SPR_40x_PID], i)) {continue ; }
@@ -550,40 +548,34 @@ static int mmu40x_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx,/* fall through */ case 0x3 :/* All accesses granted */ - ctx->prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; + *prot =PAGE_RWX ; ret =0 ;break ; +case 0x0 :if (pr !=0 ) {/* Raise Zone protection fault. */ env->spr[SPR_40x_ESR] =1 <<22 ; - ctx->prot =0 ; + *prot =0 ; ret =-2 ;break ; }/* fall through */ case 0x1 : - check_perms: +check_perms:/* Check from TLB entry */ - ctx->prot = tlb->prot; - ret =check_prot (ctx->prot, access_type); + *prot = tlb->prot; + ret =check_prot (*prot, access_type);if (ret ==-2 ) { env->spr[SPR_40x_ESR] =0 ; }break ; } -if (ret >=0 ) { - ctx->raddr = raddr; -qemu_log_mask (CPU_LOG_MMU ,"%s: access granted " TARGET_FMT_lx -" => " HWADDR_FMT_plx -" %d %d\n" , __func__, address, ctx->raddr, ctx->prot, - ret); -return 0 ; - } } -qemu_log_mask (CPU_LOG_MMU ,"%s: access refused " TARGET_FMT_lx -" => " HWADDR_FMT_plx" %d %d\n" , - __func__, address, raddr, ctx->prot, ret); +qemu_log_mask (CPU_LOG_MMU ,"%s: access %s " TARGET_FMT_lx" => " + HWADDR_FMT_plx" %d %d\n" , __func__, + ret <0 ?"refused" :"granted" , address, + ret <0 ?0 : *raddr, *prot, ret);return ret; }
@@ -1171,7 +1163,8 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx,case POWERPC_MMU_SOFT_6xx:return mmu6xx_get_physical_address (env, ctx, eaddr, access_type, type);case POWERPC_MMU_SOFT_4xx: -return mmu40x_get_physical_address (env, ctx, eaddr, access_type); +return mmu40x_get_physical_address (env, &ctx->raddr, &ctx->prot, eaddr, + access_type);case POWERPC_MMU_REAL :cpu_abort (env_cpu (env),"PowerPC in real mode do not do any translation\n" );
Signature · 1 line
2.43.0
[PULL 49/72] target/ppc/mmu_common.c: Split out BookE cases before checking real mode
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
BookE does not have real mode so split off and handle it first in get_physical_address_wtlb() before checking for real mode for other MMU models.
--- target/ppc/mmu_common.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
target/ppc/mmu_common.c +7 -7
@@ -1175,6 +1175,13 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx,int ret =-1 ;bool real_mode; +if (env->mmu_model ==POWERPC_MMU_BOOKE ) { +return mmubooke_get_physical_address (env, ctx, eaddr, access_type); + }else if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) { +return mmubooke206_get_physical_address (env, ctx, eaddr, access_type, + mmu_idx); + } + real_mode = (type ==ACCESS_CODE ) ? !FIELD_EX64 (env->msr,MSR ,IR ) : !FIELD_EX64 (env->msr,MSR ,DR );
@@ -1195,13 +1202,6 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, ret =mmu40x_get_physical_address (env, ctx, eaddr, access_type); }break ; -case POWERPC_MMU_BOOKE : - ret =mmubooke_get_physical_address (env, ctx, eaddr, access_type); -break ; -case POWERPC_MMU_BOOKE206 : - ret =mmubooke206_get_physical_address (env, ctx, eaddr, access_type, - mmu_idx); -break ;case POWERPC_MMU_REAL :if (real_mode) { ret =check_physical (env, ctx, eaddr, access_type);
Signature · 1 line
2.43.0
[PULL 58/72] target/ppc/mmu_common.c: Remove BookE from direct store handling
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
As BookE never returns -4 we can drop BookE from the direct store case in ppc_jumbo_xlate().
--- target/ppc/mmu_common.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
target/ppc/mmu_common.c +1 -6
@@ -1298,12 +1298,7 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr,/* Direct store exception */ /* No code fetch is allowed in direct-store areas */ cs->exception_index =POWERPC_EXCP_ISI ; -if ((env->mmu_model ==POWERPC_MMU_BOOKE ) || - (env->mmu_model ==POWERPC_MMU_BOOKE206 )) { - env->error_code =0 ; - }else { - env->error_code =0x10000000 ; - } + env->error_code =0x10000000 ;break ; } }else {
Signature · 1 line
2.43.0
[PULL 54/72] target/ppc/mmu_common.c: Replace hard coded constants in ppc_jumbo_xlate()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
The "2" in booke206_update_mas_tlb_miss() call corresponds to MMU_INST_FETCH which is the value of access_type in this branch; mmubooke206_esr() only checks for MMU_DATA_STORE and it's called from code access so using MMU_DATA_LOAD here seems wrong so replace it with access_type here as well that yields the same result. This also makes these calls the same as the data access branch further down.
--- target/ppc/mmu_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/mmu_common.c +2 -2
@@ -1287,13 +1287,13 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, env->spr[SPR_40x_ESR] =0x00000000 ;break ;case POWERPC_MMU_BOOKE206 : -booke206_update_mas_tlb_miss (env, eaddr,2 , mmu_idx); +booke206_update_mas_tlb_miss (env, eaddr, access_type, mmu_idx);/* fall through */ case POWERPC_MMU_BOOKE : cs->exception_index =POWERPC_EXCP_ITLB ; env->error_code =0 ; env->spr[SPR_BOOKE_DEAR ] = eaddr; - env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx,MMU_DATA_LOAD ); + env->spr[SPR_BOOKE_ESR ] =mmubooke206_esr (mmu_idx, access_type);break ;case POWERPC_MMU_REAL : cpu_abort(cs, "PowerPC in real mode should never raise "
Signature · 1 line
2.43.0
[PULL 31/72] target/ppc: BookE DECAR SPR is 32-bit
In reply to Nicholas PigginThe DECAR SPR is 32-bits width.
--- target/ppc/cpu_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/cpu_init.c +1 -1
@@ -792,7 +792,7 @@ static void register_BookE_sprs(CPUPPCState *env, uint64_t ivor_mask) 0x00000000);spr_register (env,SPR_BOOKE_DECAR ,"DECAR" ,SPR_NOACCESS ,SPR_NOACCESS , -SPR_NOACCESS , &spr_write_generic, +SPR_NOACCESS , &spr_write_generic32,0x00000000 );/* SPRGs */ spr_register(env, SPR_USPRG0, "USPRG0",
Signature · 1 line
2.43.0
[PULL 69/72] target/ppc/mmu-radix64.c: Drop a local variable
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
The value is only used once so no need to introduce a local variable for it.
--- target/ppc/mmu-radix64.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
target/ppc/mmu-radix64.c +2 -3
@@ -185,7 +185,6 @@ static bool ppc_radix64_check_prot(PowerPCCPU *cpu, MMUAccessType access_type, int mmu_idx, bool partition_scoped) {CPUPPCState *env = &cpu->env; -int need_prot;/* Check Page Attributes (pte58:59) */ if ((pte &R_PTE_ATT ) ==R_PTE_ATT_NI_IO && access_type ==MMU_INST_FETCH ) {
@@ -210,8 +209,8 @@ static bool ppc_radix64_check_prot(PowerPCCPU *cpu, MMUAccessType access_type, }/* Check if requested access type is allowed */ - need_prot =prot_for_access_type (access_type); -if (need_prot & ~*prot) {/* Page Protected for that Access */ +if (prot_for_access_type (access_type) & ~*prot) { +/* Page Protected for that Access */ *fault_cause |= access_type ==MMU_INST_FETCH ?SRR1_NOEXEC_GUARD :DSISR_PROTFAULT ;return true;
Signature · 1 line
2.43.0
[PULL 70/72] target/ppc: Add a function to check for page protection bit
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Checking if a page protection bit is set for a given access type is a common operation. Add a function to avoid repeating the same check at multiple places. As this relies on access type and page protection bit values having certain relation also add an assert to ensure that this assumption holds.
--- target/ppc/cpu_init.c | 5 +++++ target/ppc/internal.h | 23 +++++------------------ target/ppc/mmu-hash32.c | 6 +++--- target/ppc/mmu-hash64.c | 2 +- target/ppc/mmu-radix64.c | 2 +- target/ppc/mmu_common.c | 26 +++++++++++++------------- 6 files changed, 28 insertions(+), 36 deletions(-)
target/ppc/cpu_init.c +5 -0
@@ -7521,6 +7521,11 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->sysemu_ops = &ppc_sysemu_ops;INTERRUPT_STATS_PROVIDER_CLASS (oc)->get_statistics = ppc_get_irq_stats; + +/* check_prot_access_type relies on MMU access and PAGE bits relations */ +qemu_build_assert (MMU_DATA_LOAD ==0 &&MMU_DATA_STORE ==1 && +MMU_INST_FETCH ==2 &&PAGE_READ ==1 && +PAGE_WRITE ==2 &&PAGE_EXEC ==4 );#endif cc->gdb_num_core_regs =71 ;
target/ppc/internal.h +5 -18
@@ -234,27 +234,14 @@ void destroy_ppc_opcodes(PowerPCCPU *cpu);void ppc_gdb_init (CPUState *cs,PowerPCCPUClass *ppc);const gchar *ppc_gdb_arch_name (CPUState *cs); -/** -* prot_for_access_type: -* @access_type: Access type -* -* Return the protection bit required for the given access type. -*/ -static inline int prot_for_access_type (MMUAccessType access_type) +#ifndef CONFIG_USER_ONLY + +/* Check if permission bit required for the access_type is set in prot */ +static inline int check_prot_access_type (int prot,MMUAccessType access_type) { -switch (access_type) { -case MMU_INST_FETCH : -return PAGE_EXEC ; -case MMU_DATA_LOAD : -return PAGE_READ ; -case MMU_DATA_STORE : -return PAGE_WRITE ; - } -g_assert_not_reached (); +return prot & (1 << access_type); } -#ifndef CONFIG_USER_ONLY -/* PowerPC MMU emulation */ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,
target/ppc/mmu-hash32.c +3 -3
@@ -252,7 +252,7 @@ static bool ppc_hash32_direct_store(PowerPCCPU *cpu, target_ulong sr, } *prot = key ?PAGE_READ |PAGE_WRITE :PAGE_READ ; -if (*prot &prot_for_access_type (access_type)) { +if (check_prot_access_type (*prot, access_type)) { *raddr = eaddr;return true; }
@@ -403,7 +403,7 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,if (env->nb_BATs !=0 ) { raddr =ppc_hash32_bat_lookup (cpu, eaddr, access_type, protp, mmu_idx);if (raddr !=-1 ) { -if (prot_for_access_type (access_type) & ~*protp) { +if (!check_prot_access_type (*protp, access_type)) {if (guest_visible) {if (access_type ==MMU_INST_FETCH ) { cs->exception_index =POWERPC_EXCP_ISI ;
@@ -471,7 +471,7 @@ bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, prot =ppc_hash32_pte_prot (mmu_idx, sr, pte); -if (prot_for_access_type (access_type) & ~prot) { +if (!check_prot_access_type (prot, access_type)) {/* Access right violation */ qemu_log_mask (CPU_LOG_MMU ,"PTE access rejected\n" );if (guest_visible) {
target/ppc/mmu-hash64.c +1 -1
@@ -1089,7 +1089,7 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, amr_prot =ppc_hash64_amr_prot (cpu, pte); prot = exec_prot & pp_prot & amr_prot; - need_prot =prot_for_access_type (access_type); + need_prot =check_prot_access_type (PAGE_RWX , access_type);if (need_prot & ~prot) {/* Access right violation */ qemu_log_mask (CPU_LOG_MMU ,"PTE access rejected\n" );
target/ppc/mmu-radix64.c +1 -1
@@ -209,7 +209,7 @@ static bool ppc_radix64_check_prot(PowerPCCPU *cpu, MMUAccessType access_type, }/* Check if requested access type is allowed */ -if (prot_for_access_type (access_type) & ~*prot) { +if (!check_prot_access_type (*prot, access_type)) {/* Page Protected for that Access */ *fault_cause |= access_type ==MMU_INST_FETCH ?SRR1_NOEXEC_GUARD :DSISR_PROTFAULT ;
target/ppc/mmu_common.c +13 -13
@@ -114,11 +114,6 @@ static int pp_check(int key, int pp, int nx)return access; } -static int check_prot (int prot,MMUAccessType access_type) -{ -return prot &prot_for_access_type (access_type) ?0 :-2 ; -} -int ppc6xx_tlb_getnum (CPUPPCState *env,target_ulong eaddr,int way,int is_code) {
@@ -165,13 +160,14 @@ static int ppc6xx_tlb_pte_check(mmu_ctx_t *ctx, target_ulong pte0,/* Keep the matching PTE information */ ctx->raddr = pte1; ctx->prot = access; - ret =check_prot (ctx->prot, access_type); -if (ret ==0 ) { +if (check_prot_access_type (ctx->prot, access_type)) {/* Access granted */ qemu_log_mask (CPU_LOG_MMU ,"PTE access granted !\n" ); + ret =0 ; }else {/* Access right violation */ qemu_log_mask (CPU_LOG_MMU ,"PTE access rejected\n" ); + ret =-2 ; } } }
@@ -354,12 +350,14 @@ static int get_bat_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx, (virtual &0x0001F000 );/* Compute access rights */ ctx->prot = prot; - ret =check_prot (ctx->prot, access_type); -if (ret ==0 ) { +if (check_prot_access_type (ctx->prot, access_type)) {qemu_log_mask (CPU_LOG_MMU ,"BAT %d match: r " HWADDR_FMT_plx" prot=%c%c\n" , i, ctx->raddr, ctx->prot &PAGE_READ ?'R' :'-' , ctx->prot &PAGE_WRITE ?'W' :'-' ); + ret =0 ; + }else { + ret =-2 ; }break ; }
@@ -576,9 +574,11 @@ static int mmu40x_get_physical_address(CPUPPCState *env, hwaddr *raddr, check_perms:/* Check from TLB entry */ *prot = tlb->prot; - ret =check_prot (*prot, access_type); -if (ret ==-2 ) { +if (check_prot_access_type (*prot, access_type)) { + ret =0 ; + }else { env->spr[SPR_40x_ESR] =0 ; + ret =-2 ; }break ; }
@@ -636,7 +636,7 @@ static int mmubooke_check_tlb(CPUPPCState *env, ppcemb_tlb_t *tlb, }else { *prot = (tlb->prot >>4 ) &0xF ; } -if (*prot &prot_for_access_type (access_type)) { +if (check_prot_access_type (*prot, access_type)) {qemu_log_mask (CPU_LOG_MMU ,"%s: good TLB!\n" , __func__);return 0 ; }
@@ -838,7 +838,7 @@ found_tlb: *prot |=PAGE_EXEC ; } } -if (*prot &prot_for_access_type (access_type)) { +if (check_prot_access_type (*prot, access_type)) {qemu_log_mask (CPU_LOG_MMU ,"%s: good TLB!\n" , __func__);return 0 ; }
Signature · 1 line
2.43.0
[PULL 25/72] Adds migration support for Branch History Rolling Buffer (BHRB) internal state.
In reply to Nicholas PigginFrom: Glenn Miles <[email protected]>
--- target/ppc/machine.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
target/ppc/machine.c +21 -0
@@ -711,6 +711,26 @@ static const VMStateDescription vmstate_reservation = { } }; +#ifdef TARGET_PPC64 +static bool bhrb_needed (void *opaque) +{ +PowerPCCPU *cpu = opaque; +return (cpu->env.flags &POWERPC_FLAG_BHRB ) !=0 ; +} + +static const VMStateDescription vmstate_bhrb = { + .name ="cpu/bhrb" , + .version_id =1 , + .minimum_version_id =1 , + .needed = bhrb_needed, + .fields = (VMStateField []) { +VMSTATE_UINTTL (env.bhrb_offset, PowerPCCPU), +VMSTATE_UINT64_ARRAY (env.bhrb, PowerPCCPU,BHRB_MAX_NUM_ENTRIES ), +VMSTATE_END_OF_LIST () + } +}; +#endif +const VMStateDescription vmstate_ppc_cpu = { .name ="cpu" , .version_id =5 ,
@@ -756,6 +776,7 @@ const VMStateDescription vmstate_ppc_cpu = {#ifdef TARGET_PPC64 &vmstate_tm, &vmstate_slb, + &vmstate_bhrb, #endif /* TARGET_PPC64 */ &vmstate_tlb6xx, &vmstate_tlbemb,
Signature · 1 line
2.43.0
Re: [PULL 25/72] Adds migration support for Branch History Rolling Buffer (BHRB) internal state.
Quoted 41 lines · Nicholas Piggin
From: Glenn Miles <[email protected]>
Reviewed-by Nicholas Piggin <[email protected]>Signed-off-by Glenn Miles <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>--- target/ppc/machine.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)target/ppc/machine.c +20
-0@@ -711,6 +711,26 @@ static const VMStateDescription vmstate_reservation = { } }; +#ifdef TARGET_PPC64 +static bool bhrb_needed (void *opaque) +{ +PowerPCCPU *cpu = opaque; +return (cpu->env.flags &POWERPC_FLAG_BHRB ) !=0 ; +} + +static const VMStateDescription vmstate_bhrb = { + .name ="cpu/bhrb" , + .version_id =1 , + .minimum_version_id =1 , + .needed = bhrb_needed, + .fields = (VMStateField []) { +VMSTATE_UINTTL (env.bhrb_offset, PowerPCCPU), +VMSTATE_UINT64_ARRAY (env.bhrb, PowerPCCPU,BHRB_MAX_NUM_ENTRIES ), +VMSTATE_END_OF_LIST () + } +}; +#endif +const VMStateDescription vmstate_ppc_cpu = { .name ="cpu" , .version_id =5 ,
target/ppc/machine.c const VMStateDescription vmstate_ppc_cpu = { · line 779
Quoted 4 lines
target/ppc/machine.c +1
-0@@ -756,6 +776,7 @@ const VMStateDescription vmstate_ppc_cpu = {#ifdef TARGET_PPC64 &vmstate_tm, &vmstate_slb, + &vmstate_bhrb,
Running some tests now that Nick re-enabled ppc for migration tests, I see that this new state breaks backward migrations:
$ QTEST_TRACE="vmstate_*" \ QTEST_QEMU_BINARY_DST=../build-previous/qemu-system-ppc64 \ QTEST_QEMU_BINARY=./qemu-system-ppc64 \ ./tests/qtest/migration-test -p /ppc64/migration/precopy/tcp/plain ... vmstate_load_state_field cpu/slb:env.slb vmstate_n_elems env.slb: 64 vmstate_subsection_load cpu/slb vmstate_subsection_load_bad cpu/slb: cpu/bhrb/(prefix) vmstate_load_state_end cpu/slb end/0 vmstate_subsection_load_bad cpu: cpu/bhrb/(lookup) qemu-system-ppc64: error while loading state for instance 0x0 of device 'cpu' vmstate_downtime_checkpoint dst-precopy-loadvm-completed qemu-system-ppc64: load of migration failed: No such file or directory
If you want to support backwards migration, then this needs to be fixed. Otherwise we can ignore it.
Re: [PULL 25/72] Adds migration support for Branch History Rolling Buffer (BHRB) internal state.
Quoted 66 lines · Fabiano Rosas
Quoted 41 lines · Nicholas Piggin
From: Glenn Miles <[email protected]>
Reviewed-by Nicholas Piggin <[email protected]>Signed-off-by Glenn Miles <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>--- target/ppc/machine.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)target/ppc/machine.c +20
-0@@ -711,6 +711,26 @@ static const VMStateDescription vmstate_reservation = { } }; +#ifdef TARGET_PPC64 +static bool bhrb_needed (void *opaque) +{ +PowerPCCPU *cpu = opaque; +return (cpu->env.flags &POWERPC_FLAG_BHRB ) !=0 ; +} + +static const VMStateDescription vmstate_bhrb = { + .name ="cpu/bhrb" , + .version_id =1 , + .minimum_version_id =1 , + .needed = bhrb_needed, + .fields = (VMStateField []) { +VMSTATE_UINTTL (env.bhrb_offset, PowerPCCPU), +VMSTATE_UINT64_ARRAY (env.bhrb, PowerPCCPU,BHRB_MAX_NUM_ENTRIES ), +VMSTATE_END_OF_LIST () + } +}; +#endif +const VMStateDescription vmstate_ppc_cpu = { .name ="cpu" , .version_id =5 ,target/ppc/machine.c const VMStateDescription vmstate_ppc_cpu = { · line 779
Quoted 4 lines
target/ppc/machine.c +1
-0@@ -756,6 +776,7 @@ const VMStateDescription vmstate_ppc_cpu = {#ifdef TARGET_PPC64 &vmstate_tm, &vmstate_slb, + &vmstate_bhrb,Running some tests now that Nick re-enabled ppc for migration tests, I see that this new state breaks backward migrations:
$ QTEST_TRACE="vmstate_*" \ QTEST_QEMU_BINARY_DST=../build-previous/qemu-system-ppc64 \ QTEST_QEMU_BINARY=./qemu-system-ppc64 \ ./tests/qtest/migration-test -p /ppc64/migration/precopy/tcp/plain ... vmstate_load_state_field cpu/slb:env.slb vmstate_n_elems env.slb: 64 vmstate_subsection_load cpu/slb vmstate_subsection_load_bad cpu/slb: cpu/bhrb/(prefix) vmstate_load_state_end cpu/slb end/0 vmstate_subsection_load_bad cpu: cpu/bhrb/(lookup) qemu-system-ppc64: error while loading state for instance 0x0 of device 'cpu' vmstate_downtime_checkpoint dst-precopy-loadvm-completed qemu-system-ppc64: load of migration failed: No such file or directory
Quoted 2 lines
If you want to support backwards migration, then this needs to be fixed. Otherwise we can ignore it.
Hey Fabiano,
Thanks for picking that up, I missed it.
I think we could just say it's not needed, or only needed in case we are doing replay. I will work on a fix.
Thanks,
Nick
[PULL 26/72] target/ppc: larx/stcx generation need only apply DEF_MEMOP() once
In reply to Nicholas PigginUse DEF_MEMOP() consistently in larx and stcx. generation, and apply it once when it's used rather than where the macros are expanded, to reduce typing.
--- target/ppc/translate.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
target/ppc/translate.c +9 -9
@@ -2849,7 +2849,7 @@ static void gen_load_locked(DisasContext *ctx, MemOp memop)gen_set_access_type (ctx,ACCESS_RES );gen_addr_reg_index (ctx, t0); -tcg_gen_qemu_ld_tl (gpr, t0, ctx->mem_idx, memop |MO_ALIGN ); +tcg_gen_qemu_ld_tl (gpr, t0, ctx->mem_idx,DEF_MEMOP (memop) |MO_ALIGN );tcg_gen_mov_tl (cpu_reserve, t0);tcg_gen_movi_tl (cpu_reserve_length,memop_size (memop));tcg_gen_mov_tl (cpu_reserve_val, gpr);
@@ -2862,9 +2862,9 @@ static void gen_##name(DisasContext *ctx) \ }/* lwarx */ -LARX(lbarx, DEF_MEMOP(MO_UB)) -LARX(lharx, DEF_MEMOP(MO_UW)) -LARX(lwarx, DEF_MEMOP(MO_UL)) +LARX(lbarx, MO_UB) +LARX(lharx, MO_UW) +LARX(lwarx, MO_UL)static void gen_fetch_inc_conditional (DisasContext *ctx,MemOp memop,TCGv EA ,TCGCond cond,int addend)
@@ -3109,15 +3109,15 @@ static void gen_##name(DisasContext *ctx) \gen_conditional_store (ctx, memop); \ } -STCX(stbcx_, DEF_MEMOP(MO_UB)) -STCX(sthcx_, DEF_MEMOP(MO_UW)) -STCX(stwcx_, DEF_MEMOP(MO_UL)) +STCX(stbcx_, MO_UB) +STCX(sthcx_, MO_UW) +STCX(stwcx_, MO_UL)#if defined(TARGET_PPC64 )/* ldarx */ -LARX (ldarx,DEF_MEMOP (MO_UQ )) +LARX (ldarx,MO_UQ ) /* stdcx. */ -STCX (stdcx_,DEF_MEMOP (MO_UQ )) +STCX (stdcx_,MO_UQ ) /* lqarx */static void gen_lqarx (DisasContext *ctx)
Signature · 1 line
2.43.0
[PULL 04/72] tcg/cputlb: Remove non-synced variants of global TLB flushes
In reply to Nicholas PigginThese are no longer used.
tlb_flush_all_cpus: removed by previous commit.
tlb_flush_page_all_cpus: removed by previous commit.
tlb_flush_page_bits_by_mmuidx_all_cpus: never used. tlb_flush_page_by_mmuidx_all_cpus: never used. tlb_flush_page_bits_by_mmuidx_all_cpus: never used, thus:
tlb_flush_range_by_mmuidx_all_cpus: never used. tlb_flush_by_mmuidx_all_cpus: never used.
--- accel/tcg/cputlb.c | 103 -------------------------------- docs/devel/multi-thread-tcg.rst | 13 ++-- include/exec/exec-all.h | 97 +++++------------------------- 3 files changed, 19 insertions(+), 194 deletions(-)
accel/tcg/cputlb.c +0 -103
@@ -431,21 +431,6 @@ void tlb_flush(CPUState *cpu)tlb_flush_by_mmuidx (cpu,ALL_MMUIDX_BITS ); } -void tlb_flush_by_mmuidx_all_cpus (CPUState *src_cpu,uint16_t idxmap) -{ -const run_on_cpu_func fn = tlb_flush_by_mmuidx_async_work; - -tlb_debug ("mmu_idx: 0x%" PRIx16"\n" , idxmap); - -flush_all_helper (src_cpu, fn,RUN_ON_CPU_HOST_INT (idxmap)); -fn (src_cpu,RUN_ON_CPU_HOST_INT (idxmap)); -} - -void tlb_flush_all_cpus (CPUState *src_cpu) -{ -tlb_flush_by_mmuidx_all_cpus (src_cpu,ALL_MMUIDX_BITS ); -} -void tlb_flush_by_mmuidx_all_cpus_synced (CPUState *src_cpu,uint16_t idxmap) {const run_on_cpu_func fn = tlb_flush_by_mmuidx_async_work;
@@ -656,46 +641,6 @@ void tlb_flush_page(CPUState *cpu, vaddr addr)tlb_flush_page_by_mmuidx (cpu, addr,ALL_MMUIDX_BITS ); } -void tlb_flush_page_by_mmuidx_all_cpus (CPUState *src_cpu,vaddr addr, -uint16_t idxmap) -{ -tlb_debug ("addr: %016" VADDR_PRIx" mmu_idx:%" PRIx16"\n" , addr, idxmap); - -/* This should already be page aligned */ - addr &=TARGET_PAGE_MASK ; - -/* -* Allocate memory to hold addr+idxmap only when needed. -* See tlb_flush_page_by_mmuidx for details. -*/ -if (idxmap <TARGET_PAGE_SIZE ) { -flush_all_helper (src_cpu, tlb_flush_page_by_mmuidx_async_1, -RUN_ON_CPU_TARGET_PTR (addr | idxmap)); - }else { -CPUState *dst_cpu; - -/* Allocate a separate data block for each destination cpu. */ -CPU_FOREACH (dst_cpu) { -if (dst_cpu != src_cpu) { -TLBFlushPageByMMUIdxData *d - =g_new (TLBFlushPageByMMUIdxData,1 ); - - d->addr = addr; - d->idxmap = idxmap; -async_run_on_cpu (dst_cpu, tlb_flush_page_by_mmuidx_async_2, -RUN_ON_CPU_HOST_PTR (d)); - } - } - } - -tlb_flush_page_by_mmuidx_async_0 (src_cpu, addr, idxmap); -} - -void tlb_flush_page_all_cpus (CPUState *src,vaddr addr) -{ -tlb_flush_page_by_mmuidx_all_cpus (src, addr,ALL_MMUIDX_BITS ); -} -void tlb_flush_page_by_mmuidx_all_cpus_synced (CPUState *src_cpu,vaddr addr,uint16_t idxmap)
@@ -887,54 +832,6 @@ void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr,tlb_flush_range_by_mmuidx (cpu, addr,TARGET_PAGE_SIZE , idxmap, bits); } -void tlb_flush_range_by_mmuidx_all_cpus (CPUState *src_cpu, -vaddr addr,vaddr len, -uint16_t idxmap,unsigned bits) -{ -TLBFlushRangeData d; -CPUState *dst_cpu; - -/* -* If all bits are significant, and len is small, -* this devolves to tlb_flush_page. -*/ -if (bits >=TARGET_LONG_BITS && len <=TARGET_PAGE_SIZE ) { -tlb_flush_page_by_mmuidx_all_cpus (src_cpu, addr, idxmap); -return ; - } -/* If no page bits are significant, this devolves to tlb_flush. */ -if (bits <TARGET_PAGE_BITS ) { -tlb_flush_by_mmuidx_all_cpus (src_cpu, idxmap); -return ; - } - -/* This should already be page aligned */ - d.addr = addr &TARGET_PAGE_MASK ; - d.len = len; - d.idxmap = idxmap; - d.bits = bits; - -/* Allocate a separate data block for each destination cpu. */ -CPU_FOREACH (dst_cpu) { -if (dst_cpu != src_cpu) { -TLBFlushRangeData *p =g_memdup (&d,sizeof (d)); -async_run_on_cpu (dst_cpu, - tlb_flush_range_by_mmuidx_async_1, -RUN_ON_CPU_HOST_PTR (p)); - } - } - -tlb_flush_range_by_mmuidx_async_0 (src_cpu, d); -} - -void tlb_flush_page_bits_by_mmuidx_all_cpus (CPUState *src_cpu, -vaddr addr,uint16_t idxmap, -unsigned bits) -{ -tlb_flush_range_by_mmuidx_all_cpus (src_cpu, addr,TARGET_PAGE_SIZE , - idxmap, bits); -} - void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *src_cpu, vaddr addr, vaddr len,
docs/devel/multi-thread-tcg.rst +4 -9
@@ -205,15 +205,10 @@ DESIGN REQUIREMENTS: (Current solution) -We have updated cputlb.c to defer operations when a cross-vCPU -operation with async_run_on_cpu() which ensures each vCPU sees a -coherent state when it next runs its work (in a few instructions -time). - -A new set up operations (tlb_flush_*_all_cpus) take an additional flag -which when set will force synchronisation by setting the source vCPUs -work as "safe work" and exiting the cpu run loop. This ensure by the -time execution restarts all flush operations have completed. +A new set of tlb flush operations (tlb_flush_*_all_cpus_synced) force +synchronisation by setting the source vCPUs work as "safe work" and +exiting the cpu run loop. This ensures that by the time execution +restarts all flush operations have completed. TLB flag updates are all done atomically and are also protected by the corresponding page lock.
include/exec/exec-all.h +15 -82
189 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 42/72] target/ppc/mmu_common.c: Remove unneeded local variable
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
In mmubooke_check_tlb() and mmubooke206_check_tlb() we can assign the value of prot2 directly to the destination, no need to have a separate local variable for it.
--- target/ppc/mmu_common.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
target/ppc/mmu_common.c +13 -17
@@ -628,8 +628,6 @@ static int mmubooke_check_tlb(CPUPPCState *env, ppcemb_tlb_t *tlb, hwaddr *raddr, int *prot, target_ulong address, MMUAccessType access_type, int i) { -int prot2; -if (!mmubooke_check_pid (env, tlb, raddr, address, i)) {qemu_log_mask (CPU_LOG_MMU ,"%s: TLB entry not found\n" , __func__);return -1 ;
@@ -644,17 +642,16 @@ static int mmubooke_check_tlb(CPUPPCState *env, ppcemb_tlb_t *tlb, }if (FIELD_EX64 (env->msr,MSR ,PR )) { - prot2 = tlb->prot &0xF ; + *prot = tlb->prot &0xF ; }else { - prot2 = (tlb->prot >>4 ) &0xF ; + *prot = (tlb->prot >>4 ) &0xF ; } - *prot = prot2; -if (prot2 &prot_for_access_type (access_type)) { +if (*prot &prot_for_access_type (access_type)) {qemu_log_mask (CPU_LOG_MMU ,"%s: good TLB!\n" , __func__);return 0 ; } -qemu_log_mask (CPU_LOG_MMU ,"%s: no prot match: %x\n" , __func__, prot2); +qemu_log_mask (CPU_LOG_MMU ,"%s: no prot match: %x\n" , __func__, *prot);return access_type ==MMU_INST_FETCH ?-3 :-2 ; }
@@ -795,7 +792,6 @@ static int mmubooke206_check_tlb(CPUPPCState *env, ppcmas_tlb_t *tlb,target_ulong address, MMUAccessType access_type, int mmu_idx) { - int prot2 = 0; uint32_t epid;bool as, pr;bool use_epid =mmubooke206_get_as (env, mmu_idx, &epid, &as, &pr);
@@ -841,34 +837,34 @@ found_tlb:return -1 ; } + *prot =0 ;if (pr) {if (tlb->mas7_3 &MAS3_UR ) { - prot2 |=PAGE_READ ; + *prot |=PAGE_READ ; }if (tlb->mas7_3 &MAS3_UW ) { - prot2 |=PAGE_WRITE ; + *prot |=PAGE_WRITE ; }if (tlb->mas7_3 &MAS3_UX ) { - prot2 |=PAGE_EXEC ; + *prot |=PAGE_EXEC ; } }else {if (tlb->mas7_3 &MAS3_SR ) { - prot2 |=PAGE_READ ; + *prot |=PAGE_READ ; }if (tlb->mas7_3 &MAS3_SW ) { - prot2 |=PAGE_WRITE ; + *prot |=PAGE_WRITE ; }if (tlb->mas7_3 &MAS3_SX ) { - prot2 |=PAGE_EXEC ; + *prot |=PAGE_EXEC ; } } - *prot = prot2; -if (prot2 &prot_for_access_type (access_type)) { +if (*prot &prot_for_access_type (access_type)) {qemu_log_mask (CPU_LOG_MMU ,"%s: good TLB!\n" , __func__);return 0 ; } -qemu_log_mask (CPU_LOG_MMU ,"%s: no prot match: %x\n" , __func__, prot2); +qemu_log_mask (CPU_LOG_MMU ,"%s: no prot match: %x\n" , __func__, *prot);return access_type ==MMU_INST_FETCH ?-3 :-2 ; }
Signature · 1 line
2.43.0
[PULL 72/72] target/ppc: Remove pp_check() and reuse ppc_hash32_pp_prot()
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
The ppc_hash32_pp_prot() function in mmu-hash32.c is the same as pp_check() in mmu_common.c, merge these to remove duplicated code. Define the common function as static lnline otherwise exporting the function from mmu-hash32.c would stop the compiler inlining it which results in slightly lower performance.
--- target/ppc/mmu-hash32.c | 45 ----------------------------------------- target/ppc/mmu-hash32.h | 45 +++++++++++++++++++++++++++++++++++++++++ target/ppc/mmu_common.c | 44 ++-------------------------------------- 3 files changed, 47 insertions(+), 87 deletions(-)
target/ppc/mmu-hash32.c +0 -45
@@ -37,51 +37,6 @@# define LOG_BATS (...) do { } while (0)#endif -static int ppc_hash32_pp_prot (int key,int pp,int nx) -{ -int prot; - -if (key ==0 ) { -switch (pp) { -case 0x0 : -case 0x1 : -case 0x2 : - prot =PAGE_READ |PAGE_WRITE ; -break ; - -case 0x3 : - prot =PAGE_READ ; -break ; - -default : -abort (); - } - }else { -switch (pp) { -case 0x0 : - prot =0 ; -break ; - -case 0x1 : -case 0x3 : - prot =PAGE_READ ; -break ; - -case 0x2 : - prot =PAGE_READ |PAGE_WRITE ; -break ; - -default : -abort (); - } - } -if (nx ==0 ) { - prot |=PAGE_EXEC ; - } - -return prot; -} -static int ppc_hash32_pte_prot (int mmu_idx,target_ulong sr,ppc_hash_pte32_t pte) {
target/ppc/mmu-hash32.h +45 -0
51 lines not on this page · raw message
target/ppc/mmu_common.c +2 -42
64 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 27/72] target/ppc: Remove redundant MEMOP_GET_SIZE macro
In reply to Nicholas PigginThere is a memop_size() function for this.
--- target/ppc/translate.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
target/ppc/translate.c +3 -5
@@ -2840,8 +2840,6 @@ static void gen_isync(DisasContext *ctx) ctx->base.is_jmp =DISAS_EXIT_UPDATE ; } -#define MEMOP_GET_SIZE (x) (1 << ((x) & MO_SIZE)) -static void gen_load_locked (DisasContext *ctx,MemOp memop) {TCGv gpr = cpu_gpr[rD (ctx->opcode)];
@@ -2874,7 +2872,7 @@ static void gen_fetch_inc_conditional(DisasContext *ctx, MemOp memop,TCGv u =tcg_temp_new ();tcg_gen_qemu_ld_tl (t,EA , ctx->mem_idx, memop); -tcg_gen_addi_tl (t2,EA ,MEMOP_GET_SIZE (memop)); +tcg_gen_addi_tl (t2,EA ,memop_size (memop));tcg_gen_qemu_ld_tl (t2, t2, ctx->mem_idx, memop);tcg_gen_addi_tl (u, t, addend);
@@ -2884,7 +2882,7 @@ static void gen_fetch_inc_conditional(DisasContext *ctx, MemOp memop,tcg_gen_qemu_st_tl (u,EA , ctx->mem_idx, memop);/* RT = (t != t2 ? t : u = 1<<(s*8-1)) */ -tcg_gen_movi_tl (u,1 << (MEMOP_GET_SIZE (memop) *8 -1 )); +tcg_gen_movi_tl (u,1 << (memop_size (memop) *8 -1 ));tcg_gen_movcond_tl (cond, cpu_gpr[rD (ctx->opcode)], t, t2, t, u); }
@@ -3046,7 +3044,7 @@ static void gen_st_atomic(DisasContext *ctx, MemOp memop)TCGv ea_plus_s =tcg_temp_new ();tcg_gen_qemu_ld_tl (t,EA , ctx->mem_idx, memop); -tcg_gen_addi_tl (ea_plus_s,EA ,MEMOP_GET_SIZE (memop)); +tcg_gen_addi_tl (ea_plus_s,EA ,memop_size (memop));tcg_gen_qemu_ld_tl (t2, ea_plus_s, ctx->mem_idx, memop);tcg_gen_movcond_tl (TCG_COND_EQ , s, t, t2, src, t);tcg_gen_movcond_tl (TCG_COND_EQ , s2, t, t2, src, t2);
Signature · 1 line
2.43.0
[PULL 43/72] target/ppc/mmu_common.c: Simplify checking for real mode
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
In get_physical_address_wtlb() the real_mode flag depends on either the MSR[IR] or MSR[DR] bit depending on access_type. Extract just the needed bit in a more straight forward way instead of doing unnecessary computation.
--- target/ppc/mmu_common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target/ppc/mmu_common.c +4 -2
@@ -1184,8 +1184,10 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, int mmu_idx) {int ret =-1 ; -bool real_mode = (type ==ACCESS_CODE && !FIELD_EX64 (env->msr,MSR ,IR )) || - (type !=ACCESS_CODE && !FIELD_EX64 (env->msr,MSR ,DR )); +bool real_mode; + + real_mode = (type ==ACCESS_CODE ) ? !FIELD_EX64 (env->msr,MSR ,IR ) + : !FIELD_EX64 (env->msr,MSR ,DR );switch (env->mmu_model) {case POWERPC_MMU_SOFT_6xx:
Signature · 1 line
2.43.0
[PULL 07/72] target/ppc: Fix embedded memory barriers
In reply to Nicholas PigginMemory barriers are supposed to do something on BookE systems, these were probably just missed during MTTCG enablement, maybe no targets support SMP. Either way, add proper BookE implementations.
--- target/ppc/translate/misc-impl.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/translate/misc-impl.c.inc +2 -2
@@ -34,8 +34,7 @@ static bool trans_SYNC(DisasContext *ctx, arg_X_sync *a) */ if (!(ctx->insns_flags & PPC_MEM_SYNC)) { if (ctx->insns_flags & PPC_BOOKE) { - /* msync replaces sync on 440, interpreted as nop */ - /* XXX: this also catches e200 */ + tcg_gen_mb(bar | TCG_BAR_SC); return true; }
@@ -75,6 +74,7 @@ static bool trans_EIEIO(DisasContext *ctx, arg_EIEIO *a) if (!(ctx->insns_flags & PPC_MEM_EIEIO)) { if ((ctx->insns_flags & PPC_BOOKE) || (ctx->insns_flags2 & PPC2_BOOKE206)) { + tcg_gen_mb(bar | TCG_BAR_SC); return true; } return false;
Signature · 1 line
2.43.0
[PULL 17/72] target/ppc: Move cmp{rb, eqb}, tw[i], td[i], isel instructions to decodetree.
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
Moving the following instructions to decodetree specification :
cmp{rb, eqb}, t{w, d} : X-form
t{w, d}i : D-form
isel : A-formThe changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured using the '-d in_asm,op' flag. Also for CMPRB, following review comments :
Replaced repetition of arithmetic right shifting (tcg_gen_shri_i32) followed by extraction of last 8 bits (tcg_gen_ext8u_i32) with extraction of the required bits using offsets (tcg_gen_extract_i32).
--- target/ppc/excp_helper.c | 4 +- target/ppc/helper.h | 6 +- target/ppc/insn32.decode | 16 +++ target/ppc/int_helper.c | 2 +- target/ppc/translate.c | 133 +-------------------- target/ppc/translate/fixedpoint-impl.c.inc | 132 ++++++++++++++++++++ 6 files changed, 157 insertions(+), 136 deletions(-)
target/ppc/excp_helper.c +2 -2
@@ -2742,7 +2742,7 @@ void helper_rfmci(CPUPPCState *env) }#endif /* !CONFIG_USER_ONLY */ -void helper_tw(CPUPPCState *env, target_ulong arg1, target_ulong arg2, +void helper_TW(CPUPPCState *env, target_ulong arg1, target_ulong arg2, uint32_t flags) { if (!likely(!(((int32_t)arg1 < (int32_t)arg2 && (flags & 0x10)) ||
@@ -2756,7 +2756,7 @@ void helper_tw(CPUPPCState *env, target_ulong arg1, target_ulong arg2, } #ifdef TARGET_PPC64 -void helper_td(CPUPPCState *env, target_ulong arg1, target_ulong arg2, +void helper_TD(CPUPPCState *env, target_ulong arg1, target_ulong arg2, uint32_t flags) { if (!likely(!(((int64_t)arg1 < (int64_t)arg2 && (flags & 0x10)) ||
target/ppc/helper.h +3 -3
@@ -1,8 +1,8 @@ DEF_HELPER_FLAGS_3(raise_exception_err, TCG_CALL_NO_WG, noreturn, env, i32, i32) DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32) -DEF_HELPER_FLAGS_4(tw, TCG_CALL_NO_WG, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(TW, TCG_CALL_NO_WG, void, env, tl, tl, i32)#if defined(TARGET_PPC64 ) -DEF_HELPER_FLAGS_4(td, TCG_CALL_NO_WG, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(TD, TCG_CALL_NO_WG, void, env, tl, tl, i32)#endif DEF_HELPER_4(HASHST, void, env, tl, tl, tl)DEF_HELPER_4 (HASHCHK , void, env, tl, tl, tl)
@@ -67,7 +67,7 @@ DEF_HELPER_FLAGS_2(PEXTD, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_1(CDTBCD, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(CBCDTD, TCG_CALL_NO_RWG_SE, tl, tl)#if defined(TARGET_PPC64 ) -DEF_HELPER_FLAGS_2(cmpeqb, TCG_CALL_NO_RWG_SE, i32, tl, tl) +DEF_HELPER_FLAGS_2(CMPEQB, TCG_CALL_NO_RWG_SE, i32, tl, tl) DEF_HELPER_FLAGS_1(popcntw, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_2(bpermd, TCG_CALL_NO_RWG_SE, i64, i64, i64)DEF_HELPER_3 (srad, tl, env, tl, tl)
target/ppc/insn32.decode +16 -0
@@ -29,6 +29,9 @@ &A_tb frt frb rc:bool @A_tb ...... frt:5 ..... frb:5 ..... ..... rc:1 &A_tb +&A_tab_bc rt ra rb bc +@A_tab_bc ...... rt:5 ra:5 rb:5 bc:5 ..... . &A_tab_bc + &D rt ra si:int64_t @D ...... rt:5 ra:5 si:s16 &D
@@ -340,6 +343,19 @@ CMP 011111 ... - . ..... ..... 0000000000 - @X_bfl CMPL 011111 ... - . ..... ..... 0000100000 - @X_bfl CMPI 001011 ... - . ..... ................ @D_bfs CMPLI 001010 ... - . ..... ................ @D_bfu +CMPRB 011111 ... - . ..... ..... 0011000000 - @X_bfl +CMPEQB 011111 ... -- ..... ..... 0011100000 - @X_bf + +### Fixed-Point Trap Instructions + +TW 011111 ..... ..... ..... 0000000100 - @X +TD 011111 ..... ..... ..... 0001000100 - @X +TWI 000011 ..... ..... ................ @D +TDI 000010 ..... ..... ................ @D + +### Fixed-Point Select Instruction + +ISEL 011111 ..... ..... ..... ..... 01111 - @A_tab_bc ### Fixed-Point Arithmetic Instructions
target/ppc/int_helper.c +1 -1
@@ -159,7 +159,7 @@ uint64_t helper_DIVDE(CPUPPCState *env, uint64_t rau, uint64_t rbu, uint32_t oe)/* When you XOR the pattern and there is a match, that byte will be zero */ #define hasvalue (x, n) (haszero((x) ^ pattern(n))) -uint32_t helper_cmpeqb (target_ulong ra,target_ulong rb) +uint32_t helper_CMPEQB (target_ulong ra,target_ulong rb) {return hasvalue (rb, ra) ?CRF_GT :0 ; }
target/ppc/translate.c +3 -130
169 lines not on this page · raw message
target/ppc/translate/fixedpoint-impl.c.inc +132 -0
144 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 09/72] target/ppc: Merge various fpu helpers
In reply to Nicholas PigginFrom: Chinmay Rath <[email protected]>
This patch merges the definitions of the following set of fpu helper methods, which are similar, using macros :
1. f{add, sub, mul, div}(s)
2. fre(s)
3. frsqrte(s)
--- target/ppc/fpu_helper.c | 221 +++++++++++----------------------------- 1 file changed, 62 insertions(+), 159 deletions(-)
target/ppc/fpu_helper.c +62 -159
@@ -490,54 +490,12 @@ static void float_invalid_op_addsub(CPUPPCState *env, int flags, } } -/* fadd - fadd. */ -float64 helper_fadd (CPUPPCState *env,float64 arg1,float64 arg2) +static inline void addsub_flags_handler (CPUPPCState *env,int flags, +uintptr_t ra) { -float64 ret =float64_add (arg1, arg2, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); - -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_addsub (env, flags,1 ,GETPC ()); - } - -return ret; -} - -/* fadds - fadds. */ -float64 helper_fadds (CPUPPCState *env,float64 arg1,float64 arg2) -{ -float64 ret =float64r32_add (arg1, arg2, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); - -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_addsub (env, flags,1 ,GETPC ()); - } -return ret; -} - -/* fsub - fsub. */ -float64 helper_fsub (CPUPPCState *env,float64 arg1,float64 arg2) -{ -float64 ret =float64_sub (arg1, arg2, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_addsub (env, flags,1 ,GETPC ()); +float_invalid_op_addsub (env, flags,1 , ra); } - -return ret; -} - -/* fsubs - fsubs. */ -float64 helper_fsubs (CPUPPCState *env,float64 arg1,float64 arg2) -{ -float64 ret =float64r32_sub (arg1, arg2, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); - -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_addsub (env, flags,1 ,GETPC ()); - } -return ret; } static void float_invalid_op_mul(CPUPPCState *env, int flags,
@@ -550,29 +508,11 @@ static void float_invalid_op_mul(CPUPPCState *env, int flags, } } -/* fmul - fmul. */ -float64 helper_fmul (CPUPPCState *env,float64 arg1,float64 arg2) -{ -float64 ret =float64_mul (arg1, arg2, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); - -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_mul (env, flags,1 ,GETPC ()); - } - -return ret; -} - -/* fmuls - fmuls. */ -float64 helper_fmuls (CPUPPCState *env,float64 arg1,float64 arg2) +static inline void mul_flags_handler (CPUPPCState *env,int flags,uintptr_t ra) { -float64 ret =float64r32_mul (arg1, arg2, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_mul (env, flags,1 ,GETPC ()); +float_invalid_op_mul (env, flags,1 , ra); } -return ret; } static void float_invalid_op_div(CPUPPCState *env, int flags,
@@ -587,36 +527,14 @@ static void float_invalid_op_div(CPUPPCState *env, int flags, } } -/* fdiv - fdiv. */ -float64 helper_fdiv (CPUPPCState *env,float64 arg1,float64 arg2) -{ -float64 ret =float64_div (arg1, arg2, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); - -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_div (env, flags,1 ,GETPC ()); - } -if (unlikely (flags & float_flag_divbyzero)) { -float_zero_divide_excp (env,GETPC ()); - } - -return ret; -} - -/* fdivs - fdivs. */ -float64 helper_fdivs (CPUPPCState *env,float64 arg1,float64 arg2) +static inline void div_flags_handler (CPUPPCState *env,int flags,uintptr_t ra) { -float64 ret =float64r32_div (arg1, arg2, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_div (env, flags,1 ,GETPC ()); +float_invalid_op_div (env, flags,1 , ra); }if (unlikely (flags & float_flag_divbyzero)) { -float_zero_divide_excp (env,GETPC ()); +float_zero_divide_excp (env, ra); } - -return ret; } static uint64_t float_invalid_cvt(CPUPPCState *env, int flags,
@@ -812,81 +730,66 @@ float64 helper_##name(CPUPPCState *env, float64 arg) \ FPU_FSQRT(FSQRT, float64_sqrt) FPU_FSQRT(FSQRTS, float64r32_sqrt) -/* fre - fre. */ -float64 helper_fre (CPUPPCState *env,float64 arg) -{ -/* "Estimate" the reciprocal with actual division. */ -float64 ret =float64_div (float64_one, arg, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); - -if (unlikely (flags & float_flag_invalid_snan)) { -float_invalid_op_vxsnan (env,GETPC ()); - } -if (unlikely (flags & float_flag_divbyzero)) { -float_zero_divide_excp (env,GETPC ()); -/* For FPSCR.ZE == 0, the result is 1/2. */ - ret =float64_set_sign (float64_half,float64_is_neg (arg)); - } - -return ret; +#define FPU_FRE (name, op) \ +float64 helper_##name(CPUPPCState *env, float64 arg) \ +{ \ +/* "Estimate" the reciprocal with actual division. */ \ +float64 ret =op (float64_one, arg, &env->fp_status); \ +int flags =get_float_exception_flags (&env->fp_status); \ + \ +if (unlikely (flags & float_flag_invalid_snan)) { \ +float_invalid_op_vxsnan (env,GETPC ()); \ + } \ +if (unlikely (flags & float_flag_divbyzero)) { \ +float_zero_divide_excp (env,GETPC ()); \ +/* For FPSCR.ZE == 0, the result is 1/2. */ \ + ret =float64_set_sign (float64_half,float64_is_neg (arg)); \ + } \ + \ +return ret; \ } -/* fres - fres. */ -uint64_t helper_fres (CPUPPCState *env,uint64_t arg) -{ -/* "Estimate" the reciprocal with actual division. */ -float64 ret =float64r32_div (float64_one, arg, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); - -if (unlikely (flags & float_flag_invalid_snan)) { -float_invalid_op_vxsnan (env,GETPC ()); - } -if (unlikely (flags & float_flag_divbyzero)) { -float_zero_divide_excp (env,GETPC ()); -/* For FPSCR.ZE == 0, the result is 1/2. */ - ret =float64_set_sign (float64_half,float64_is_neg (arg)); - } - -return ret; +#define FPU_FRSQRTE (name, op) \ +float64 helper_##name(CPUPPCState *env, float64 arg) \ +{ \ +/* "Estimate" the reciprocal with actual division. */ \ +float64 rets =float64_sqrt (arg, &env->fp_status); \ +float64 retd =op (float64_one, rets, &env->fp_status); \ +int flags =get_float_exception_flags (&env->fp_status); \ + \ +if (unlikely (flags & float_flag_invalid)) { \ +float_invalid_op_sqrt (env, flags,1 ,GETPC ()); \ + } \ +if (unlikely (flags & float_flag_divbyzero)) { \ +/* Reciprocal of (square root of) zero. */ \ +float_zero_divide_excp (env,GETPC ()); \ + } \ + \ +return retd; \ } -/* frsqrte - frsqrte. */ -float64 helper_frsqrte (CPUPPCState *env,float64 arg) -{ -/* "Estimate" the reciprocal with actual division. */ -float64 rets =float64_sqrt (arg, &env->fp_status); -float64 retd =float64_div (float64_one, rets, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); - -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_sqrt (env, flags,1 ,GETPC ()); - } -if (unlikely (flags & float_flag_divbyzero)) { -/* Reciprocal of (square root of) zero. */ -float_zero_divide_excp (env,GETPC ()); - } - -return retd; +#define FPU_HELPER (name, op, flags_handler) \ +float64 helper_##name(CPUPPCState *env, float64 arg1, float64 arg2) \ +{ \ + float64 ret = op(arg1, arg2, &env->fp_status); \ + int flags = get_float_exception_flags(&env->fp_status); \ + uintptr_t ra = GETPC(); \ + flags_handler(env, flags, ra); \ + return ret; \ } -/* frsqrtes - frsqrtes. */ -float64 helper_frsqrtes (CPUPPCState *env,float64 arg) -{ -/* "Estimate" the reciprocal with actual division. */ -float64 rets =float64_sqrt (arg, &env->fp_status); -float64 retd =float64r32_div (float64_one, rets, &env->fp_status); -int flags =get_float_exception_flags (&env->fp_status); - -if (unlikely (flags & float_flag_invalid)) { -float_invalid_op_sqrt (env, flags,1 ,GETPC ()); - } -if (unlikely (flags & float_flag_divbyzero)) { -/* Reciprocal of (square root of) zero. */ -float_zero_divide_excp (env,GETPC ()); - } - -return retd; -} +FPU_FRE(fre, float64_div) +FPU_FRE(fres, float64r32_div) +FPU_FRSQRTE(frsqrte, float64_div) +FPU_FRSQRTE(frsqrtes, float64r32_div) +FPU_HELPER(fadd, float64_add, addsub_flags_handler) +FPU_HELPER(fadds, float64r32_add, addsub_flags_handler) +FPU_HELPER(fsub, float64_sub, addsub_flags_handler) +FPU_HELPER(fsubs, float64r32_sub, addsub_flags_handler) +FPU_HELPER(fmul, float64_mul, mul_flags_handler) +FPU_HELPER(fmuls, float64r32_mul, mul_flags_handler) +FPU_HELPER(fdiv, float64_div, div_flags_handler) +FPU_HELPER (fdivs, float64r32_div, div_flags_handler) /* fsel - fsel. */uint64_t helper_FSEL (uint64_t a,uint64_t b,uint64_t c)
Signature · 1 line
2.43.0
[PULL 22/72] This commit is preparatory to the addition of Branch History Rolling Buffer (BHRB) functionality, which is being provided today starting with the P8 processor.
In reply to Nicholas PigginFrom: Glenn Miles <[email protected]>
BHRB uses several SPR register fields to control whether or not a branch instruction's address (and sometimes target address) should be recorded. Checking each of these fields with each branch instruction using jitted code would lead to a significant decrease in performance.
Therefore, it was decided that BHRB configuration bits that are not expected to change frequently should have their state summarized in an hflag so that the amount of checking done by jitted code can be reduced.
This commit contains the changes for summarizing the state of the following register fields in the HFLAGS_BHRB_ENABLE hflag:
MMCR0[FCP] - Determines if BHRB recording is frozen in the
problem state
MMCR0[FCPC] - A modifier for MMCR0[FCP]
MMCRA[BHRBRD] - Disables all BHRB recording for a thread
--- target/ppc/cpu.h | 5 +++++ target/ppc/cpu_init.c | 4 ++-- target/ppc/helper.h | 1 + target/ppc/helper_regs.c | 37 ++++++++++++++++++++++++++++++++ target/ppc/machine.c | 2 +- target/ppc/power8-pmu-regs.c.inc | 5 +++++ target/ppc/power8-pmu.c | 15 +++++++++---- target/ppc/power8-pmu.h | 4 ++-- target/ppc/spr_common.h | 1 + target/ppc/translate.c | 2 ++ 10 files changed, 67 insertions(+), 9 deletions(-)
target/ppc/cpu.h +5 -0
@@ -533,6 +533,8 @@ FIELD(MSR, LE, MSR_LE, 1)#define MMCR0_FC56 PPC_BIT(59)/* PMC Freeze Counters 5-6 bit */ #define MMCR0_PMC1CE PPC_BIT(48)/* MMCR0 PMC1 Condition Enabled */ #define MMCR0_PMCjCE PPC_BIT(49)/* MMCR0 PMCj Condition Enabled */ +#define MMCR0_FCP PPC_BIT(34)/* Freeze Counters/BHRB if PR=1 */ +#define MMCR0_FCPC PPC_BIT(51)/* Condition for FCP bit */ /* MMCR0 userspace r/w mask */ #define MMCR0_UREG_MASK (MMCR0_FC | MMCR0_PMAO | MMCR0_PMAE)/* MMCR2 userspace r/w mask */
@@ -545,6 +547,8 @@ FIELD(MSR, LE, MSR_LE, 1)#define MMCR2_UREG_MASK (MMCR2_FC1P0 | MMCR2_FC2P0 | MMCR2_FC3P0 | \ MMCR2_FC4P0 | MMCR2_FC5P0 | MMCR2_FC6P0) +#define MMCRA_BHRBRD PPC_BIT(26)/* BHRB Recording Disable */ +#define MMCR1_EVT_SIZE 8/* extract64() does a right shift before extracting */ #define MMCR1_PMC1SEL_START 32
@@ -797,6 +801,7 @@ enum {HFLAGS_PMCJCE =17 ,/* MMCR0 PMCjCE bit */ HFLAGS_PMC_OTHER =18 ,/* PMC other than PMC5-6 is enabled */ HFLAGS_INSN_CNT =19 ,/* PMU instruction count enabled */ +HFLAGS_BHRB_ENABLE =20 ,/* Summary flag for enabling BHRB */ HFLAGS_VSX =23 ,/* MSR_VSX if cpu has VSX */ HFLAGS_VR = 25, /* MSR_VR if cpu has VRE */
target/ppc/cpu_init.c +2 -2
@@ -5152,7 +5152,7 @@ static void register_book3s_pmu_sup_sprs(CPUPPCState *env) KVM_REG_PPC_MMCR1, 0x00000000);spr_register_kvm (env,SPR_POWER_MMCRA ,"MMCRA" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_MMCRA,KVM_REG_PPC_MMCRA ,0x00000000 ); spr_register_kvm(env, SPR_POWER_PMC1, "PMC1", SPR_NOACCESS, SPR_NOACCESS,
@@ -7196,7 +7196,7 @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type)if (env->mmu_model !=POWERPC_MMU_REAL ) {ppc_tlb_invalidate_all (env); } -pmu_mmcr01_updated (env); +pmu_mmcr01a_updated (env); }/* clean any pending stop state */
target/ppc/helper.h +1 -0
@@ -30,6 +30,7 @@ DEF_HELPER_2(store_dawr0, void, env, tl) DEF_HELPER_2(store_dawrx0, void, env, tl) DEF_HELPER_2(store_mmcr0, void, env, tl) DEF_HELPER_2(store_mmcr1, void, env, tl) +DEF_HELPER_2(store_mmcrA, void, env, tl) DEF_HELPER_3(store_pmc, void, env, i32, i64) DEF_HELPER_2(read_pmc, tl, env, i32)DEF_HELPER_2 (insns_inc, void, env, i32)
target/ppc/helper_regs.c +37 -0
@@ -47,6 +47,39 @@ void hreg_swap_gpr_tgpr(CPUPPCState *env) env->tgpr[3 ] = tmp; } +#if defined(TARGET_PPC64 ) +static bool hreg_check_bhrb_enable (CPUPPCState *env) +{ +bool pr = !!(env->msr & (1 <<MSR_PR )); +target_long mmcr0; +bool fcp; +bool hv; + +/* ISA 3.1 adds the PMCRA[BRHBRD] and problem state checks */ +if ((env->insns_flags2 &PPC2_ISA310 ) && + ((env->spr[SPR_POWER_MMCRA ] &MMCRA_BHRBRD ) || !pr)) { +return false; + } + +/* Check for BHRB "frozen" conditions */ + mmcr0 = env->spr[SPR_POWER_MMCR0 ]; + fcp = !!(mmcr0 &MMCR0_FCP ); +if (mmcr0 &MMCR0_FCPC ) { + hv = !!(env->msr & (1ull <<MSR_HV )); +if (fcp) { +if (hv && pr) { +return false; + } + }else if (!hv && pr) { +return false; + } + }else if (fcp && pr) { +return false; + } +return true; +} +#endif +static uint32_t hreg_compute_pmu_hflags_value (CPUPPCState *env) {uint32_t hflags =0 ;
@@ -61,6 +94,9 @@ static uint32_t hreg_compute_pmu_hflags_value(CPUPPCState *env)if (env->spr[SPR_POWER_MMCR0 ] & MMCR0_PMCjCE) { hflags |=1 <<HFLAGS_PMCJCE ; } +if (hreg_check_bhrb_enable (env)) { + hflags |=1 <<HFLAGS_BHRB_ENABLE ; + }#ifndef CONFIG_USER_ONLY if (env->pmc_ins_cnt) {
@@ -85,6 +121,7 @@ static uint32_t hreg_compute_pmu_hflags_mask(CPUPPCState *env) hflags_mask |=1 <<HFLAGS_PMCJCE ; hflags_mask |=1 <<HFLAGS_INSN_CNT ; hflags_mask |=1 <<HFLAGS_PMC_OTHER ; + hflags_mask |=1 <<HFLAGS_BHRB_ENABLE ;#endif return hflags_mask; }
target/ppc/machine.c +1 -1
@@ -333,7 +333,7 @@ static int cpu_post_load(void *opaque, int version_id)* triggered types (including HDEC) would need to carry more state. */ cpu_ppc_store_decr (env, env->spr[SPR_DECR ]); -pmu_mmcr01_updated (env); +pmu_mmcr01a_updated (env); }return 0 ;
target/ppc/power8-pmu-regs.c.inc +5 -0
@@ -175,6 +175,11 @@ void spr_write_MMCR2_ureg(DisasContext *ctx, int sprn, int gprn) gen_store_spr(SPR_POWER_MMCR2, masked_gprn); } +void spr_write_MMCRA(DisasContext *ctx, int sprn, int gprn) +{ + gen_helper_store_mmcrA(tcg_env, cpu_gpr[gprn]); +} + void spr_read_PMC(DisasContext *ctx, int gprn, int sprn) { TCGv_i32 t_sprn = tcg_constant_i32(sprn);
target/ppc/power8-pmu.c +11 -4
@@ -82,7 +82,7 @@ static void pmu_update_summaries(CPUPPCState *env) env->pmc_cyc_cnt = cyc_cnt; } -void pmu_mmcr01_updated (CPUPPCState *env) +void pmu_mmcr01a_updated (CPUPPCState *env) {PowerPCCPU *cpu =env_archcpu (env);
@@ -260,7 +260,7 @@ void helper_store_mmcr0(CPUPPCState *env, target_ulong value) env->spr[SPR_POWER_MMCR0 ] = value; -pmu_mmcr01_updated (env); +pmu_mmcr01a_updated (env);/* Update cycle overflow timers with the current MMCR0 state */ pmu_update_overflow_timers (env);
@@ -272,7 +272,14 @@ void helper_store_mmcr1(CPUPPCState *env, uint64_t value) env->spr[SPR_POWER_MMCR1 ] = value; -pmu_mmcr01_updated (env); +pmu_mmcr01a_updated (env); +} + +void helper_store_mmcrA (CPUPPCState *env,uint64_t value) +{ + env->spr[SPR_POWER_MMCRA ] = value; + +pmu_mmcr01a_updated (env); }target_ulong helper_read_pmc (CPUPPCState *env,uint32_t sprn)
@@ -301,7 +308,7 @@ static void perfm_alert(PowerPCCPU *cpu) env->spr[SPR_POWER_MMCR0 ] |=MMCR0_FC ;/* Changing MMCR0_FC requires summaries and hflags update */ -pmu_mmcr01_updated (env); +pmu_mmcr01a_updated (env);/* * Delete all pending timers if we need to freeze
target/ppc/power8-pmu.h +2 -2
@@ -18,10 +18,10 @@#define PMC_COUNTER_NEGATIVE_VAL 0x80000000ULvoid cpu_ppc_pmu_init (CPUPPCState *env); -void pmu_mmcr01_updated (CPUPPCState *env); +void pmu_mmcr01a_updated (CPUPPCState *env);#else static inline void cpu_ppc_pmu_init (CPUPPCState *env) { } -static inline void pmu_mmcr01_updated (CPUPPCState *env) { } +static inline void pmu_mmcr01a_updated (CPUPPCState *env) { }#endif #endif
target/ppc/spr_common.h +1 -0
@@ -85,6 +85,7 @@ void spr_write_generic32(DisasContext *ctx, int sprn, int gprn);void spr_core_write_generic (DisasContext *ctx,int sprn,int gprn);void spr_write_MMCR0 (DisasContext *ctx,int sprn,int gprn);void spr_write_MMCR1 (DisasContext *ctx,int sprn,int gprn); +void spr_write_MMCRA (DisasContext *ctx,int sprn,int gprn);void spr_write_PMC (DisasContext *ctx,int sprn,int gprn);void spr_write_CTRL (DisasContext *ctx,int sprn,int gprn);void spr_read_xer (DisasContext *ctx,int gprn,int sprn);
target/ppc/translate.c +2 -0
@@ -193,6 +193,7 @@ struct DisasContext {bool mmcr0_pmcjce;bool pmc_other;bool pmu_insn_cnt; +bool bhrb_enable;ppc_spr_t *spr_cb;/* Needed to check rights for mfspr/mtspr */ int singlestep_enabled;uint32_t flags;
@@ -6345,6 +6346,7 @@ static void ppc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->mmcr0_pmcjce = (hflags >>HFLAGS_PMCJCE ) &1 ; ctx->pmc_other = (hflags >>HFLAGS_PMC_OTHER ) &1 ; ctx->pmu_insn_cnt = (hflags >>HFLAGS_INSN_CNT ) &1 ; + ctx->bhrb_enable = (hflags >>HFLAGS_BHRB_ENABLE ) &1 ; ctx->singlestep_enabled =0 ;if ((hflags >>HFLAGS_SE ) &1 ) {
Signature · 1 line
2.43.0
[PULL 28/72] target/ppc: Make checkstop actually stop the system
In reply to Nicholas Piggincheckstop state does not halt the system, interrupts continue to be serviced, and other CPUs run. Make it stop the machine with qemu_system_guest_panicked.
--- target/ppc/excp_helper.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
target/ppc/excp_helper.c +13 -3
@@ -19,6 +19,8 @@#include "qemu/osdep.h" #include "qemu/main-loop.h" #include "qemu/log.h" +#include "sysemu/sysemu.h" +#include "sysemu/runstate.h" #include "cpu.h" #include "exec/exec-all.h" #include "internal.h"
@@ -425,6 +427,8 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu, target_ulong vector,static void powerpc_mcheck_checkstop (CPUPPCState *env) { +/* KVM guests always have MSR[ME] enabled */ +#ifdef CONFIG_TCG CPUState *cs =env_cpu (env);if (FIELD_EX64 (env->msr,MSR ,ME )) {
@@ -437,9 +441,15 @@ static void powerpc_mcheck_checkstop(CPUPPCState *env)if (qemu_log_separate ()) {qemu_log ("Machine check while not allowed. " "Entering checkstop state\n" ); - } - cs->halted =1 ; -cpu_interrupt_exittb (cs); + +/* +* This stops the machine and logs CPU state without killing QEMU +* (like cpu_abort()) so the machine can still be debugged (because +* it is often a guest error). +*/ +qemu_system_guest_panicked (NULL ); +cpu_loop_exit_noexc (cs); +#endif }static void powerpc_excp_40x (PowerPCCPU *cpu,int excp)
Signature · 1 line
2.43.0
[PULL 37/72] target/ppc: Implement SPRC/SPRD SPRs
In reply to Nicholas PigginThis implements the POWER SPRC/SPRD SPRs, and SCRATCH0-7 registers that can be accessed via these indirect SPRs.
SCRATCH registers only provide storage, but they are used by firmware for low level crash and progress data, so this implementation logs writes to the registers to help with analysis.
--- target/ppc/cpu.h | 7 +++-- target/ppc/cpu_init.c | 10 ++++++ target/ppc/helper.h | 3 ++ target/ppc/misc_helper.c | 66 ++++++++++++++++++++++++++++++++++++++++ target/ppc/spr_common.h | 3 ++ target/ppc/translate.c | 18 +++++++++++ 6 files changed, 105 insertions(+), 2 deletions(-)
target/ppc/cpu.h +5 -2
@@ -1264,6 +1264,9 @@ struct CPUArchState {ppc_slb_t slb[MAX_SLB_ENTRIES ];/* PowerPC 64 SLB area */ struct CPUBreakpoint *ciabr_breakpoint;struct CPUWatchpoint *dawr0_watchpoint; + +/* POWER CPU regs/state */ +target_ulong scratch[8 ];/* SCRATCH registers (shared across core) */ #endif target_ulong sr[32 ];/* segment registers */ uint32_t nb_BATs;/* number of BATs */
@@ -1806,9 +1809,9 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_SPRG2 (0x112)#define SPR_SPRG3 (0x113)#define SPR_SPRG4 (0x114) -#define SPR_SCOMC (0x114) +#define SPR_POWER_SPRC (0x114)#define SPR_SPRG5 (0x115) -#define SPR_SCOMD (0x115) +#define SPR_POWER_SPRD (0x115)#define SPR_SPRG6 (0x116)#define SPR_SPRG7 (0x117)#define SPR_ASR (0x118)
target/ppc/cpu_init.c +10 -0
@@ -5777,6 +5777,16 @@ static void register_power_common_book4_sprs(CPUPPCState *env)SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_core_write_generic, 0x00000000); +spr_register_hv (env,SPR_POWER_SPRC ,"SPRC" , +SPR_NOACCESS ,SPR_NOACCESS , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_sprc, +0x00000000 ); +spr_register_hv (env,SPR_POWER_SPRD ,"SPRD" , +SPR_NOACCESS ,SPR_NOACCESS , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_sprd, &spr_write_sprd, +0x00000000 );#endif }
target/ppc/helper.h +3 -0
@@ -730,6 +730,9 @@ DEF_HELPER_2(book3s_msgsndp, void, env, tl) DEF_HELPER_2(book3s_msgclrp, void, env, tl) DEF_HELPER_1(load_tfmr, tl, env) DEF_HELPER_2(store_tfmr, void, env, tl) +DEF_HELPER_FLAGS_2(store_sprc, TCG_CALL_NO_RWG, void, env, tl) +DEF_HELPER_FLAGS_1(load_sprd, TCG_CALL_NO_RWG_SE, tl, env) +DEF_HELPER_FLAGS_2(store_sprd, TCG_CALL_NO_RWG, void, env, tl)#endif DEF_HELPER_2(store_sdr1, void, env, tl)DEF_HELPER_2 (store_pidr, void, env, tl)
target/ppc/misc_helper.c +66 -0
72 lines not on this page · raw message
target/ppc/spr_common.h +3 -0
@@ -207,6 +207,9 @@ void spr_write_lpcr(DisasContext *ctx, int sprn, int gprn);void spr_read_dexcr_ureg (DisasContext *ctx,int gprn,int sprn);void spr_read_ppr32 (DisasContext *ctx,int sprn,int gprn);void spr_write_ppr32 (DisasContext *ctx,int sprn,int gprn); +void spr_write_sprc (DisasContext *ctx,int sprn,int gprn); +void spr_read_sprd (DisasContext *ctx,int sprn,int gprn); +void spr_write_sprd (DisasContext *ctx,int sprn,int gprn);#endif void register_low_BATs (CPUPPCState *env);
target/ppc/translate.c +18 -0
@@ -1301,6 +1301,24 @@ void spr_write_tfmr(DisasContext *ctx, int sprn, int gprn)gen_helper_store_tfmr (tcg_env, cpu_gpr[gprn]); } +void spr_write_sprc (DisasContext *ctx,int sprn,int gprn) +{ +gen_helper_store_sprc (tcg_env, cpu_gpr[gprn]); +} + +void spr_read_sprd (DisasContext *ctx,int gprn,int sprn) +{ +gen_helper_load_sprd (cpu_gpr[gprn], tcg_env); +} + +void spr_write_sprd (DisasContext *ctx,int sprn,int gprn) +{ +if (!gen_serialize_core (ctx)) { +return ; + } +gen_helper_store_sprd (tcg_env, cpu_gpr[gprn]); +} +void spr_write_lpcr (DisasContext *ctx,int sprn,int gprn) {translator_io_start (&ctx->base);
Signature · 1 line
2.43.0
[PULL 46/72] target/ppc/mmu_common.c: Move else branch to avoid large if block
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
In mmu6xx_get_physical_address() we have a large if block with a two line else branch that effectively returns. Invert the condition and move the else there to allow deindenting the large if block to make the flow easier to follow.
--- target/ppc/mmu_common.c | 71 ++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 37 deletions(-)
target/ppc/mmu_common.c +34 -37
@@ -405,47 +405,44 @@ static int mmu6xx_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, ret =-1 ;if (!ds) {/* Check if instruction fetch is allowed, if needed */ -if (type !=ACCESS_CODE || ctx->nx ==0 ) { -/* Page address translation */ -qemu_log_mask (CPU_LOG_MMU ,"htab_base " HWADDR_FMT_plx -" htab_mask " HWADDR_FMT_plx -" hash " HWADDR_FMT_plx"\n" , -ppc_hash32_hpt_base (cpu),ppc_hash32_hpt_mask (cpu), hash); - ctx->hash[0 ] = hash; - ctx->hash[1 ] = ~hash; - -/* Initialize real address with an invalid value */ - ctx->raddr = (hwaddr)-1ULL ; -/* Software TLB search */ - ret =ppc6xx_tlb_check (env, ctx, eaddr, access_type); +if (type ==ACCESS_CODE && ctx->nx) { +qemu_log_mask (CPU_LOG_MMU ,"No access allowed\n" ); +return -3 ; + } +/* Page address translation */ +qemu_log_mask (CPU_LOG_MMU ,"htab_base " HWADDR_FMT_plx" htab_mask " + HWADDR_FMT_plx" hash " HWADDR_FMT_plx"\n" , +ppc_hash32_hpt_base (cpu),ppc_hash32_hpt_mask (cpu), hash); + ctx->hash[0 ] = hash; + ctx->hash[1 ] = ~hash; + +/* Initialize real address with an invalid value */ + ctx->raddr = (hwaddr)-1ULL ; +/* Software TLB search */ + ret =ppc6xx_tlb_check (env, ctx, eaddr, access_type);#if defined(DUMP_PAGE_TABLES ) -if (qemu_loglevel_mask (CPU_LOG_MMU )) { -CPUState *cs =env_cpu (env); -hwaddr curaddr; -uint32_t a0, a1, a2, a3; - -qemu_log ("Page table: " HWADDR_FMT_plx" len " HWADDR_FMT_plx -"\n" ,ppc_hash32_hpt_base (cpu), -ppc_hash32_hpt_mask (cpu) +0x80 ); -for (curaddr =ppc_hash32_hpt_base (cpu); - curaddr < (ppc_hash32_hpt_base (cpu) - +ppc_hash32_hpt_mask (cpu) +0x80 ); - curaddr +=16 ) { - a0 =ldl_phys (cs->as, curaddr); - a1 =ldl_phys (cs->as, curaddr +4 ); - a2 =ldl_phys (cs->as, curaddr +8 ); - a3 =ldl_phys (cs->as, curaddr +12 ); -if (a0 !=0 || a1 !=0 || a2 !=0 || a3 !=0 ) { -qemu_log (HWADDR_FMT_plx": %08x %08x %08x %08x\n" , - curaddr, a0, a1, a2, a3); - } +if (qemu_loglevel_mask (CPU_LOG_MMU )) { +CPUState *cs =env_cpu (env); +hwaddr curaddr; +uint32_t a0, a1, a2, a3; + +qemu_log ("Page table: " HWADDR_FMT_plx" len " HWADDR_FMT_plx"\n" , +ppc_hash32_hpt_base (cpu),ppc_hash32_hpt_mask (cpu) +0x80 ); +for (curaddr =ppc_hash32_hpt_base (cpu); + curaddr < (ppc_hash32_hpt_base (cpu) + +ppc_hash32_hpt_mask (cpu) +0x80 ); + curaddr +=16 ) { + a0 =ldl_phys (cs->as, curaddr); + a1 =ldl_phys (cs->as, curaddr +4 ); + a2 =ldl_phys (cs->as, curaddr +8 ); + a3 =ldl_phys (cs->as, curaddr +12 ); +if (a0 !=0 || a1 !=0 || a2 !=0 || a3 !=0 ) { +qemu_log (HWADDR_FMT_plx": %08x %08x %08x %08x\n" , + curaddr, a0, a1, a2, a3); } } -#endif - }else { -qemu_log_mask (CPU_LOG_MMU ,"No access allowed\n" ); - ret =-3 ; } +#endif }else {qemu_log_mask (CPU_LOG_MMU ,"direct store...\n" );/* Direct-store segment : absolutely *BUGGY* for now */
Signature · 1 line
2.43.0
[PULL 52/72] target/ppc/mmu_common.c: Fix misindented qemu_log_mask() calls
In reply to Nicholas PigginFrom: BALATON Zoltan <[email protected]>
Fix several qemu_log_mask() calls that are misindented.
--- target/ppc/mmu_common.c | 42 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
target/ppc/mmu_common.c +20 -22
@@ -315,8 +315,8 @@ static int get_bat_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx,int ret =-1 ;bool ifetch = access_type ==MMU_INST_FETCH ; -qemu_log_mask (CPU_LOG_MMU ,"%s: %cBAT v " TARGET_FMT_lx"\n" , __func__, - ifetch ?'I' :'D' , virtual); +qemu_log_mask (CPU_LOG_MMU ,"%s: %cBAT v " TARGET_FMT_lx"\n" , __func__, + ifetch ?'I' :'D' , virtual);if (ifetch) { BATlt = env->IBAT[1 ]; BATut = env->IBAT[0 ];
@@ -330,9 +330,9 @@ static int get_bat_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx, BEPIu = *BATu &0xF0000000 ; BEPIl = *BATu &0x0FFE0000 ;bat_size_prot (env, &bl, &valid, &prot, BATu, BATl); -qemu_log_mask (CPU_LOG_MMU ,"%s: %cBAT%d v " TARGET_FMT_lx" BATu " - TARGET_FMT_lx" BATl " TARGET_FMT_lx"\n" , __func__, - ifetch ?'I' :'D' , i, virtual, *BATu, *BATl); +qemu_log_mask (CPU_LOG_MMU ,"%s: %cBAT%d v " TARGET_FMT_lx" BATu " + TARGET_FMT_lx" BATl " TARGET_FMT_lx"\n" , __func__, + ifetch ?'I' :'D' , i, virtual, *BATu, *BATl);if ((virtual &0xF0000000 ) == BEPIu && ((virtual &0x0FFE0000 ) & ~bl) == BEPIl) {/* BAT matches */
@@ -364,12 +364,11 @@ static int get_bat_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx, BEPIu = *BATu &0xF0000000 ; BEPIl = *BATu &0x0FFE0000 ; bl = (*BATu &0x00001FFC ) <<15 ; -qemu_log_mask (CPU_LOG_MMU ,"%s: %cBAT%d v " - TARGET_FMT_lx" BATu " TARGET_FMT_lx -" BATl " TARGET_FMT_lx"\n\t" TARGET_FMT_lx" " - TARGET_FMT_lx" " TARGET_FMT_lx"\n" , - __func__, ifetch ?'I' :'D' , i, virtual, - *BATu, *BATl, BEPIu, BEPIl, bl); +qemu_log_mask (CPU_LOG_MMU ,"%s: %cBAT%d v " TARGET_FMT_lx +" BATu " TARGET_FMT_lx" BATl " TARGET_FMT_lx +"\n\t" TARGET_FMT_lx" " TARGET_FMT_lx" " + TARGET_FMT_lx"\n" , __func__, ifetch ?'I' :'D' , + i, virtual, *BATu, *BATl, BEPIu, BEPIl, bl); } } }
@@ -415,9 +414,8 @@ static int mmu6xx_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, hash = vsid ^ pgidx; ctx->ptem = (vsid <<7 ) | (pgidx >>10 ); -qemu_log_mask (CPU_LOG_MMU , -"pte segment: key=%d ds %d nx %d vsid " TARGET_FMT_lx"\n" , - ctx->key, ds, ctx->nx, vsid); +qemu_log_mask (CPU_LOG_MMU ,"pte segment: key=%d ds %d nx %d vsid " + TARGET_FMT_lx"\n" , ctx->key, ds, ctx->nx, vsid);if (!ds) {/* Check if instruction fetch is allowed, if needed */ if (type ==ACCESS_CODE && ctx->nx) {
@@ -583,9 +581,9 @@ static int mmu40x_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx,return 0 ; } } -qemu_log_mask (CPU_LOG_MMU ,"%s: access refused " TARGET_FMT_lx -" => " HWADDR_FMT_plx -" %d %d\n" , __func__, address, raddr, ctx->prot, ret); +qemu_log_mask (CPU_LOG_MMU ,"%s: access refused " TARGET_FMT_lx +" => " HWADDR_FMT_plx" %d %d\n" , + __func__, address, raddr, ctx->prot, ret);return ret; }
@@ -704,11 +702,11 @@ int ppcmas_tlb_check(CPUPPCState *env, ppcmas_tlb_t *tlb, hwaddr *raddrp, } mask = ~(booke206_tlb_to_page_size (env, tlb) -1 ); -qemu_log_mask (CPU_LOG_MMU ,"%s: TLB ADDR=0x" TARGET_FMT_lx -" PID=0x%x MAS1=0x%x MAS2=0x%" PRIx64" mask=0x%" - HWADDR_PRIx" MAS7_3=0x%" PRIx64" MAS8=0x%" PRIx32"\n" , - __func__, address, pid, tlb->mas1, tlb->mas2, mask, - tlb->mas7_3, tlb->mas8); +qemu_log_mask (CPU_LOG_MMU ,"%s: TLB ADDR=0x" TARGET_FMT_lx +" PID=0x%x MAS1=0x%x MAS2=0x%" PRIx64" mask=0x%" + HWADDR_PRIx" MAS7_3=0x%" PRIx64" MAS8=0x%" PRIx32"\n" , + __func__, address, pid, tlb->mas1, tlb->mas2, mask, + tlb->mas7_3, tlb->mas8);/* Check PID */ tlb_pid = (tlb->mas1 &MAS1_TID_MASK ) >>MAS1_TID_SHIFT ;
Signature · 1 line
2.43.0
Quoted 7 lines · Nicholas Piggin
The following changes since commit
70581940cabcc51b329652becddfbc6a261b1b83:Merge tag 'pull-tcg-20240523' of https://gitlab.com/rth7680/qemu into staging (2024-05-23 09:47:40 -0700)
are available in the Git repository at:
https://gitlab.com/npiggin/qemu.git tags/pull-ppc-for-9.1-1-20240524
[snip]
Quoted 5 lines
Glenn Miles (4):
This commit is preparatory to the addition of Branch History Rolling Buffer (BHRB) functionality, which is being provided today starting with the P8 processor.
This commit continues adding support for the Branch History Rolling Buffer (BHRB) as is provided starting with the P8 processor and continuing with its successors. This commit is limited to the recording and filtering of taken branches. Add support for the clrbhrb and mfbhrbe instructions.
Adds migration support for Branch History Rolling Buffer (BHRB) internal state.
The BHRB patch subject lines have gone haywire and I didn't notice before now. Probably my fault. Hold off and I will fix and give a new tag to pull.
Thanks,
Nick