From patchwork Thu Feb 25 15:56:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 82036 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1PFvGpq027353 for ; Thu, 25 Feb 2010 15:57:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759402Ab0BYP5O (ORCPT ); Thu, 25 Feb 2010 10:57:14 -0500 Received: from thoth.sbs.de ([192.35.17.2]:17132 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759314Ab0BYP5N (ORCPT ); Thu, 25 Feb 2010 10:57:13 -0500 Received: from mail3.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id o1PFurs4023335; Thu, 25 Feb 2010 16:56:53 +0100 Received: from [139.25.109.167] (mchn012c.ww002.siemens.net [139.25.109.167] (may be forged)) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1PFurIE023348; Thu, 25 Feb 2010 16:56:53 +0100 Message-ID: <4B869DC6.1080403@siemens.com> Date: Thu, 25 Feb 2010 16:56:54 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti CC: kvm@vger.kernel.org, qemu-devel@nongnu.org, Gleb Natapov Subject: Re: [PATCH v4 07/10] qemu-kvm: Cleanup/fix TSC and PV clock writeback References: In-Reply-To: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 25 Feb 2010 15:57:16 +0000 (UTC) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 840c1c9..285c05a 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -965,8 +965,19 @@ void kvm_arch_load_regs(CPUState *env, int level) set_msr_entry(&msrs[n++], MSR_LSTAR , env->lstar); } #endif - set_msr_entry(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr); - set_msr_entry(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr); + if (level == KVM_PUT_FULL_STATE) { + /* + * KVM is yet unable to synchronize TSC values of multiple VCPUs on + * writeback. Until this is fixed, we only write the offset to SMP + * guests after migration, desynchronizing the VCPUs, but avoiding + * huge jump-backs that would occur without any writeback at all. + */ + if (smp_cpus == 1 || env->tsc != 0) { + set_msr_entry(&msrs[n++], MSR_IA32_TSC, env->tsc); + } + set_msr_entry(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr); + set_msr_entry(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr); + } rc = kvm_set_msrs(env, msrs, n); if (rc == -1) @@ -986,18 +997,6 @@ void kvm_arch_load_regs(CPUState *env, int level) kvm_guest_debug_workarounds(env); } -void kvm_load_tsc(CPUState *env) -{ - int rc; - struct kvm_msr_entry msr; - - set_msr_entry(&msr, MSR_IA32_TSC, env->tsc); - - rc = kvm_set_msrs(env, &msr, 1); - if (rc == -1) - perror("kvm_set_tsc FAILED.\n"); -} - void kvm_arch_save_regs(CPUState *env) { struct kvm_regs regs; diff --git a/qemu-kvm.h b/qemu-kvm.h index c6ff652..827cac5 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -958,7 +958,6 @@ int handle_tpr_access(void *opaque, CPUState *env, uint64_t rip, #ifdef TARGET_I386 #define qemu_kvm_has_pit_state2() kvm_has_pit_state2(kvm_context) #endif -void kvm_load_tsc(CPUState *env); #else #define kvm_nested 0 #define qemu_kvm_has_gsi_routing() (0) @@ -966,9 +965,6 @@ void kvm_load_tsc(CPUState *env); #define qemu_kvm_has_pit_state2() (0) #endif #define qemu_kvm_cpu_stop(env) do {} while(0) -static inline void kvm_load_tsc(CPUState *env) -{ -} #endif void kvm_mutex_unlock(void); diff --git a/target-i386/machine.c b/target-i386/machine.c index bcc315b..b547e2a 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -354,11 +354,6 @@ static int cpu_post_load(void *opaque, int version_id) hw_breakpoint_insert(env, i); tlb_flush(env, 1); - - if (kvm_enabled()) { - kvm_load_tsc(env); - } - return 0; }