From patchwork Fri Dec 31 12:01:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 77067 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 F30B21007D5 for ; Fri, 31 Dec 2010 23:04:53 +1100 (EST) Received: from localhost ([127.0.0.1]:44294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PYdj1-00080t-9K for incoming@patchwork.ozlabs.org; Fri, 31 Dec 2010 07:04:51 -0500 Received: from [140.186.70.92] (port=35842 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PYdgK-0006pE-Hv for qemu-devel@nongnu.org; Fri, 31 Dec 2010 07:02:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PYdgH-0006gj-T7 for qemu-devel@nongnu.org; Fri, 31 Dec 2010 07:02:04 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:41040) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PYdgH-0006g1-FX for qemu-devel@nongnu.org; Fri, 31 Dec 2010 07:02:01 -0500 Received: from smtp08.web.de ( [172.20.5.216]) by fmmailgate03.web.de (Postfix) with ESMTP id 699D81838FA29; Fri, 31 Dec 2010 13:02:00 +0100 (CET) Received: from [88.64.22.98] (helo=localhost.localdomain) by smtp08.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1PYdgG-0007EU-00; Fri, 31 Dec 2010 13:02:00 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Fri, 31 Dec 2010 13:01:49 +0100 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX18thkW2XxbR2OguotjUSc0L+Rcqizl+avoYzEtb szD+DJsPlLq/gQCprgNONKDTORdhPBYZ1EJs3+WbL1SHnmwfUA Nt3+9IQUg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: Jan Kiszka , Glauber Costa , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 2/5] kvm: x86: Reset paravirtual MSRs 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 From: Jan Kiszka Make sure to clear MSR_KVM_SYSTEM_TIME, MSR_KVM_WALL_CLOCK, and MSR_KVM_ASYNC_PF_EN so that a freshly booted guest cannot be disturbed by old values. Signed-off-by: Jan Kiszka CC: Glauber Costa --- target-i386/kvm.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 000f3b0..d05a2b9 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -454,6 +454,9 @@ void kvm_arch_reset_vcpu(CPUState *env) env->interrupt_injected = -1; env->nmi_injected = 0; env->nmi_pending = 0; + env->system_time_msr = 0; + env->wall_clock_msr = 0; + env->async_pf_en_msr = 0; if (kvm_irqchip_in_kernel()) { env->mp_state = cpu_is_bsp(env) ? KVM_MP_STATE_RUNNABLE : KVM_MP_STATE_UNINITIALIZED; @@ -846,6 +849,13 @@ static int kvm_put_msrs(CPUState *env, int level) if (smp_cpus == 1 || env->tsc != 0) { kvm_msr_entry_set(&msrs[n++], MSR_IA32_TSC, env->tsc); } + } + /* + * The following paravirtual MSRs have side effects on the guest or are + * too heavy for normal writeback. Limit them to reset or full state + * updates. + */ + if (level >= KVM_PUT_RESET_STATE) { 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);