From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Richard Henderson" <richard.henderson@linaro.org>,
<qemu-devel@nongnu.org>
Cc: <qemu-ppc@nongnu.org>, <balaton@eik.bme.hu>
Subject: Re: [PATCH 3/4] target/ppc: Split out helper_dbczl for 970
Date: Wed, 17 Jul 2024 21:33:20 +1000 [thread overview]
Message-ID: <D2RS5EPS7RZF.25PF4KRH25PH6@gmail.com> (raw)
In-Reply-To: <20240702234659.2106870-4-richard.henderson@linaro.org>
On Wed Jul 3, 2024 at 9:46 AM AEST, Richard Henderson wrote:
> We can determine at translation time whether the insn is or
> is not dbczl. We must retain a runtime check against the
> HID5 register, but we can move that to a separate function
> that never affects other ppc models.
Looks right I think. You could go one further and have the
HID bit on 970 a hflag, but that might be overkill without
numbers...
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> target/ppc/helper.h | 7 +++++--
> target/ppc/mem_helper.c | 34 +++++++++++++++++++++-------------
> target/ppc/translate.c | 24 ++++++++++++++----------
> 3 files changed, 40 insertions(+), 25 deletions(-)
>
> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> index 76b8f25c77..afc56855ff 100644
> --- a/target/ppc/helper.h
> +++ b/target/ppc/helper.h
> @@ -46,8 +46,11 @@ 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_3(dcbz, TCG_CALL_NO_WG, void, env, tl, i32)
> -DEF_HELPER_FLAGS_3(dcbzep, TCG_CALL_NO_WG, void, env, tl, 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)
> +#ifdef TARGET_PPC64
> +DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl)
> +#endif
> DEF_HELPER_FLAGS_2(icbi, TCG_CALL_NO_WG, void, env, tl)
> DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl)
> DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32)
> diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
> index 5067919ff8..d4957efd6e 100644
> --- a/target/ppc/mem_helper.c
> +++ b/target/ppc/mem_helper.c
> @@ -296,26 +296,34 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr,
> }
> }
>
> -void helper_dcbz(CPUPPCState *env, target_ulong addr, uint32_t opcode)
> +void helper_dcbz(CPUPPCState *env, target_ulong addr)
> {
> - int dcbz_size = env->dcache_line_size;
> -
> -#if defined(TARGET_PPC64)
> - /* Check for dcbz vs dcbzl on 970 */
> - if (env->excp_model == POWERPC_EXCP_970 &&
> - !(opcode & 0x00200000) && ((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) {
> - dcbz_size = 32;
> - }
> -#endif
> -
> - dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC());
> + dcbz_common(env, addr, env->dcache_line_size,
> + ppc_env_mmu_index(env, false), GETPC());
> }
>
> -void helper_dcbzep(CPUPPCState *env, target_ulong addr, uint32_t opcode)
> +void helper_dcbzep(CPUPPCState *env, target_ulong addr)
> {
> dcbz_common(env, addr, env->dcache_line_size, PPC_TLB_EPID_STORE, GETPC());
> }
>
> +#ifdef TARGET_PPC64
> +void helper_dcbzl(CPUPPCState *env, target_ulong addr)
> +{
> + int dcbz_size = env->dcache_line_size;
> +
> + /*
> + * The translator checked for POWERPC_EXCP_970.
> + * All that's left is to check HID5.
> + */
> + if (((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) {
> + dcbz_size = 32;
> + }
> +
> + dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC());
> +}
> +#endif
> +
> void helper_icbi(CPUPPCState *env, target_ulong addr)
> {
> addr &= ~(env->dcache_line_size - 1);
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index 0bc16d7251..2664c94522 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -200,6 +200,7 @@ struct DisasContext {
> uint32_t flags;
> uint64_t insns_flags;
> uint64_t insns_flags2;
> + powerpc_excp_t excp_model;
Should we make this TARGET_PPC64 only? I think so, I can check
it an fold that in.
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Thanks,
Nick
> };
>
> #define DISAS_EXIT DISAS_TARGET_0 /* exit to main loop, pc updated */
> @@ -4445,27 +4446,29 @@ static void gen_dcblc(DisasContext *ctx)
> /* dcbz */
> static void gen_dcbz(DisasContext *ctx)
> {
> - TCGv tcgv_addr;
> - TCGv_i32 tcgv_op;
> + TCGv tcgv_addr = tcg_temp_new();
>
> gen_set_access_type(ctx, ACCESS_CACHE);
> - tcgv_addr = tcg_temp_new();
> - tcgv_op = tcg_constant_i32(ctx->opcode & 0x03FF000);
> gen_addr_reg_index(ctx, tcgv_addr);
> - gen_helper_dcbz(tcg_env, tcgv_addr, tcgv_op);
> +
> +#ifdef TARGET_PPC64
> + if (ctx->excp_model == POWERPC_EXCP_970 && !(ctx->opcode & 0x00200000)) {
> + gen_helper_dcbzl(tcg_env, tcgv_addr);
> + return;
> + }
> +#endif
> +
> + gen_helper_dcbz(tcg_env, tcgv_addr);
> }
>
> /* dcbzep */
> static void gen_dcbzep(DisasContext *ctx)
> {
> - TCGv tcgv_addr;
> - TCGv_i32 tcgv_op;
> + TCGv tcgv_addr = tcg_temp_new();
>
> gen_set_access_type(ctx, ACCESS_CACHE);
> - tcgv_addr = tcg_temp_new();
> - tcgv_op = tcg_constant_i32(ctx->opcode & 0x03FF000);
> gen_addr_reg_index(ctx, tcgv_addr);
> - gen_helper_dcbzep(tcg_env, tcgv_addr, tcgv_op);
> + gen_helper_dcbzep(tcg_env, tcgv_addr);
> }
>
> /* dst / dstt */
> @@ -6480,6 +6483,7 @@ static void ppc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
> ctx->hv = (hflags >> HFLAGS_HV) & 1;
> ctx->insns_flags = env->insns_flags;
> ctx->insns_flags2 = env->insns_flags2;
> + ctx->excp_model = env->excp_model;
> ctx->access_type = -1;
> ctx->need_access_type = !mmu_is_64bit(env->mmu_model);
> ctx->le_mode = (hflags >> HFLAGS_LE) & 1;
next prev parent reply other threads:[~2024-07-17 11:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 23:46 [PATCH 0/4] target/ppc: Cleanups for dcbz Richard Henderson
2024-07-02 23:46 ` [PATCH 1/4] target/ppc/mem_helper.c: Remove a conditional from dcbz_common() Richard Henderson
2024-07-17 11:36 ` Nicholas Piggin
2024-07-02 23:46 ` [PATCH 2/4] target/ppc: Hoist dcbz_size out of dcbz_common Richard Henderson
2024-07-17 11:23 ` Nicholas Piggin
2024-07-02 23:46 ` [PATCH 3/4] target/ppc: Split out helper_dbczl for 970 Richard Henderson
2024-07-17 11:33 ` Nicholas Piggin [this message]
2024-07-02 23:46 ` [PATCH 4/4] target/ppc: Merge helper_{dcbz,dcbzep} Richard Henderson
2024-07-17 11:35 ` Nicholas Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D2RS5EPS7RZF.25PF4KRH25PH6@gmail.com \
--to=npiggin@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.