From patchwork Thu Jul 17 11:05:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 371154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BE2BB140093 for ; Thu, 17 Jul 2014 23:50:58 +1000 (EST) Received: from localhost ([::1]:44414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7m5I-0003ya-Ks for incoming@patchwork.ozlabs.org; Thu, 17 Jul 2014 09:50:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7jeJ-0006Vz-IH for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:15:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7jeC-00080d-Qv for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:14:55 -0400 Received: from mail.ispras.ru ([83.149.199.45]:47580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7jV0-0005Ra-4l for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:05:18 -0400 Received: from [10.10.150.172] (unknown [80.250.189.177]) by mail.ispras.ru (Postfix) with ESMTPSA id 65B4E540151; Thu, 17 Jul 2014 15:05:17 +0400 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Thu, 17 Jul 2014 15:05:21 +0400 Message-ID: <20140717110520.8352.77911.stgit@PASHA-ISP> In-Reply-To: <20140717110153.8352.80175.stgit@PASHA-ISP> References: <20140717110153.8352.80175.stgit@PASHA-ISP> User-Agent: StGit/0.16 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 X-Mailman-Approved-At: Thu, 17 Jul 2014 09:36:33 -0400 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, fred.konrad@greensocs.com Subject: [Qemu-devel] [RFC PATCH v2 36/49] pl031: vmstate in replay mode 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 This patch modifies vmstate for PL031 RTC. It removes querying of the rtc and virtual clocks while saving and restoring VM state, because in replay mode these clocks are stopped while saving. And reading the clock while restoring the VM state may lead to read of the incorrect values, because clocks cache in replay module could not be loaded yet. Signed-off-by: Pavel Dovgalyuk --- hw/timer/pl031.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c index 02c814f..017b1ce 100644 --- a/hw/timer/pl031.c +++ b/hw/timer/pl031.c @@ -220,19 +220,27 @@ static void pl031_pre_save(void *opaque) { PL031State *s = opaque; - /* tick_offset is base_time - rtc_clock base time. Instead, we want to - * store the base time relative to the QEMU_CLOCK_VIRTUAL for backwards-compatibility. */ - int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - s->tick_offset_vmstate = s->tick_offset + delta / get_ticks_per_sec(); + if (replay_mode == REPLAY_NONE) { + /* tick_offset is base_time - rtc_clock base time. Instead, we want to + * store the base time relative to the QEMU_CLOCK_VIRTUAL for backwards-compatibility. */ + int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + s->tick_offset_vmstate = s->tick_offset + delta / get_ticks_per_sec(); + } else { + s->tick_offset_vmstate = s->tick_offset; + } } static int pl031_post_load(void *opaque, int version_id) { PL031State *s = opaque; - int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - s->tick_offset = s->tick_offset_vmstate - delta / get_ticks_per_sec(); - pl031_set_alarm(s); + if (replay_mode == REPLAY_NONE) { + int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + s->tick_offset = s->tick_offset_vmstate - delta / get_ticks_per_sec(); + pl031_set_alarm(s); + } else { + s->tick_offset = s->tick_offset_vmstate; + } return 0; }