few fixes for hppa target
v2 cover few fixes for hppa target
Hi,
here are a few fixes for the hppa target i made while debugging some wide mode issues.
Changes in v2:
- use Richards version for access id matching
- add trans_fic()
Sven Schnelle (6):
target/hppa: ldcw,s uses static shift of 3 target/hppa: fix shrp for wide mode target/hppa: fix access_id check target/hppa: exit tb on flush cache instructions target/hppa: mask privilege bits in mfia target/hppa: fix do_stdby_e()
target/hppa/insns.decode | 6 ++-- target/hppa/mem_helper.c | 59 +++++++++++++++++++++++++++++++++------- target/hppa/op_helper.c | 10 +++---- target/hppa/translate.c | 19 ++++++++++--- 4 files changed, 72 insertions(+), 22 deletions(-)
Signature · 1 line
2.43.2
PATCH v2 1/6 target/hppa: ldcw,s uses static shift of 3
--- target/hppa/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/translate.c +1 -1
@@ -3085,7 +3085,7 @@ static bool trans_ldc(DisasContext *ctx, arg_ldst *a) dest =dest_gpr (ctx, a->t); } -form_gva (ctx, &addr, &ofs, a->b, a->x, a->scale ? a->size :0 , +form_gva (ctx, &addr, &ofs, a->b, a->x, a->scale ?3 :0 , a->disp, a->sp, a->m,MMU_DISABLED (ctx));/*
Signature · 1 line
2.43.2
PATCH v2 2/6 target/hppa: fix shrp for wide mode
In reply to Sven Schnelle--- target/hppa/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/hppa/translate.c +2 -2
@@ -3462,7 +3462,7 @@ static bool trans_shrp_sar(DisasContext *ctx, arg_shrp_sar *a)/* Install the new nullification. */ cond_free (&ctx->null_cond);if (a->c) { - ctx->null_cond =do_sed_cond (ctx, a->c, false, dest); + ctx->null_cond =do_sed_cond (ctx, a->c, a->d, dest); }return nullify_end (ctx); }
@@ -3505,7 +3505,7 @@ static bool trans_shrp_imm(DisasContext *ctx, arg_shrp_imm *a)/* Install the new nullification. */ cond_free (&ctx->null_cond);if (a->c) { - ctx->null_cond =do_sed_cond (ctx, a->c, false, dest); + ctx->null_cond =do_sed_cond (ctx, a->c, a->d, dest); }return nullify_end (ctx); }
Signature · 1 line
2.43.2
PATCH v2 3/6 target/hppa: fix access_id check
In reply to Sven SchnellePA2.0 provides 8 instead of 4 PID registers.
--- target/hppa/mem_helper.c | 59 +++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 10 deletions(-)
target/hppa/mem_helper.c +49 -10
@@ -152,6 +152,49 @@ static HPPATLBEntry *hppa_alloc_tlb_ent(CPUHPPAState *env)return ent; } +#define ACCESS_ID_MASK 0xffff + +/* Return the set of protections allowed by a PID match. */ +static int match_prot_id_1 (uint32_t access_id,uint32_t prot_id) +{ +if (((access_id ^ (prot_id >>1 )) &ACCESS_ID_MASK ) ==0 ) { +return (prot_id &1 + ?PROT_EXEC |PROT_READ + :PROT_EXEC |PROT_READ |PROT_WRITE ); + } +return 0 ; +} + +static int match_prot_id32 (CPUHPPAState *env,uint32_t access_id) +{ +int r, i; + +for (i =CR_PID1 ; i <=CR_PID4 ; ++i) { + r =match_prot_id_1 (access_id, env->cr[i]); +if (r) { +return r; + } + } +return 0 ; +} + +static int match_prot_id64 (CPUHPPAState *env,uint32_t access_id) +{ +int r, i; + +for (i =CR_PID1 ; i <=CR_PID4 ; ++i) { + r =match_prot_id_1 (access_id, env->cr[i]); +if (r) { +return r; + } + r =match_prot_id_1 (access_id, env->cr[i] >>32 ); +if (r) { +return r; + } + } +return 0 ; +} +int hppa_get_physical_address (CPUHPPAState *env,vaddr addr,int mmu_idx,int type,hwaddr *pphys,int *pprot,HPPATLBEntry **tlb_entry)
@@ -226,16 +269,12 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,/* access_id == 0 means public page and no check is performed */ if (ent->access_id &&MMU_IDX_TO_P (mmu_idx)) { -/* If bits [31:1] match, and bit 0 is set, suppress write. */ -int match = ent->access_id *2 +1 ; - -if (match == env->cr[CR_PID1 ] || match == env->cr[CR_PID2 ] || - match == env->cr[CR_PID3 ] || match == env->cr[CR_PID4 ]) { - prot &=PAGE_READ |PAGE_EXEC ; -if (type ==PAGE_WRITE ) { - ret =EXCP_DMPI ; - goto egress; - } +int access_prot = (hppa_is_pa20 (env) + ?match_prot_id64 (env, ent->access_id) + :match_prot_id32 (env, ent->access_id)); +if (prot & ~access_prot) { + ret = type &PAGE_EXEC ?EXCP_IMP :EXCP_DMPI ; + goto egress; } }
Signature · 1 line
2.43.2
Re: [PATCH v2 3/6] target/hppa: fix access_id check
Quoted 6 lines · Sven Schnelle
PA2.0 provides 8 instead of 4 PID registers.
Signed-off-by Sven Schnelle <[email protected]>--- target/hppa/mem_helper.c | 59 +++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 10 deletions(-)
target/hppa/mem_helper.c static HPPATLBEntry *hppa_alloc_tlb_ent(CPUHPPAState *env) · line 163
Quoted 7 lines
target/hppa/mem_helper.c +7
-0+/* Return the set of protections allowed by a PID match. */ +static int match_prot_id_1 (uint32_t access_id,uint32_t prot_id) +{ +if (((access_id ^ (prot_id >>1 )) &ACCESS_ID_MASK ) ==0 ) { +return (prot_id &1 + ?PROT_EXEC |PROT_READ + :PROT_EXEC |PROT_READ |PROT_WRITE );
Tabs? Anyway, weird indentation...
r~
PATCH v2 4/6 target/hppa: exit tb on flush cache instructions
In reply to Sven SchnelleWhen the guest modifies the tb it is currently executing from, it executes a fic instruction. Exit the tb on such instruction, otherwise we might execute stale code.
--- target/hppa/insns.decode | 6 +++--- target/hppa/translate.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-)
target/hppa/insns.decode +3 -3
@@ -143,9 +143,9 @@ getshadowregs 1111 1111 1111 1101 1110 1010 1101 0010 nop 000001 ----- ----- -- 11001010 0 ----- # fdc, disp nop_addrx 000001 ..... ..... -- 01001010 . ----- @addrx # fdc, index nop_addrx 000001 ..... ..... -- 01001011 . ----- @addrx # fdce -nop_addrx 000001 ..... ..... --- 0001010 . ----- @addrx # fic 0x0a -nop_addrx 000001 ..... ..... -- 01001111 . 00000 @addrx # fic 0x4f -nop_addrx 000001 ..... ..... --- 0001011 . ----- @addrx # fice +fic 000001 ..... ..... --- 0001010 . ----- @addrx # fic 0x0a +fic 000001 ..... ..... -- 01001111 . 00000 @addrx # fic 0x4f +fic 000001 ..... ..... --- 0001011 . ----- @addrx # fice nop_addrx 000001 ..... ..... -- 01001110 . 00000 @addrx # pdc probe 000001 b:5 ri:5 sp:2 imm:1 100011 write:1 0 t:5
target/hppa/translate.c +11 -0
@@ -2293,6 +2293,17 @@ static bool trans_nop_addrx(DisasContext *ctx, arg_ldst *a)return true; } +static bool trans_fic (DisasContext *ctx,arg_fic *a) +{ +arg_ldst b; + + b.b = a->b; + b.x = a->x; + b.m = a->m; + ctx->base.is_jmp =DISAS_IAQ_N_STALE ; +return trans_nop_addrx (ctx, &b); +} +static bool trans_probe (DisasContext *ctx,arg_probe *a) {TCGv_i64 dest, ofs;
Signature · 1 line
2.43.2
PATCH v2 5/6 target/hppa: mask privilege bits in mfia
In reply to Sven Schnellemfia should return only the iaoq bits without privilege bits.
--- target/hppa/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/translate.c +1 -1
@@ -1961,7 +1961,7 @@ static bool trans_mfia(DisasContext *ctx, arg_mfia *a) {unsigned rt = a->t;TCGv_i64 tmp =dest_gpr (ctx, rt); -tcg_gen_movi_i64 (tmp, ctx->iaoq_f); +tcg_gen_movi_i64 (tmp, ctx->iaoq_f & ~3ULL );save_gpr (ctx, rt, tmp);cond_free (&ctx->null_cond);
Signature · 1 line
2.43.2
PATCH v2 6/6 target/hppa: fix do_stdby_e()
In reply to Sven Schnellestdby,e,m was writing data from the wrong half of the register into memory for cases 0-3.
--- target/hppa/op_helper.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
target/hppa/op_helper.c +5 -5
@@ -281,17 +281,17 @@ static void do_stdby_e(CPUHPPAState *env, target_ulong addr, uint64_t val,case 3 :/* The 3 byte store must appear atomic. */ if (parallel) { -atomic_store_mask32 (env, addr -3 , val,0xffffff00u , ra); +atomic_store_mask32 (env, addr -3 , val >>32 ,0xffffff00u , ra); }else { -cpu_stw_data_ra (env, addr -3 , val >>16 , ra); -cpu_stb_data_ra (env, addr -1 , val >>8 , ra); +cpu_stw_data_ra (env, addr -3 , val >>48 , ra); +cpu_stb_data_ra (env, addr -1 , val >>40 , ra); }break ;case 2 : -cpu_stw_data_ra (env, addr -2 , val >>16 , ra); +cpu_stw_data_ra (env, addr -2 , val >>48 , ra);break ;case 1 : -cpu_stb_data_ra (env, addr -1 , val >>24 , ra); +cpu_stb_data_ra (env, addr -1 , val >>56 , ra);break ;default :/* Nothing is stored, but protection is checked and the
Signature · 1 line
2.43.2