From patchwork Wed Dec 19 13:36:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 207394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AA77D2C0092 for ; Thu, 20 Dec 2012 02:23:23 +1100 (EST) Received: from localhost ([::1]:32993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlJpg-0007b6-Qr for incoming@patchwork.ozlabs.org; Wed, 19 Dec 2012 08:37:12 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlJpP-0007NH-Am for qemu-devel@nongnu.org; Wed, 19 Dec 2012 08:36:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TlJpJ-0004TM-9F for qemu-devel@nongnu.org; Wed, 19 Dec 2012 08:36:55 -0500 Received: from cantor2.suse.de ([195.135.220.15]:60374 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlJpJ-0004T4-08 for qemu-devel@nongnu.org; Wed, 19 Dec 2012 08:36:49 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 865FAA5208; Wed, 19 Dec 2012 14:36:48 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Wed, 19 Dec 2012 14:36:19 +0100 Message-Id: <1355924196-19288-4-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355924196-19288-1-git-send-email-afaerber@suse.de> References: <1355924196-19288-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson Subject: [Qemu-devel] [PATCH 03/20] target-alpha: Avoid leaking the alarm timer over reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Acked-by: Richard Henderson --- 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 32e3777..e1d7715 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; /* Those resources are used only in QEMU core */ 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 */