[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 22/24] target/ppc: fix timebase register reset state
From: |
Nicholas Piggin |
Subject: |
[PATCH v5 22/24] target/ppc: fix timebase register reset state |
Date: |
Tue, 19 Mar 2024 01:46:19 +1000 |
(H)DEC and PURR get reset before icount does, which causes them to be
skewed and not match the init state. This can cause replay to not
match the recorded trace exactly. For DEC and HDEC this is usually not
noticable since they tend to get programmed before affecting the
target machine. PURR has been observed to cause replay bugs when
running Linux.
Fix this by resetting using a time of 0.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
hw/ppc/ppc.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index e6fa5580c0..ddcbf8972b 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -1122,16 +1122,21 @@ void cpu_ppc_tb_reset(CPUPPCState *env)
timer_del(tb_env->hdecr_timer);
ppc_set_irq(cpu, PPC_INTERRUPT_HDECR, 0);
tb_env->hdecr_next = 0;
+ _cpu_ppc_store_hdecr(cpu, 0, 0, 0, 64);
}
/*
* There is a bug in Linux 2.4 kernels:
* if a decrementer exception is pending when it enables msr_ee at startup,
* it's not ready to handle it...
+ *
+ * On machine reset, in this is called before icount is reset, so
+ * for icount-mode, setting TB registers using now=qemu_clock_get_ns
+ * results in them being skewed when icount does get reset. Use an
+ * explicit 0 to get a consistent reset state.
*/
- cpu_ppc_store_decr(env, -1);
- cpu_ppc_store_hdecr(env, -1);
- cpu_ppc_store_purr(env, 0x0000000000000000ULL);
+ _cpu_ppc_store_decr(cpu, 0, 0, -1, 64);
+ _cpu_ppc_store_purr(env, 0, 0);
}
void cpu_ppc_tb_free(CPUPPCState *env)
--
2.42.0
- Re: [PATCH v5 13/24] tests/avocado: replay_linux.py remove the timeout expected guards, (continued)
- [PATCH v5 15/24] tests/avocado: reverse_debugging.py add test for x86-64 q35 machine, Nicholas Piggin, 2024/03/18
- [PATCH v5 16/24] tests/avocado: reverse_debugging.py verify addresses between record and replay, Nicholas Piggin, 2024/03/18
- [PATCH v5 17/24] tests/avocado: reverse_debugging.py stop VM before sampling icount, Nicholas Piggin, 2024/03/18
- [PATCH v5 14/24] tests/avocado: reverse_debugging.py mark aarch64 and pseries as not flaky, Nicholas Piggin, 2024/03/18
- [PATCH v5 18/24] tests/avocado: reverse_debugging reverse-step at the end of the trace, Nicholas Piggin, 2024/03/18
- [PATCH v5 19/24] tests/avocado: reverse_debugging.py add snapshot testing, Nicholas Piggin, 2024/03/18
- [PATCH v5 20/24] replay: simple auto-snapshot mode for record, Nicholas Piggin, 2024/03/18
- [PATCH v5 21/24] tests/avocado: reverse_debugging.py test auto-snapshot mode, Nicholas Piggin, 2024/03/18
- [PATCH v5 22/24] target/ppc: fix timebase register reset state,
Nicholas Piggin <=
- [PATCH v5 23/24] spapr: Fix vpa dispatch count for record-replay, Nicholas Piggin, 2024/03/18
- [PATCH v5 24/24] tests/avocado: replay_linux.py add ppc64 pseries test, Nicholas Piggin, 2024/03/18