Message ID | 20240710032814.104643-9-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | Fixes for user-only munmap races | expand |
On Tue, 9 Jul 2024, Richard Henderson wrote: > Merge the two and pass the mmu_idx directly from translation. > Swap the argument order in dcbz_common to avoid extra swaps. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/ppc/helper.h | 3 +-- > target/ppc/mem_helper.c | 14 ++++---------- > target/ppc/translate.c | 4 ++-- > 3 files changed, 7 insertions(+), 14 deletions(-) > > diff --git a/target/ppc/helper.h b/target/ppc/helper.h > index afc56855ff..4fa089cbf9 100644 > --- a/target/ppc/helper.h > +++ b/target/ppc/helper.h > @@ -46,8 +46,7 @@ DEF_HELPER_FLAGS_3(stmw, TCG_CALL_NO_WG, void, env, tl, i32) > DEF_HELPER_4(lsw, void, env, tl, i32, i32) > DEF_HELPER_5(lswx, void, env, tl, i32, i32, i32) > DEF_HELPER_FLAGS_4(stsw, TCG_CALL_NO_WG, void, env, tl, i32, i32) > -DEF_HELPER_FLAGS_2(dcbz, TCG_CALL_NO_WG, void, env, tl) > -DEF_HELPER_FLAGS_2(dcbzep, TCG_CALL_NO_WG, void, env, tl) > +DEF_HELPER_FLAGS_3(dcbz, TCG_CALL_NO_WG, void, env, tl, int) > #ifdef TARGET_PPC64 > DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl) Why only dcbz but not dcbzl as well to make them uniform? Regards, BALATON Zoltan > #endif > diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c > index d4957efd6e..24bae3b80c 100644 > --- a/target/ppc/mem_helper.c > +++ b/target/ppc/mem_helper.c > @@ -271,7 +271,7 @@ void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb, > } > > static void dcbz_common(CPUPPCState *env, target_ulong addr, > - int dcbz_size, int mmu_idx, uintptr_t retaddr) > + int mmu_idx, int dcbz_size, uintptr_t retaddr) > { > target_ulong mask = ~(target_ulong)(dcbz_size - 1); > void *haddr; > @@ -296,15 +296,9 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, > } > } > > -void helper_dcbz(CPUPPCState *env, target_ulong addr) > +void helper_dcbz(CPUPPCState *env, target_ulong addr, int mmu_idx) > { > - dcbz_common(env, addr, env->dcache_line_size, > - ppc_env_mmu_index(env, false), GETPC()); > -} > - > -void helper_dcbzep(CPUPPCState *env, target_ulong addr) > -{ > - dcbz_common(env, addr, env->dcache_line_size, PPC_TLB_EPID_STORE, GETPC()); > + dcbz_common(env, addr, mmu_idx, env->dcache_line_size, GETPC()); > } > > #ifdef TARGET_PPC64 > @@ -320,7 +314,7 @@ void helper_dcbzl(CPUPPCState *env, target_ulong addr) > dcbz_size = 32; > } > > - dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC()); > + dcbz_common(env, addr, ppc_env_mmu_index(env, false), dcbz_size, GETPC()); > } > #endif > > diff --git a/target/ppc/translate.c b/target/ppc/translate.c > index 2664c94522..285734065b 100644 > --- a/target/ppc/translate.c > +++ b/target/ppc/translate.c > @@ -4458,7 +4458,7 @@ static void gen_dcbz(DisasContext *ctx) > } > #endif > > - gen_helper_dcbz(tcg_env, tcgv_addr); > + gen_helper_dcbz(tcg_env, tcgv_addr, tcg_constant_i32(ctx->mem_idx)); > } > > /* dcbzep */ > @@ -4468,7 +4468,7 @@ static void gen_dcbzep(DisasContext *ctx) > > gen_set_access_type(ctx, ACCESS_CACHE); > gen_addr_reg_index(ctx, tcgv_addr); > - gen_helper_dcbzep(tcg_env, tcgv_addr); > + gen_helper_dcbz(tcg_env, tcgv_addr, tcg_constant_i32(PPC_TLB_EPID_STORE)); > } > > /* dst / dstt */ >
On 7/10/24 05:20, BALATON Zoltan wrote: > On Tue, 9 Jul 2024, Richard Henderson wrote: >> Merge the two and pass the mmu_idx directly from translation. >> Swap the argument order in dcbz_common to avoid extra swaps. >> >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> >> --- >> target/ppc/helper.h | 3 +-- >> target/ppc/mem_helper.c | 14 ++++---------- >> target/ppc/translate.c | 4 ++-- >> 3 files changed, 7 insertions(+), 14 deletions(-) >> >> diff --git a/target/ppc/helper.h b/target/ppc/helper.h >> index afc56855ff..4fa089cbf9 100644 >> --- a/target/ppc/helper.h >> +++ b/target/ppc/helper.h >> @@ -46,8 +46,7 @@ DEF_HELPER_FLAGS_3(stmw, TCG_CALL_NO_WG, void, env, tl, i32) >> DEF_HELPER_4(lsw, void, env, tl, i32, i32) >> DEF_HELPER_5(lswx, void, env, tl, i32, i32, i32) >> DEF_HELPER_FLAGS_4(stsw, TCG_CALL_NO_WG, void, env, tl, i32, i32) >> -DEF_HELPER_FLAGS_2(dcbz, TCG_CALL_NO_WG, void, env, tl) >> -DEF_HELPER_FLAGS_2(dcbzep, TCG_CALL_NO_WG, void, env, tl) >> +DEF_HELPER_FLAGS_3(dcbz, TCG_CALL_NO_WG, void, env, tl, int) >> #ifdef TARGET_PPC64 >> DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl) > > Why only dcbz but not dcbzl as well to make them uniform? Because dcbzl has extra logic, so doesn't get merged. The expansion of ppc_env_mmu_index() is not large, so there's no gain in passing it in. The point was to eliminate duplication where it was easy. r~
diff --git a/target/ppc/helper.h b/target/ppc/helper.h index afc56855ff..4fa089cbf9 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -46,8 +46,7 @@ DEF_HELPER_FLAGS_3(stmw, TCG_CALL_NO_WG, void, env, tl, i32) DEF_HELPER_4(lsw, void, env, tl, i32, i32) DEF_HELPER_5(lswx, void, env, tl, i32, i32, i32) DEF_HELPER_FLAGS_4(stsw, TCG_CALL_NO_WG, void, env, tl, i32, i32) -DEF_HELPER_FLAGS_2(dcbz, TCG_CALL_NO_WG, void, env, tl) -DEF_HELPER_FLAGS_2(dcbzep, TCG_CALL_NO_WG, void, env, tl) +DEF_HELPER_FLAGS_3(dcbz, TCG_CALL_NO_WG, void, env, tl, int) #ifdef TARGET_PPC64 DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl) #endif diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index d4957efd6e..24bae3b80c 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -271,7 +271,7 @@ void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb, } static void dcbz_common(CPUPPCState *env, target_ulong addr, - int dcbz_size, int mmu_idx, uintptr_t retaddr) + int mmu_idx, int dcbz_size, uintptr_t retaddr) { target_ulong mask = ~(target_ulong)(dcbz_size - 1); void *haddr; @@ -296,15 +296,9 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, } } -void helper_dcbz(CPUPPCState *env, target_ulong addr) +void helper_dcbz(CPUPPCState *env, target_ulong addr, int mmu_idx) { - dcbz_common(env, addr, env->dcache_line_size, - ppc_env_mmu_index(env, false), GETPC()); -} - -void helper_dcbzep(CPUPPCState *env, target_ulong addr) -{ - dcbz_common(env, addr, env->dcache_line_size, PPC_TLB_EPID_STORE, GETPC()); + dcbz_common(env, addr, mmu_idx, env->dcache_line_size, GETPC()); } #ifdef TARGET_PPC64 @@ -320,7 +314,7 @@ void helper_dcbzl(CPUPPCState *env, target_ulong addr) dcbz_size = 32; } - dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC()); + dcbz_common(env, addr, ppc_env_mmu_index(env, false), dcbz_size, GETPC()); } #endif diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 2664c94522..285734065b 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -4458,7 +4458,7 @@ static void gen_dcbz(DisasContext *ctx) } #endif - gen_helper_dcbz(tcg_env, tcgv_addr); + gen_helper_dcbz(tcg_env, tcgv_addr, tcg_constant_i32(ctx->mem_idx)); } /* dcbzep */ @@ -4468,7 +4468,7 @@ static void gen_dcbzep(DisasContext *ctx) gen_set_access_type(ctx, ACCESS_CACHE); gen_addr_reg_index(ctx, tcgv_addr); - gen_helper_dcbzep(tcg_env, tcgv_addr); + gen_helper_dcbz(tcg_env, tcgv_addr, tcg_constant_i32(PPC_TLB_EPID_STORE)); } /* dst / dstt */
Merge the two and pass the mmu_idx directly from translation. Swap the argument order in dcbz_common to avoid extra swaps. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/ppc/helper.h | 3 +-- target/ppc/mem_helper.c | 14 ++++---------- target/ppc/translate.c | 4 ++-- 3 files changed, 7 insertions(+), 14 deletions(-)