[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 23/32] booke_ppc: limit booke timer to max when timeou
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PATCH 23/32] booke_ppc: limit booke timer to max when timeout overflow |
Date: |
Sun, 30 Jun 2013 03:45:00 +0200 |
From: Bharat Bhushan <address@hidden>
Limit watchdog and fit timer to maximum timeout value which
qemu timer can support (INT64_MAX). This maximum timeout will be
hundreds of years, so limiting to max timeout is pretty safe.
Signed-off-by: Bharat Bhushan <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
hw/ppc/ppc_booke.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/ppc_booke.c b/hw/ppc/ppc_booke.c
index e41b036..000c27f 100644
--- a/hw/ppc/ppc_booke.c
+++ b/hw/ppc/ppc_booke.c
@@ -131,17 +131,33 @@ static void booke_update_fixed_timer(CPUPPCState
*env,
struct QEMUTimer *timer)
{
ppc_tb_t *tb_env = env->tb_env;
- uint64_t lapse;
+ uint64_t delta_tick, ticks = 0;
uint64_t tb;
- uint64_t period = 1 << (target_bit + 1);
+ uint64_t period;
uint64_t now;
now = qemu_get_clock_ns(vm_clock);
tb = cpu_ppc_get_tb(tb_env, now, tb_env->tb_offset);
+ period = 1ULL << target_bit;
+ delta_tick = period - (tb & (period - 1));
- lapse = period - ((tb - (1 << target_bit)) & (period - 1));
+ /* the timer triggers only when the selected bit toggles from 0 to 1 */
+ if (tb & period) {
+ ticks = period;
+ }
- *next = now + muldiv64(lapse, get_ticks_per_sec(), tb_env->tb_freq);
+ if (ticks + delta_tick < ticks) {
+ /* Overflow, so assume the biggest number we can express. */
+ ticks = UINT64_MAX;
+ } else {
+ ticks += delta_tick;
+ }
+
+ *next = now + muldiv64(ticks, get_ticks_per_sec(), tb_env->tb_freq);
+ if ((*next < now) || (*next > INT64_MAX)) {
+ /* Overflow, so assume the biggest number the qemu timer supports. */
+ *next = INT64_MAX;
+ }
/* XXX: If expire time is now. We can't run the callback because we don't
* have access to it. So we just set the timer one nanosecond later.
--
1.8.1.4
- [Qemu-ppc] [PATCH 07/32] PPC: Add non-kvm stub file, (continued)
- [Qemu-ppc] [PATCH 07/32] PPC: Add non-kvm stub file, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 12/32] mpc8544_guts: Fix MemoryRegion name, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 13/32] mpc8544_guts: QOM'ify, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 29/32] PPC: Newworld: Add uninorth token register, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 09/32] intc/openpic: QOM'ify, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 14/32] mpc8544_guts: Turn qdev initfn into instance_init, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 19/32] pseries: Fix compiler warning (conversion of pointer to integral value), Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 05/32] PPC: e500: factor out mpic init code, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 10/32] intc/openpic: Convert to QOM realize, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 22/32] Graphics: Switch to 800x600x32 as default mode, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 23/32] booke_ppc: limit booke timer to max when timeout overflow,
Alexander Graf <=
- [Qemu-ppc] [PATCH 11/32] intc/openpic_kvm: Fix QOM and build issues, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 30/32] PPC: Newworld: Add second uninorth control register set, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 28/32] PPC: Add clock-frequency export for Mac machines, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 21/32] pseries: Update MAINTAINERS information, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 04/32] openpic: factor out some common defines into openpic.h, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 20/32] target-ppc kvm: save cr register, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 17/32] target-ppc: Change default machine for 64-bit, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 25/32] PPC: Add dump_mmu() for 6xx, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 31/32] mac-io: Add escc-legacy memory alias region, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 24/32] target-ppc: Introduce unrealizefn for PowerPCCPU, Alexander Graf, 2013/06/29