diff options
author | Clément Chigot <chigot@adacore.com> | 2024-07-15 10:46:39 +0200 |
---|---|---|
committer | Nicholas Piggin <npiggin@gmail.com> | 2024-11-04 09:09:21 +1000 |
commit | f10827a845bbbb0354617cc1a69e95e4c1eb18ce (patch) | |
tree | 66cf7a0ced9cf2f5895ae9936407c91f31eb89d2 | |
parent | ddf4dd46e5c31bd223f2e867f2cae43bfd41dfb9 (diff) |
hw/ppc: fix decrementer with BookE timers
The BookE decrementer stops at 0, meaning that it won't decremented
towards "negative" values. However, the current logic is inverted: decr
is updated solely when the resulting value would be negative.
Signed-off-by: Clément Chigot <chigot@adacore.com>
Fixes: 8e0a5ac87800 ("hw/ppc: Avoid decrementer rounding errors")
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
-rw-r--r-- | hw/ppc/ppc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index fde4619412..b86b5847de 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -728,7 +728,9 @@ static inline int64_t __cpu_ppc_load_decr(CPUPPCState *env, int64_t now, int64_t decr; n = ns_to_tb(tb_env->decr_freq, now); - if (next > n && tb_env->flags & PPC_TIMER_BOOKE) { + + /* BookE timers stop when reaching 0. */ + if (next < n && tb_env->flags & PPC_TIMER_BOOKE) { decr = 0; } else { decr = next - n; |