* [PATCH v3] ppc/ppc405: Fix TLB flushing
@ 2022-01-13 18:03 Cédric Le Goater
2022-01-17 14:40 ` Fabiano Rosas
0 siblings, 1 reply; 2+ messages in thread
From: Cédric Le Goater @ 2022-01-13 18:03 UTC (permalink / raw)
To: qemu-ppc, qemu-devel
Cc: Thomas Huth, Fabiano Rosas, Greg Kurz, Christophe Leroy,
Cédric Le Goater, David Gibson
Commit cd0c6f473532 did not take into account 405 CPUs when adding
support to batching of TCG tlb flushes. Set the TLB_NEED_LOCAL_FLUSH
flag when the SPR_40x_PID is set or a TLB updated.
Cc: Thomas Huth <thuth@redhat.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Fabiano Rosas <farosas@linux.ibm.com>
Fixes: cd0c6f473532 ("ppc: Do some batching of TCG tlb flushes")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
Changes in v3:
- (re) Program the flush operation when the TLB is updated.
Changes in v2:
- Rely on the SPR_40x_PID store helper to program the flush operation
target/ppc/helper.h | 1 +
target/ppc/mmu_helper.c | 12 +++++++++++-
target/ppc/translate.c | 2 +-
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index f9c72dcd504d..08165184005c 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -708,6 +708,7 @@ DEF_HELPER_FLAGS_1(load_40x_pit, TCG_CALL_NO_RWG, tl, env)
DEF_HELPER_FLAGS_2(store_40x_pit, TCG_CALL_NO_RWG, void, env, tl)
DEF_HELPER_FLAGS_2(store_40x_tcr, TCG_CALL_NO_RWG, void, env, tl)
DEF_HELPER_FLAGS_2(store_40x_tsr, TCG_CALL_NO_RWG, void, env, tl)
+DEF_HELPER_2(store_40x_pid, void, env, tl)
DEF_HELPER_2(store_40x_dbcr0, void, env, tl)
DEF_HELPER_2(store_40x_sler, void, env, tl)
DEF_HELPER_FLAGS_2(store_booke_tcr, TCG_CALL_NO_RWG, void, env, tl)
diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c
index 59df6952aea1..a2a52a12c3a4 100644
--- a/target/ppc/mmu_helper.c
+++ b/target/ppc/mmu_helper.c
@@ -664,6 +664,14 @@ static inline int booke_page_size_to_tlb(target_ulong page_size)
#define PPC4XX_TLBLO_ATTR_MASK 0x000000FF
#define PPC4XX_TLBLO_RPN_MASK 0xFFFFFC00
+void helper_store_40x_pid(CPUPPCState *env, target_ulong val)
+{
+ if (env->spr[SPR_40x_PID] != val) {
+ env->spr[SPR_40x_PID] = val;
+ env->tlb_need_flush |= TLB_NEED_LOCAL_FLUSH;
+ }
+}
+
target_ulong helper_4xx_tlbre_hi(CPUPPCState *env, target_ulong entry)
{
ppcemb_tlb_t *tlb;
@@ -681,7 +689,7 @@ target_ulong helper_4xx_tlbre_hi(CPUPPCState *env, target_ulong entry)
size = PPC4XX_TLBHI_SIZE_DEFAULT;
}
ret |= size << PPC4XX_TLBHI_SIZE_SHIFT;
- env->spr[SPR_40x_PID] = tlb->PID;
+ helper_store_40x_pid(env, tlb->PID);
return ret;
}
@@ -794,6 +802,8 @@ void helper_4xx_tlbwe_lo(CPUPPCState *env, target_ulong entry,
tlb->prot & PAGE_WRITE ? 'w' : '-',
tlb->prot & PAGE_EXEC ? 'x' : '-',
tlb->prot & PAGE_VALID ? 'v' : '-', (int)tlb->PID);
+
+ env->tlb_need_flush |= TLB_NEED_LOCAL_FLUSH;
}
target_ulong helper_4xx_tlbsx(CPUPPCState *env, target_ulong address)
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 40232201bb0c..3ad1be60e71d 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -894,7 +894,7 @@ void spr_write_40x_pid(DisasContext *ctx, int sprn, int gprn)
{
TCGv t0 = tcg_temp_new();
tcg_gen_andi_tl(t0, cpu_gpr[gprn], 0xFF);
- gen_store_spr(SPR_40x_PID, t0);
+ gen_helper_store_40x_pid(cpu_env, t0);
tcg_temp_free(t0);
}
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] ppc/ppc405: Fix TLB flushing
2022-01-13 18:03 [PATCH v3] ppc/ppc405: Fix TLB flushing Cédric Le Goater
@ 2022-01-17 14:40 ` Fabiano Rosas
0 siblings, 0 replies; 2+ messages in thread
From: Fabiano Rosas @ 2022-01-17 14:40 UTC (permalink / raw)
To: Cédric Le Goater, qemu-ppc, qemu-devel
Cc: Thomas Huth, David Gibson, Greg Kurz, Christophe Leroy,
Cédric Le Goater
Cédric Le Goater <clg@kaod.org> writes:
> Commit cd0c6f473532 did not take into account 405 CPUs when adding
> support to batching of TCG tlb flushes. Set the TLB_NEED_LOCAL_FLUSH
> flag when the SPR_40x_PID is set or a TLB updated.
>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Fabiano Rosas <farosas@linux.ibm.com>
> Fixes: cd0c6f473532 ("ppc: Do some batching of TCG tlb flushes")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-17 15:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-13 18:03 [PATCH v3] ppc/ppc405: Fix TLB flushing Cédric Le Goater
2022-01-17 14:40 ` Fabiano Rosas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).