target-sparc improvements
v2 cover target-sparc improvements
The two main goals in this patch set are:
* Make use of the new MO_ALIGN_* flags, to allow less use of check_align, and support partially misaligned fp memory ops.
* More cleanups for ASIs, in the end using the new atomic ops.
The final two patches require the "cmpxchg atomic" v6 patch set. Otherwise this patch set should apply to master. The full tree is at
git://github.com/rth7680/qemu.git tgt-sparc-6
Changes since v1:
* The "Remove asi helper code handled inline" patch retains the code within ldda to handle asis that must be handled out of line.
This fixes the FreeBSD 10.3 boot problem. While the UA2007 spec (and thus sun4v?) doesn't allow for such, it would seem that US2 hardware does.
* Dropped the "Optimize writeback of cpu_cond" patch.
This fixes the debian 7.8 install. Not sure exactly what's wrong with it yet, but let's just drop it for now.
r~
Richard Henderson (15):
target-sparc: Use overalignment flags for twinx and block asis
target-sparc: Introduce cpu_raise_exception_ra
target-sparc: Add MMU_PHYS_IDX
target-sparc: Use MMU_PHYS_IDX for bypass asis
target-sparc: Handle more twinx asis
target-sparc: Implement swap_asi inline
target-sparc: Implement ldstub_asi inline
target-sparc: Implement cas_asi/casx_asi inline
target-sparc: Implement BCOPY/BFILL inline
target-sparc: Remove asi helper code handled inline
target-sparc: Implement ldqf and stqf inline
target-sparc: Allow 4-byte alignment on fp mem ops
target-sparc: Remove MMU_MODE*_SUFFIX
target-sparc: Use tcg_gen_atomic_xchg_tl
target-sparc: Use tcg_gen_atomic_cmpxchg_tl
target-sparc/cpu.h | 34 +- target-sparc/helper.c | 52 ++- target-sparc/helper.h | 7 - target-sparc/ldst_helper.c | 998 ++++++++------------------------------------- target-sparc/mmu_helper.c | 47 ++- target-sparc/translate.c | 434 +++++++++++++------- target-sparc/win_helper.c | 37 +- 7 files changed, 531 insertions(+), 1078 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/15 target-sparc: Use overalignment flags for twinx and block asis
This allows us to enforce 16 and 64-byte alignment without any extra overhead.
Message-Id: <[email protected]>
--- target-sparc/translate.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
target-sparc/translate.c +12 -9
@@ -2385,20 +2385,23 @@ static void gen_ldf_asi(DisasContext *dc, TCGv addr,case GET_ASI_BLOCK :/* Valid for lddfa on aligned registers only. */ if (size ==8 && (rd &7 ) ==0 ) { +TCGMemOp memop;TCGv eight;int i; -gen_check_align (addr,0x3f );gen_address_mask (dc, addr); +/* The first operation checks required alignment. */ + memop = da.memop |MO_ALIGN_64 ; eight =tcg_const_tl (8 );for (i =0 ; ; ++i) {tcg_gen_qemu_ld_i64 (cpu_fpr[rd /2 + i], addr, - da.mem_idx, da.memop); + da.mem_idx, memop);if (i ==7 ) {break ; }tcg_gen_add_tl (addr, addr, eight); + memop = da.memop; }tcg_temp_free (eight); }else {
@@ -2488,20 +2491,23 @@ static void gen_stf_asi(DisasContext *dc, TCGv addr,case GET_ASI_BLOCK :/* Valid for stdfa on aligned registers only. */ if (size ==8 && (rd &7 ) ==0 ) { +TCGMemOp memop;TCGv eight;int i; -gen_check_align (addr,0x3f );gen_address_mask (dc, addr); +/* The first operation checks required alignment. */ + memop = da.memop |MO_ALIGN_64 ; eight =tcg_const_tl (8 );for (i =0 ; ; ++i) {tcg_gen_qemu_st_i64 (cpu_fpr[rd /2 + i], addr, - da.mem_idx, da.memop); + da.mem_idx, memop);if (i ==7 ) {break ; }tcg_gen_add_tl (addr, addr, eight); + memop = da.memop; }tcg_temp_free (eight); }else {
@@ -2539,9 +2545,8 @@ static void gen_ldda_asi(DisasContext *dc, TCGv addr, int insn, int rd)return ;case GET_ASI_DTWINX : -gen_check_align (addr,15 );gen_address_mask (dc, addr); -tcg_gen_qemu_ld_i64 (hi, addr, da.mem_idx, da.memop); +tcg_gen_qemu_ld_i64 (hi, addr, da.mem_idx, da.memop |MO_ALIGN_16 );tcg_gen_addi_tl (addr, addr,8 );tcg_gen_qemu_ld_i64 (lo, addr, da.mem_idx, da.memop);break ;
@@ -2594,9 +2599,8 @@ static void gen_stda_asi(DisasContext *dc, TCGv hi, TCGv addr,break ;case GET_ASI_DTWINX : -gen_check_align (addr,15 );gen_address_mask (dc, addr); -tcg_gen_qemu_st_i64 (hi, addr, da.mem_idx, da.memop); +tcg_gen_qemu_st_i64 (hi, addr, da.mem_idx, da.memop |MO_ALIGN_16 );tcg_gen_addi_tl (addr, addr,8 );tcg_gen_qemu_st_i64 (lo, addr, da.mem_idx, da.memop);break ;
@@ -5468,7 +5472,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)if (gen_trap_ifnofpu (dc)) { goto jmp_insn; } -gen_check_align (cpu_addr,7 );gen_stf_asi (dc, cpu_addr, insn,16 ,QFPREG (rd)); }break ;
Signature · 1 line
2.7.4
PATCH v2 2/15 target-sparc: Introduce cpu_raise_exception_ra
In reply to Richard HendersonSeveral helpers call helper_raise_exception directly, which requires in turn that their callers have performed save_state. The new function allows a TCG return address to be passed in so that we can restore PC + NPC + flags data from that.
This fixes a bug in the usage of helper_check_align, whose callers had not been calling save_state. It fixes another bug in which the divide helpers used GETPC at a level other than the direct callee from TCG.
This allows the translator to avoid save_state prior to SAVE, RESTORE, and FLUSHW instructions.
--- target-sparc/cpu.h | 1 + target-sparc/helper.c | 52 +++++++++++++--------------- target-sparc/ldst_helper.c | 85 +++++++++++++++++++++------------------------- target-sparc/translate.c | 3 -- target-sparc/win_helper.c | 37 ++++++++++---------- 5 files changed, 82 insertions(+), 96 deletions(-)
target-sparc/cpu.h +1 -0
@@ -549,6 +549,7 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); +void cpu_raise_exception_ra(CPUSPARCState *, int, uintptr_t) QEMU_NORETURN;#ifndef NO_CPU_IO_DEFS /* cpu_init.c */
target-sparc/helper.c +23 -29
141 lines not on this page · raw message
target-sparc/ldst_helper.c +39 -46
261 lines not on this page · raw message
target-sparc/translate.c +0 -3
@@ -3458,7 +3458,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)break ; }else if (xop ==0x2b ) {/* rdtbr / V9 flushw */ #ifdef TARGET_SPARC64 -save_state (dc);gen_helper_flushw (cpu_env);#else if (!supervisor (dc))
@@ -5062,12 +5061,10 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)/* nop */ break ;case 0x3c :/* save */ -save_state (dc);gen_helper_save (cpu_env);gen_store_gpr (dc, rd, cpu_tmp0);break ;case 0x3d :/* restore */ -save_state (dc);gen_helper_restore (cpu_env);gen_store_gpr (dc, rd, cpu_tmp0);break ;
target-sparc/win_helper.c +19 -18
@@ -19,6 +19,7 @@#include "qemu/osdep.h" #include "cpu.h" +#include "exec/exec-all.h" #include "exec/helper-proto.h" #include "trace.h"
@@ -111,13 +112,13 @@ void helper_rett(CPUSPARCState *env)unsigned int cwp;if (env->psret ==1 ) { -helper_raise_exception (env,TT_ILL_INSN ); +cpu_raise_exception_ra (env,TT_ILL_INSN ,GETPC ()); } env->psret =1 ; cwp =cpu_cwp_inc (env, env->cwp +1 ) ;if (env->wim & (1 << cwp)) { -helper_raise_exception (env,TT_WIN_UNF ); +cpu_raise_exception_ra (env,TT_WIN_UNF ,GETPC ()); }cpu_set_cwp (env, cwp); env->psrs = env->psrps;
@@ -131,7 +132,7 @@ void helper_save(CPUSPARCState *env) cwp =cpu_cwp_dec (env, env->cwp -1 );if (env->wim & (1 << cwp)) { -helper_raise_exception (env,TT_WIN_OVF ); +cpu_raise_exception_ra (env,TT_WIN_OVF ,GETPC ()); }cpu_set_cwp (env, cwp); }
@@ -142,7 +143,7 @@ void helper_restore(CPUSPARCState *env) cwp =cpu_cwp_inc (env, env->cwp +1 );if (env->wim & (1 << cwp)) { -helper_raise_exception (env,TT_WIN_UNF ); +cpu_raise_exception_ra (env,TT_WIN_UNF ,GETPC ()); }cpu_set_cwp (env, cwp); }
@@ -150,7 +151,7 @@ void helper_restore(CPUSPARCState *env)void helper_wrpsr (CPUSPARCState *env,target_ulong new_psr) {if ((new_psr &PSR_CWP ) >= env->nwindows) { -helper_raise_exception (env,TT_ILL_INSN ); +cpu_raise_exception_ra (env,TT_ILL_INSN ,GETPC ()); }else {cpu_put_psr (env, new_psr); }
@@ -170,14 +171,14 @@ void helper_save(CPUSPARCState *env) cwp =cpu_cwp_dec (env, env->cwp -1 );if (env->cansave ==0 ) { -helper_raise_exception (env,TT_SPILL | (env->otherwin !=0 ? - (TT_WOTHER | - ((env->wstate &0x38 ) >>1 )) : - ((env->wstate &0x7 ) <<2 ))); +int tt =TT_SPILL | (env->otherwin !=0 + ? (TT_WOTHER | ((env->wstate &0x38 ) >>1 )) + : ((env->wstate &0x7 ) <<2 )); +cpu_raise_exception_ra (env, tt,GETPC ()); }else {if (env->cleanwin - env->canrestore ==0 ) {/* XXX Clean windows without trap */ -helper_raise_exception (env,TT_CLRWIN ); +cpu_raise_exception_ra (env,TT_CLRWIN ,GETPC ()); }else { env->cansave--; env->canrestore++;
@@ -192,10 +193,10 @@ void helper_restore(CPUSPARCState *env) cwp =cpu_cwp_inc (env, env->cwp +1 );if (env->canrestore ==0 ) { -helper_raise_exception (env,TT_FILL | (env->otherwin !=0 ? - (TT_WOTHER | - ((env->wstate &0x38 ) >>1 )) : - ((env->wstate &0x7 ) <<2 ))); +int tt =TT_FILL | (env->otherwin !=0 + ? (TT_WOTHER | ((env->wstate &0x38 ) >>1 )) + : ((env->wstate &0x7 ) <<2 )); +cpu_raise_exception_ra (env, tt,GETPC ()); }else { env->cansave++; env->canrestore--;
@@ -206,10 +207,10 @@ void helper_restore(CPUSPARCState *env)void helper_flushw (CPUSPARCState *env) {if (env->cansave != env->nwindows -2 ) { -helper_raise_exception (env,TT_SPILL | (env->otherwin !=0 ? - (TT_WOTHER | - ((env->wstate &0x38 ) >>1 )) : - ((env->wstate &0x7 ) <<2 ))); +int tt =TT_SPILL | (env->otherwin !=0 + ? (TT_WOTHER | ((env->wstate &0x38 ) >>1 )) + : ((env->wstate &0x7 ) <<2 )); +cpu_raise_exception_ra (env, tt,GETPC ()); } }
Signature · 1 line
2.7.4
PATCH v2 3/15 target-sparc: Add MMU_PHYS_IDX
In reply to Richard HendersonIt's handy to have a mmu idx for physical addresses, so that mmu disabled and physical access asis can use the same path as normal accesses.
--- target-sparc/cpu.h | 25 +++++++++++++++++------- target-sparc/ldst_helper.c | 27 ++++++-------------------- target-sparc/mmu_helper.c | 47 ++++++++++++++++++++++++++++------------------ 3 files changed, 53 insertions(+), 46 deletions(-)
target-sparc/cpu.h +18 -7
@@ -225,9 +225,9 @@ enum {#define MAX_NWINDOWS 32 #if !defined(TARGET_SPARC64) -#define NB_MMU_MODES 2 +#define NB_MMU_MODES 3 #else -#define NB_MMU_MODES 6 +#define NB_MMU_MODES 7 typedef struct trap_state { uint64_t tpc; uint64_t tnpc;
@@ -649,11 +649,13 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);#define MMU_MODE4_SUFFIX _nucleus#define MMU_HYPV_IDX 5#define MMU_MODE5_SUFFIX _hypv +#define MMU_PHYS_IDX 6#else #define MMU_USER_IDX 0#define MMU_MODE0_SUFFIX _user#define MMU_KERNEL_IDX 1#define MMU_MODE1_SUFFIX _kernel +#define MMU_PHYS_IDX 2#endif #if defined (TARGET_SPARC64 )
@@ -673,18 +675,27 @@ static inline int cpu_supervisor_mode(CPUSPARCState *env1) } #endif -static inline int cpu_mmu_index (CPUSPARCState *env1,bool ifetch) +static inline int cpu_mmu_index(CPUSPARCState *env, bool ifetch) { #if defined(CONFIG_USER_ONLY) return MMU_USER_IDX; #elif !defined(TARGET_SPARC64) - return env1->psrs; + if ((env->mmuregs[0] & MMU_E) == 0) { /* MMU disabled */ + return MMU_PHYS_IDX; + } else { + return env->psrs; + } #else - if (env1->tl > 0) { + /* IMMU or DMMU disabled. */ + if (ifetch + ? (env->lsu & IMMU_E) == 0 || (env->pstate & PS_RED) != 0 + : (env->lsu & DMMU_E) == 0) { + return MMU_PHYS_IDX; + } else if (env->tl > 0) { return MMU_NUCLEUS_IDX; - } else if (cpu_hypervisor_mode(env1)) { + } else if (cpu_hypervisor_mode(env)) { return MMU_HYPV_IDX; - } else if (cpu_supervisor_mode(env1)) { + } else if (cpu_supervisor_mode(env)) { return MMU_KERNEL_IDX; } else { return MMU_USER_IDX;
target-sparc/ldst_helper.c +6 -21
@@ -887,10 +887,10 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,case 0 :/* Control Register */ env->mmuregs[reg] = (env->mmuregs[reg] &0xff000000 ) | (val &0x00ffffff ); -/* Mappings generated during no-fault mode or MMU -disabled mode are invalid in normal mode */ -if ((oldreg & (MMU_E |MMU_NF | env->def->mmu_bm)) != - (env->mmuregs[reg] & (MMU_E |MMU_NF | env->def->mmu_bm))) { +/* Mappings generated during no-fault mode +are invalid in normal mode. */ +if ((oldreg ^ env->mmuregs[reg]) + & (MMU_NF | env->def->mmu_bm)) {tlb_flush (CPU (cpu),1 ); }break ;
@@ -1866,23 +1866,8 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,/* XXX */ return ;case ASI_LSU_CONTROL :/* LSU */ - { -uint64_t oldreg; - - oldreg = env->lsu; - env->lsu = val & (DMMU_E |IMMU_E ); -/* Mappings generated during D/I MMU disabled mode are -invalid in normal mode */ -if (oldreg != env->lsu) { -DPRINTF_MMU ("LSU change: 0x%" PRIx64" -> 0x%" PRIx64"\n" , - oldreg, env->lsu); -#ifdef DEBUG_MMU -dump_mmu (stdout, fprintf, env); -#endif -tlb_flush (CPU (cpu),1 ); - } -return ; - } + env->lsu = val & (DMMU_E |IMMU_E ); +return ;case ASI_IMMU :/* I-MMU regs */ {int reg = (addr >>3 ) &0xf ;
target-sparc/mmu_helper.c +29 -18
80 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 4/15 target-sparc: Use MMU_PHYS_IDX for bypass asis
In reply to Richard Henderson--- target-sparc/translate.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
target-sparc/translate.c +19 -0
@@ -2046,6 +2046,11 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop) mem_idx =MMU_KERNEL_IDX ; type =GET_ASI_DIRECT ;break ; +case ASI_M_BYPASS :/* MMU passthrough */ +case ASI_LEON_BYPASS :/* LEON MMU passthrough */ + mem_idx =MMU_PHYS_IDX ; + type =GET_ASI_DIRECT ; +break ; } }else {gen_exception (dc,TT_PRIV_INSN );
@@ -2066,6 +2071,14 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop) type =GET_ASI_EXCP ; }else {switch (asi) { +case ASI_REAL :/* Bypass */ +case ASI_REAL_IO :/* Bypass, non-cacheable */ +case ASI_REAL_L :/* Bypass LE */ +case ASI_REAL_IO_L :/* Bypass, non-cacheable LE */ +case ASI_TWINX_REAL :/* Real address, twinx */ +case ASI_TWINX_REAL_L :/* Real address, twinx, LE */ + mem_idx =MMU_PHYS_IDX ; +break ;case ASI_N :/* Nucleus */ case ASI_NL :/* Nucleus LE */ case ASI_TWINX_N :
@@ -2123,6 +2136,10 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop)break ; }switch (asi) { +case ASI_REAL : +case ASI_REAL_IO : +case ASI_REAL_L : +case ASI_REAL_IO_L :case ASI_N :case ASI_NL :case ASI_AIUP :
@@ -2135,6 +2152,8 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop)case ASI_PL : type =GET_ASI_DIRECT ;break ; +case ASI_TWINX_REAL : +case ASI_TWINX_REAL_L :case ASI_TWINX_N :case ASI_TWINX_NL :case ASI_TWINX_AIUP :
Signature · 1 line
2.7.4
PATCH v2 5/15 target-sparc: Handle more twinx asis
In reply to Richard HendersonAs used by HelenOS, presumably for ultra 2 and 3, prior to the sun4v platform and the current twinx names.
--- target-sparc/translate.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target-sparc/translate.c +8 -0
@@ -2077,12 +2077,16 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop)case ASI_REAL_IO_L :/* Bypass, non-cacheable LE */ case ASI_TWINX_REAL :/* Real address, twinx */ case ASI_TWINX_REAL_L :/* Real address, twinx, LE */ +case ASI_QUAD_LDD_PHYS : +case ASI_QUAD_LDD_PHYS_L : mem_idx =MMU_PHYS_IDX ;break ;case ASI_N :/* Nucleus */ case ASI_NL :/* Nucleus LE */ case ASI_TWINX_N :case ASI_TWINX_NL : +case ASI_NUCLEUS_QUAD_LDD : +case ASI_NUCLEUS_QUAD_LDD_L : mem_idx =MMU_NUCLEUS_IDX ;break ;case ASI_AIUP :/* As if user primary */
@@ -2164,6 +2168,10 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop)case ASI_TWINX_PL :case ASI_TWINX_S :case ASI_TWINX_SL : +case ASI_QUAD_LDD_PHYS : +case ASI_QUAD_LDD_PHYS_L : +case ASI_NUCLEUS_QUAD_LDD : +case ASI_NUCLEUS_QUAD_LDD_L : type =GET_ASI_DTWINX ;break ;case ASI_BLK_COMMIT_P :
Signature · 1 line
2.7.4
PATCH v2 6/15 target-sparc: Implement swap_asi inline
In reply to Richard Henderson--- target-sparc/translate.c | 49 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 28 deletions(-)
target-sparc/translate.c +21 -28
@@ -2001,6 +2001,18 @@ static inline void gen_ne_fop_QD(DisasContext *dc, int rd, int rs,gen_update_fprs_dirty (dc,QFPREG (rd)); } +static void gen_swap (DisasContext *dc,TCGv dst,TCGv src, +TCGv addr,int mmu_idx,TCGMemOp memop) +{ +/* ??? Should be atomic. */ +TCGv t0 =tcg_temp_new (); +gen_address_mask (dc, addr); +tcg_gen_qemu_ld_tl (t0, addr, mmu_idx, memop); +tcg_gen_qemu_st_tl (src, addr, mmu_idx, memop); +tcg_gen_mov_tl (dst, t0); +tcg_temp_free (t0); +} +/* asi moves */ #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64) typedef enum {
@@ -2302,26 +2314,12 @@ static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src,switch (da.type) {case GET_ASI_EXCP :break ; +case GET_ASI_DIRECT : +gen_swap (dc, dst, src, addr, da.mem_idx, da.memop); +break ;default : - { -TCGv_i32 r_asi =tcg_const_i32 (da.asi); -TCGv_i32 r_mop =tcg_const_i32 (MO_UL ); -TCGv_i64 s64, t64; - -save_state (dc); - t64 =tcg_temp_new_i64 (); -gen_helper_ld_asi (t64, cpu_env, addr, r_asi, r_mop); - - s64 =tcg_temp_new_i64 (); -tcg_gen_extu_tl_i64 (s64, src); -gen_helper_st_asi (cpu_env, addr, s64, r_asi, r_mop); -tcg_temp_free_i64 (s64); -tcg_temp_free_i32 (r_mop); -tcg_temp_free_i32 (r_asi); - -tcg_gen_trunc_i64_tl (dst, t64); -tcg_temp_free_i64 (t64); - } +/* ??? Should be DAE_invalid_asi. */ +gen_exception (dc,TT_DATA_ACCESS );break ; } }
@@ -5207,15 +5205,10 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)break ;case 0x0f :/* swap, swap register with memory. Also atomically */ - { -TCGv t0 =get_temp_tl (dc); -CHECK_IU_FEATURE (dc,SWAP ); - cpu_src1 =gen_load_gpr (dc, rd); -gen_address_mask (dc, cpu_addr); -tcg_gen_qemu_ld32u (t0, cpu_addr, dc->mem_idx); -tcg_gen_qemu_st32 (cpu_src1, cpu_addr, dc->mem_idx); -tcg_gen_mov_tl (cpu_val, t0); - } +CHECK_IU_FEATURE (dc,SWAP ); + cpu_src1 =gen_load_gpr (dc, rd); +gen_swap (dc, cpu_val, cpu_src1, cpu_addr, + dc->mem_idx,MO_TEUL );break ;#if !defined(CONFIG_USER_ONLY ) || defined(TARGET_SPARC64 )case 0x10 :/* lda, V9 lduwa, load word alternate */
Signature · 1 line
2.7.4
PATCH v2 7/15 target-sparc: Implement ldstub_asi inline
In reply to Richard Henderson--- target-sparc/translate.c | 52 +++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 31 deletions(-)
target-sparc/translate.c +21 -31
@@ -2013,6 +2013,20 @@ static void gen_swap(DisasContext *dc, TCGv dst, TCGv src,tcg_temp_free (t0); } +static void gen_ldstub (DisasContext *dc,TCGv dst,TCGv addr,int mmu_idx) +{ +/* ??? Should be atomic. */ +TCGv_i32 t0 =tcg_temp_new_i32 (); +TCGv_i32 t1 =tcg_const_i32 (0xff ); + +gen_address_mask (dc, addr); +tcg_gen_qemu_ld_i32 (t0, addr, mmu_idx,MO_UB ); +tcg_gen_qemu_st_i32 (t1, addr, mmu_idx,MO_UB ); +tcg_gen_extu_i32_tl (dst, t0); +tcg_temp_free_i32 (t0); +tcg_temp_free_i32 (t1); +} +/* asi moves */ #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64) typedef enum {
@@ -2351,25 +2365,12 @@ static void gen_ldstub_asi(DisasContext *dc, TCGv dst, TCGv addr, int insn)switch (da.type) {case GET_ASI_EXCP :break ; +case GET_ASI_DIRECT : +gen_ldstub (dc, dst, addr, da.mem_idx); +break ;default : - { -TCGv_i32 r_asi =tcg_const_i32 (da.asi); -TCGv_i32 r_mop =tcg_const_i32 (MO_UB ); -TCGv_i64 s64, t64; - -save_state (dc); - t64 =tcg_temp_new_i64 (); -gen_helper_ld_asi (t64, cpu_env, addr, r_asi, r_mop); - - s64 =tcg_const_i64 (0xff ); -gen_helper_st_asi (cpu_env, addr, s64, r_asi, r_mop); -tcg_temp_free_i64 (s64); -tcg_temp_free_i32 (r_mop); -tcg_temp_free_i32 (r_asi); - -tcg_gen_trunc_i64_tl (dst, t64); -tcg_temp_free_i64 (t64); - } +/* ??? Should be DAE_invalid_asi. */ +gen_exception (dc,TT_DATA_ACCESS );break ; } }
@@ -5189,19 +5190,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)gen_address_mask (dc, cpu_addr);tcg_gen_qemu_ld16s (cpu_val, cpu_addr, dc->mem_idx);break ; -case 0xd :/* ldstub -- XXX: should be atomically */ - { -TCGv r_const; -TCGv tmp =tcg_temp_new (); - -gen_address_mask (dc, cpu_addr); -tcg_gen_qemu_ld8u (tmp, cpu_addr, dc->mem_idx); - r_const =tcg_const_tl (0xff ); -tcg_gen_qemu_st8 (r_const, cpu_addr, dc->mem_idx); -tcg_gen_mov_tl (cpu_val, tmp); -tcg_temp_free (r_const); -tcg_temp_free (tmp); - } +case 0xd :/* ldstub */ +gen_ldstub (dc, cpu_val, cpu_addr, dc->mem_idx);break ;case 0x0f :/* swap, swap register with memory. Also atomically */
Signature · 1 line
2.7.4
PATCH v2 8/15 target-sparc: Implement cas_asi/casx_asi inline
In reply to Richard Henderson--- target-sparc/helper.h | 4 --- target-sparc/ldst_helper.c | 29 ------------------- target-sparc/translate.c | 70 +++++++++++++++++++++++++++++++--------------- 3 files changed, 47 insertions(+), 56 deletions(-)
target-sparc/helper.h +0 -4
@@ -18,7 +18,6 @@ DEF_HELPER_2(wrcwp, void, env, tl) DEF_HELPER_FLAGS_2(array8, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_1(popc, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_3(ldda_asi, TCG_CALL_NO_WG, void, env, tl, int) -DEF_HELPER_FLAGS_5(casx_asi, TCG_CALL_NO_WG, tl, env, tl, tl, tl, i32) DEF_HELPER_FLAGS_2(set_softint, TCG_CALL_NO_RWG, void, env, i64) DEF_HELPER_FLAGS_2(clear_softint, TCG_CALL_NO_RWG, void, env, i64)DEF_HELPER_FLAGS_2 (write_softint,TCG_CALL_NO_RWG , void, env, i64)
@@ -26,9 +25,6 @@ DEF_HELPER_FLAGS_2(tick_set_count, TCG_CALL_NO_RWG, void, ptr, i64) DEF_HELPER_FLAGS_3(tick_get_count, TCG_CALL_NO_WG, i64, env, ptr, int) DEF_HELPER_FLAGS_2(tick_set_limit, TCG_CALL_NO_RWG, void, ptr, i64)#endif -#if !defined(CONFIG_USER_ONLY ) || defined(TARGET_SPARC64 ) -DEF_HELPER_FLAGS_5(cas_asi, TCG_CALL_NO_WG, tl, env, tl, tl, tl, i32) -#endif DEF_HELPER_FLAGS_3(check_align, TCG_CALL_NO_WG, void, env, tl, i32) DEF_HELPER_1(debug, void, env)DEF_HELPER_1 (save, void, env)
target-sparc/ldst_helper.c +0 -29
@@ -2150,37 +2150,8 @@ void helper_ldda_asi(CPUSPARCState *env, target_ulong addr, int asi)QT0 .high = h; QT0.low = l; } - -target_ulong helper_casx_asi (CPUSPARCState *env,target_ulong addr, -target_ulong val1,target_ulong val2, -uint32_t asi) -{ -target_ulong ret; - - ret =helper_ld_asi (env, addr, asi,MO_Q ); -if (val2 == ret) { -helper_st_asi (env, addr, val1, asi,MO_Q ); - } -return ret; -}#endif /* TARGET_SPARC64 */ -#if !defined(CONFIG_USER_ONLY ) || defined(TARGET_SPARC64 ) -target_ulong helper_cas_asi (CPUSPARCState *env,target_ulong addr, -target_ulong val1,target_ulong val2,uint32_t asi) -{ -target_ulong ret; - - val2 &=0xffffffffUL ; - ret =helper_ld_asi (env, addr, asi,MO_UL ); - ret &=0xffffffffUL ; -if (val2 == ret) { -helper_st_asi (env, addr, val1 &0xffffffffUL , asi,MO_UL ); - } -return ret; -} -#endif /* !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64) */ -void helper_ldqf (CPUSPARCState *env,target_ulong addr,int mem_idx) {/* XXX add 128 bit load */
target-sparc/translate.c +47 -23
94 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 9/15 target-sparc: Implement BCOPY/BFILL inline
In reply to Richard Henderson--- target-sparc/translate.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)
target-sparc/translate.c +63 -0
@@ -2036,6 +2036,8 @@ typedef enum {GET_ASI_DTWINX ,GET_ASI_BLOCK ,GET_ASI_SHORT , +GET_ASI_BCOPY , +GET_ASI_BFILL , } ASIType; typedef struct {
@@ -2077,6 +2079,14 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop) mem_idx =MMU_PHYS_IDX ; type =GET_ASI_DIRECT ;break ; +case ASI_M_BCOPY :/* Block copy, sta access */ + mem_idx =MMU_KERNEL_IDX ; + type =GET_ASI_BCOPY ; +break ; +case ASI_M_BFILL :/* Block fill, stda access */ + mem_idx =MMU_KERNEL_IDX ; + type =GET_ASI_BFILL ; +break ; } }else {gen_exception (dc,TT_PRIV_INSN );
@@ -2294,6 +2304,38 @@ static void gen_st_asi(DisasContext *dc, TCGv src, TCGv addr,gen_address_mask (dc, addr);tcg_gen_qemu_st_tl (src, addr, da.mem_idx, da.memop);break ; +#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) +case GET_ASI_BCOPY : +/* Copy 32 bytes from the address in SRC to ADDR. */ +/* ??? The original qemu code suggests 4-byte alignment, dropping +the low bits, but the only place I can see this used is in the +Linux kernel with 32 byte alignment, which would make more sense +as a cacheline-style operation. */ + { +TCGv s_addr =tcg_temp_new (); +TCGv d_addr =tcg_temp_new (); +TCGv four =tcg_const_tl (4 ); +TCGv_i32 tmp =tcg_temp_new_i32 (); +int i; + +tcg_gen_andi_tl (s_addr, src,-4 ); +tcg_gen_andi_tl (d_addr, addr,-4 ); +for (i =0 ; i <32 ; i +=4 ) { +/* Since the loads and stores are paired, allow the +copy to happen in the host endianness. */ +tcg_gen_qemu_ld_i32 (tmp, s_addr, da.mem_idx,MO_UL ); +tcg_gen_qemu_st_i32 (tmp, d_addr, da.mem_idx,MO_UL ); +tcg_gen_add_tl (s_addr, s_addr, four); +tcg_gen_add_tl (d_addr, d_addr, four); + } + +tcg_temp_free (s_addr); +tcg_temp_free (d_addr); +tcg_temp_free (four); +tcg_temp_free_i32 (tmp); + } +break ; +#endif default : {TCGv_i32 r_asi =tcg_const_i32 (da.asi);
@@ -2766,6 +2808,27 @@ static void gen_stda_asi(DisasContext *dc, TCGv hi, TCGv addr,gen_address_mask (dc, addr);tcg_gen_qemu_st_i64 (t64, addr, da.mem_idx, da.memop);break ; +case GET_ASI_BFILL : +/* Store 32 bytes of T64 to ADDR. */ +/* ??? The original qemu code suggests 8-byte alignment, dropping +the low bits, but the only place I can see this used is in the +Linux kernel with 32 byte alignment, which would make more sense +as a cacheline-style operation. */ + { +TCGv d_addr =tcg_temp_new (); +TCGv eight =tcg_const_tl (8 ); +int i; + +tcg_gen_andi_tl (d_addr, addr,-8 ); +for (i =0 ; i <32 ; i +=8 ) { +tcg_gen_qemu_st_i64 (t64, d_addr, da.mem_idx, da.memop); +tcg_gen_add_tl (d_addr, d_addr, eight); + } + +tcg_temp_free (d_addr); +tcg_temp_free (eight); + } +break ;default : {TCGv_i32 r_asi =tcg_const_i32 (da.asi);
Signature · 1 line
2.7.4
PATCH v2 10/15 target-sparc: Remove asi helper code handled inline
In reply to Richard HendersonNow that we never call out to helpers when direct accesses can handle an asi, remove the corresponding code in those helpers. For ldda, this removes the entire helper.
--- target-sparc/helper.h | 1 - target-sparc/ldst_helper.c | 811 ++++++++------------------------------------- target-sparc/translate.c | 34 +- 3 files changed, 156 insertions(+), 690 deletions(-)
target-sparc/helper.h +0 -1
@@ -17,7 +17,6 @@ DEF_HELPER_1(rdcwp, tl, env) DEF_HELPER_2(wrcwp, void, env, tl) DEF_HELPER_FLAGS_2(array8, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_1(popc, TCG_CALL_NO_RWG_SE, tl, tl) -DEF_HELPER_FLAGS_3(ldda_asi, TCG_CALL_NO_WG, void, env, tl, int) DEF_HELPER_FLAGS_2(set_softint, TCG_CALL_NO_RWG, void, env, i64) DEF_HELPER_FLAGS_2(clear_softint, TCG_CALL_NO_RWG, void, env, i64)DEF_HELPER_FLAGS_2 (write_softint,TCG_CALL_NO_RWG , void, env, i64)
target-sparc/ldst_helper.c +130 -681
966 lines not on this page · raw message
target-sparc/translate.c +26 -8
@@ -2652,15 +2652,27 @@ static void gen_ldda_asi(DisasContext *dc, TCGv addr, int insn, int rd)break ;default : +/* ??? In theory we've handled all of the ASIs that are valid +for ldda, and this should raise DAE_invalid_asi. However, +real hardware allows others. This can be seen with e.g. +FreeBSD 10.3 wrt ASI_IC_TAG. */ {TCGv_i32 r_asi =tcg_const_i32 (da.asi); +TCGv_i32 r_mop =tcg_const_i32 (da.memop); +TCGv_i64 tmp =tcg_temp_new_i64 ();save_state (dc); -gen_helper_ldda_asi (cpu_env, addr, r_asi); +gen_helper_ld_asi (tmp, cpu_env, addr, r_asi, r_mop);tcg_temp_free_i32 (r_asi); +tcg_temp_free_i32 (r_mop); - tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUSPARCState, qt0.high)); - tcg_gen_ld_i64(lo, cpu_env, offsetof(CPUSPARCState, qt0.low)); +/* See above. */ +if ((da.memop &MO_BSWAP ) ==MO_TE ) { +tcg_gen_extr32_i64 (lo, hi, tmp); + }else { +tcg_gen_extr32_i64 (hi, lo, tmp); + } +tcg_temp_free_i64 (tmp); }break ; }
@@ -2705,15 +2717,21 @@ static void gen_stda_asi(DisasContext *dc, TCGv hi, TCGv addr,break ;default : +/* ??? In theory we've handled all of the ASIs that are valid +for stda, and this should raise DAE_invalid_asi. */ {TCGv_i32 r_asi =tcg_const_i32 (da.asi); -TCGv_i32 r_mop =tcg_const_i32 (MO_Q ); -TCGv_i64 t64; +TCGv_i32 r_mop =tcg_const_i32 (da.memop); +TCGv_i64 t64 =tcg_temp_new_i64 (); -save_state (dc); +/* See above. */ +if ((da.memop &MO_BSWAP ) ==MO_TE ) { +tcg_gen_concat32_i64 (t64, lo, hi); + }else { +tcg_gen_concat32_i64 (t64, hi, lo); + } - t64 =tcg_temp_new_i64 (); -tcg_gen_concat_tl_i64 (t64, lo, hi); +save_state (dc);gen_helper_st_asi (cpu_env, addr, t64, r_asi, r_mop);tcg_temp_free_i32 (r_mop);tcg_temp_free_i32 (r_asi);
Signature · 1 line
2.7.4
PATCH v2 11/15 target-sparc: Implement ldqf and stqf inline
In reply to Richard HendersonAt the same time, fix a problem with stqf_asi, when a write might access two pages.
--- target-sparc/helper.h | 2 -- target-sparc/ldst_helper.c | 72 ------------------------------------------ target-sparc/translate.c | 79 +++++++++++++++++++++++++++++++++------------- 3 files changed, 57 insertions(+), 96 deletions(-)
target-sparc/helper.h +0 -2
@@ -38,8 +38,6 @@ DEF_HELPER_3(tsubcctv, tl, env, tl, tl) DEF_HELPER_FLAGS_3(sdivx, TCG_CALL_NO_WG, s64, env, s64, s64) DEF_HELPER_FLAGS_3(udivx, TCG_CALL_NO_WG, i64, env, i64, i64)#endif -DEF_HELPER_FLAGS_3(ldqf, TCG_CALL_NO_WG, void, env, tl, int) -DEF_HELPER_FLAGS_3(stqf, TCG_CALL_NO_WG, void, env, tl, int)#if !defined(CONFIG_USER_ONLY ) || defined(TARGET_SPARC64 ) DEF_HELPER_FLAGS_4(ld_asi, TCG_CALL_NO_WG, i64, env, tl, int, i32)DEF_HELPER_FLAGS_5 (st_asi,TCG_CALL_NO_WG , void, env, tl, i64, int, i32)
target-sparc/ldst_helper.c +0 -72
78 lines not on this page · raw message
target-sparc/translate.c +57 -22
113 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 12/15 target-sparc: Allow 4-byte alignment on fp mem ops
In reply to Richard HendersonThe cpu is allowed to require stricter alignment on these 8- and 16-byte operations, and the OS is required to fix up the accesses as necessary, so the previous code was not wrong.
However, we can easily handle this misalignment for all direct 8-byte operations and for direct 16-byte loads.
We must retain 16-byte alignment for 16-byte stores, so that we don't have to probe for writability of a second page before performing the first of two 8-byte stores. We also retain 8-byte alignment for no-fault loads, since they are rare and it's not worth extending the helpers for this.
--- target-sparc/translate.c | 86 +++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 42 deletions(-)
target-sparc/translate.c +44 -42
@@ -2459,6 +2459,7 @@ static void gen_ldf_asi(DisasContext *dc, TCGv addr, {DisasASI da =get_asi (dc, insn, (size ==4 ?MO_TEUL :MO_TEQ ));TCGv_i32 d32; +TCGv_i64 d64;switch (da.type) {case GET_ASI_EXCP :
@@ -2473,12 +2474,17 @@ static void gen_ldf_asi(DisasContext *dc, TCGv addr,gen_store_fpr_F (dc, rd, d32);break ;case 8 : -tcg_gen_qemu_ld_i64 (cpu_fpr[rd /2 ], addr, da.mem_idx, da.memop); +tcg_gen_qemu_ld_i64 (cpu_fpr[rd /2 ], addr, da.mem_idx, + da.memop |MO_ALIGN_4 );break ;case 16 : -tcg_gen_qemu_ld_i64 (cpu_fpr[rd /2 ], addr, da.mem_idx, da.memop); + d64 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld_i64 (d64, addr, da.mem_idx, da.memop |MO_ALIGN_4 );tcg_gen_addi_tl (addr, addr,8 ); -tcg_gen_qemu_ld_i64 (cpu_fpr[rd/2 +1 ], addr, da.mem_idx, da.memop); +tcg_gen_qemu_ld_i64 (cpu_fpr[rd/2 +1 ], addr, da.mem_idx, + da.memop |MO_ALIGN_4 ); +tcg_gen_mov_i64 (cpu_fpr[rd /2 ], d64); +tcg_temp_free_i64 (d64);break ;default :g_assert_not_reached ();
@@ -2534,22 +2540,23 @@ static void gen_ldf_asi(DisasContext *dc, TCGv addr,but we can just use the integer asi helper for them. */ switch (size) {case 4 : - { -TCGv d64 =tcg_temp_new_i64 (); -gen_helper_ld_asi (d64, cpu_env, addr, r_asi, r_mop); - d32 =gen_dest_fpr_F (dc); -tcg_gen_extrl_i64_i32 (d32, d64); -tcg_temp_free_i64 (d64); -gen_store_fpr_F (dc, rd, d32); - } + d64 =tcg_temp_new_i64 (); +gen_helper_ld_asi (d64, cpu_env, addr, r_asi, r_mop); + d32 =gen_dest_fpr_F (dc); +tcg_gen_extrl_i64_i32 (d32, d64); +tcg_temp_free_i64 (d64); +gen_store_fpr_F (dc, rd, d32);break ;case 8 :gen_helper_ld_asi (cpu_fpr[rd /2 ], cpu_env, addr, r_asi, r_mop);break ;case 16 : -gen_helper_ld_asi (cpu_fpr[rd /2 ], cpu_env, addr, r_asi, r_mop); + d64 =tcg_temp_new_i64 (); +gen_helper_ld_asi (d64, cpu_env, addr, r_asi, r_mop);tcg_gen_addi_tl (addr, addr,8 );gen_helper_ld_asi (cpu_fpr[rd/2 +1 ], cpu_env, addr, r_asi, r_mop); +tcg_gen_mov_i64 (cpu_fpr[rd /2 ], d64); +tcg_temp_free_i64 (d64);break ;default :g_assert_not_reached ();
@@ -2579,15 +2586,15 @@ static void gen_stf_asi(DisasContext *dc, TCGv addr,tcg_gen_qemu_st_i32 (d32, addr, da.mem_idx, da.memop);break ;case 8 : -/* ??? Only 4-byte alignment required. However, it is legal -for the cpu to signal the alignment fault, and the OS trap -handler is required to fix it up. */ -tcg_gen_qemu_st_i64 (cpu_fpr[rd /2 ], addr, da.mem_idx, da.memop); +tcg_gen_qemu_st_i64 (cpu_fpr[rd /2 ], addr, da.mem_idx, + da.memop |MO_ALIGN_4 );break ;case 16 : -/* Only 4-byte alignment required. See above. Requiring -16-byte alignment here avoids having to probe the second -page before performing the first write. */ +/* Only 4-byte alignment required. However, it is legal for the +cpu to signal the alignment fault, and the OS trap handler is +required to fix it up. Requiring 16-byte alignment here avoids +having to probe the second page before performing the first +write. */ tcg_gen_qemu_st_i64 (cpu_fpr[rd /2 ], addr, da.mem_idx, da.memop |MO_ALIGN_16 );tcg_gen_addi_tl (addr, addr,8 );
@@ -5423,18 +5430,15 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) skip_move: ;#endif }else if (xop >=0x20 && xop <0x24 ) { -TCGv t0; -if (gen_trap_ifnofpu (dc)) { goto jmp_insn; }switch (xop) {case 0x20 :/* ldf, load fpreg */ gen_address_mask (dc, cpu_addr); - t0 =get_temp_tl (dc); -tcg_gen_qemu_ld32u (t0, cpu_addr, dc->mem_idx); cpu_dst_32 =gen_dest_fpr_F (dc); -tcg_gen_trunc_tl_i32 (cpu_dst_32, t0); +tcg_gen_qemu_ld_i32 (cpu_dst_32, cpu_addr, + dc->mem_idx,MO_TEUL );gen_store_fpr_F (dc, rd, cpu_dst_32);break ;case 0x21 :/* ldfsr, V9 ldxfsr */
@@ -5442,26 +5446,28 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)gen_address_mask (dc, cpu_addr);if (rd ==1 ) {TCGv_i64 t64 =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (t64, cpu_addr, dc->mem_idx); +tcg_gen_qemu_ld_i64 (t64, cpu_addr, + dc->mem_idx,MO_TEQ );gen_helper_ldxfsr (cpu_fsr, cpu_env, cpu_fsr, t64);tcg_temp_free_i64 (t64);break ; }#endif cpu_dst_32 =get_temp_i32 (dc); - t0 =get_temp_tl (dc); -tcg_gen_qemu_ld32u (t0, cpu_addr, dc->mem_idx); -tcg_gen_trunc_tl_i32 (cpu_dst_32, t0); +tcg_gen_qemu_ld_i32 (cpu_dst_32, cpu_addr, + dc->mem_idx,MO_TEUL );gen_helper_ldfsr (cpu_fsr, cpu_env, cpu_fsr, cpu_dst_32);break ;case 0x22 :/* ldqf, load quad fpreg */ CHECK_FPU_FEATURE (dc,FLOAT128 );gen_address_mask (dc, cpu_addr); cpu_src1_64 =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (cpu_src1_64, cpu_addr, dc->mem_idx); +tcg_gen_qemu_ld_i64 (cpu_src1_64, cpu_addr, dc->mem_idx, +MO_TEQ |MO_ALIGN_4 );tcg_gen_addi_tl (cpu_addr, cpu_addr,8 ); cpu_src2_64 =tcg_temp_new_i64 (); -tcg_gen_qemu_ld64 (cpu_src2_64, cpu_addr, dc->mem_idx); +tcg_gen_qemu_ld_i64 (cpu_src2_64, cpu_addr, dc->mem_idx, +MO_TEQ |MO_ALIGN_4 );gen_store_fpr_Q (dc, rd, cpu_src1_64, cpu_src2_64);tcg_temp_free_i64 (cpu_src1_64);tcg_temp_free_i64 (cpu_src2_64);
@@ -5469,7 +5475,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)case 0x23 :/* lddf, load double fpreg */ gen_address_mask (dc, cpu_addr); cpu_dst_64 =gen_dest_fpr_D (dc, rd); -tcg_gen_qemu_ld64 (cpu_dst_64, cpu_addr, dc->mem_idx); +tcg_gen_qemu_ld_i64 (cpu_dst_64, cpu_addr, dc->mem_idx, +MO_TEQ |MO_ALIGN_4 );gen_store_fpr_D (dc, rd, cpu_dst_64);break ;default :
@@ -5542,13 +5549,10 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) }switch (xop) {case 0x24 :/* stf, store fpreg */ - { -TCGv t =get_temp_tl (dc); -gen_address_mask (dc, cpu_addr); - cpu_src1_32 =gen_load_fpr_F (dc, rd); -tcg_gen_ext_i32_tl (t, cpu_src1_32); -tcg_gen_qemu_st32 (t, cpu_addr, dc->mem_idx); - } +gen_address_mask (dc, cpu_addr); + cpu_src1_32 =gen_load_fpr_F (dc, rd); +tcg_gen_qemu_st_i32 (cpu_src1_32, cpu_addr, + dc->mem_idx,MO_TEUL );break ;case 0x25 :/* stfsr, V9 stxfsr */ {
@@ -5594,12 +5598,10 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)#endif #endif case 0x27 :/* stdf, store double fpreg */ -/* ??? Only 4-byte alignment required. However, it is -legal for the cpu to signal the alignment fault, and -the OS trap handler is required to fix it up. */ gen_address_mask (dc, cpu_addr); cpu_src1_64 =gen_load_fpr_D (dc, rd); -tcg_gen_qemu_st64 (cpu_src1_64, cpu_addr, dc->mem_idx); +tcg_gen_qemu_st_i64 (cpu_src1_64, cpu_addr, dc->mem_idx, +MO_TEQ |MO_ALIGN_4 );break ;default : goto illegal_insn;
Signature · 1 line
2.7.4
PATCH v2 13/15 target-sparc: Remove MMU_MODE*_SUFFIX
In reply to Richard HendersonThe functions that these generate are no longer used.
--- target-sparc/cpu.h | 8 -------- 1 file changed, 8 deletions(-)
target-sparc/cpu.h +0 -8
@@ -638,23 +638,15 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);/* MMU modes definitions */ #if defined (TARGET_SPARC64 )#define MMU_USER_IDX 0 -#define MMU_MODE0_SUFFIX _user#define MMU_USER_SECONDARY_IDX 1 -#define MMU_MODE1_SUFFIX _user_secondary#define MMU_KERNEL_IDX 2 -#define MMU_MODE2_SUFFIX _kernel#define MMU_KERNEL_SECONDARY_IDX 3 -#define MMU_MODE3_SUFFIX _kernel_secondary#define MMU_NUCLEUS_IDX 4 -#define MMU_MODE4_SUFFIX _nucleus#define MMU_HYPV_IDX 5 -#define MMU_MODE5_SUFFIX _hypv#define MMU_PHYS_IDX 6#else #define MMU_USER_IDX 0 -#define MMU_MODE0_SUFFIX _user#define MMU_KERNEL_IDX 1 -#define MMU_MODE1_SUFFIX _kernel#define MMU_PHYS_IDX 2#endif
Signature · 1 line
2.7.4
PATCH v2 14/15 target-sparc: Use tcg_gen_atomic_xchg_tl
In reply to Richard Henderson--- target-sparc/translate.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
target-sparc/translate.c +4 -15
@@ -2026,27 +2026,16 @@ static inline void gen_ne_fop_QD(DisasContext *dc, int rd, int rs,static void gen_swap (DisasContext *dc,TCGv dst,TCGv src,TCGv addr,int mmu_idx,TCGMemOp memop) { -/* ??? Should be atomic. */ -TCGv t0 =tcg_temp_new ();gen_address_mask (dc, addr); -tcg_gen_qemu_ld_tl (t0, addr, mmu_idx, memop); -tcg_gen_qemu_st_tl (src, addr, mmu_idx, memop); -tcg_gen_mov_tl (dst, t0); -tcg_temp_free (t0); +tcg_gen_atomic_xchg_tl (dst, addr, src, mmu_idx, memop); }static void gen_ldstub (DisasContext *dc,TCGv dst,TCGv addr,int mmu_idx) { -/* ??? Should be atomic. */ -TCGv_i32 t0 =tcg_temp_new_i32 (); -TCGv_i32 t1 =tcg_const_i32 (0xff ); - +TCGv m1 =tcg_const_tl (0xff );gen_address_mask (dc, addr); -tcg_gen_qemu_ld_i32 (t0, addr, mmu_idx,MO_UB ); -tcg_gen_qemu_st_i32 (t1, addr, mmu_idx,MO_UB ); -tcg_gen_extu_i32_tl (dst, t0); -tcg_temp_free_i32 (t0); -tcg_temp_free_i32 (t1); +tcg_gen_atomic_xchg_tl (dst, addr, m1, mmu_idx,MO_UB ); +tcg_temp_free (m1); }/* asi moves */
Signature · 1 line
2.7.4
PATCH v2 15/15 target-sparc: Use tcg_gen_atomic_cmpxchg_tl
In reply to Richard Henderson--- target-sparc/translate.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-)
target-sparc/translate.c +7 -24
@@ -2391,31 +2391,21 @@ static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src, } } -static void gen_cas_asi (DisasContext *dc,TCGv addr,TCGv cmpr, +static void gen_cas_asi (DisasContext *dc,TCGv addr,TCGv cmpv,int insn,int rd) {DisasASI da =get_asi (dc, insn,MO_TEUL ); -TCGv cmpv, oldv, tmpv; +TCGv oldv;switch (da.type) {case GET_ASI_EXCP :return ;case GET_ASI_DIRECT : - cmpv =tcg_temp_new (); oldv =tcg_temp_new (); - tmpv =tcg_temp_new (); -tcg_gen_ext32u_tl (cmpv, cmpr); - -/* ??? Should be atomic. */ -tcg_gen_qemu_ld_tl (oldv, addr, da.mem_idx, da.memop); -tcg_gen_movcond_tl (TCG_COND_EQ , tmpv, oldv, cmpv, -gen_load_gpr (dc, rd), oldv); -tcg_gen_qemu_st_tl (tmpv, addr, da.mem_idx, da.memop); - +tcg_gen_atomic_cmpxchg_tl (oldv, addr, cmpv,gen_load_gpr (dc, rd), + da.mem_idx, da.memop);gen_store_gpr (dc, rd, oldv); -tcg_temp_free (cmpv);tcg_temp_free (oldv); -tcg_temp_free (tmpv);break ;default :/* ??? Should be DAE_invalid_asi. */
@@ -2770,24 +2760,17 @@ static void gen_casx_asi(DisasContext *dc, TCGv addr, TCGv cmpv, int insn, int rd) {DisasASI da =get_asi (dc, insn,MO_TEQ ); -TCGv oldv, tmpv; +TCGv oldv;switch (da.type) {case GET_ASI_EXCP :return ;case GET_ASI_DIRECT : oldv =tcg_temp_new (); - tmpv =tcg_temp_new (); - -/* ??? Should be atomic. */ -tcg_gen_qemu_ld_tl (oldv, addr, da.mem_idx, da.memop); -tcg_gen_movcond_tl (TCG_COND_EQ , tmpv, oldv, cmpv, -gen_load_gpr (dc, rd), oldv); -tcg_gen_qemu_st_tl (tmpv, addr, da.mem_idx, da.memop); - +tcg_gen_atomic_cmpxchg_tl (oldv, addr, cmpv,gen_load_gpr (dc, rd), + da.mem_idx, da.memop);gen_store_gpr (dc, rd, oldv);tcg_temp_free (oldv); -tcg_temp_free (tmpv);break ;default :/* ??? Should be DAE_invalid_asi. */
Signature · 1 line
2.7.4
Your series seems to have some coding style problems. See output below for more information:
Hi,
Your series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v2 00/15] target-sparc improvements
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git show --no-patch --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
27c5285 target-sparc: Use tcg_gen_atomic_cmpxchg_tl
2069f01 target-sparc: Use tcg_gen_atomic_xchg_tl
f53a73a target-sparc: Remove MMU_MODE*_SUFFIX
549a774 target-sparc: Allow 4-byte alignment on fp mem ops d6ae826 target-sparc: Implement ldqf and stqf inline de30bb1 target-sparc: Remove asi helper code handled inline ea72a1b target-sparc: Implement BCOPY/BFILL inline
bc0d872 target-sparc: Implement cas_asi/casx_asi inline 1a9423b target-sparc: Implement ldstub_asi inline
b1f9907 target-sparc: Implement swap_asi inline
6d810e8 target-sparc: Handle more twinx asis
561899b target-sparc: Use MMU_PHYS_IDX for bypass asis f6c907c target-sparc: Add MMU_PHYS_IDX
c3cc123 target-sparc: Introduce cpu_raise_exception_ra 3d4d48a target-sparc: Use overalignment flags for twinx and block asis
=== OUTPUT BEGIN ===
Checking PATCH 1/15: target-sparc: Use overalignment flags for twinx and block asis... Checking PATCH 2/15: target-sparc: Introduce cpu_raise_exception_ra... Checking PATCH 3/15: target-sparc: Add MMU_PHYS_IDX...
Checking PATCH 4/15: target-sparc: Use MMU_PHYS_IDX for bypass asis... Checking PATCH 5/15: target-sparc: Handle more twinx asis...
Checking PATCH 6/15: target-sparc: Implement swap_asi inline...
Checking PATCH 7/15: target-sparc: Implement ldstub_asi inline... Checking PATCH 8/15: target-sparc: Implement cas_asi/casx_asi inline... Checking PATCH 9/15: target-sparc: Implement BCOPY/BFILL inline... Checking PATCH 10/15: target-sparc: Remove asi helper code handled inline... Checking PATCH 11/15: target-sparc: Implement ldqf and stqf inline... Checking PATCH 12/15: target-sparc: Allow 4-byte alignment on fp mem ops...
ERROR: spaces required around that '/' (ctx:VxV)
#47: FILE: target-sparc/translate.c:2484:
+ tcg_gen_qemu_ld_i64(cpu_fpr[rd/2+1], addr, da.mem_idx,
^
ERROR: spaces required around that '+' (ctx:VxV)
#47: FILE: target-sparc/translate.c:2484:
+ tcg_gen_qemu_ld_i64(cpu_fpr[rd/2+1], addr, da.mem_idx,
^
total: 2 errors, 0 warnings, 175 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 13/15: target-sparc: Remove MMU_MODE*_SUFFIX... Checking PATCH 14/15: target-sparc: Use tcg_gen_atomic_xchg_tl... Checking PATCH 15/15: target-sparc: Use tcg_gen_atomic_cmpxchg_tl... === OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Quoted 48 lines · Richard Henderson
The two main goals in this patch set are:
* Make use of the new MO_ALIGN_* flags, to allow less use of
check_align, and support partially misaligned fp memory ops.* More cleanups for ASIs, in the end using the new atomic ops.
The final two patches require the "cmpxchg atomic" v6 patch set. Otherwise this patch set should apply to master. The full tree is at
git://github.com/rth7680/qemu.gittgt-sparc-6Changes since v1:
* The "Remove asi helper code handled inline" patch retains the code within ldda to handle asis that must be handled out of line.
This fixes the FreeBSD 10.3 boot problem. While the UA2007 spec (and thus sun4v?) doesn't allow for such, it would seem that US2 hardware does.
* Dropped the "Optimize writeback of
cpu_cond" patch.This fixes the debian 7.8 install. Not sure exactly what's wrong with it yet, but let's just drop it for now.
r~
Richard Henderson (15):
target-sparc: Use overalignment flags for twinx and block asis
target-sparc: Introducecpu_raise_exception_ra
target-sparc: AddMMU_PHYS_IDX
target-sparc: UseMMU_PHYS_IDXfor bypass asis
target-sparc: Handle more twinx asis
target-sparc: Implementswap_asiinline
target-sparc: Implementldstub_asiinline
target-sparc: Implement cas_asi/casx_asi inline
target-sparc: Implement BCOPY/BFILL inline
target-sparc: Remove asi helper code handled inline
target-sparc: Implement ldqf and stqf inline
target-sparc: Allow 4-byte alignment on fp mem ops
target-sparc: Remove MMU_MODE*_SUFFIX
target-sparc: Usetcg_gen_atomic_xchg_tl
target-sparc: Usetcg_gen_atomic_cmpxchg_tl
Quoted 8 lines
target-sparc/cpu.h | 34 +- target-sparc/helper.c | 52 ++- target-sparc/helper.h | 7 - target-sparc/ldst_helper.c | 998 ++++++++------------------------------------- target-sparc/mmu_helper.c | 47 ++- target-sparc/translate.c | 434 +++++++++++++------- target-sparc/win_helper.c | 37 +- 7 files changed, 531 insertions(+), 1078 deletions(-)
Hi Richard,
Great work - this version now passes all my local SPARC32/SPARC64 boot tests.
ATB,
Mark.