+Richard/Peter

On 1/11/26 15:23, Kirill A. Korinsky wrote:
tlbwr replaces a random architectural TLB entry. Once that happens, the
evicted entry must stop translating guest virtual addresses.

The current helper keeps the evicted entry in QEMU-only extra TLB state.
That makes the old mapping survive until some later operation discards
the extra entries. A guest can observe this directly by writing through
a TLB mapping, replacing that entry with tlbwr, and writing through the
old virtual address again.

Invalidate the replaced entry instead of shadowing it. This keeps the
translated TLB state aligned with the architectural TLB contents.

Signed-off-by: Kirill A. Korinsky <[email protected]>
---
  target/mips/tcg/system/tlb_helper.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/mips/tcg/system/tlb_helper.c 
b/target/mips/tcg/system/tlb_helper.c
index 9e01c07609..08b978b3f5 100644
--- a/target/mips/tcg/system/tlb_helper.c
+++ b/target/mips/tcg/system/tlb_helper.c
@@ -165,7 +165,7 @@ static void r4k_helper_tlbwr(CPUMIPSState *env)
  {
      int r = cpu_mips_get_random(env);
- r4k_invalidate_tlb(env, r, 1);
+    r4k_invalidate_tlb(env, r, 0);
      r4k_fill_tlb(env, r);
  }

IIUC target-level shadow became redundant with commit 88e89a57f985
("implementing victim TLB for QEMU system emulated TLB", 2014) and
later 68fea0385530 ("accel/tcg: Avoid caching overwritten tlb
entries", 2018). We can thus remove 814b9a47490c ("MIPS TLB
performance improvements", 2006) as no longer necessary.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

Peter, Richard, extra eyes welcomed :)

Reply via email to