From patchwork Tue Oct 20 14:04:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 36464 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9FE51B7B88 for ; Wed, 21 Oct 2009 01:04:42 +1100 (EST) Received: from localhost ([127.0.0.1]:37638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0FKK-0008F9-0a for incoming@patchwork.ozlabs.org; Tue, 20 Oct 2009 10:04:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0FJr-0008Eu-Ca for qemu-devel@nongnu.org; Tue, 20 Oct 2009 10:04:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0FJn-0008E9-QS for qemu-devel@nongnu.org; Tue, 20 Oct 2009 10:04:11 -0400 Received: from [199.232.76.173] (port=57364 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0FJn-0008E4-My for qemu-devel@nongnu.org; Tue, 20 Oct 2009 10:04:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47852) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0FJm-000259-E2 for qemu-devel@nongnu.org; Tue, 20 Oct 2009 10:04:07 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9KE45CX026668; Tue, 20 Oct 2009 10:04:05 -0400 Received: from localhost.localdomain (vpn-12-215.rdu.redhat.com [10.11.12.215]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9KE42CR021002; Tue, 20 Oct 2009 10:04:03 -0400 From: Glauber Costa To: qemu-devel@nongnu.org Date: Tue, 20 Oct 2009 12:04:01 -0200 Message-Id: <1256047441-9846-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, Marcelo Tosatti Subject: [Qemu-devel] [PATCH] properly save kvm system time msr registers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Currently, the msrs involved in setting up pvclock are not saved over migration and/or save/restore. This patch puts their value in special fields in our CPUState, and deal with them using vmstate. kvm also has to account for it, by including them in the msr list for the ioctls. This is a backport from qemu-kvm.git Signed-off-by: Glauber Costa Signed-off-by: Marcelo Tosatti --- target-i386/cpu.h | 2 ++ target-i386/kvm.c | 13 +++++++++++++ target-i386/machine.c | 3 +++ 3 files changed, 18 insertions(+), 0 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 5929d28..f589044 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -651,6 +651,8 @@ typedef struct CPUX86State { target_ulong fmask; target_ulong kernelgsbase; #endif + uint64_t system_time_msr; + uint64_t wall_clock_msr; uint64_t tsc; diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 0e69b57..8a6fa29 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -18,6 +18,7 @@ #include #include +#include #include "qemu-common.h" #include "sysemu.h" @@ -500,6 +501,9 @@ static int kvm_put_msrs(CPUState *env) kvm_msr_entry_set(&msrs[n++], MSR_LSTAR, env->lstar); } #endif + kvm_msr_entry_set(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr); + kvm_msr_entry_set(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr); + msr_data.info.nmsrs = n; return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &msr_data); @@ -634,6 +638,9 @@ static int kvm_get_msrs(CPUState *env) msrs[n++].index = MSR_LSTAR; } #endif + msrs[n++].index = MSR_KVM_SYSTEM_TIME; + msrs[n++].index = MSR_KVM_WALL_CLOCK; + msr_data.info.nmsrs = n; ret = kvm_vcpu_ioctl(env, KVM_GET_MSRS, &msr_data); if (ret < 0) @@ -670,6 +677,12 @@ static int kvm_get_msrs(CPUState *env) case MSR_IA32_TSC: env->tsc = msrs[i].data; break; + case MSR_KVM_SYSTEM_TIME: + env->system_time_msr = msrs[i].data; + break; + case MSR_KVM_WALL_CLOCK: + env->wall_clock_msr = msrs[i].data; + break; } } diff --git a/target-i386/machine.c b/target-i386/machine.c index b13eff4..f6fe216 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -475,6 +475,9 @@ const VMStateDescription vmstate_cpu = { VMSTATE_UINT64_ARRAY_V(mce_banks, CPUState, MCE_BANKS_DEF *4, 10), /* rdtscp */ VMSTATE_UINT64_V(tsc_aux, CPUState, 11), + /* KVM pvclock msr */ + VMSTATE_UINT64_V(system_time_msr, CPUState, 11), + VMSTATE_UINT64_V(wall_clock_msr, CPUState, 11), VMSTATE_END_OF_LIST() } };