[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [FYI qom-cpu v2 3/5] target-alpha: Avoid leaking the alarm
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [FYI qom-cpu v2 3/5] target-alpha: Avoid leaking the alarm timer over reset |
Date: |
Sun, 9 Dec 2012 02:40:14 +0100 |
Move the timer from CPUAlphaState to AlphaCPU to avoid the pointer being
zero'ed once we implement reset. Would cause a segfault in
sys_helper.c:helper_set_alarm().
This also simplifies timer initialization in Typhoon.
Signed-off-by: Andreas Färber <address@hidden>
Acked-by: Richard Henderson <address@hidden>
---
hw/alpha_typhoon.c | 3 +--
target-alpha/cpu-qom.h | 3 +++
target-alpha/cpu.h | 1 -
target-alpha/sys_helper.c | 6 ++++--
4 Dateien geändert, 8 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)
diff --git a/hw/alpha_typhoon.c b/hw/alpha_typhoon.c
index 4cc810f..40b3a47 100644
--- a/hw/alpha_typhoon.c
+++ b/hw/alpha_typhoon.c
@@ -724,8 +724,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
AlphaCPU *cpu = cpus[i];
s->cchip.cpu[i] = cpu;
if (cpu != NULL) {
- CPUAlphaState *env = &cpu->env;
- env->alarm_timer = qemu_new_timer_ns(rtc_clock,
+ cpu->alarm_timer = qemu_new_timer_ns(rtc_clock,
typhoon_alarm_timer,
(void *)((uintptr_t)s + i));
}
diff --git a/target-alpha/cpu-qom.h b/target-alpha/cpu-qom.h
index 6b4ca6d..98585d5 100644
--- a/target-alpha/cpu-qom.h
+++ b/target-alpha/cpu-qom.h
@@ -58,6 +58,9 @@ typedef struct AlphaCPU {
/*< public >*/
CPUAlphaState env;
+
+ /* This alarm doesn't exist in real hardware; we wish it did. */
+ struct QEMUTimer *alarm_timer;
} AlphaCPU;
static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env)
diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h
index 853ea8e..ff48c1a 100644
--- a/target-alpha/cpu.h
+++ b/target-alpha/cpu.h
@@ -277,7 +277,6 @@ struct CPUAlphaState {
#endif
/* This alarm doesn't exist in real hardware; we wish it did. */
- struct QEMUTimer *alarm_timer;
uint64_t alarm_expire;
#if TARGET_LONG_BITS > HOST_LONG_BITS
diff --git a/target-alpha/sys_helper.c b/target-alpha/sys_helper.c
index 40ca49c..d4f14ef 100644
--- a/target-alpha/sys_helper.c
+++ b/target-alpha/sys_helper.c
@@ -77,11 +77,13 @@ uint64_t helper_get_time(void)
void helper_set_alarm(CPUAlphaState *env, uint64_t expire)
{
+ AlphaCPU *cpu = alpha_env_get_cpu(env);
+
if (expire) {
env->alarm_expire = expire;
- qemu_mod_timer(env->alarm_timer, expire);
+ qemu_mod_timer(cpu->alarm_timer, expire);
} else {
- qemu_del_timer(env->alarm_timer);
+ qemu_del_timer(cpu->alarm_timer);
}
}
#endif /* CONFIG_USER_ONLY */
--
1.7.10.4
- [Qemu-devel] [PATCH qom-cpu v2 0/5] target-alpha: CPU subclasses, Andreas Färber, 2012/12/08
- [Qemu-devel] [FYI qom-cpu v2 1/5] target-alpha: Let cpu_alpha_init() return AlphaCPU, Andreas Färber, 2012/12/08
- [Qemu-devel] [FYI qom-cpu v2 3/5] target-alpha: Avoid leaking the alarm timer over reset,
Andreas Färber <=
- [Qemu-devel] [FYI qom-cpu v2 2/5] alpha: Pass AlphaCPU array to Typhoon, Andreas Färber, 2012/12/08
- [Qemu-devel] [PATCH qom-cpu v2 5/5] target-alpha: Add support for -cpu ?, Andreas Färber, 2012/12/08
- [Qemu-devel] [PATCH qom-cpu v2 4/5] target-alpha: Turn CPU definitions into subclasses, Andreas Färber, 2012/12/08
- Re: [Qemu-devel] [PATCH qom-cpu v2 0/5] target-alpha: CPU subclasses, Richard Henderson, 2012/12/10